@mastra/dane 0.0.2-alpha.7 → 0.0.2-alpha.71

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 (89) hide show
  1. package/LICENSE +44 -0
  2. package/README.md +25 -4
  3. package/data/crawl/conventional-commit.json +25 -0
  4. package/dist/commands/changelog.d.ts +2 -0
  5. package/dist/commands/changelog.d.ts.map +1 -0
  6. package/dist/commands/changelog.js +15 -0
  7. package/dist/commands/commit-message.d.ts +2 -0
  8. package/dist/commands/commit-message.d.ts.map +1 -0
  9. package/dist/commands/commit-message.js +32 -0
  10. package/dist/commands/config.d.ts +3 -0
  11. package/dist/commands/config.d.ts.map +1 -0
  12. package/dist/commands/config.js +40 -0
  13. package/dist/commands/issue-labeler.d.ts.map +1 -1
  14. package/dist/commands/issue-labeler.js +19 -2
  15. package/dist/commands/link-checker.d.ts +4 -0
  16. package/dist/commands/link-checker.d.ts.map +1 -0
  17. package/dist/commands/link-checker.js +16 -0
  18. package/dist/commands/message.d.ts.map +1 -1
  19. package/dist/commands/message.js +3 -1
  20. package/dist/commands/new-contributor-message.d.ts +2 -0
  21. package/dist/commands/new-contributor-message.d.ts.map +1 -0
  22. package/dist/commands/new-contributor-message.js +43 -0
  23. package/dist/commands/publish-packages.d.ts +2 -0
  24. package/dist/commands/publish-packages.d.ts.map +1 -0
  25. package/dist/commands/publish-packages.js +11 -0
  26. package/dist/commands/telephone-game.d.ts +2 -0
  27. package/dist/commands/telephone-game.d.ts.map +1 -0
  28. package/dist/commands/telephone-game.js +32 -0
  29. package/dist/config/index.d.ts +12 -0
  30. package/dist/config/index.d.ts.map +1 -0
  31. package/dist/config/index.js +75 -0
  32. package/dist/index.js +30 -2
  33. package/dist/mastra/agents/index.d.ts +116 -0
  34. package/dist/mastra/agents/index.d.ts.map +1 -1
  35. package/dist/mastra/agents/index.js +92 -24
  36. package/dist/mastra/agents/model.d.ts +7 -0
  37. package/dist/mastra/agents/model.d.ts.map +1 -0
  38. package/dist/mastra/agents/model.js +7 -0
  39. package/dist/mastra/agents/new-contributor.d.ts +3 -0
  40. package/dist/mastra/agents/new-contributor.d.ts.map +1 -0
  41. package/dist/mastra/agents/new-contributor.js +12 -0
  42. package/dist/mastra/index.d.ts +157 -1
  43. package/dist/mastra/index.d.ts.map +1 -1
  44. package/dist/mastra/index.js +19 -3
  45. package/dist/mastra/integrations/index.d.ts +2 -0
  46. package/dist/mastra/integrations/index.d.ts.map +1 -1
  47. package/dist/mastra/integrations/index.js +19 -2
  48. package/dist/mastra/tools/crawl.d.ts +3 -0
  49. package/dist/mastra/tools/crawl.d.ts.map +1 -1
  50. package/dist/mastra/tools/crawl.js +4 -2
  51. package/dist/mastra/tools/execa.d.ts.map +1 -1
  52. package/dist/mastra/tools/execa.js +5 -1
  53. package/dist/mastra/tools/image.d.ts +27 -0
  54. package/dist/mastra/tools/image.d.ts.map +1 -0
  55. package/dist/mastra/tools/image.js +37 -0
  56. package/dist/mastra/tools/mcp.d.ts +3 -0
  57. package/dist/mastra/tools/mcp.d.ts.map +1 -0
  58. package/dist/mastra/tools/mcp.js +12 -0
  59. package/dist/mastra/tools/pdf.d.ts.map +1 -1
  60. package/dist/mastra/tools/pdf.js +3 -2
  61. package/dist/mastra/tools/pnpm.d.ts +60 -0
  62. package/dist/mastra/tools/pnpm.d.ts.map +1 -0
  63. package/dist/mastra/tools/pnpm.js +128 -0
  64. package/dist/mastra/workflows/changelog.d.ts +10 -0
  65. package/dist/mastra/workflows/changelog.d.ts.map +1 -0
  66. package/dist/mastra/workflows/changelog.js +149 -0
  67. package/dist/mastra/workflows/chat.d.ts.map +1 -1
  68. package/dist/mastra/workflows/chat.js +6 -11
  69. package/dist/mastra/workflows/commit-message.d.ts +10 -0
  70. package/dist/mastra/workflows/commit-message.d.ts.map +1 -0
  71. package/dist/mastra/workflows/commit-message.js +138 -0
  72. package/dist/mastra/workflows/first-contributor.d.ts +16 -0
  73. package/dist/mastra/workflows/first-contributor.d.ts.map +1 -0
  74. package/dist/mastra/workflows/first-contributor.js +122 -0
  75. package/dist/mastra/workflows/index.d.ts +1 -0
  76. package/dist/mastra/workflows/index.d.ts.map +1 -1
  77. package/dist/mastra/workflows/index.js +1 -0
  78. package/dist/mastra/workflows/issue-labeler.js +1 -1
  79. package/dist/mastra/workflows/link-checker.d.ts +13 -0
  80. package/dist/mastra/workflows/link-checker.d.ts.map +1 -0
  81. package/dist/mastra/workflows/link-checker.js +102 -0
  82. package/dist/mastra/workflows/publish-packages.d.ts +3 -0
  83. package/dist/mastra/workflows/publish-packages.d.ts.map +1 -0
  84. package/dist/mastra/workflows/publish-packages.js +273 -0
  85. package/dist/mastra/workflows/telephone-game.d.ts +3 -0
  86. package/dist/mastra/workflows/telephone-game.d.ts.map +1 -0
  87. package/dist/mastra/workflows/telephone-game.js +95 -0
  88. package/package.json +13 -9
  89. package/test-files/716a95a5c57a56d32a32b1c9592d6df0.png +0 -0
