File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Developed and maintained by Waren Gonzaga with the help of project contributors.
2+ # GitHub Sponsors: https://github.com/sponsors/warengonzaga
3+
4+ github : warengonzaga
5+
6+ # Sponsoring this project means a lot to me. Your support helps me to continue building great open-source projects just like this.
Original file line number Diff line number Diff line change 1+ # # node
12node_modules
3+
4+ # # yarn
5+ yarn-error.log
6+
7+ # # build
28dist
3- .env
9+
10+ # # env
11+ .env
Original file line number Diff line number Diff line change 11{
22 "name" : " magicc" ,
3- "version" : " 0.0.0" ,
4- "license" : " MIT" ,
3+ "version" : " 0.1.0" ,
4+ "author" : " Waren Gonzaga" ,
5+ "description" : " You can do `magicc`, you can build anything that you desire." ,
6+ "keywords" : [
7+ " magicc" ,
8+ " openai" ,
9+ " git" ,
10+ " commit" ,
11+ " tool" ,
12+ " ai" ,
13+ " cli"
14+ ],
15+ "license" : " GPL-3.0" ,
516 "bin" : " dist/cli.js" ,
617 "type" : " module" ,
718 "engines" : {
8- "node" : " >=16 "
19+ "node" : " >=18 "
920 },
1021 "scripts" : {
1122 "build" : " babel --out-dir=dist source" ,
1223 "dev" : " babel --out-dir=dist --watch source" ,
24+ "clean" : " rm -rf dist" ,
1325 "test" : " prettier --check . && xo && ava"
1426 },
1527 "files" : [
1628 " dist"
1729 ],
1830 "dependencies" : {
31+ "dotenv" : " ^16.4.5" ,
1932 "ink" : " ^4.1.0" ,
2033 "ink-big-text" : " ^2.0.0" ,
2134 "ink-gradient" : " ^3.0.0" ,
2235 "meow" : " ^11.0.0" ,
36+ "openai" : " ^4.28.4" ,
2337 "react" : " ^18.2.0"
2438 },
2539 "devDependencies" : {
2640 "@babel/cli" : " ^7.21.0" ,
2741 "@babel/preset-react" : " ^7.18.6" ,
2842 "@vdemedes/prettier-config" : " ^2.0.1" ,
2943 "ava" : " ^5.2.0" ,
44+ "babel-plugin-inline-json-import" : " ^0.3.2" ,
3045 "chalk" : " ^5.2.0" ,
3146 "eslint-config-xo-react" : " ^0.27.0" ,
3247 "eslint-plugin-react" : " ^7.32.2" ,
5570 "babel" : {
5671 "presets" : [
5772 " @babel/preset-react"
73+ ],
74+ "plugins" : [
75+ " inline-json-import"
5876 ]
5977 }
6078}
Original file line number Diff line number Diff line change @@ -2,13 +2,16 @@ import React from 'react';
22import { Text } from 'ink' ;
33import BigText from 'ink-big-text' ;
44import Gradient from 'ink-gradient' ;
5+ import getGitDiff from './utils/openai.js' ;
56
67export default function App ( ) {
8+ getGitDiff ( ) ;
9+
710 return (
811 < >
912 < Gradient name = "passion" >
1013 < BigText text = "Magicc" />
11- < Text > You can do `magicc`, you can commit anything that you desire. 🪄</ Text >
14+ < Text > You can do `magicc`, you can build anything that you desire. 🪄</ Text >
1215 </ Gradient >
1316 </ >
1417 ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "prompt" : " You are a helpful assistant that outputs git commit message based on git diff. Ignore changes in dev dependencies and package-lock.json."
3+ }
Original file line number Diff line number Diff line change 1+ import execa from 'execa' ;
2+ import OpenAI from 'openai' ;
3+ import dotenv from 'dotenv' ;
4+ import config from './config.json' ;
5+
6+ dotenv . config ( ) ;
7+
8+ const openai = new OpenAI ( process . env . OPENAI_API_KEY ) ;
9+
10+ async function getGitDiff ( ) {
11+ try {
12+ const { stdout : gitDiff } = await execa ( 'git' , [ 'diff' ] ) ;
13+
14+ const completion = await openai . chat . completions . create ( {
15+ messages : [
16+ {
17+ role : "system" ,
18+ content : config . prompt ,
19+ } ,
20+ { role : "user" , content : gitDiff } ,
21+ ] ,
22+ model : "gpt-3.5-turbo-0125"
23+ } ) ;
24+ console . log ( completion . choices [ 0 ] . message . content ) ;
25+ } catch ( error ) {
26+ console . error ( error ) ;
27+ }
28+ }
29+
30+ export default getGitDiff ;
You can’t perform that action at this time.
0 commit comments