fix(core): update

This commit is contained in:
2024-06-22 13:11:22 +02:00
parent 1489420e47
commit 15397e8609
8 changed files with 727 additions and 159 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsdoc',
version: '1.1.29',
version: '1.1.30',
description: 'An advanced TypeScript documentation tool using AI to generate and enhance documentation for TypeScript projects.'
}

View File

@ -0,0 +1,55 @@
import * as plugins from '../plugins.js';
import { AiDoc } from '../classes.aidoc.js';
import { ProjectContext } from './projectcontext.js';
export class Commit {
private aiDocsRef: AiDoc;
private projectDir: string;
constructor(aiDocsRef: AiDoc, projectDirArg: string) {
this.aiDocsRef = aiDocsRef;
this.projectDir = projectDirArg;
}
public async build() {
const projectContext = new ProjectContext(this.projectDir);
const contextString = await projectContext.update();
let result = await this.aiDocsRef.openaiInstance.chat({
systemMessage: `
You create a commit message for a git commit.
The commit message should be based on the files in the project.
You should not include any licensing information.
You should not include any personal information.
Important: Answer only in valid JSON.
Your answer should be parseable with JSON.parse() without modifying anything.
Here is the structure of the JSON you should return:
{
recommendedNextVersionLevel: 'patch' | 'minor' | 'major'; // the recommended next version level of the project
recommendedNextVersion: string; // the recommended next version of the project
message: string; // the commit message. use conventional commits format
}
You are being given the files of the project. You should use them to create the commit message.
Also you are given a diff
`,
messageHistory: [],
userMessage: contextString,
});
console.log(result.message);
const resultObject = JSON.parse(result.message.replace('```json', '').replace('```', ''));
const npmextraJson = (await projectContext.gatherFiles()).smartfilesNpmextraJSON;
const npmextraJsonContent = JSON.parse(npmextraJson.contents.toString());
npmextraJsonContent.gitzone.module.commit = resultObject.message;
npmextraJson.contents = Buffer.from(JSON.stringify(npmextraJsonContent, null, 2));
await npmextraJson.write();
}
}

View File

@ -84,4 +84,13 @@ export class AiDoc {
const descriptionInstance = new aiDocsClasses.Description(this, projectDirArg);
return await descriptionInstance.build();
}
public async buildNextCommit(projectDirArg: string) {
}
public async getProjectContext(projectDirArg: string) {
const projectContextInstance = new aiDocsClasses.ProjectContext(projectDirArg);
return await projectContextInstance.gatherFiles();
}
}

View File

@ -10,13 +10,27 @@ import * as smartai from '@push.rocks/smartai';
import * as smartcli from '@push.rocks/smartcli';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartfile from '@push.rocks/smartfile';
import * as smartgit from '@push.rocks/smartgit';
import * as smartinteract from '@push.rocks/smartinteract';
import * as smartlog from '@push.rocks/smartlog';
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
import * as smartpath from '@push.rocks/smartpath';
import * as smartshell from '@push.rocks/smartshell';
export { npmextra, qenv, smartai, smartcli, smartdelay, smartfile, smartinteract, smartlog, smartlogDestinationLocal, smartpath, smartshell };
export {
npmextra,
qenv,
smartai,
smartcli,
smartdelay,
smartfile,
smartgit,
smartinteract,
smartlog,
smartlogDestinationLocal,
smartpath,
smartshell,
};
// third party scope
import * as typedoc from 'typedoc';