gityo 1.0.5 → 1.0.7
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.
- package/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -181113,7 +181113,7 @@ function createLiveGit(baseDir) {
|
|
|
181113
181113
|
}
|
|
181114
181114
|
var system_prompt_default = "You are a strict Git commit message generator. ONLY output the commit message, nothing else.\n\nREQUIRED FORMAT:\n- First line: <type>(<scope>): <subject> (max 50 characters)\n- Types: feat, fix, docs, style, refactor, perf, test, chore, ci\n- Subject: imperative mood, lowercase, no period\n- If body needed: blank line + detailed explanation (wrapped at 72 chars)\n\nSTRICT RULES:\n1. MUST use conventional commits format: type(scope): subject\n2. Subject line MUST be under 50 characters\n3. Subject MUST be in imperative mood (e.g., \"add\", \"fix\", \"update\")\n4. Subject MUST be lowercase\n5. Subject MUST NOT end with a period\n6. MUST provide clear context about WHAT changed and WHY\n7. MUST be specific about affected functions, components, or modules\n8. MUST NOT use vague terms like \"Update\", \"Fix stuff\", \"Changes\"\n9. If including a body, MUST have exactly one blank line between subject and body\n10. Body lines MUST wrap at 72 characters\n\nOUTPUT INSTRUCTION:\nReturn ONLY the commit message. No explanations, no extra text, no markdown formatting.\n\nEXAMPLE:\nfeat(llm): add support for streaming responses\n\nImplement streaming response handling for commit message\ngeneration to improve user experience with large diffs.\nAdds new stream event handlers and updates the API contract.\n\nAnalyze the diff and generate a message following ALL rules above.";
|
|
181115
181115
|
async function generateCommitMessage(languageModel, instructions, diff) {
|
|
181116
|
-
return
|
|
181116
|
+
return (await generateText({
|
|
181117
181117
|
model: languageModel,
|
|
181118
181118
|
instructions: system_prompt_default,
|
|
181119
181119
|
messages: [{
|
|
@@ -181123,7 +181123,7 @@ async function generateCommitMessage(languageModel, instructions, diff) {
|
|
|
181123
181123
|
role: "user",
|
|
181124
181124
|
content: instructions || "Generate a concise git commit message based on the above instructions and diff."
|
|
181125
181125
|
}]
|
|
181126
|
-
})).text.trim()
|
|
181126
|
+
})).text.trim();
|
|
181127
181127
|
}
|
|
181128
181128
|
function resolveLanguageModel(modelConfig) {
|
|
181129
181129
|
const envVarNames = Array.isArray(modelConfig.apiKeyEnv) ? modelConfig.apiKeyEnv : [modelConfig.apiKeyEnv];
|
|
@@ -197976,24 +197976,23 @@ async function mainController(options = {}) {
|
|
|
197976
197976
|
if (files.length === 0) return console.log("No changed files found.");
|
|
197977
197977
|
const { diff, hasStaged } = await getCommitDiff(git);
|
|
197978
197978
|
if (finalCommitMessage.length > 0) {
|
|
197979
|
-
console.log(source_default.yellow
|
|
197980
|
-
console.log(source_default.
|
|
197979
|
+
console.log(source_default.yellow("✓ Using direct commit message"));
|
|
197980
|
+
console.log(source_default.cyan.dim(finalCommitMessage));
|
|
197981
197981
|
console.log("");
|
|
197982
197982
|
}
|
|
197983
197983
|
if (finalCommitMessage.length === 0 && !forceLLMGenerate) finalCommitMessage = await promptForCommitMessageInput(modelConfig.model);
|
|
197984
197984
|
if (finalCommitMessage.length === 0) while (true) {
|
|
197985
|
-
if (forceLLMGenerate) console.log(source_default.yellow
|
|
197986
|
-
finalCommitMessage = (await runWithLoading("Generating commit message", () => generateCommitMessage(languageModel, config$4.instructions ?? null, diff))).
|
|
197985
|
+
if (forceLLMGenerate) console.log(source_default.yellow("• Using LLM to generate message"));
|
|
197986
|
+
finalCommitMessage = (await runWithLoading("Generating commit message", () => generateCommitMessage(languageModel, config$4.instructions ?? null, diff))).trim();
|
|
197987
197987
|
if (finalCommitMessage.length === 0) throw new Error("The selected model returned an empty commit message.");
|
|
197988
|
-
console.log(source_default.
|
|
197988
|
+
console.log(source_default.cyan.dim(finalCommitMessage));
|
|
197989
197989
|
console.log("");
|
|
197990
197990
|
if (forceLLMGenerate || config$4.autoAcceptCommitMessage) break;
|
|
197991
197991
|
const action = await promptForGeneratedCommitAction();
|
|
197992
197992
|
if (action === "accept" || action === "cancel") break;
|
|
197993
197993
|
}
|
|
197994
197994
|
if (finalCommitMessage.length === 0) throw new Error("Commit message cannot be empty.");
|
|
197995
|
-
console.log("");
|
|
197996
|
-
console.log(source_default.yellow.dim("✓ Committing changes"));
|
|
197995
|
+
console.log(source_default.green("✓ Committing changes"));
|
|
197997
197996
|
if (!hasStaged) await git.add(["-A"]);
|
|
197998
197997
|
console.log(files.join("\n"));
|
|
197999
197998
|
console.log("");
|
|
@@ -198015,7 +198014,7 @@ function handleError(fn$1) {
|
|
|
198015
198014
|
}
|
|
198016
198015
|
});
|
|
198017
198016
|
}
|
|
198018
|
-
const app = new Command().name("gityo").description("Stage changes, generate or enter a commit message, create a commit, and run a post-commit git command.").option("-g, --generate", "Generate a commit message without asking.").option("-m, --message <message>", "Use the provided message as the commit message.").option("-p, --post", "Run the post-commit git command without asking.").option("--model <model>", "Model key from config to use (defaults to \"default\").").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").action((options) => {
|
|
198017
|
+
const app = new Command().name("gityo").description("Stage changes, generate or enter a commit message, create a commit, and run a post-commit git command.").option("-g, --generate", "Generate a commit message and commit without asking.").option("-m, --message <message>", "Use the provided message as the commit message.").option("-p, --post", "Run the post-commit git command without asking.").option("--model <model>", "Model key from config to use (defaults to \"default\").").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").action((options) => {
|
|
198019
198018
|
if (options.generate && options.message) {
|
|
198020
198019
|
console.error("Cannot use --generate and --message together.");
|
|
198021
198020
|
process.exit(1);
|