@mudlab/create-workflow 1.0.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/README.md +78 -0
- package/bin/create.js +84 -0
- package/package.json +31 -0
- package/template/.env.example +11 -0
- package/template/CLAUDE.md +947 -0
- package/template/README.md +49 -0
- package/template/assets/.gitkeep +3 -0
- package/template/directives/.gitkeep +12 -0
- package/template/execution/push_workflow.js +396 -0
- package/template/execution/tools/.gitkeep +18 -0
- package/template/execution/tools_directives/.gitkeep +12 -0
- package/template/execution/workflows/.gitkeep +10 -0
- package/template/package.json +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @mudlab/create-workflow
|
|
2
|
+
|
|
3
|
+
Scaffold a new [Mudlab](https://mudlab.io) workflow project in seconds.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using pnpm
|
|
9
|
+
pnpm create @mudlab/workflow my-automations
|
|
10
|
+
|
|
11
|
+
# Using npm
|
|
12
|
+
npx @mudlab/create-workflow my-automations
|
|
13
|
+
|
|
14
|
+
# Using yarn
|
|
15
|
+
yarn create @mudlab/workflow my-automations
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd my-automations
|
|
22
|
+
cp .env.example .env
|
|
23
|
+
# Add your Mudlab API key to .env
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What You Get
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
my-automations/
|
|
30
|
+
├── CLAUDE.md # AI orchestrator instructions (3-layer architecture)
|
|
31
|
+
├── README.md # Project readme
|
|
32
|
+
├── .env.example # Environment template
|
|
33
|
+
├── .gitignore # Git ignore rules
|
|
34
|
+
├── package.json # Project config
|
|
35
|
+
├── directives/ # Workflow documentation (SOPs)
|
|
36
|
+
├── execution/
|
|
37
|
+
│ ├── push_workflow.js # Push workflows to Mudlab
|
|
38
|
+
│ ├── tools/ # Node.js tool functions
|
|
39
|
+
│ ├── tools_directives/ # AI usage instructions for tools
|
|
40
|
+
│ └── workflows/ # Workflow package definitions (JSON)
|
|
41
|
+
├── assets/ # Static assets
|
|
42
|
+
└── .tmp/ # Temp files (gitignored)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Building Workflows
|
|
46
|
+
|
|
47
|
+
1. **Create a tool** in `execution/tools/my_tool.js`:
|
|
48
|
+
```javascript
|
|
49
|
+
async function run({ input, env, context }) {
|
|
50
|
+
const { name, API_KEY } = input;
|
|
51
|
+
// Your logic here
|
|
52
|
+
return {
|
|
53
|
+
action: "completed",
|
|
54
|
+
message: `Processed ${name}`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
module.exports = { run };
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. **Create a workflow** in `execution/workflows/my_workflow.json`
|
|
61
|
+
|
|
62
|
+
3. **Create a directive** in `directives/my_workflow.md`
|
|
63
|
+
|
|
64
|
+
4. **Push to Mudlab**:
|
|
65
|
+
```bash
|
|
66
|
+
node execution/push_workflow.js execution/workflows/my_workflow.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
See the generated `CLAUDE.md` for the complete 3-layer architecture documentation.
|
|
70
|
+
|
|
71
|
+
## Learn More
|
|
72
|
+
|
|
73
|
+
- [Mudlab Documentation](https://mudlab.io/docs)
|
|
74
|
+
- [GitHub](https://github.com/mudlab/create-workflow)
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/bin/create.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const projectName = process.argv[2];
|
|
7
|
+
|
|
8
|
+
if (!projectName) {
|
|
9
|
+
console.error('Usage: pnpm create @mudlab/workflow <project-name>');
|
|
10
|
+
console.error('');
|
|
11
|
+
console.error('Example:');
|
|
12
|
+
console.error(' pnpm create @mudlab/workflow my-automations');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Validate project name
|
|
17
|
+
if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
|
|
18
|
+
console.error('Error: Project name can only contain letters, numbers, hyphens, and underscores');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
23
|
+
|
|
24
|
+
// Check if directory already exists
|
|
25
|
+
if (fs.existsSync(targetDir)) {
|
|
26
|
+
console.error(`Error: Directory "${projectName}" already exists`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log(`\nCreating Mudlab workflow project in ${targetDir}...\n`);
|
|
31
|
+
|
|
32
|
+
// Get template directory (relative to this script)
|
|
33
|
+
const templateDir = path.join(__dirname, '..', 'template');
|
|
34
|
+
|
|
35
|
+
// Copy template directory recursively
|
|
36
|
+
function copyDir(src, dest) {
|
|
37
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
38
|
+
|
|
39
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
40
|
+
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
const srcPath = path.join(src, entry.name);
|
|
43
|
+
const destPath = path.join(dest, entry.name);
|
|
44
|
+
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
copyDir(srcPath, destPath);
|
|
47
|
+
} else {
|
|
48
|
+
fs.copyFileSync(srcPath, destPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// Copy template
|
|
55
|
+
copyDir(templateDir, targetDir);
|
|
56
|
+
|
|
57
|
+
// Update package.json with project name
|
|
58
|
+
const pkgPath = path.join(targetDir, 'package.json');
|
|
59
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
60
|
+
pkg.name = projectName;
|
|
61
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
62
|
+
|
|
63
|
+
// Rename .env.example to .env (commented out - let user do it manually for safety)
|
|
64
|
+
// const envExample = path.join(targetDir, '.env.example');
|
|
65
|
+
// const envFile = path.join(targetDir, '.env');
|
|
66
|
+
// if (fs.existsSync(envExample)) {
|
|
67
|
+
// fs.renameSync(envExample, envFile);
|
|
68
|
+
// }
|
|
69
|
+
|
|
70
|
+
console.log('Done! Next steps:\n');
|
|
71
|
+
console.log(` cd ${projectName}`);
|
|
72
|
+
console.log(' cp .env.example .env');
|
|
73
|
+
console.log(' # Edit .env with your Mudlab API key\n');
|
|
74
|
+
console.log('Then start building workflows:');
|
|
75
|
+
console.log(' 1. Add tools in execution/tools/');
|
|
76
|
+
console.log(' 2. Add workflows in execution/workflows/');
|
|
77
|
+
console.log(' 3. Add directives in directives/');
|
|
78
|
+
console.log(' 4. Push: node execution/push_workflow.js execution/workflows/your_workflow.json\n');
|
|
79
|
+
console.log('See CLAUDE.md for the full 3-layer architecture guide.\n');
|
|
80
|
+
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Error creating project:', error.message);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mudlab/create-workflow",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create Mudlab workflow projects with a single command",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-mudlab-workflow": "./bin/create.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"template"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mudlab",
|
|
14
|
+
"workflow",
|
|
15
|
+
"automation",
|
|
16
|
+
"ai",
|
|
17
|
+
"cli",
|
|
18
|
+
"scaffold",
|
|
19
|
+
"create"
|
|
20
|
+
],
|
|
21
|
+
"author": "Mudlab <support@mudlab.io>",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/mudlab/create-workflow.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://mudlab.io",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=16"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Mudlab API Configuration
|
|
2
|
+
MUDLAB_API_URL=http://localhost:3000
|
|
3
|
+
MUDLAB_API_KEY=your_mudlab_api_key_here
|
|
4
|
+
|
|
5
|
+
# Add your integration API keys below
|
|
6
|
+
# These are passed to tools when running workflows locally
|
|
7
|
+
# Example:
|
|
8
|
+
# NOTION_API_KEY=your_notion_api_key
|
|
9
|
+
# NOTION_DATABASE_ID=your_database_id
|
|
10
|
+
# RESEND_API_KEY=your_resend_api_key
|
|
11
|
+
# STRIPE_API_KEY=your_stripe_api_key
|