@mastra/dane 0.0.2-alpha.4 → 0.0.2-alpha.40
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 +25 -4
- package/data/crawl/conventional-commit.json +25 -0
- package/dist/commands/commit-message.d.ts +2 -0
- package/dist/commands/commit-message.d.ts.map +1 -0
- package/dist/commands/commit-message.js +31 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +40 -0
- package/dist/commands/issue-labeler.d.ts +1 -0
- package/dist/commands/issue-labeler.d.ts.map +1 -0
- package/dist/commands/issue-labeler.js +17 -1
- package/dist/commands/message.d.ts +1 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/publish-packages.d.ts +2 -0
- package/dist/commands/publish-packages.d.ts.map +1 -0
- package/dist/commands/publish-packages.js +9 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +75 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -1
- package/dist/mastra/agents/index.d.ts +115 -0
- package/dist/mastra/agents/index.d.ts.map +1 -0
- package/dist/mastra/agents/index.js +54 -24
- package/dist/mastra/index.d.ts +123 -0
- package/dist/mastra/index.d.ts.map +1 -0
- package/dist/mastra/index.js +7 -2
- package/dist/mastra/integrations/index.d.ts +3 -0
- package/dist/mastra/integrations/index.d.ts.map +1 -0
- package/dist/mastra/integrations/index.js +19 -2
- package/dist/mastra/tools/browser.d.ts +1 -0
- package/dist/mastra/tools/browser.d.ts.map +1 -0
- package/dist/mastra/tools/calendar.d.ts +1 -0
- package/dist/mastra/tools/calendar.d.ts.map +1 -0
- package/dist/mastra/tools/crawl.d.ts +4 -0
- package/dist/mastra/tools/crawl.d.ts.map +1 -0
- package/dist/mastra/tools/crawl.js +4 -2
- package/dist/mastra/tools/execa.d.ts +1 -0
- package/dist/mastra/tools/execa.d.ts.map +1 -0
- package/dist/mastra/tools/execa.js +5 -1
- package/dist/mastra/tools/fs.d.ts +1 -0
- package/dist/mastra/tools/fs.d.ts.map +1 -0
- package/dist/mastra/tools/image.d.ts +27 -0
- package/dist/mastra/tools/image.d.ts.map +1 -0
- package/dist/mastra/tools/image.js +37 -0
- package/dist/mastra/tools/pdf.d.ts +1 -0
- package/dist/mastra/tools/pdf.d.ts.map +1 -0
- package/dist/mastra/tools/pdf.js +3 -2
- package/dist/mastra/tools/pnpm.d.ts +60 -0
- package/dist/mastra/tools/pnpm.d.ts.map +1 -0
- package/dist/mastra/tools/pnpm.js +128 -0
- package/dist/mastra/workflows/chat.d.ts +1 -0
- package/dist/mastra/workflows/chat.d.ts.map +1 -0
- package/dist/mastra/workflows/chat.js +6 -11
- package/dist/mastra/workflows/commit-message.d.ts +10 -0
- package/dist/mastra/workflows/commit-message.d.ts.map +1 -0
- package/dist/mastra/workflows/commit-message.js +137 -0
- package/dist/mastra/workflows/index.d.ts +2 -0
- package/dist/mastra/workflows/index.d.ts.map +1 -0
- package/dist/mastra/workflows/index.js +1 -0
- package/dist/mastra/workflows/issue-labeler.d.ts +1 -0
- package/dist/mastra/workflows/issue-labeler.d.ts.map +1 -0
- package/dist/mastra/workflows/issue-labeler.js +1 -1
- package/dist/mastra/workflows/publish-packages.d.ts +3 -0
- package/dist/mastra/workflows/publish-packages.d.ts.map +1 -0
- package/dist/mastra/workflows/publish-packages.js +205 -0
- package/package.json +14 -10
- package/test/data/05-versions-space.pdf +0 -0
- package/test/data/05-versions-space.pdf.txt +42 -0
- package/test-files/716a95a5c57a56d32a32b1c9592d6df0.png +0 -0
- package/test-files/roman.md +79 -0
- package/test-files/sample-1.pdf +0 -0
- package/test-files/taxes/2022.txt +45 -0
- package/test-files/taxes/2023.txt +44 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createTool } from '@mastra/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { writeFileSync } from 'fs';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { stabilityai } from '../integrations/index.js';
|
|
7
|
+
export const imageTool = createTool({
|
|
8
|
+
id: 'imageTool',
|
|
9
|
+
name: 'imageTool',
|
|
10
|
+
description: 'Generate an image based on a text prompt',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
directory: z.string(),
|
|
13
|
+
prompt: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
message: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ context: { directory, prompt } }) => {
|
|
19
|
+
try {
|
|
20
|
+
console.log('\n' + chalk.blue(`Generating image...`));
|
|
21
|
+
const generateImageResult = await stabilityai.generateImage(prompt);
|
|
22
|
+
const file = resolve(directory, generateImageResult.filename);
|
|
23
|
+
writeFileSync(file, generateImageResult.buffer);
|
|
24
|
+
console.log(chalk.blue(`Successfully generated: ${file}`));
|
|
25
|
+
return {
|
|
26
|
+
message: `Successfully created ${file}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
if (e instanceof Error) {
|
|
31
|
+
console.log(`\n${chalk.red(e.message)}`);
|
|
32
|
+
return { message: e.message };
|
|
33
|
+
}
|
|
34
|
+
return { message: 'Error' };
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/pdf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;iDAsClB,CAAC"}
|
package/dist/mastra/tools/pdf.js
CHANGED
|
@@ -2,8 +2,9 @@ import { createTool } from '@mastra/core';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { existsSync, readFileSync } from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import pdf from 'pdf-parse';
|
|
6
5
|
import { z } from 'zod';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import pdfParse from 'pdf-parse/lib/pdf-parse.js';
|
|
7
8
|
export const readPDF = createTool({
|
|
8
9
|
id: 'readPDF',
|
|
9
10
|
name: 'Read PDF',
|
|
@@ -27,7 +28,7 @@ export const readPDF = createTool({
|
|
|
27
28
|
// Read the PDF file
|
|
28
29
|
const dataBuffer = readFileSync(pdfPath);
|
|
29
30
|
// Parse PDF content
|
|
30
|
-
const data = await
|
|
31
|
+
const data = await pdfParse(dataBuffer);
|
|
31
32
|
console.log(chalk.blue('\n'));
|
|
32
33
|
console.log(chalk.blue('PDF Information:'));
|
|
33
34
|
console.log(chalk.blue('-----------------'));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const pnpmBuild: import("@mastra/core").Tool<"pnpmBuild", z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
packagePath: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
name: string;
|
|
7
|
+
packagePath: string;
|
|
8
|
+
}, {
|
|
9
|
+
name: string;
|
|
10
|
+
packagePath: string;
|
|
11
|
+
}>, z.ZodObject<{
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
message: string;
|
|
15
|
+
}, {
|
|
16
|
+
message: string;
|
|
17
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
packagePath: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
name: string;
|
|
22
|
+
packagePath: string;
|
|
23
|
+
}, {
|
|
24
|
+
name: string;
|
|
25
|
+
packagePath: string;
|
|
26
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
27
|
+
export declare const pnpmChangesetStatus: import("@mastra/core").Tool<"pnpmChangesetStatus", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
28
|
+
message: z.ZodArray<z.ZodString, "many">;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
message: string[];
|
|
31
|
+
}, {
|
|
32
|
+
message: string[];
|
|
33
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
34
|
+
export declare const pnpmChangesetPublish: import("@mastra/core").Tool<"pnpmChangesetPublish", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
message: string;
|
|
38
|
+
}, {
|
|
39
|
+
message: string;
|
|
40
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
41
|
+
export declare const activeDistTag: import("@mastra/core").Tool<"activeDistTag", z.ZodObject<{
|
|
42
|
+
packagePath: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
packagePath: string;
|
|
45
|
+
}, {
|
|
46
|
+
packagePath: string;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
message: z.ZodString;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
message: string;
|
|
51
|
+
}, {
|
|
52
|
+
message: string;
|
|
53
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
54
|
+
packagePath: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
packagePath: string;
|
|
57
|
+
}, {
|
|
58
|
+
packagePath: string;
|
|
59
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
60
|
+
//# sourceMappingURL=pnpm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/pnpm.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDA8BpB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;6IA8B9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;6IA0B/B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;iDA8BxB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createTool } from '@mastra/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa, ExecaError } from 'execa';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const pnpmBuild = createTool({
|
|
8
|
+
id: 'pnpmBuild',
|
|
9
|
+
name: 'PNPM Build Tool',
|
|
10
|
+
description: 'Used to build the pnpm module',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
name: z.string(),
|
|
13
|
+
packagePath: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
message: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ context: { name, packagePath } }) => {
|
|
19
|
+
try {
|
|
20
|
+
console.log(chalk.green(`Building: ${name} at ${packagePath}`));
|
|
21
|
+
const p = execa(`pnpm`, ['build'], {
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
cwd: packagePath,
|
|
24
|
+
reject: false,
|
|
25
|
+
});
|
|
26
|
+
console.log(`\n`);
|
|
27
|
+
await p;
|
|
28
|
+
return { message: 'Done' };
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
if (e instanceof ExecaError) {
|
|
33
|
+
return { message: e.message };
|
|
34
|
+
}
|
|
35
|
+
return { message: 'Error' };
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export const pnpmChangesetStatus = createTool({
|
|
40
|
+
id: 'pnpmChangesetStatus',
|
|
41
|
+
name: 'PNPM Changeset Status Tool',
|
|
42
|
+
description: 'Used to check which pnpm modules need to be published',
|
|
43
|
+
inputSchema: z.object({}),
|
|
44
|
+
outputSchema: z.object({
|
|
45
|
+
message: z.array(z.string()),
|
|
46
|
+
}),
|
|
47
|
+
execute: async () => {
|
|
48
|
+
try {
|
|
49
|
+
console.log('Checking');
|
|
50
|
+
const { stdout } = await execa('pnpm', ['publish', '-r', '--dry-run', '--no-git-checks'], {
|
|
51
|
+
all: true,
|
|
52
|
+
// We want to see stderr too since pnpm sometimes puts important info there
|
|
53
|
+
stderr: 'inherit',
|
|
54
|
+
});
|
|
55
|
+
const lines = stdout.split('\n');
|
|
56
|
+
const filteredLines = lines.filter(line => line.startsWith('+'));
|
|
57
|
+
const packages = filteredLines.map(line => line.trim().substring(2).split('@').slice(0, -1).join('@'));
|
|
58
|
+
return { message: packages };
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error(e);
|
|
62
|
+
if (e instanceof ExecaError) {
|
|
63
|
+
return { message: [e.message] };
|
|
64
|
+
}
|
|
65
|
+
return { message: ['Error'] };
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
export const pnpmChangesetPublish = createTool({
|
|
70
|
+
id: 'pnpmChangesetPublish',
|
|
71
|
+
name: 'PNPM Changeset Publish Tool',
|
|
72
|
+
description: 'Used to publish the pnpm module',
|
|
73
|
+
inputSchema: z.object({}),
|
|
74
|
+
outputSchema: z.object({
|
|
75
|
+
message: z.string(),
|
|
76
|
+
}),
|
|
77
|
+
execute: async () => {
|
|
78
|
+
try {
|
|
79
|
+
console.log(chalk.green(`Publishing...`));
|
|
80
|
+
const p = execa(`pnpm`, ['changeset', 'publish'], {
|
|
81
|
+
stdio: 'inherit',
|
|
82
|
+
reject: false,
|
|
83
|
+
});
|
|
84
|
+
console.log(`\n`);
|
|
85
|
+
await p;
|
|
86
|
+
return { message: 'Done' };
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.error(e);
|
|
90
|
+
if (e instanceof ExecaError) {
|
|
91
|
+
return { message: e.message };
|
|
92
|
+
}
|
|
93
|
+
return { message: 'Error' };
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
export const activeDistTag = createTool({
|
|
98
|
+
id: 'activeDistTag',
|
|
99
|
+
name: 'PNPM Changeset set active tag',
|
|
100
|
+
description: 'Used to set active tag on the pnpm module',
|
|
101
|
+
inputSchema: z.object({
|
|
102
|
+
packagePath: z.string(),
|
|
103
|
+
}),
|
|
104
|
+
outputSchema: z.object({
|
|
105
|
+
message: z.string(),
|
|
106
|
+
}),
|
|
107
|
+
execute: async ({ context }) => {
|
|
108
|
+
try {
|
|
109
|
+
const pkgJson = JSON.parse(readFileSync(path.join(context.packagePath, 'package.json'), 'utf-8'));
|
|
110
|
+
const version = pkgJson.version;
|
|
111
|
+
console.log(chalk.green(`Setting active tag to latest for ${pkgJson.name}@${version}`));
|
|
112
|
+
const p = execa(`npm`, ['dist-tag', `add`, `${pkgJson.name}@${version}`, `latest`], {
|
|
113
|
+
stdio: 'inherit',
|
|
114
|
+
reject: false,
|
|
115
|
+
});
|
|
116
|
+
console.log(`\n`);
|
|
117
|
+
await p;
|
|
118
|
+
return { message: 'Done' };
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
console.error(e);
|
|
122
|
+
if (e instanceof ExecaError) {
|
|
123
|
+
return { message: e.message };
|
|
124
|
+
}
|
|
125
|
+
return { message: 'Error' };
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;;;;;;GAM1B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { input } from '@inquirer/prompts';
|
|
1
2
|
import { Step, Workflow } from '@mastra/core';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { dane } from '../agents/index.js';
|
|
6
6
|
export const messageWorkflow = new Workflow({
|
|
@@ -16,14 +16,10 @@ const messageStep = new Step({
|
|
|
16
16
|
message: z.string(),
|
|
17
17
|
}),
|
|
18
18
|
execute: async () => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
message: '\n You:',
|
|
24
|
-
validate: input => input.trim().length > 0 || 'Message cannot be empty',
|
|
25
|
-
},
|
|
26
|
-
]);
|
|
19
|
+
const content = await input({
|
|
20
|
+
message: '\n You:',
|
|
21
|
+
validate: input => input.trim().length > 0 || 'Message cannot be empty',
|
|
22
|
+
});
|
|
27
23
|
return { message: content };
|
|
28
24
|
},
|
|
29
25
|
});
|
|
@@ -51,8 +47,7 @@ const messageOutputStep = new Step({
|
|
|
51
47
|
if (!messages || messages.length === 0) {
|
|
52
48
|
messages = [];
|
|
53
49
|
}
|
|
54
|
-
const res = await mastra?.agents?.['dane']?.
|
|
55
|
-
stream: true,
|
|
50
|
+
const res = await mastra?.agents?.['dane']?.stream(message, {
|
|
56
51
|
maxSteps: 5,
|
|
57
52
|
resourceid,
|
|
58
53
|
threadId,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Workflow } from '@mastra/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const commitMessageGenerator: Workflow<any, z.ZodObject<{
|
|
4
|
+
repoPath: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
repoPath: string;
|
|
7
|
+
}, {
|
|
8
|
+
repoPath: string;
|
|
9
|
+
}>>;
|
|
10
|
+
//# sourceMappingURL=commit-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/commit-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,sBAAsB;;;;;;GAKjC,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Step, Workflow } from '@mastra/core';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { fsTool } from '../tools/fs.js';
|
|
7
|
+
export const commitMessageGenerator = new Workflow({
|
|
8
|
+
name: 'commit-message',
|
|
9
|
+
triggerSchema: z.object({
|
|
10
|
+
repoPath: z.string(),
|
|
11
|
+
}),
|
|
12
|
+
});
|
|
13
|
+
const getDiff = new Step({
|
|
14
|
+
id: 'getDiff',
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
diff: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ context }) => {
|
|
19
|
+
const repoPath = context?.machineContext?.triggerData?.repoPath;
|
|
20
|
+
// Get the git diff of staged changes
|
|
21
|
+
const diff = execSync('git diff --staged', {
|
|
22
|
+
cwd: repoPath,
|
|
23
|
+
encoding: 'utf-8',
|
|
24
|
+
});
|
|
25
|
+
return { diff };
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const readConventionalCommitSpec = new Step({
|
|
29
|
+
id: 'readConventionalCommitSpec',
|
|
30
|
+
outputSchema: z.object({
|
|
31
|
+
fileData: z.any(),
|
|
32
|
+
}),
|
|
33
|
+
execute: async () => {
|
|
34
|
+
const fileData = await fsTool.execute({
|
|
35
|
+
context: { action: 'read', file: 'data/crawl/conventional-commit.json', data: '' },
|
|
36
|
+
});
|
|
37
|
+
return { fileData };
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const generateMessage = new Step({
|
|
41
|
+
id: 'generateMessage',
|
|
42
|
+
outputSchema: z.object({
|
|
43
|
+
commitMessage: z.string(),
|
|
44
|
+
generated: z.boolean(),
|
|
45
|
+
guidelines: z.array(z.string()),
|
|
46
|
+
}),
|
|
47
|
+
execute: async ({ context, mastra }) => {
|
|
48
|
+
const diffStep = context?.machineContext?.stepResults?.getDiff;
|
|
49
|
+
const fileDataStep = context?.machineContext?.stepResults?.readConventionalCommitSpec;
|
|
50
|
+
if (!diffStep || diffStep.status !== 'success') {
|
|
51
|
+
return { commitMessage: '', generated: false, guidelines: [] };
|
|
52
|
+
}
|
|
53
|
+
const daneCommitGenerator = mastra?.agents?.daneCommitMessage;
|
|
54
|
+
const res = await daneCommitGenerator?.generate(`
|
|
55
|
+
Given this git diff:
|
|
56
|
+
${diffStep.payload.diff}
|
|
57
|
+
|
|
58
|
+
IF THE DIFF IS EMPTY, RETURN "No staged changes found", AND SET GENERATED TO FALSE,
|
|
59
|
+
OTHERWISE, SET GENERATED TO TRUE
|
|
60
|
+
|
|
61
|
+
${fileDataStep?.status === 'success' && fileDataStep?.payload?.fileData?.message
|
|
62
|
+
? `USE THE FOLLOWING GUIDELINES: ${fileDataStep?.payload?.fileData?.message}`
|
|
63
|
+
: `USE THE FOLLOWING GUIDELINES:
|
|
64
|
+
- Start with a verb in the present tense
|
|
65
|
+
- Be specific but concise
|
|
66
|
+
- Focus on the "what" and "why" of the changes
|
|
67
|
+
IF THERE ARE MULTIPLE LOGICAL CHANGES, USE THE DESCRIPTION TO EXPLAIN THE CHANGES IN BULLET POINTS.
|
|
68
|
+
|
|
69
|
+
- Keep the first line under 50 characters
|
|
70
|
+
- If needed, add more detailed description after a blank line`}
|
|
71
|
+
|
|
72
|
+
RETURN THE GUIDELINES YOU ARE USING AS AN ARRAY OF STRINGS ON THE GUIDELINES KEY, AND THE COMMIT MESSAGE ON THE COMMIT MESSAGE KEY
|
|
73
|
+
`, {
|
|
74
|
+
output: z.object({
|
|
75
|
+
commitMessage: z.string(),
|
|
76
|
+
generated: z.boolean(),
|
|
77
|
+
guidelines: z.array(z.string()),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
if (!res?.object?.generated) {
|
|
81
|
+
throw new Error(res?.object?.commitMessage);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
commitMessage: res?.object?.commitMessage,
|
|
85
|
+
generated: res?.object?.generated,
|
|
86
|
+
guidelines: res?.object?.guidelines,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const confirmationStep = new Step({
|
|
91
|
+
id: 'confirmation',
|
|
92
|
+
outputSchema: z.object({
|
|
93
|
+
confirm: z.boolean(),
|
|
94
|
+
}),
|
|
95
|
+
execute: async ({ context }) => {
|
|
96
|
+
const parentStep = context?.machineContext?.stepResults?.generateMessage;
|
|
97
|
+
if (!parentStep || parentStep.status !== 'success') {
|
|
98
|
+
return { confirm: false };
|
|
99
|
+
}
|
|
100
|
+
if (!parentStep.payload.generated) {
|
|
101
|
+
return { confirm: false };
|
|
102
|
+
}
|
|
103
|
+
const commitMessage = parentStep.payload.commitMessage;
|
|
104
|
+
const confirmationMessage = await confirm({
|
|
105
|
+
message: `\n Would you like to use this commit message? \n\n ${chalk.yellow(commitMessage)}\n\n`,
|
|
106
|
+
});
|
|
107
|
+
return { confirm: confirmationMessage };
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const commitStep = new Step({
|
|
111
|
+
id: 'commit',
|
|
112
|
+
outputSchema: z.object({
|
|
113
|
+
commit: z.boolean(),
|
|
114
|
+
}),
|
|
115
|
+
execute: async ({ context }) => {
|
|
116
|
+
const parentStep = context?.machineContext?.stepResults?.confirmation;
|
|
117
|
+
if (!parentStep || parentStep.status !== 'success' || !parentStep.payload.confirm) {
|
|
118
|
+
throw new Error('Commit message generation cancelled');
|
|
119
|
+
}
|
|
120
|
+
if (context?.machineContext?.stepResults?.generateMessage?.status !== 'success') {
|
|
121
|
+
throw new Error('Failed to generate commit message');
|
|
122
|
+
}
|
|
123
|
+
const commitMessage = context?.machineContext?.stepResults?.generateMessage?.payload?.commitMessage;
|
|
124
|
+
execSync(`git commit -m "${commitMessage}"`, {
|
|
125
|
+
cwd: context?.machineContext?.triggerData?.repoPath,
|
|
126
|
+
encoding: 'utf-8',
|
|
127
|
+
});
|
|
128
|
+
return { commit: true };
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
commitMessageGenerator
|
|
132
|
+
.step(getDiff)
|
|
133
|
+
.then(readConventionalCommitSpec)
|
|
134
|
+
.then(generateMessage)
|
|
135
|
+
.then(confirmationStep)
|
|
136
|
+
.then(commitStep)
|
|
137
|
+
.commit();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-labeler.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/issue-labeler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;GAO7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/publish-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAM9C,eAAO,MAAM,gBAAgB,oBAE3B,CAAC"}
|