@mastra/dane 0.0.2-alpha.13 → 0.0.2-alpha.15

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,2 @@
1
+ export declare function commitMessageCommand(): Promise<void>;
2
+ //# sourceMappingURL=commit-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../src/commands/commit-message.ts"],"names":[],"mappings":"AAKA,wBAAsB,oBAAoB,kBAgCzC"}
@@ -0,0 +1,31 @@
1
+ import chalk from 'chalk';
2
+ import { execSync } from 'child_process';
3
+ import { mastra } from '../mastra/index.js';
4
+ export async function commitMessageCommand() {
5
+ console.log(chalk.green("Hi! I'm Dane!"));
6
+ console.log(chalk.green('Let me generate a commit message for you..\n'));
7
+ try {
8
+ const workflow = mastra.getWorkflow('commitMessage');
9
+ if (!workflow) {
10
+ console.error(chalk.red('Commit message workflow not found. Make sure it is properly set up.'));
11
+ process.exit(1);
12
+ }
13
+ // Get the current path
14
+ const currentPath = execSync('pwd', { encoding: 'utf-8' }).trim();
15
+ const result = await workflow.execute({
16
+ triggerData: {
17
+ repoPath: currentPath,
18
+ },
19
+ });
20
+ const errorMessage = Object.values(result.results).find(result => result.status === 'failed')?.error;
21
+ if (result.results?.commit?.status !== 'success') {
22
+ console.error(chalk.red(`\n${errorMessage}`));
23
+ return;
24
+ }
25
+ console.log(chalk.green('\nCommit message generated and committed successfully'));
26
+ }
27
+ catch (error) {
28
+ console.error(chalk.red('Error:', error?.message || 'An unknown error occurred'));
29
+ process.exit(1);
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const configCommand: Command;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SAiCtB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Command } from 'commander';
2
+ import { ConfigManager } from '../mastra/config';
3
+ export const configCommand = new Command('config')
4
+ .description('Manage Dane configuration')
5
+ .option('--set <key=value>', 'Set a configuration value')
6
+ .option('--get <key>', 'Get a configuration value')
7
+ .option('--list', 'List all configuration values')
8
+ .option('--del <key>', 'Delete a configuration value')
9
+ .action(options => {
10
+ const configManager = new ConfigManager();
11
+ if (options.set) {
12
+ const [key, value] = options.set.split('=');
13
+ if (!key || !value) {
14
+ console.error('Invalid format. Use --set KEY=VALUE');
15
+ process.exit(1);
16
+ }
17
+ configManager.set(key, value);
18
+ console.log(`Set ${key} successfully`);
19
+ }
20
+ else if (options.get) {
21
+ const value = configManager.get(options.get);
22
+ if (value === undefined) {
23
+ console.log(`No value set for ${options.get}`);
24
+ }
25
+ else {
26
+ console.log(value);
27
+ }
28
+ }
29
+ else if (options.del) {
30
+ configManager.delete(options.del);
31
+ console.log(`Deleted ${options.del} successfully`);
32
+ }
33
+ else if (options.list) {
34
+ const config = configManager.list();
35
+ console.log(JSON.stringify(config, null, 2));
36
+ }
37
+ else {
38
+ console.log('No action specified. Use --help to see available options.');
39
+ }
40
+ });
package/dist/index.js CHANGED
@@ -1,11 +1,18 @@
1
1
  #! /usr/bin/env node
2
- import dotenv from 'dotenv';
3
- dotenv.config();
4
- process.env.NODE_NO_WARNINGS = '1';
5
2
  import { Command } from 'commander';
3
+ import dotenv from 'dotenv';
4
+ import { commitMessageCommand } from './commands/commit-message.js';
5
+ import { configCommand } from './commands/config.js';
6
6
  import { issueLabelerCommand } from './commands/issue-labeler.js';
7
7
  import { message } from './commands/message.js';
8
+ dotenv.config();
9
+ process.env.NODE_NO_WARNINGS = '1';
8
10
  const program = new Command();
9
11
  program.command('chat').action(message);
10
- program.command('issue-labeler').action(issueLabelerCommand);
12
+ program
13
+ .command('issue-labeler')
14
+ .description('Automatically label GitHub issues based on their content and context')
15
+ .action(issueLabelerCommand);
16
+ program.command('commit').action(commitMessageCommand);
17
+ program.addCommand(configCommand);
11
18
  program.parse(process.argv);
@@ -1,4 +1,5 @@
1
1
  import { Agent } from '@mastra/core';
2
+ export declare const daneCommitMessage: Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
2
3
  export declare const daneIssueLabeler: Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
3
4
  export declare const dane: Agent<{
4
5
  fsTool: import("@mastra/core").Tool<"fsTool", import("zod").ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAUrC,eAAO,MAAM,gBAAgB,8EAW3B,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4Df,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAkBrC,eAAO,MAAM,iBAAiB,8EAa5B,CAAC;AAEH,eAAO,MAAM,gBAAgB,8EAO3B,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDf,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Agent } from '@mastra/core';
2
+ import { config } from '../config';
2
3
  import { browserTool, googleSearch } from '../tools/browser.js';
3
4
  import { listEvents } from '../tools/calendar.js';
4
5
  import { crawl } from '../tools/crawl.js';
@@ -6,17 +7,33 @@ import { execaTool } from '../tools/execa.js';
6
7
  import { fsTool } from '../tools/fs.js';
7
8
  import { imageTool } from '../tools/image.js';
8
9
  import { readPDF } from '../tools/pdf.js';
10
+ const getBaseModelConfig = () => ({
11
+ provider: 'ANTHROPIC',
12
+ toolChoice: 'auto',
13
+ name: 'claude-3-5-sonnet-20241022',
14
+ apiKey: config.getAnthropicApiKey(),
15
+ });
16
+ export const daneCommitMessage = new Agent({
17
+ name: 'DaneCommitMessage',
18
+ instructions: `
19
+ You are Dane, the ultimate GitHub operator.
20
+ You help engineers generate commit messages.
21
+
22
+ GENERATE MESSAGES ACCORDING TO THE GIT COMMIT MESSAGE CONVENTION.
23
+
24
+ GENERATE A SCOPE FOR THE COMMIT MESSAGE IF NECESSARY.
25
+
26
+ FIGURE OUT THE BEST TOP LEVEL SEMANTIC MATCH TO USE AS THE SCOPE.
27
+ `,
28
+ model: getBaseModelConfig(),
29
+ });
9
30
  export const daneIssueLabeler = new Agent({
10
31
  name: 'DaneIssueLabeler',
11
32
  instructions: `
12
33
  You are Dane, the ultimate GitHub operator.
13
34
  You help engineers label their issues.
14
35
  `,
15
- model: {
16
- provider: 'ANTHROPIC',
17
- toolChoice: 'auto',
18
- name: 'claude-3-5-sonnet-20241022',
19
- },
36
+ model: getBaseModelConfig(),
20
37
  });
21
38
  export const dane = new Agent({
22
39
  name: 'Dane',
@@ -61,11 +78,7 @@ export const dane = new Agent({
61
78
  * Don't reference tools when you communicate with the user. Do not mention what tools you are using.
62
79
  * Tell the user what you are doing.
63
80
  `,
64
- model: {
65
- provider: 'ANTHROPIC',
66
- toolChoice: 'auto',
67
- name: 'claude-3-5-sonnet-20241022',
68
- },
81
+ model: getBaseModelConfig(),
69
82
  tools: {
70
83
  fsTool,
71
84
  execaTool,
@@ -75,7 +88,5 @@ export const dane = new Agent({
75
88
  listEvents,
76
89
  crawl,
77
90
  imageTool,
78
- // TODO I SHOULD BE ABLE TO PASS A WORKFLOW EXECUTE HERE
79
- // browserAgentRelay,
80
91
  },
81
92
  });
@@ -0,0 +1,12 @@
1
+ export declare class ConfigManager {
2
+ private configPath;
3
+ constructor();
4
+ private ensureConfigExists;
5
+ get(key: string): string | undefined;
6
+ set(key: string, value: string): void;
7
+ delete(key: string): void;
8
+ list(): Record<string, string>;
9
+ getAnthropicApiKey(): string;
10
+ }
11
+ export declare const config: ConfigManager;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/config/index.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAS;;IAS3B,OAAO,CAAC,kBAAkB;IAUnB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IASpC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAYzB,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ9B,kBAAkB,IAAI,MAAM;CAiBpC;AAGD,eAAO,MAAM,MAAM,eAAsB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import * as fs from 'fs';
2
+ import * as os from 'os';
3
+ import * as path from 'path';
4
+ export class ConfigManager {
5
+ constructor() {
6
+ const homeDir = os.homedir();
7
+ const configDir = path.join(homeDir, '.dane');
8
+ this.configPath = path.join(configDir, 'config.json');
9
+ this.ensureConfigExists();
10
+ }
11
+ ensureConfigExists() {
12
+ const configDir = path.dirname(this.configPath);
13
+ if (!fs.existsSync(configDir)) {
14
+ fs.mkdirSync(configDir, { recursive: true });
15
+ }
16
+ if (!fs.existsSync(this.configPath)) {
17
+ fs.writeFileSync(this.configPath, JSON.stringify({}, null, 2));
18
+ }
19
+ }
20
+ get(key) {
21
+ try {
22
+ const config = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));
23
+ return config[key];
24
+ }
25
+ catch (error) {
26
+ return undefined;
27
+ }
28
+ }
29
+ set(key, value) {
30
+ try {
31
+ const config = fs.existsSync(this.configPath) ? JSON.parse(fs.readFileSync(this.configPath, 'utf-8')) : {};
32
+ config[key] = value;
33
+ fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2));
34
+ }
35
+ catch (error) {
36
+ throw new Error(`Failed to set config value: ${error}`);
37
+ }
38
+ }
39
+ delete(key) {
40
+ try {
41
+ const config = fs.existsSync(this.configPath) ? JSON.parse(fs.readFileSync(this.configPath, 'utf-8')) : {};
42
+ if (key in config) {
43
+ delete config[key];
44
+ fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2));
45
+ }
46
+ }
47
+ catch (error) {
48
+ throw new Error(`Failed to delete config value: ${error}`);
49
+ }
50
+ }
51
+ list() {
52
+ try {
53
+ return JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));
54
+ }
55
+ catch (error) {
56
+ return {};
57
+ }
58
+ }
59
+ getAnthropicApiKey() {
60
+ const key = this.get('ANTHROPIC_API_KEY');
61
+ if (!key) {
62
+ // Check if we're in a command that requires the API key
63
+ const command = process.argv[2] || '';
64
+ const configCommands = ['config', '--help', '-h'];
65
+ // Only throw if we're not in a config-related command
66
+ if (!configCommands.includes(command)) {
67
+ throw new Error('ANTHROPIC_API_KEY not found in config. Please set it using: dane config --set ANTHROPIC_API_KEY=your_key_here');
68
+ }
69
+ return '';
70
+ }
71
+ return key;
72
+ }
73
+ }
74
+ // Create a singleton instance for easy access
75
+ export const config = new ConfigManager();
@@ -193,6 +193,7 @@ export declare const mastra: Mastra<{
193
193
  }>, import("@mastra/core").WorkflowContext<any>>>;
194
194
  }>;
195
195
  daneIssueLabeler: import("@mastra/core").Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
196
+ daneCommitMessage: import("@mastra/core").Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
196
197
  }, {
197
198
  message: import("@mastra/core").Workflow<any, import("zod").ZodObject<{
198
199
  resourceid: import("zod").ZodString;
@@ -217,5 +218,12 @@ export declare const mastra: Mastra<{
217
218
  owner: string;
218
219
  issue_number: number;
219
220
  }>>;
220
- }, import("@mastra/core").ConsoleLogger<import("@mastra/core").BaseLogMessage>>;
221
+ commitMessage: import("@mastra/core").Workflow<any, import("zod").ZodObject<{
222
+ repoPath: import("zod").ZodString;
223
+ }, "strip", import("zod").ZodTypeAny, {
224
+ repoPath: string;
225
+ }, {
226
+ repoPath: string;
227
+ }>>;
228
+ }, import("@mastra/core").BaseLogger<import("@mastra/core").BaseLogMessage>>;
221
229
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mastra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,cAAc,CAAC;AAYpD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+EAsBjB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mastra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAYtC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAqBjB,CAAC"}
@@ -1,9 +1,9 @@
1
- import { createLogger, Mastra } from '@mastra/core';
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, daneCommitMessage, daneIssueLabeler } from './agents/index.js';
5
5
  import { firecrawl } from './integrations/index.js';
6
- import { messageWorkflow, githubIssueLabeler } from './workflows/index.js';
6
+ import { messageWorkflow, githubIssueLabeler, commitMessageGenerator } from './workflows/index.js';
7
7
  const engine = new PostgresEngine({
8
8
  url: 'postgres://postgres:postgres@localhost:5433/mastra',
9
9
  });
@@ -11,6 +11,7 @@ export const mastra = new Mastra({
11
11
  agents: {
12
12
  dane,
13
13
  daneIssueLabeler,
14
+ daneCommitMessage,
14
15
  },
15
16
  engine,
16
17
  memory: new UpstashKVMemory({
@@ -21,11 +22,9 @@ export const mastra = new Mastra({
21
22
  workflows: {
22
23
  message: messageWorkflow,
23
24
  githubIssueLabeler: githubIssueLabeler,
25
+ commitMessage: commitMessageGenerator,
24
26
  },
25
- logger: createLogger({
26
- level: 'DEBUG',
27
- type: 'CONSOLE'
28
- }),
27
+ logger: false,
29
28
  syncs: {
30
29
  ...firecrawl.getSyncs(),
31
30
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/pdf.ts"],"names":[],"mappings":"AAMA,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,9 +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
- // @ts-ignore
6
- import pdfParse from "pdf-parse/lib/pdf-parse.js";
7
5
  import { z } from 'zod';
6
+ // @ts-ignore
7
+ import pdfParse from 'pdf-parse/lib/pdf-parse.js';
8
8
  export const readPDF = createTool({
9
9
  id: 'readPDF',
10
10
  name: 'Read PDF',
@@ -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"}
@@ -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 { content } = await inquirer.prompt([
20
- {
21
- type: 'input',
22
- name: 'content',
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
  });
@@ -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;AAExB,eAAO,MAAM,sBAAsB;;;;;;GAKjC,CAAC"}
@@ -0,0 +1,105 @@
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
+ export const commitMessageGenerator = new Workflow({
7
+ name: 'commit-message',
8
+ triggerSchema: z.object({
9
+ repoPath: z.string(),
10
+ }),
11
+ });
12
+ const getDiff = new Step({
13
+ id: 'getDiff',
14
+ outputSchema: z.object({
15
+ diff: z.string(),
16
+ }),
17
+ execute: async ({ context }) => {
18
+ const repoPath = context?.machineContext?.triggerData?.repoPath;
19
+ // Get the git diff of staged changes
20
+ const diff = execSync('git diff --staged', {
21
+ cwd: repoPath,
22
+ encoding: 'utf-8',
23
+ });
24
+ return { diff };
25
+ },
26
+ });
27
+ const generateMessage = new Step({
28
+ id: 'generateMessage',
29
+ outputSchema: z.object({
30
+ commitMessage: z.string(),
31
+ generated: z.boolean(),
32
+ }),
33
+ execute: async ({ context, mastra }) => {
34
+ const parentStep = context?.machineContext?.stepResults?.getDiff;
35
+ if (!parentStep || parentStep.status !== 'success') {
36
+ return { commitMessage: '', generated: false };
37
+ }
38
+ const daneCommitGenerator = mastra?.agents?.daneCommitMessage;
39
+ const res = await daneCommitGenerator?.generate(`
40
+ Given this git diff:
41
+ ${parentStep.payload.diff}
42
+
43
+ IF THE DIFF IS EMPTY, RETURN "No staged changes found", AND SET GENERATED TO FALSE,
44
+ OTHERWISE, SET GENERATED TO TRUE
45
+
46
+ Please generate a concise and descriptive commit message that follows these guidelines:
47
+ - Start with a verb in the present tense
48
+ - Be specific but concise
49
+ - Focus on the "what" and "why" of the changes
50
+ - Keep the first line under 50 characters
51
+ - If needed, add more detailed description after a blank line
52
+ `, {
53
+ schema: z.object({
54
+ commitMessage: z.string(),
55
+ generated: z.boolean(),
56
+ }),
57
+ });
58
+ if (!res?.object?.generated) {
59
+ throw new Error(res?.object?.commitMessage);
60
+ }
61
+ return { commitMessage: res?.object?.commitMessage, generated: res?.object?.generated };
62
+ },
63
+ });
64
+ const confirmationStep = new Step({
65
+ id: 'confirmation',
66
+ outputSchema: z.object({
67
+ confirm: z.boolean(),
68
+ }),
69
+ execute: async ({ context }) => {
70
+ const parentStep = context?.machineContext?.stepResults?.generateMessage;
71
+ if (!parentStep || parentStep.status !== 'success') {
72
+ return { confirm: false };
73
+ }
74
+ if (!parentStep.payload.generated) {
75
+ return { confirm: false };
76
+ }
77
+ const commitMessage = parentStep.payload.commitMessage;
78
+ const confirmationMessage = await confirm({
79
+ message: `\n Would you like to use this commit message? \n\n ${chalk.yellow(commitMessage)}\n\n`,
80
+ });
81
+ return { confirm: confirmationMessage };
82
+ },
83
+ });
84
+ const commitStep = new Step({
85
+ id: 'commit',
86
+ outputSchema: z.object({
87
+ commit: z.boolean(),
88
+ }),
89
+ execute: async ({ context }) => {
90
+ const parentStep = context?.machineContext?.stepResults?.confirmation;
91
+ if (!parentStep || parentStep.status !== 'success' || !parentStep.payload.confirm) {
92
+ throw new Error('Commit message generation cancelled');
93
+ }
94
+ if (context?.machineContext?.stepResults?.generateMessage?.status !== 'success') {
95
+ throw new Error('Failed to generate commit message');
96
+ }
97
+ const commitMessage = context?.machineContext?.stepResults?.generateMessage?.payload?.commitMessage;
98
+ execSync(`git commit -m "${commitMessage}"`, {
99
+ cwd: context?.machineContext?.triggerData?.repoPath,
100
+ encoding: 'utf-8',
101
+ });
102
+ return { commit: true };
103
+ },
104
+ });
105
+ commitMessageGenerator.step(getDiff).then(generateMessage).then(confirmationStep).then(commitStep).commit();
@@ -1,3 +1,4 @@
1
1
  export * from './chat.js';
2
2
  export * from './issue-labeler.js';
3
+ export * from './commit-message.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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"}
@@ -1,2 +1,3 @@
1
1
  export * from './chat.js';
2
2
  export * from './issue-labeler.js';
3
+ export * from './commit-message.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/dane",
3
- "version": "0.0.2-alpha.13",
3
+ "version": "0.0.2-alpha.15",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -21,13 +21,13 @@
21
21
  "tsx": "^4.19.2"
22
22
  },
23
23
  "dependencies": {
24
+ "@inquirer/prompts": "^7.2.1",
24
25
  "boxen": "^8.0.1",
25
26
  "chalk": "^5.3.0",
26
27
  "cli-table3": "^0.6.5",
27
28
  "commander": "^12.1.0",
28
29
  "dotenv": "^16.4.7",
29
30
  "execa": "^9.3.1",
30
- "inquirer": "^12.2.0",
31
31
  "luxon": "^3.5.0",
32
32
  "node-ical": "^0.20.1",
33
33
  "node-screenshots": "^0.2.1",
@@ -37,17 +37,16 @@
37
37
  "sqlite3": "^5.1.7",
38
38
  "typescript": "^5.5.4",
39
39
  "zod": "^3.24.0",
40
- "@mastra/core": "0.1.27-alpha.44",
41
- "@mastra/engine": "0.0.5-alpha.38",
42
- "@mastra/firecrawl": "1.0.4-alpha.29",
43
- "@mastra/github": "1.0.3-alpha.28",
44
- "@mastra/stabilityai": "1.0.1-alpha.19",
45
- "@mastra/memory": "0.0.2-alpha.23",
46
- "@mastra/rag": "0.0.2-alpha.28"
40
+ "@mastra/core": "0.1.27-alpha.45",
41
+ "@mastra/firecrawl": "1.0.4-alpha.30",
42
+ "@mastra/engine": "0.0.5-alpha.39",
43
+ "@mastra/github": "1.0.3-alpha.29",
44
+ "@mastra/memory": "0.0.2-alpha.24",
45
+ "@mastra/rag": "0.0.2-alpha.29",
46
+ "@mastra/stabilityai": "1.0.1-alpha.20"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "npx tsc",
50
- "issue-labeler": "npx bun src/issue-labeler.ts",
51
50
  "start": "npx bun src/index.ts",
52
51
  "test": "echo \"Error: no test specified\" && exit 1"
53
52
  }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=commit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/commit.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";