@mastra/dane 0.0.4 → 0.0.5-alpha.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.
Files changed (109) hide show
  1. package/package.json +9 -9
  2. package/dist/commands/changelog.d.ts +0 -2
  3. package/dist/commands/changelog.d.ts.map +0 -1
  4. package/dist/commands/changelog.js +0 -15
  5. package/dist/commands/commit-message.d.ts +0 -2
  6. package/dist/commands/commit-message.d.ts.map +0 -1
  7. package/dist/commands/commit-message.js +0 -32
  8. package/dist/commands/config.d.ts +0 -3
  9. package/dist/commands/config.d.ts.map +0 -1
  10. package/dist/commands/config.js +0 -40
  11. package/dist/commands/issue-labeler.d.ts +0 -2
  12. package/dist/commands/issue-labeler.d.ts.map +0 -1
  13. package/dist/commands/issue-labeler.js +0 -35
  14. package/dist/commands/link-checker.d.ts +0 -4
  15. package/dist/commands/link-checker.d.ts.map +0 -1
  16. package/dist/commands/link-checker.js +0 -16
  17. package/dist/commands/message.d.ts +0 -2
  18. package/dist/commands/message.d.ts.map +0 -1
  19. package/dist/commands/message.js +0 -14
  20. package/dist/commands/new-contributor-message.d.ts +0 -2
  21. package/dist/commands/new-contributor-message.d.ts.map +0 -1
  22. package/dist/commands/new-contributor-message.js +0 -43
  23. package/dist/commands/publish-packages.d.ts +0 -2
  24. package/dist/commands/publish-packages.d.ts.map +0 -1
  25. package/dist/commands/publish-packages.js +0 -11
  26. package/dist/commands/telephone-game.d.ts +0 -2
  27. package/dist/commands/telephone-game.d.ts.map +0 -1
  28. package/dist/commands/telephone-game.js +0 -30
  29. package/dist/config/index.d.ts +0 -12
  30. package/dist/config/index.d.ts.map +0 -1
  31. package/dist/config/index.js +0 -75
  32. package/dist/index.d.ts +0 -3
  33. package/dist/index.d.ts.map +0 -1
  34. package/dist/index.js +0 -37
  35. package/dist/mastra/agents/index.d.ts +0 -165
  36. package/dist/mastra/agents/index.d.ts.map +0 -1
  37. package/dist/mastra/agents/index.js +0 -111
  38. package/dist/mastra/agents/memory.d.ts +0 -3
  39. package/dist/mastra/agents/memory.d.ts.map +0 -1
  40. package/dist/mastra/agents/memory.js +0 -10
  41. package/dist/mastra/agents/model.d.ts +0 -2
  42. package/dist/mastra/agents/model.d.ts.map +0 -1
  43. package/dist/mastra/agents/model.js +0 -8
  44. package/dist/mastra/agents/new-contributor.d.ts +0 -3
  45. package/dist/mastra/agents/new-contributor.d.ts.map +0 -1
  46. package/dist/mastra/agents/new-contributor.js +0 -14
  47. package/dist/mastra/agents/package-publisher.d.ts +0 -65
  48. package/dist/mastra/agents/package-publisher.d.ts.map +0 -1
  49. package/dist/mastra/agents/package-publisher.js +0 -170
  50. package/dist/mastra/index.d.ts +0 -291
  51. package/dist/mastra/index.d.ts.map +0 -1
  52. package/dist/mastra/index.js +0 -37
  53. package/dist/mastra/integrations/index.d.ts +0 -5
  54. package/dist/mastra/integrations/index.d.ts.map +0 -1
  55. package/dist/mastra/integrations/index.js +0 -23
  56. package/dist/mastra/tools/browser.d.ts +0 -40
  57. package/dist/mastra/tools/browser.d.ts.map +0 -1
  58. package/dist/mastra/tools/browser.js +0 -116
  59. package/dist/mastra/tools/calendar.d.ts +0 -21
  60. package/dist/mastra/tools/calendar.d.ts.map +0 -1
  61. package/dist/mastra/tools/calendar.js +0 -134
  62. package/dist/mastra/tools/crawl.d.ts +0 -36
  63. package/dist/mastra/tools/crawl.d.ts.map +0 -1
  64. package/dist/mastra/tools/crawl.js +0 -27
  65. package/dist/mastra/tools/execa.d.ts +0 -27
  66. package/dist/mastra/tools/execa.d.ts.map +0 -1
  67. package/dist/mastra/tools/execa.js +0 -43
  68. package/dist/mastra/tools/fs.d.ts +0 -33
  69. package/dist/mastra/tools/fs.d.ts.map +0 -1
  70. package/dist/mastra/tools/fs.js +0 -36
  71. package/dist/mastra/tools/image.d.ts +0 -27
  72. package/dist/mastra/tools/image.d.ts.map +0 -1
  73. package/dist/mastra/tools/image.js +0 -37
  74. package/dist/mastra/tools/mcp.d.ts +0 -3
  75. package/dist/mastra/tools/mcp.d.ts.map +0 -1
  76. package/dist/mastra/tools/mcp.js +0 -12
  77. package/dist/mastra/tools/pdf.d.ts +0 -21
  78. package/dist/mastra/tools/pdf.d.ts.map +0 -1
  79. package/dist/mastra/tools/pdf.js +0 -42
  80. package/dist/mastra/tools/pnpm.d.ts +0 -60
  81. package/dist/mastra/tools/pnpm.d.ts.map +0 -1
  82. package/dist/mastra/tools/pnpm.js +0 -127
  83. package/dist/mastra/workflows/changelog.d.ts +0 -10
  84. package/dist/mastra/workflows/changelog.d.ts.map +0 -1
  85. package/dist/mastra/workflows/changelog.js +0 -239
  86. package/dist/mastra/workflows/chat.d.ts +0 -13
  87. package/dist/mastra/workflows/chat.d.ts.map +0 -1
  88. package/dist/mastra/workflows/chat.js +0 -90
  89. package/dist/mastra/workflows/commit-message.d.ts +0 -10
  90. package/dist/mastra/workflows/commit-message.d.ts.map +0 -1
  91. package/dist/mastra/workflows/commit-message.js +0 -141
  92. package/dist/mastra/workflows/first-contributor.d.ts +0 -16
  93. package/dist/mastra/workflows/first-contributor.d.ts.map +0 -1
  94. package/dist/mastra/workflows/first-contributor.js +0 -124
  95. package/dist/mastra/workflows/index.d.ts +0 -4
  96. package/dist/mastra/workflows/index.d.ts.map +0 -1
  97. package/dist/mastra/workflows/index.js +0 -3
  98. package/dist/mastra/workflows/issue-labeler.d.ts +0 -16
  99. package/dist/mastra/workflows/issue-labeler.d.ts.map +0 -1
  100. package/dist/mastra/workflows/issue-labeler.js +0 -85
  101. package/dist/mastra/workflows/link-checker.d.ts +0 -13
  102. package/dist/mastra/workflows/link-checker.d.ts.map +0 -1
  103. package/dist/mastra/workflows/link-checker.js +0 -102
  104. package/dist/mastra/workflows/publish-packages.d.ts +0 -3
  105. package/dist/mastra/workflows/publish-packages.d.ts.map +0 -1
  106. package/dist/mastra/workflows/publish-packages.js +0 -252
  107. package/dist/mastra/workflows/telephone-game.d.ts +0 -3
  108. package/dist/mastra/workflows/telephone-game.d.ts.map +0 -1
  109. package/dist/mastra/workflows/telephone-game.js +0 -97
