Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c83725120 | |||
a060cd1a03 | |||
e8372effc7 | |||
571249705e | |||
927cd961fd | |||
63b4fcc232 | |||
4188ed7f24 | |||
1feddc6e85 | |||
499baebc18 | |||
01fc0d0c6e | |||
b6c9cea5d1 | |||
a949039192 | |||
11bde9d756 | |||
eac26521c6 | |||
e1323569f5 | |||
41e4bd6689 | |||
164a58ec59 | |||
e1c0f82fe8 | |||
8a0046818b | |||
97fa9db32f | |||
d61de9b615 | |||
fba54035ea | |||
9a3d8588a8 | |||
eb8f8fa70a | |||
afe7b5e99e | |||
e074562362 | |||
240d6bb314 | |||
2d0839a1da | |||
9f250ae2b3 | |||
1223bb8567 | |||
9395cfc166 | |||
3b4c6bd97f |
32
changelog.md
Normal file
32
changelog.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
```markdown
|
||||
## [1.2.4]
|
||||
### Fixed
|
||||
- Refactor logger initialization to use commitinfo data
|
||||
|
||||
## 1.3.0
|
||||
feat(core): Added smarttime dependency and improved changelog generation
|
||||
```
|
||||
|
||||
## [1.2.4] - 1.2.4
|
||||
fix(logging): Refactor logger initialization to use commitinfo data
|
||||
|
||||
## [1.2.3]
|
||||
fix(aidocs): Fix bug in AiDoc class causing undefined token handling
|
||||
|
||||
## [1.2.2] - 2023-11-20
|
||||
### Fixed
|
||||
- Fix bug in AiDoc class causing undefined token handling
|
||||
|
||||
## [1.2.1] - 2023-11-10
|
||||
### Fixed
|
||||
- Fixed usage of plugins in project context and readme generation
|
||||
|
||||
## [1.2.0] - 2023-11-01
|
||||
### Added
|
||||
- Enhance changelog generation by supporting complete generation in the absence of previous changelog files
|
||||
|
||||
## [1.1.42] - 2023-10-30
|
||||
### Fixed
|
||||
- Improve commit message generation by handling empty diffs and updating changelog instructions
|
10
package.json
10
package.json
@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "@git.zone/tsdoc",
|
||||
"version": "1.1.32",
|
||||
"version": "1.3.0",
|
||||
"private": false,
|
||||
"description": "An advanced TypeScript documentation tool using AI to generate and enhance documentation for TypeScript projects.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"author": "Task Venture Capital GmbH",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tsdoc": "cli.js"
|
||||
@ -38,6 +39,7 @@
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartpath": "^5.0.18",
|
||||
"@push.rocks/smartshell": "^3.0.5",
|
||||
"@push.rocks/smarttime": "^4.0.6",
|
||||
"typedoc": "^0.26.0",
|
||||
"typescript": "^5.5.2"
|
||||
},
|
||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -47,6 +47,9 @@ importers:
|
||||
'@push.rocks/smartshell':
|
||||
specifier: ^3.0.5
|
||||
version: 3.0.5
|
||||
'@push.rocks/smarttime':
|
||||
specifier: ^4.0.6
|
||||
version: 4.0.6
|
||||
typedoc:
|
||||
specifier: ^0.26.0
|
||||
version: 0.26.0(typescript@5.5.2)
|
||||
|
@ -15,12 +15,25 @@ tap.test('should create an AIdocs class', async () => {
|
||||
|
||||
tap.test('should start AIdocs', async () => {
|
||||
await aidocs.start();
|
||||
});
|
||||
|
||||
tap.skip.test('should start AIdocs', async () => {
|
||||
await aidocs.buildReadme('./');
|
||||
});
|
||||
|
||||
tap.test('should start AIdocs', async () => {
|
||||
await aidocs.start();
|
||||
tap.skip.test('should start AIdocs', async () => {
|
||||
await aidocs.buildDescription('./');
|
||||
});
|
||||
|
||||
tap.test('should build commit object', async () => {
|
||||
const commitObject = await aidocs.buildNextCommitObject('./');
|
||||
console.log(commitObject);
|
||||
expect(commitObject).not.toBeUndefined();
|
||||
expect(commitObject).toHaveProperty('recommendedNextVersion');
|
||||
expect(commitObject).toHaveProperty('recommendedNextVersionLevel');
|
||||
expect(commitObject).toHaveProperty('recommendedNextVersionScope');
|
||||
expect(commitObject).toHaveProperty('recommendedNextVersionMessage');
|
||||
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsdoc',
|
||||
version: '1.1.32',
|
||||
version: '1.3.0',
|
||||
description: 'An advanced TypeScript documentation tool using AI to generate and enhance documentation for TypeScript projects.'
|
||||
}
|
||||
|
@ -2,6 +2,15 @@ import * as plugins from '../plugins.js';
|
||||
import { AiDoc } from '../classes.aidoc.js';
|
||||
import { ProjectContext } from './projectcontext.js';
|
||||
|
||||
export interface INextCommitObject {
|
||||
recommendedNextVersionLevel: 'fix' | 'feat' | 'BREAKING CHANGE'; // the recommended next version level of the project
|
||||
recommendedNextVersionScope: string; // the recommended scope name of the next version, like "core" or "cli", or specific class names.
|
||||
recommendedNextVersionMessage: string; // the commit message. Don't put fix() feat() or BREAKING CHANGE in the message. Please just the message itself.
|
||||
recommendedNextVersionDetauls: string[]; // detailed bullet points for the changelog
|
||||
recommendedNextVersion: string; // the recommended next version of the project, x.x.x
|
||||
changelog?: string; // the changelog for the next version
|
||||
}
|
||||
|
||||
export class Commit {
|
||||
private aiDocsRef: AiDoc;
|
||||
private projectDir: string;
|
||||
@ -11,9 +20,23 @@ export class Commit {
|
||||
this.projectDir = projectDirArg;
|
||||
}
|
||||
|
||||
public async build() {
|
||||
public async buildNextCommitObject(): Promise<INextCommitObject> {
|
||||
const smartgitInstance = new plugins.smartgit.Smartgit();
|
||||
await smartgitInstance.init();
|
||||
const gitRepo = await plugins.smartgit.GitRepo.fromOpeningRepoDir(
|
||||
smartgitInstance,
|
||||
this.projectDir
|
||||
);
|
||||
const diffString = await gitRepo.getUncommittedDiff();
|
||||
const projectContext = new ProjectContext(this.projectDir);
|
||||
const contextString = await projectContext.update();
|
||||
let contextString = await projectContext.update();
|
||||
contextString = `
|
||||
${contextString}
|
||||
|
||||
Below is the diff of the uncommitted changes. If nothing is changed, there are no changes:
|
||||
|
||||
${diffString || 'No changes.'}
|
||||
`;
|
||||
|
||||
let result = await this.aiDocsRef.openaiInstance.chat({
|
||||
systemMessage: `
|
||||
@ -27,10 +50,13 @@ 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
|
||||
|
||||
interface {
|
||||
recommendedNextVersionLevel: 'fix' | 'feat' | 'BREAKING CHANGE'; // the recommended next version level of the project
|
||||
recommendedNextVersionScope: string; // the recommended scope name of the next version, like "core" or "cli", or specific class names.
|
||||
recommendedNextVersionMessage: string; // the commit message. Don't put fix() feat() or BREAKING CHANGE in the message. Please just the message itself.
|
||||
recommendedNextVersionDetails: string[]; // detailed bullet points for the changelog
|
||||
recommendedNextVersion: string; // the recommended next version of the project, x.x.x
|
||||
}
|
||||
|
||||
You are being given the files of the project. You should use them to create the commit message.
|
||||
@ -41,15 +67,55 @@ Also you are given a diff
|
||||
userMessage: contextString,
|
||||
});
|
||||
|
||||
console.log(result.message);
|
||||
const resultObject = JSON.parse(result.message.replace('```json', '').replace('```', ''));
|
||||
// console.log(result.message);
|
||||
const resultObject: INextCommitObject = JSON.parse(
|
||||
result.message.replace('```json', '').replace('```', '')
|
||||
);
|
||||
|
||||
const npmextraJson = (await projectContext.gatherFiles()).smartfilesNpmextraJSON;
|
||||
const npmextraJsonContent = JSON.parse(npmextraJson.contents.toString());
|
||||
// lets build the changelog based on that
|
||||
const commitMessages = await gitRepo.getAllCommitMessages();
|
||||
const previousChangelogPath = plugins.path.join(this.projectDir, 'changelog.md');
|
||||
let previousChangelog: plugins.smartfile.SmartFile;
|
||||
if (await plugins.smartfile.fs.fileExists(previousChangelogPath)) {
|
||||
previousChangelog = await plugins.smartfile.SmartFile.fromFilePath(previousChangelogPath);
|
||||
}
|
||||
|
||||
npmextraJsonContent.gitzone.module.commit = resultObject.message;
|
||||
if (!previousChangelog) {
|
||||
let result2 = await this.aiDocsRef.openaiInstance.chat({
|
||||
messageHistory: [],
|
||||
systemMessage: `
|
||||
You are building a changelog.md file for the project.
|
||||
Omit commits and versions that lack relevant changes.
|
||||
|
||||
npmextraJson.contents = Buffer.from(JSON.stringify(npmextraJsonContent, null, 2));
|
||||
await npmextraJson.write();
|
||||
A changelog entry should look like this:
|
||||
|
||||
## yyyy-mm-dd - x.x.x - scope here
|
||||
main descriptiom here
|
||||
- detailed bullet points follow
|
||||
|
||||
You are given:
|
||||
* the commit messages of the project
|
||||
|
||||
Only return the changelog file, so it can be written directly to changelog.md`,
|
||||
userMessage: `
|
||||
Here are the commit messages:
|
||||
|
||||
${commitMessages.join('\n')}
|
||||
`,
|
||||
});
|
||||
|
||||
previousChangelog = await plugins.smartfile.SmartFile.fromString(previousChangelogPath, result2.message, 'utf8');
|
||||
}
|
||||
|
||||
let oldChangelog = previousChangelog.contents.toString().replace('# Changelog\n\n', '');
|
||||
let newDateString = new plugins.smarttime.ExtendedDate().exportToEuropeanDate();
|
||||
let newChangelog = `# Changelog\n\n${
|
||||
`## ${newDateString} - {{nextVersion}} - {{nextVersionScope}}
|
||||
{{nextVersionMessage}}
|
||||
{{nextVersionDetails}}
|
||||
`}\n\n${oldChangelog}\n`;
|
||||
resultObject.changelog = newChangelog;
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
export * from './commit.js';
|
||||
export * from './description.js';
|
||||
export * from './projectcontext.js';
|
||||
export * from './readme.js';
|
||||
|
@ -7,7 +7,7 @@ export class AiDoc {
|
||||
|
||||
public npmextraKV: plugins.npmextra.KeyValueStore;
|
||||
public qenvInstance: plugins.qenv.Qenv;
|
||||
public smartinteractInstance: plugins.smartinteract.SmartInteract;
|
||||
public aidocInteract: plugins.smartinteract.SmartInteract;
|
||||
public openaiInstance: plugins.smartai.OpenAiProvider;
|
||||
|
||||
argvArg: any;
|
||||
@ -33,7 +33,7 @@ export class AiDoc {
|
||||
|
||||
public async start() {
|
||||
// lets care about prerequisites
|
||||
this.smartinteractInstance = new plugins.smartinteract.SmartInteract();
|
||||
this.aidocInteract = new plugins.smartinteract.SmartInteract();
|
||||
this.qenvInstance = new plugins.qenv.Qenv();
|
||||
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
|
||||
this.npmextraKV = new plugins.npmextra.KeyValueStore({
|
||||
@ -51,9 +51,9 @@ export class AiDoc {
|
||||
// lets try smartinteract
|
||||
// wait for a second until OpenAI fixes punycode problem...
|
||||
await plugins.smartdelay.delayFor(1000);
|
||||
const answerObject = await this.smartinteractInstance.askQuestion({
|
||||
const answerObject = await this.aidocInteract.askQuestion({
|
||||
type: 'input',
|
||||
message: `Please provide your OpenAI token`,
|
||||
message: `Please provide your OpenAI token. This will be persisted in your home directory.`,
|
||||
name: 'OPENAI_TOKEN',
|
||||
default: '',
|
||||
});
|
||||
@ -85,7 +85,10 @@ export class AiDoc {
|
||||
return await descriptionInstance.build();
|
||||
}
|
||||
|
||||
public async buildNextCommit(projectDirArg: string) {}
|
||||
public async buildNextCommitObject(projectDirArg: string) {
|
||||
const commitInstance = new aiDocsClasses.Commit(this, projectDirArg);
|
||||
return await commitInstance.buildNextCommitObject();
|
||||
}
|
||||
|
||||
public async getProjectContext(projectDirArg: string) {
|
||||
const projectContextInstance = new aiDocsClasses.ProjectContext(projectDirArg);
|
||||
|
@ -1,15 +1,6 @@
|
||||
import { commitinfo } from './00_commitinfo_data.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
company: 'Some Company',
|
||||
companyunit: 'Some CompanyUnit',
|
||||
containerName: 'Some Containername',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone',
|
||||
},
|
||||
minimumLogLevel: 'silly',
|
||||
});
|
||||
export const logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo);
|
||||
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||
|
@ -16,6 +16,7 @@ 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';
|
||||
import * as smarttime from '@push.rocks/smarttime';
|
||||
|
||||
export {
|
||||
npmextra,
|
||||
@ -30,6 +31,7 @@ export {
|
||||
smartlogDestinationLocal,
|
||||
smartpath,
|
||||
smartshell,
|
||||
smarttime,
|
||||
};
|
||||
|
||||
// third party scope
|
||||
|
Reference in New Issue
Block a user