@@ -1,16 +1,27 @@
1
1
  import { Mastra } from '@mastra/core';
2
2
  import { PostgresEngine } from '@mastra/engine';
3
3
  import { UpstashKVMemory } from '@mastra/memory';
4
- import { dane, daneIssueLabeler } from './agents/index.js';
4
+ import { dane, daneChangeLog, daneCommitMessage, daneIssueLabeler, daneLinkChecker, danePackagePublisher, } from './agents/index.js';
5
+ import { daneNewContributor } from './agents/new-contributor';
5
6
  import { firecrawl } from './integrations/index.js';
6
- import { messageWorkflow, githubIssueLabeler } from './workflows/index.js';
7
+ import { changelogWorkflow } from './workflows/changelog.js';
8
+ import { githubFirstContributorMessage } from './workflows/first-contributor';
9
+ import { messageWorkflow, githubIssueLabeler, commitMessageGenerator } from './workflows/index.js';
10
+ import { linkCheckerWorkflow } from './workflows/link-checker.js';
11
+ import { packagePublisher } from './workflows/publish-packages.js';
12
+ import { telephoneGameWorkflow } from './workflows/telephone-game.js';
7
13
  const engine = new PostgresEngine({
8
14
  url: 'postgres://postgres:postgres@localhost:5433/mastra',
9
15
  });