@@ -1,127 +0,0 @@
1
- import { createTool } from '@mastra/core/tools';
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(`\n 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(chalk.green(`\nRunning command: pnpm publish -r --dry-run --no-git-checks`));
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
- });
54
- const lines = stdout.split('\n');
55
- const filteredLines = lines.filter(line => line.startsWith('+'));
56
- const packages = filteredLines.map(line => line.trim().substring(2).split('@').slice(0, -1).join('@'));
57
- return { message: packages };
58
- }
59
- catch (e) {
60
- console.error(e);
61
- if (e instanceof ExecaError) {
62
- return { message: [e.message] };
63
- }
64
- return { message: ['Error'] };
65
- }
66
- },
67
- });
68
- export const pnpmChangesetPublish = createTool({
69
- id: 'pnpmChangesetPublish',
70
- name: 'PNPM Changeset Publish Tool',
71
- description: 'Used to publish the pnpm module',
72
- inputSchema: z.object({}),
73
- outputSchema: z.object({
74
- message: z.string(),
75
- }),
76
- execute: async () => {
77
- try {
78
- console.log(chalk.green(`Publishing...`));
79
- const p = execa(`pnpm`, ['changeset', 'publish'], {
80
- stdio: 'inherit',
81
- reject: false,
82
- });
83
- console.log(`\n`);
84
- await p;
85
- return { message: 'Done' };
86
- }
87
- catch (e) {
88
- console.error(e);
89
- if (e instanceof ExecaError) {
90
- return { message: e.message };
91
- }
92
- return { message: 'Error' };
93
- }
94
- },
95
- });
96
- export const activeDistTag = createTool({
97
- id: 'activeDistTag',
98
- name: 'PNPM Active Dist Tag Tool',
99
- description: 'Set active dist tag on pnpm module',
100
- inputSchema: z.object({
101
- packagePath: z.string(),
102
- }),
103
- outputSchema: z.object({
104
- message: z.string(),
105
- }),
106
- execute: async ({ context }) => {
107
- try {
108
- const pkgJson = JSON.parse(readFileSync(path.join(context.packagePath, 'package.json'), 'utf-8'));
109
- const version = pkgJson.version;
110
- console.log(chalk.green(`Setting active tag to latest for ${pkgJson.name}@${version}`));
111
- const p = execa(`npm`, ['dist-tag', `add`, `${pkgJson.name}@${version}`, `latest`], {
112
- stdio: 'inherit',
113
- reject: false,
114
- });
115
- console.log(`\n`);
116
- await p;
117
- return { message: 'Done' };
118
- }
119
- catch (e) {
120
- console.error(e);
121
- if (e instanceof ExecaError) {
122
- return { message: e.message };
123
- }
124
- return { message: 'Error' };
125
- }
126
- },
127
- });
@@ -1,10 +0,0 @@
1
- import { Workflow } from '@mastra/core/workflows';
2
- import { z } from 'zod';
3
- export declare const changelogWorkflow: Workflow<any, z.ZodObject<{
4
- channelId: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- channelId: string;
7
- }, {
8
- channelId: string;
9
- }>>;
10
- //# sourceMappingURL=changelog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/changelog.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;;;;;;GAK5B,CAAC"}
@@ -1,239 +0,0 @@
1
- import { delay } from '@mastra/core';
2
- import { Step, Workflow } from '@mastra/core/workflows';
3
- import chalk from 'chalk';
4
- import { execa } from 'execa';
5
- import { existsSync, readFileSync, writeFileSync } from 'fs';
6
- import { z } from 'zod';
7
- import { slack } from '../tools/mcp.js';
8
- export const changelogWorkflow = new Workflow({
9
- name: 'changelog',
10
- triggerSchema: z.object({
11
- channelId: z.string(),
12
- }),
13
- });
14
- const stepA1 = new Step({
15
- id: 'stepA1',
16
- description: 'Get a git diff',
17
- outputSchema: z.object({
18
- message: z.string(),
19
- }),
20
- execute: async ({ mastra }) => {
21
- // For today
22
- try {
23
- await slack.connect();
24
- }
25
- catch (e) {
26
- console.error(e);
27
- }
28
- const today = new Date().toISOString().split('T')[0];
29
- if (existsSync(`generated-changelogs/changelog-${today}`)) {
30
- console.log(chalk.red(`Changelog for today already exists`));
31
- return {
32
- message: readFileSync(`generated-changelogs/changelog-${today}`, 'utf-8'),
33
- };
34
- }
35
- console.log(today);
36
- // For 7 days ago
37
- const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
38
- console.log(weekAgo);
39
- const cwd = process.cwd();
40
- console.log(cwd);
41
- const modulePaths = [
42
- 'packages/core',
43
- 'packages/cli',
44
- 'packages/create-mastra',
45
- 'packages/deployer',
46
- 'packages/evals',
47
- 'packages/rag',
48
- 'packages/memory',
49
- 'packages/mcp',
50
- // Deployers
51
- 'deployers/cloudflare',
52
- 'deployers/netlify',
53
- 'deployers/vercel',
54
- // Speech modules
55
- 'speech/azure',
56
- 'speech/deepgram',
57
- 'speech/elevenlabs',
58
- 'speech/google',
59
- 'speech/ibm',
60
- 'speech/murf',
61
- 'speech/openai',
62
- 'speech/playai',
63
- 'speech/replicate',
64
- 'speech/speechify',
65
- // Storage modules
66
- 'stores/pg',
67
- 'stores/astra',
68
- 'stores/chroma',
69
- 'stores/pinecone',
70
- 'stores/qdrant',
71
- 'stores/upstash',
72
- 'stores/vectorize',
73
- ];
74
- const moduleChangelogs = [];
75
- let generatedText = '';
76
- let TOKEN_LIMIT = 80000;
77
- for (const modulePath of modulePaths) {
78
- const args = [
79
- '--no-pager',
80
- 'diff',
81
- '--unified=1', // Reduced context to 1 line
82
- '--no-prefix',
83
- '--color=never',
84
- `main@{${weekAgo}}`,
85
- `main@{${today}}`,
86
- '--',
87
- modulePath,
88
- ':!**/node_modules/**',
89
- ':!**/.turbo/**',
90
- ':!**/.next/**',
91
- ':!**/coverage/**',
92
- ':!**/package-lock.json',
93
- ':!**/pnpm-lock.yaml',
94
- ':!**/yarn.lock',
95
- ':!**/*.bin',
96
- ':!**/*.exe',
97
- ':!**/*.dll',
98
- ':!**/*.so',
99
- ':!**/*.dylib',
100
- ':!**/*.class',
101
- ':!**/dist/**',
102
- ];
103
- console.log(`git ${args.join(' ')}`);
104
- try {
105
- const diff = await execa('git', args, {
106
- cwd,
107
- });
108
- const output = diff.stdout.trim();
109
- if (output) {
110
- // Only generate changelog if there are changes
111
- console.log(`${modulePath} changes length: ${output.length}`);
112
- const modulePrompt = `
113
- Time: ${weekAgo} - ${today}
114
- Module: ${modulePath}
115
-
116
- Git diff to generate from: ${output}
117
-
118
- # Task
119
- 1. Create a structured narrative changelog that highlights key updates and improvements for this module.
120
- 2. Focus only on meaningful changes, ignore trivial ones.
121
- 3. Group changes into categories:
122
- - New features
123
- - Improvements
124
- - Notable bug fixes
125
- - Build/deployment improvements
126
- - Performance optimizations
127
- `;
128
- const agent = mastra?.agents?.daneChangeLog;
129
- if (!agent) {
130
- throw new Error('LLM not found');
131
- }
132
- const result = await agent.generate(modulePrompt);
133
- moduleChangelogs.push({
134
- module: modulePath,
135
- changelog: result.text,
136
- });
137
- generatedText += `\n ## ${modulePath}\n${result.text}`;
138
- writeFileSync(`generated-changelogs/changelog-${today}`, generatedText);
139
- if (result.usage.promptTokens) {
140
- console.log(`Total prompt tokens used: ${result.usage.promptTokens}`);
141
- }
142
- TOKEN_LIMIT -= result.usage.promptTokens;
143
- if (TOKEN_LIMIT < 20000) {
144
- await delay(60000);
145
- TOKEN_LIMIT = 80000;
146
- }
147
- }
148
- }
149
- catch (e) {
150
- console.error(`Error processing ${modulePath}:`, e);
151
- }
152
- }
153
- // Combine all changelogs
154
- const combinedChangelog = moduleChangelogs
155
- .map(({ module, changelog }) => `## ${module}\n${changelog}`)
156
- .join('\n\n');
157
- writeFileSync(`generated-changelogs/changelog-${today}`, combinedChangelog);
158
- return {
159
- message: combinedChangelog,
160
- };
161
- },
162
- });
163
- const stepA2 = new Step({
164
- id: 'stepA2',
165
- description: 'Make changelog',
166
- outputSchema: z.object({
167
- message: z.string(),
168
- }),
169
- execute: async ({ context, mastra }) => {
170
- if (context?.steps.stepA1?.status !== 'success') {
171
- throw new Error('Message not found');
172
- }
173
- const agent = mastra?.agents?.daneChangeLog;
174
- if (!agent) {
175
- throw new Error('LLM not found');
176
- }
177
- const today = new Date().toISOString().split('T')[0];
178
- const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
179
- const tools = await slack.tools();
180
- const channelId = context.triggerData.channelId;
181
- const prompt = `
182
- Time: ${weekAgo} - ${today}
183
-
184
- ${context.steps.stepA1.output.message}
185
- # Task
186
- 1. create a structured narrative changelog that highlights key updates and improvements.
187
- 2. Include what packages were changed
188
-
189
- ## Structure
190
-
191
- 1. Opening
192
- - Brief welcome/context (1-2 sentences)
193
- - Time period covered
194
-
195
- 2. Major Updates (3-4 key highlights)
196
- - Lead with the most impactful changes
197
- - Include brief technical context where needed
198
- - Reference relevant PR numbers
199
- - Link to examples/docs where applicable
200
-
201
- 3. Technical Improvements
202
- - Group related changes
203
- - Focus on developer impact
204
- - Include code snippets if helpful
205
-
206
- 4. Documentation & Examples
207
- - New guides/tutorials
208
- - Updated examples
209
- - API documentation changes
210
-
211
- 5. Bug Fixes & Infrastructure
212
- - Notable bug fixes
213
- - Build/deployment improvements
214
- - Performance optimizations
215
-
216
- Finally send this to this slack channel: "${channelId}" with the tool slack_post_message
217
- `;
218
- console.log(chalk.green(`Generating...`));
219
- try {
220
- const result = await agent.generate(prompt, {
221
- toolsets: {
222
- slack: tools,
223
- },
224
- });
225
- console.log(chalk.green(result.text));
226
- return {
227
- message: result.text,
228
- };
229
- }
230
- catch (e) {
231
- console.log(chalk.red(e));
232
- return {
233
- message: e,
234
- };
235
- }
236
- },
237
- });
238
- // Update workflow to use both steps
239
- changelogWorkflow.step(stepA1).then(stepA2).commit();
@@ -1,13 +0,0 @@
1
- import { Workflow } from '@mastra/core/workflows';
2
- import { z } from 'zod';
3
- export declare const messageWorkflow: Workflow<any, z.ZodObject<{
4
- resourceId: z.ZodString;
5
- threadId: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- resourceId: string;
8
- threadId: string;
9
- }, {
10
- resourceId: string;
11
- threadId: string;
12
- }>>;
13
- //# sourceMappingURL=chat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;;;;;;GAM1B,CAAC"}
@@ -1,90 +0,0 @@
1
- import { input } from '@inquirer/prompts';
2
- import { Step, Workflow } from '@mastra/core/workflows';
3
- import chalk from 'chalk';
4
- import { z } from 'zod';
5
- import { dane } from '../agents/index.js';
6
- export const messageWorkflow = new Workflow({
7
- name: 'entry',
8
- triggerSchema: z.object({
9
- resourceId: z.string(),
10
- threadId: z.string(),
11
- }),
12
- });
13
- const messageStep = new Step({
14
- id: 'message-input',
15
- outputSchema: z.object({
16
- message: z.string(),
17
- }),
18
- execute: async () => {
19
- const content = await input({
20
- message: '\n You:',
21
- validate: input => input.trim().length > 0 || 'Message cannot be empty',
22
- });
23
- return { message: content };
24
- },
25
- });
26
- const messageOutputStep = new Step({
27
- id: 'message-output',
28
- outputSchema: z.object({
29
- message: z.string(),
30
- }),
31
- // SHOULD BE ABLE TO ACCESS ALL MASTRA PRIMS FROM EXECTUE
32
- execute: async ({ context, mastra }) => {
33
- // WISH THIS WAS TYPED
34
- const threadId = context?.triggerData?.threadId;
35
- const resourceId = context?.triggerData?.resourceId;
36
- const messageInputStatus = context?.steps?.['message-input']?.status;
37
- if (messageInputStatus !== 'success') {
38
- return { message: 'Failure in workflow' };
39
- }
40
- // is there someway to know what steps are flowing into this one and type their props
41
- const message = context?.steps?.['message-input']?.output?.message;
42
- try {
43
- // TODO: why was this unused?
44
- // let messages = await mastra?.memory?.getContextWindow({
45
- // threadId,
46
- // format: 'core_message',
47
- // });
48
- //
49
- // if (!messages || messages.length === 0) {
50
- // messages = [];
51
- // }
52
- const res = await mastra?.agents?.['dane']?.stream(message, {
53
- maxSteps: 5,
54
- resourceId,
55
- threadId,
56
- context: [],
57
- });
58
- if (res) {
59
- console.log(chalk.green(`\nDane: \n`));
60
- for await (const chunk of res.textStream) {
61
- process.stdout.write(chalk.green(chunk));
62
- }
63
- console.log(chalk.green(`\n`));
64
- return { message: 'success' };
65
- }
66
- }
67
- catch (e) {
68
- console.log(chalk.red(`\n`));
69
- console.log(chalk.red(`\n`));
70
- console.log(chalk.red(`Error streaming results. Let's try again.`));
71
- if (e instanceof Error) {
72
- console.log(chalk.red(e.message));
73
- }
74
- }
75
- const res = await dane.generate(message, {
76
- maxSteps: 5,
77
- threadId,
78
- resourceId,
79
- });
80
- console.log(chalk.green(res?.text));
81
- return { message: res?.text };
82
- },
83
- });
84
- messageWorkflow
85
- .step(messageStep)
86
- .after(messageStep)
87
- .step(messageOutputStep)
88
- .after(messageOutputStep)
89
- .step(messageStep)
90
- .commit();
@@ -1,10 +0,0 @@
1
- import { Workflow } from '@mastra/core/workflows';
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/commit-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,sBAAsB;;;;;;GAKjC,CAAC"}
@@ -1,141 +0,0 @@
1
- import { confirm } from '@inquirer/prompts';
2
- import { Step, Workflow } from '@mastra/core/workflows';
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?.getStepResult('trigger')?.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 ({ suspend }) => {
34
- if (!fsTool?.execute) {
35
- return { fileData: null };
36
- }
37
- const fileData = await fsTool.execute({
38
- context: { action: 'read', file: 'data/crawl/conventional-commit.json', data: '' },
39
- suspend,
40
- });
41
- return { fileData };
42
- },
43
- });
44
- const generateMessage = new Step({
45
- id: 'generateMessage',
46
- outputSchema: z.object({
47
- commitMessage: z.string(),
48
- generated: z.boolean(),
49
- guidelines: z.array(z.string()),
50
- }),
51
- execute: async ({ context, mastra }) => {
52
- const diffData = context?.getStepResult('getDiff');
53
- const fileData = context?.getStepResult('readConventionalCommitSpec');
54
- if (!diffData) {
55
- return { commitMessage: '', generated: false, guidelines: [] };
56
- }
57
- const daneCommitGenerator = mastra?.agents?.daneCommitMessage;
58
- const res = await daneCommitGenerator?.generate(`
59
- Given this git diff:
60
- ${diffData.diff}
61
-
62
- IF THE DIFF IS EMPTY, RETURN "No staged changes found", AND SET GENERATED TO FALSE,
63
- OTHERWISE, SET GENERATED TO TRUE
64
-
65
- ${fileData && fileData.fileData?.message
66
- ? `USE THE FOLLOWING GUIDELINES: ${fileData.fileData?.message}`
67
- : `USE THE FOLLOWING GUIDELINES:
68
- - Start with a verb in the present tense
69
- - Be specific but concise
70
- - Focus on the "what" and "why" of the changes
71
- IF THERE ARE MULTIPLE LOGICAL CHANGES, USE THE DESCRIPTION TO EXPLAIN THE CHANGES IN BULLET POINTS.
72
-
73
- - Keep the first line under 50 characters
74
- - If needed, add more detailed description after a blank line`}
75
-
76
- RETURN THE GUIDELINES YOU ARE USING AS AN ARRAY OF STRINGS ON THE GUIDELINES KEY, AND THE COMMIT MESSAGE ON THE COMMIT MESSAGE KEY
77
- `, {
78
- output: z.object({
79
- commitMessage: z.string(),
80
- generated: z.boolean(),
81
- guidelines: z.array(z.string()),
82
- }),
83
- });
84
- if (!res?.object?.generated) {
85
- throw new Error(res?.object?.commitMessage);
86
- }
87
- return {
88
- commitMessage: res?.object?.commitMessage,
89
- generated: res?.object?.generated,
90
- guidelines: res?.object?.guidelines,
91
- };
92
- },
93
- });
94
- const confirmationStep = new Step({
95
- id: 'confirmation',
96
- outputSchema: z.object({
97
- confirm: z.boolean(),
98
- }),
99
- execute: async ({ context }) => {
100
- const parentStep = context?.steps?.generateMessage;
101
- if (!parentStep || parentStep.status !== 'success') {
102
- return { confirm: false };
103
- }
104
- if (!parentStep.output.generated) {
105
- return { confirm: false };
106
- }
107
- const commitMessage = parentStep.output.commitMessage;
108
- const confirmationMessage = await confirm({
109
- message: `\n Would you like to use this commit message? \n\n ${chalk.yellow(commitMessage)}\n\n`,
110
- });
111
- return { confirm: confirmationMessage };
112
- },
113
- });
114
- const commitStep = new Step({
115
- id: 'commit',
116
- outputSchema: z.object({
117
- commit: z.boolean(),
118
- }),
119
- execute: async ({ context }) => {
120
- const parentStep = context?.steps?.confirmation;
121
- if (!parentStep || parentStep.status !== 'success' || !parentStep.output.confirm) {
122
- throw new Error('Commit message generation cancelled');
123
- }
124
- if (context?.steps?.generateMessage?.status !== 'success') {
125
- throw new Error('Failed to generate commit message');
126
- }
127
- const commitMessage = context?.steps?.generateMessage?.output?.commitMessage;
128
- execSync(`git commit -m "${commitMessage}"`, {
129
- cwd: context?.triggerData?.repoPath,
130
- encoding: 'utf-8',
131
- });
132
- return { commit: true };
133
- },
134
- });
135
- commitMessageGenerator
136
- .step(getDiff)
137
- .then(readConventionalCommitSpec)
138
- .then(generateMessage)
139
- .then(confirmationStep)
140
- .then(commitStep)
141
- .commit();
@@ -1,16 +0,0 @@
1
- import { Workflow } from '@mastra/core/workflows';
2
- import { z } from 'zod';
3
- export declare const githubFirstContributorMessage: Workflow<any, z.ZodObject<{
4
- repo: z.ZodString;
5
- owner: z.ZodString;
6
- pr_number: z.ZodNumber;
7
- }, "strip", z.ZodTypeAny, {
8
- repo: string;
9
- owner: string;
10
- pr_number: number;
11
- }, {
12
- repo: string;
13
- owner: string;
14
- pr_number: number;
15
- }>>;
16
- //# sourceMappingURL=first-contributor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"first-contributor.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/first-contributor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,6BAA6B;;;;;;;;;;;;GAOxC,CAAC"}