|
|
|
|
@@ -137,8 +137,30 @@ export class Commit {
|
|
|
|
|
console.log(`The model may not be able to process all information effectively.`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let result = await this.aiDocsRef.openaiInstance.chat({
|
|
|
|
|
systemMessage: `
|
|
|
|
|
// Use DualAgentOrchestrator for commit message generation with Guardian validation
|
|
|
|
|
const commitOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
|
|
|
|
|
openaiToken: this.aiDocsRef.getOpenaiToken(),
|
|
|
|
|
defaultProvider: 'openai',
|
|
|
|
|
guardianPolicyPrompt: `
|
|
|
|
|
You validate commit messages for semantic versioning compliance.
|
|
|
|
|
|
|
|
|
|
APPROVE if:
|
|
|
|
|
- Version level (fix/feat/BREAKING CHANGE) matches the scope of changes in the diff
|
|
|
|
|
- Commit message is clear, professional, and follows conventional commit conventions
|
|
|
|
|
- No personal information, licensing details, or AI mentions (Claude/Codex) included
|
|
|
|
|
- JSON structure is valid with all required fields
|
|
|
|
|
- Scope accurately reflects the changed modules/files
|
|
|
|
|
|
|
|
|
|
REJECT with specific feedback if:
|
|
|
|
|
- Version level doesn't match the scope of changes (e.g., "feat" for a typo fix should be "fix")
|
|
|
|
|
- Message is vague, unprofessional, or contains sensitive information
|
|
|
|
|
- JSON is malformed or missing required fields (recommendedNextVersionLevel, recommendedNextVersionScope, recommendedNextVersionMessage, recommendedNextVersionDetails, recommendedNextVersion)
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await commitOrchestrator.start();
|
|
|
|
|
|
|
|
|
|
const commitTaskPrompt = `
|
|
|
|
|
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.
|
|
|
|
|
@@ -163,14 +185,20 @@ For the recommendedNextVersionDetails, please only add a detail entries to the a
|
|
|
|
|
You are being given the files of the project. You should use them to create the commit message.
|
|
|
|
|
Also you are given a diff.
|
|
|
|
|
Never mention CLAUDE code, or codex.
|
|
|
|
|
`,
|
|
|
|
|
messageHistory: [],
|
|
|
|
|
userMessage: contextString,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// console.log(result.message);
|
|
|
|
|
Project context and diff:
|
|
|
|
|
${contextString}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const commitResult = await commitOrchestrator.run(commitTaskPrompt);
|
|
|
|
|
await commitOrchestrator.stop();
|
|
|
|
|
|
|
|
|
|
if (!commitResult.success) {
|
|
|
|
|
throw new Error(`Commit message generation failed: ${commitResult.status}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resultObject: INextCommitObject = JSON.parse(
|
|
|
|
|
result.message.replace('```json', '').replace('```', '')
|
|
|
|
|
commitResult.result.replace('```json', '').replace('```', '')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const previousChangelogPath = plugins.path.join(this.projectDir, 'changelog.md');
|
|
|
|
|
@@ -183,9 +211,31 @@ Never mention CLAUDE code, or codex.
|
|
|
|
|
// lets build the changelog based on that
|
|
|
|
|
const commitMessages = await gitRepo.getAllCommitMessages();
|
|
|
|
|
console.log(JSON.stringify(commitMessages, null, 2));
|
|
|
|
|
let result2 = await this.aiDocsRef.openaiInstance.chat({
|
|
|
|
|
messageHistory: [],
|
|
|
|
|
systemMessage: `
|
|
|
|
|
|
|
|
|
|
// Use DualAgentOrchestrator for changelog generation with Guardian validation
|
|
|
|
|
const changelogOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
|
|
|
|
|
openaiToken: this.aiDocsRef.getOpenaiToken(),
|
|
|
|
|
defaultProvider: 'openai',
|
|
|
|
|
guardianPolicyPrompt: `
|
|
|
|
|
You validate changelog generation.
|
|
|
|
|
|
|
|
|
|
APPROVE if:
|
|
|
|
|
- Changelog follows proper markdown format with ## headers for each version
|
|
|
|
|
- Entries are chronologically ordered (newest first)
|
|
|
|
|
- Version ranges for trivial commits are properly summarized
|
|
|
|
|
- No duplicate or empty entries
|
|
|
|
|
- Format matches: ## yyyy-mm-dd - x.x.x - scope
|
|
|
|
|
|
|
|
|
|
REJECT with feedback if:
|
|
|
|
|
- Markdown formatting is incorrect
|
|
|
|
|
- Entries are not meaningful or helpful
|
|
|
|
|
- Dates or versions are malformed
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await changelogOrchestrator.start();
|
|
|
|
|
|
|
|
|
|
const changelogTaskPrompt = `
|
|
|
|
|
You are building a changelog.md file for the project.
|
|
|
|
|
Omit commits and versions that lack relevant changes, but make sure to mention them as a range with a summarizing message instead.
|
|
|
|
|
|
|
|
|
|
@@ -199,17 +249,23 @@ A changelog entry should look like this:
|
|
|
|
|
You are given:
|
|
|
|
|
* the commit messages of the project
|
|
|
|
|
|
|
|
|
|
Only return the changelog file, so it can be written directly to changelog.md`,
|
|
|
|
|
userMessage: `
|
|
|
|
|
Only return the changelog file content, so it can be written directly to changelog.md.
|
|
|
|
|
|
|
|
|
|
Here are the commit messages:
|
|
|
|
|
|
|
|
|
|
${JSON.stringify(commitMessages, null, 2)}
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const changelogResult = await changelogOrchestrator.run(changelogTaskPrompt);
|
|
|
|
|
await changelogOrchestrator.stop();
|
|
|
|
|
|
|
|
|
|
if (!changelogResult.success) {
|
|
|
|
|
throw new Error(`Changelog generation failed: ${changelogResult.status}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousChangelog = plugins.smartfileFactory.fromString(
|
|
|
|
|
previousChangelogPath,
|
|
|
|
|
result2.message.replaceAll('```markdown', '').replaceAll('```', ''),
|
|
|
|
|
changelogResult.result.replaceAll('```markdown', '').replaceAll('```', ''),
|
|
|
|
|
'utf8'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|