10
16
  export const mastra = new Mastra({
11
17
  agents: {
12
18
  dane,
19
+ danePackagePublisher,
20
+ daneLinkChecker,
13
21
  daneIssueLabeler,
22
+ daneCommitMessage,
23
+ daneChangeLog,
24
+ daneNewContributor,
14
25
  },
15
26
  engine,
16
27
  memory: new UpstashKVMemory({
@@ -21,8 +32,13 @@ export const mastra = new Mastra({
21
32
  workflows: {
22
33
  message: messageWorkflow,
23
34
  githubIssueLabeler: githubIssueLabeler,
35
+ commitMessage: commitMessageGenerator,
36
+ packagePublisher: packagePublisher,
37
+ telephoneGame: telephoneGameWorkflow,
38
+ changelog: changelogWorkflow,
39
+ githubFirstContributorMessage: githubFirstContributorMessage,
40
+ linkChecker: linkCheckerWorkflow,
24
41
  },
25
- logger: false,
26
42
  syncs: {
27
43
  ...firecrawl.getSyncs(),
28
44
  },
@@ -1,5 +1,7 @@
1
1
  import { FirecrawlIntegration } from "@mastra/firecrawl";
2
2
  import { GithubIntegration } from "@mastra/github";
3
+ import { StabilityAiIntegration } from "@mastra/stabilityai";
3
4
  export declare const firecrawl: FirecrawlIntegration;
4
5
  export declare const github: GithubIntegration;
6
+ export declare const stabilityai: StabilityAiIntegration;
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,SAAS,sBAIpB,CAAC;AAEH,eAAO,MAAM,MAAM,mBAIjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAc7D,eAAO,MAAM,SAAS,sBAIpB,CAAC;AAEH,eAAO,MAAM,MAAM,mBAIjB,CAAC;AAEH,eAAO,MAAM,WAAW,wBAItB,CAAC"}
@@ -1,12 +1,29 @@
1
1
  import { FirecrawlIntegration } from "@mastra/firecrawl";
2
2
  import { GithubIntegration } from "@mastra/github";
3
+ import { StabilityAiIntegration } from "@mastra/stabilityai";
4
+ import { config } from "../../config/index.js";
5
+ // Helper function to get key from config or env
6
+ const getApiKey = (configKey, envKey) => {
7
+ const configValue = config.get(configKey);
8
+ if (configValue)
9
+ return configValue;
10
+ const envValue = process.env[envKey];
11
+ if (envValue)
12
+ return envValue;
13
+ return '';
14
+ };
3
15
  export const firecrawl = new FirecrawlIntegration({
4
16
  config: {
5
- API_KEY: process.env.FIRECRAWL_API_KEY,
17
+ API_KEY: getApiKey('FIRECRAWL_API_KEY', 'FIRECRAWL_API_KEY'),
6
18
  },
7
19
  });
8
20
  export const github = new GithubIntegration({
9
21
  config: {
10
- PERSONAL_ACCESS_TOKEN: process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
22
+ PERSONAL_ACCESS_TOKEN: getApiKey('GITHUB_PERSONAL_ACCESS_TOKEN', 'GITHUB_PERSONAL_ACCESS_TOKEN'),
23
+ }
24
+ });
25
+ export const stabilityai = new StabilityAiIntegration({
26
+ config: {
27
+ API_KEY: getApiKey('STABILITYAI_API_KEY', 'STABILITYAI_API_KEY'),
11
28
  }
12
29
  });
@@ -13,10 +13,13 @@ export declare const crawl: import("@mastra/core").Tool<"crawler", z.ZodObject<{
13
13
  limit?: number | undefined;
14
14
  }>, z.ZodObject<{
15
15
  message: z.ZodString;
16
+ crawlData: z.ZodAny;
16
17
  }, "strip", z.ZodTypeAny, {
17
18
  message: string;
19
+ crawlData?: any;
18
20
  }, {
19
21
  message: string;
22
+ crawlData?: any;
20
23
  }>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
21
24
  url: z.ZodString;
22
25
  limit: z.ZodDefault<z.ZodNumber>;
@@ -1 +1 @@
1
- {"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/crawl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAsBhB,CAAC"}
1
+ {"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/crawl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAwBhB,CAAC"}
@@ -11,14 +11,16 @@ export const crawl = createTool({
11
11
  }),
12
12
  outputSchema: z.object({
13
13
  message: z.string(),
14
+ crawlData: z.any(),
14
15
  }),
15
16
  execute: async ({ context, mastra }) => {
16
- await mastra?.syncs?.['FIRECRAWL:CRAWL_AND_SYNC']?.execute({
17
+ const crawlData = await mastra?.syncs?.['FIRECRAWL:CRAWL_AND_SYNC']?.execute({
17
18
  context,
18
- mastra,
19
+ engine: mastra?.engine,
19
20
  });
20
21
  return {
21
22
  message: 'The website has been successfully crawled and chunks have been synced to the database. Finish.',
23
+ crawlData,
22
24
  };
23
25
  },
24
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"execa.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/execa.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDAwBpB,CAAC"}
1
+ {"version":3,"file":"execa.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/execa.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDA4BpB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { createTool } from '@mastra/core';
2
2
  import chalk from 'chalk';
3
- import { execa } from 'execa';
3
+ import { execa, ExecaError } from 'execa';
4
4
  import { Transform } from 'stream';
5
5
  import { z } from 'zod';
6
6
  // Create transform stream that applies chalk
@@ -25,6 +25,7 @@ export const execaTool = createTool({
25
25
  }),
26
26
  execute: async ({ context: { command, args } }) => {
27
27
  try {
28
+ console.log(chalk.green(`Running command: ${command} ${args.join(' ')}`));
28
29
  const p = execa(command, args);
29
30
  console.log(`\n`);
30
31
  p.stdout.pipe(colorTransform).pipe(process.stdout);
@@ -33,6 +34,9 @@ export const execaTool = createTool({
33
34
  return { message: r.stdout };
34
35
  }
35
36
  catch (e) {
37
+ if (e instanceof ExecaError) {
38
+ return { message: e.message };
39
+ }
36
40
  return { message: 'Error' };
37
41
  }
38
42
  },
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ export declare const imageTool: import("@mastra/core").Tool<"imageTool", z.ZodObject<{
3
+ directory: z.ZodString;
4
+ prompt: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ directory: string;
7
+ prompt: string;
8
+ }, {
9
+ directory: string;
10
+ prompt: 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
+ directory: z.ZodString;
19
+ prompt: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ directory: string;
22
+ prompt: string;
23
+ }, {
24
+ directory: string;
25
+ prompt: string;
26
+ }>, import("@mastra/core").WorkflowContext<any>>>;
27
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/image.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDAgCpB,CAAC"}
@@ -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,3 @@
1
+ import { MastraMCPClient } from '@mastra/mcp';
2
+ export declare const slack: MastraMCPClient;
3
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,KAAK,iBAUhB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { MastraMCPClient } from '@mastra/mcp';
2
+ export const slack = new MastraMCPClient({
3
+ name: 'Slack',
4
+ server: {
5
+ command: '/usr/local/bin/docker',
6
+ args: ['run', '-i', '--rm', '-e', 'SLACK_BOT_TOKEN', '-e', 'SLACK_TEAM_ID', 'mcp/slack'],
7
+ env: {
8
+ SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN,
9
+ SLACK_TEAM_ID: process.env.SLACK_TEAM_ID,
10
+ },
11
+ },
12
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/pdf.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;iDAsClB,CAAC"}
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"}
@@ -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 pdf(dataBuffer);
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(`\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('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,10 @@
1
+ import { Workflow } from '@mastra/core';
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;;;;;;GAK5B,CAAC"}
@@ -0,0 +1,149 @@
1
+ import { Step, Workflow } from '@mastra/core';
2
+ import chalk from 'chalk';
3
+ import { execa } from 'execa';
4
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
5
+ import { z } from 'zod';
6
+ import { slack } from '../tools/mcp.js';
7
+ export const changelogWorkflow = new Workflow({
8
+ name: 'changelog',
9
+ triggerSchema: z.object({
10
+ channelId: z.string(),
11
+ }),
12
+ });
13
+ const stepA1 = new Step({
14
+ id: 'stepA1',
15
+ description: 'Get a git diff',
16
+ outputSchema: z.object({
17
+ message: z.string(),
18
+ }),
19
+ execute: async () => {
20
+ console.log('SUH');
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
+ console.log(today);
30
+ // For 7 days ago
31
+ const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
32
+ console.log(weekAgo);
33
+ const cwd = process.cwd();
34
+ console.log(cwd);
35
+ const args = [
36
+ '--no-pager',
37
+ 'diff',
38
+ '--unified=1', // Reduced context to 1 line
39
+ '--no-prefix',
40
+ '--color=never',
41
+ '--shortstat', // Get size first to check
42
+ `main@{${weekAgo}}`,
43
+ `main@{${today}}`,
44
+ '--',
45
+ 'packages/**',
46
+ // 'docs/**'
47
+ ];
48
+ console.log(args);
49
+ const p = execa('git', args, {
50
+ cwd,
51
+ });
52
+ try {
53
+ const diff = await p;
54
+ return {
55
+ message: diff.stdout,
56
+ };
57
+ }
58
+ catch (e) {
59
+ console.error(e);
60
+ return {
61
+ message: 'Error, do not compute',
62
+ };
63
+ }
64
+ },
65
+ });
66
+ const stepA2 = new Step({
67
+ id: 'stepA2',
68
+ description: 'Make changelog',
69
+ outputSchema: z.object({
70
+ message: z.string(),
71
+ }),
72
+ execute: async ({ context, mastra }) => {
73
+ if (context.machineContext?.stepResults.stepA1?.status !== 'success') {
74
+ throw new Error('Message not found');
75
+ }
76
+ const agent = mastra?.agents?.daneChangeLog;
77
+ if (!agent) {
78
+ throw new Error('LLM not found');
79
+ }
80
+ const today = new Date().toISOString().split('T')[0];
81
+ const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
82
+ const tools = await slack.tools();
83
+ if (existsSync(`changelog-${today}`)) {
84
+ const existing = readFileSync(`changelog-${today}`, 'utf-8');
85
+ await agent.generate(`
86
+ Send this ${existing} to this slack channel: "${context.machineContext.triggerData.channelId}" with the tool slack_post_message.
87
+ Format it in markdown so it displays nicely in slack.
88
+ `, {
89
+ toolsets: {
90
+ slack: tools,
91
+ },
92
+ });
93
+ return {
94
+ message: existing,
95
+ };
96
+ }
97
+ const channelId = context.machineContext.triggerData.channelId;
98
+ const prompt = `
99
+ Time: ${weekAgo} - ${today}
100
+
101
+ Git diff to generate from: ${context.machineContext.stepResults.stepA1.payload.message}
102
+ # Task
103
+ 1. create a structured narrative changelog that highlights key updates and improvements.
104
+ 2. Include what packages were changed
105
+
106
+ ## Structure
107
+
108
+ 1. Opening
109
+ - Brief welcome/context (1-2 sentences)
110
+ - Time period covered
111
+
112
+ 2. Major Updates (3-4 key highlights)
113
+ - Lead with the most impactful changes
114
+ - Include brief technical context where needed
115
+ - Reference relevant PR numbers
116
+ - Link to examples/docs where applicable
117
+
118
+ 3. Technical Improvements
119
+ - Group related changes
120
+ - Focus on developer impact
121
+ - Include code snippets if helpful
122
+
123
+ 4. Documentation & Examples
124
+ - New guides/tutorials
125
+ - Updated examples
126
+ - API documentation changes
127
+
128
+ 5. Bug Fixes & Infrastructure
129
+ - Notable bug fixes
130
+ - Build/deployment improvements
131
+ - Performance optimizations
132
+
133
+
134
+ Finally send this to this slack channel: "${channelId}" with the tool slack_post_message
135
+ `;
136
+ console.log(chalk.green(`Generating...`));
137
+ const result = await agent.generate(prompt, {
138
+ toolsets: {
139
+ slack: tools,
140
+ },
141
+ });
142
+ console.log(chalk.green(result.text));
143
+ writeFileSync(`changelog-${today}`, result.text);
144
+ return {
145
+ message: result.text,
146
+ };
147
+ },
148
+ });
149
+ changelogWorkflow.step(stepA1).then(stepA2).commit();
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;;;;;;GAM1B,CAAC"}
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"}