gityo 1.1.10 → 1.1.11

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.
@@ -227027,8 +227027,12 @@ const PROVIDER_NPM_PACKAGES = Object.keys(SUPPORTED_PROVIDERS);
227027
227027
  function resolveModelConfig(models, modelKey) {
227028
227028
  const modelKeys = Object.keys(models ?? {});
227029
227029
  if (!models || modelKeys.length === 0) throw new Error("No models configured. Edit your config file to add a model — run `gityo config` to see where.");
227030
- const modelConfig = models[modelKey ?? modelKeys[0]];
227031
- if (modelConfig) return modelConfig;
227030
+ const key$1 = modelKey ?? modelKeys[0];
227031
+ const modelConfig = models[key$1];
227032
+ if (modelConfig) return {
227033
+ ...modelConfig,
227034
+ key: key$1
227035
+ };
227032
227036
  throw new Error(`Model '${modelKey}' is not configured. Available models: ${modelKeys.join(", ")}.`);
227033
227037
  }
227034
227038
  function resolveLanguageModel(modelConfig) {
@@ -227320,7 +227324,7 @@ async function mainController(options = {}) {
227320
227324
  console.log("");
227321
227325
  }
227322
227326
  if (finalCommitMessage.length === 0) while (true) {
227323
- finalCommitMessage = await runWithLoading("Generating commit message", () => writeCommitMessage(prepared, diff));
227327
+ finalCommitMessage = await runWithLoading(`Generating commit message (${prepared.modelConfig.key})`, () => writeCommitMessage(prepared, diff));
227324
227328
  console.log(source_default.cyan.dim(finalCommitMessage));
227325
227329
  console.log("");
227326
227330
  if (forceLLMGenerate || config$4.autoAcceptCommitMessage) break;
@@ -227350,7 +227354,8 @@ async function prepareCommit(options) {
227350
227354
  const root = (await git.revparse(["--show-toplevel"])).trim();
227351
227355
  const config$4 = await loadConfig(root);
227352
227356
  const modelKey = options.model ?? config$4.commitModel ?? config$4.model;
227353
- const languageModel = resolveLanguageModel(resolveModelConfig(config$4.models, modelKey));
227357
+ const modelConfig = resolveModelConfig(config$4.models, modelKey);
227358
+ const languageModel = resolveLanguageModel(modelConfig);
227354
227359
  const styleKey = options.style ?? config$4.commitStyle ?? "default";
227355
227360
  const style = await resolveStyle(styleKey, config$4.commitStyles, options.cwd);
227356
227361
  if (!style) {
@@ -227364,6 +227369,7 @@ async function prepareCommit(options) {
227364
227369
  liveGit,
227365
227370
  root,
227366
227371
  config: config$4,
227372
+ modelConfig,
227367
227373
  languageModel,
227368
227374
  style,
227369
227375
  instructions,
@@ -227567,6 +227573,17 @@ async function createPullRequest(cwd, input$3) {
227567
227573
  input$3.head
227568
227574
  ], cwd);
227569
227575
  }
227576
+ async function editPullRequest(cwd, number$7, input$3) {
227577
+ await exec("gh", [
227578
+ "pr",
227579
+ "edit",
227580
+ String(number$7),
227581
+ "--title",
227582
+ input$3.title,
227583
+ "--body",
227584
+ input$3.body
227585
+ ], cwd);
227586
+ }
227570
227587
  async function mergePullRequest(cwd, number$7, method, output$3) {
227571
227588
  await execWithOutput("gh", [
227572
227589
  "pr",
@@ -234573,7 +234590,8 @@ async function resolvePrBranches(cwd, baseArg, headArg) {
234573
234590
  }
234574
234591
  async function loadPullRequestContext(cwd, options = {}) {
234575
234592
  const config$4 = await loadConfig(await getRepoRoot$1(cwd));
234576
- const languageModel = resolveLanguageModel(resolveModelConfig(config$4.models, options.modelKey ?? config$4.prModel ?? config$4.model));
234593
+ const modelConfig = resolveModelConfig(config$4.models, options.modelKey ?? config$4.prModel ?? config$4.model);
234594
+ const languageModel = resolveLanguageModel(modelConfig);
234577
234595
  const titleStyleKey = options.titleStyle ?? config$4.prTitleStyle ?? "default";
234578
234596
  const titleStyle = config$4.prTitleStyles?.[titleStyleKey] ?? PR_TITLE_STYLES[titleStyleKey];
234579
234597
  if (!titleStyle) {
@@ -234593,11 +234611,13 @@ async function loadPullRequestContext(cwd, options = {}) {
234593
234611
  }).join(", ");
234594
234612
  throw new Error(`Pull request body style '${bodyStyleKey}' is not configured. Available body styles: ${availableStyles}.`);
234595
234613
  }
234614
+ const bodyInstructions = typeof bodyStyle === "string" ? bodyStyle : await readFile(path.resolve(cwd, bodyStyle.path), "utf8");
234596
234615
  return {
234597
234616
  config: config$4,
234598
234617
  languageModel,
234618
+ modelKey: modelConfig.key,
234599
234619
  titleInstructions,
234600
- bodyInstructions: typeof bodyStyle === "string" ? bodyStyle : await readFile(path.resolve(cwd, bodyStyle.path), "utf8")
234620
+ bodyInstructions
234601
234621
  };
234602
234622
  }
234603
234623
  async function createPullRequest$1(options) {
@@ -234607,16 +234627,22 @@ async function createPullRequest$1(options) {
234607
234627
  const context = buildCompareContext(compare, maxDiffTokens);
234608
234628
  let draft = "";
234609
234629
  while (true) {
234610
- draft = await runWithLoading("Generating pull request title and body", () => generatePullRequest({
234630
+ draft = await runWithLoading(`Generating pull request title and body (${options.modelKey})`, () => generatePullRequest({
234611
234631
  languageModel: options.languageModel,
234612
234632
  systemPrompt: options.systemPrompt,
234613
234633
  context
234614
234634
  }));
234615
234635
  console.log(renderPullRequest(draft).trim());
234616
234636
  console.log("");
234617
- if (options.autoAccept || await acceptGenerated(`Create PR: ${source_default.red.bold(options.base)} ${source_default.reset("←")} ${source_default.yellow.bold(options.head)}`, "generate a new pull message")) break;
234637
+ if (options.autoAccept || await acceptGenerated(`${options.existing ? `Update PR #${options.existing.number}` : "Create PR"}: ${source_default.red.bold(options.base)} ${source_default.reset("←")} ${source_default.yellow.bold(options.head)}`, "generate a new pull message")) break;
234618
234638
  }
234619
234639
  const content = parsePullRequestContent(draft);
234640
+ if (options.existing) {
234641
+ if (options.autoAccept) console.log(source_default.green("✓ Updating pull request"));
234642
+ await editPullRequest(options.cwd, options.existing.number, content);
234643
+ console.log(options.existing.url);
234644
+ return options.existing;
234645
+ }
234620
234646
  if (options.autoAccept) console.log(source_default.green("✓ Creating pull request"));
234621
234647
  const pullRequest = await submitPullRequest(options.cwd, content, {
234622
234648
  base: options.base,
@@ -235016,4 +235042,4 @@ async function publishRelease(cwd, input$3, replace, output$3) {
235016
235042
  if (replace) await deleteRelease(cwd, input$3.tag, output$3);
235017
235043
  await createRelease(cwd, input$3, output$3);
235018
235044
  }
235019
- export { mainController as A, COMMIT_STYLE_PROMPTS as B, generatePullRequest as C, mergePullRequest as D, getDefaultBranch as E, mergeTheme as F, getGit as G, PR_TITLE_PROMPTS as H, selectionTheme as I, dist_default as J, source_default as K, GLOBAL_CONFIG_FILE_PATH as L, writeCommitMessage as M, runWithLoading as N, openPullRequest as O, acceptGenerated as P, PROJECT_CONFIG_FILE_NAME as R, buildPullRequestSystemPrompt as S, findPullRequest as T, DEFAULT_MAX_DIFF_TOKENS as U, PR_BODY_PROMPTS as V, getCommitDiff as W, loadPullRequestContext as _, verifyReleaseCommits as a, submitPullRequest as b, getBranchHeadSha as c, releaseExists as d, buildCompareContext as f, getCurrentBranch as g, formatCompareSummary as h, resolveReleaseModel as i, prepareCommit as j, getCommitFiles as k, listReleaseCommits as l, fetchPullRequestCompare as m, getPreviousTag as n, writeReleaseNotes as o, createPullRequest$1 as p, dist_default$1 as q, publishRelease as r, getRepoRoot as s, bumpVersionTag as t, listReleases as u, parsePullRequestContent as v, fetchCompare as w, createRenderer as x, resolvePrBranches as y, loadConfig as z };
235045
+ export { mainController as A, COMMIT_STYLE_PROMPTS as B, generatePullRequest as C, mergePullRequest as D, getDefaultBranch as E, mergeTheme as F, DEFAULT_MAX_DIFF_TOKENS as G, PR_TITLE_PROMPTS as H, selectionTheme as I, source_default as J, getCommitDiff as K, GLOBAL_CONFIG_FILE_PATH as L, writeCommitMessage as M, runWithLoading as N, openPullRequest as O, acceptGenerated as P, PROJECT_CONFIG_FILE_NAME as R, buildPullRequestSystemPrompt as S, findPullRequest as T, resolveLanguageModel as U, PR_BODY_PROMPTS as V, resolveModelConfig as W, dist_default as X, dist_default$1 as Y, loadPullRequestContext as _, verifyReleaseCommits as a, submitPullRequest as b, getBranchHeadSha as c, releaseExists as d, buildCompareContext as f, getCurrentBranch as g, formatCompareSummary as h, resolveReleaseModel as i, prepareCommit as j, getCommitFiles as k, listReleaseCommits as l, fetchPullRequestCompare as m, getPreviousTag as n, writeReleaseNotes as o, createPullRequest$1 as p, getGit as q, publishRelease as r, getRepoRoot as s, bumpVersionTag as t, listReleases as u, parsePullRequestContent as v, fetchCompare as w, createRenderer as x, resolvePrBranches as y, loadConfig as z };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as mainController, B as COMMIT_STYLE_PROMPTS, D as mergePullRequest, E as getDefaultBranch, F as mergeTheme, G as getGit, H as PR_TITLE_PROMPTS, I as selectionTheme, J as dist_default, K as source_default, L as GLOBAL_CONFIG_FILE_PATH, N as runWithLoading, O as openPullRequest, P as acceptGenerated, R as PROJECT_CONFIG_FILE_NAME, S as buildPullRequestSystemPrompt, T as findPullRequest, V as PR_BODY_PROMPTS, _ as loadPullRequestContext, a as verifyReleaseCommits, c as getBranchHeadSha, d as releaseExists, g as getCurrentBranch, h as formatCompareSummary, i as resolveReleaseModel, k as getCommitFiles, l as listReleaseCommits, n as getPreviousTag, o as writeReleaseNotes, p as createPullRequest, q as dist_default$1, r as publishRelease, s as getRepoRoot, t as bumpVersionTag, u as listReleases, w as fetchCompare, x as createRenderer, y as resolvePrBranches, z as loadConfig } from "./flow-Dt1FS1vI.js";
2
+ import { A as mainController, B as COMMIT_STYLE_PROMPTS, D as mergePullRequest, E as getDefaultBranch, F as mergeTheme, H as PR_TITLE_PROMPTS, I as selectionTheme, J as source_default, L as GLOBAL_CONFIG_FILE_PATH, N as runWithLoading, O as openPullRequest, P as acceptGenerated, R as PROJECT_CONFIG_FILE_NAME, S as buildPullRequestSystemPrompt, T as findPullRequest, U as resolveLanguageModel, V as PR_BODY_PROMPTS, W as resolveModelConfig, X as dist_default, Y as dist_default$1, _ as loadPullRequestContext, a as verifyReleaseCommits, c as getBranchHeadSha, d as releaseExists, g as getCurrentBranch, h as formatCompareSummary, k as getCommitFiles, l as listReleaseCommits, n as getPreviousTag, o as writeReleaseNotes, p as createPullRequest, q as getGit, r as publishRelease, s as getRepoRoot, t as bumpVersionTag, u as listReleases, w as fetchCompare, x as createRenderer, y as resolvePrBranches, z as loadConfig } from "./flow-BJ8xhhps.js";
3
3
  import "./defineProperty-DZ5JLFN4.js";
4
4
  import "./token-util-CV7QlXpE.js";
5
5
  import { EventEmitter } from "node:events";
@@ -1699,7 +1699,7 @@ function useColor() {
1699
1699
  if (process$1.env.FORCE_COLOR || process$1.env.CLICOLOR_FORCE !== void 0) return true;
1700
1700
  }
1701
1701
  new Command();
1702
- var version = "1.1.10";
1702
+ var version = "1.1.11";
1703
1703
  const CONFIG_SCHEMA_URL = "https://github.com/NazmusSayad/gityo/raw/refs/heads/schema/schema.json";
1704
1704
  async function showConfigController() {
1705
1705
  const projectConfigPath = path.join(process.cwd(), PROJECT_CONFIG_FILE_NAME);
@@ -1750,19 +1750,22 @@ async function createPullRequestController(baseArg, headArg, options = {}) {
1750
1750
  yolo: options.yolo ?? false,
1751
1751
  scope: options.all ? "everything" : "staged-or-changes"
1752
1752
  });
1753
+ const existing = options.update ? await findPullRequest(cwd, branches.base, branches.head) : null;
1753
1754
  const pullRequest = await createPullRequest({
1754
1755
  cwd,
1755
1756
  base: branches.base,
1756
1757
  head: branches.head,
1757
1758
  systemPrompt,
1758
1759
  languageModel: context.languageModel,
1760
+ modelKey: context.modelKey,
1759
1761
  maxDiffTokens: context.config.maxDiffTokens,
1760
- autoAccept: options.yolo ?? false
1762
+ autoAccept: options.yolo ?? false,
1763
+ existing
1761
1764
  }).catch(async (error) => {
1762
1765
  if (!options.web) throw error;
1763
- const existing = await findPullRequest(cwd, branches.base, branches.head);
1764
- if (!existing) throw error;
1765
- return existing;
1766
+ const existing$1 = await findPullRequest(cwd, branches.base, branches.head);
1767
+ if (!existing$1) throw error;
1768
+ return existing$1;
1766
1769
  });
1767
1770
  if (options.web) await openPullRequest(cwd, pullRequest.number);
1768
1771
  }
@@ -1780,7 +1783,7 @@ async function mergePullRequestController(baseArg, headArg, options = {}) {
1780
1783
  scope: options.all ? "everything" : "staged-or-changes"
1781
1784
  });
1782
1785
  let pullRequest = await findPullRequest(cwd, branches.base, branches.head);
1783
- if (pullRequest) {
1786
+ if (pullRequest && !options.update) {
1784
1787
  console.log(formatCompareSummary(await fetchCompare(cwd, branches.base, branches.head)));
1785
1788
  console.log(pullRequest.url);
1786
1789
  } else pullRequest = await createPullRequest({
@@ -1789,8 +1792,10 @@ async function mergePullRequestController(baseArg, headArg, options = {}) {
1789
1792
  head: branches.head,
1790
1793
  systemPrompt,
1791
1794
  languageModel: context.languageModel,
1795
+ modelKey: context.modelKey,
1792
1796
  maxDiffTokens: context.config.maxDiffTokens,
1793
- autoAccept: options.yolo ?? false
1797
+ autoAccept: options.yolo ?? false,
1798
+ existing: pullRequest
1794
1799
  });
1795
1800
  console.log("");
1796
1801
  if (options.yolo) console.log(source_default.yellow(`✓ Merging pull request #${pullRequest.number}`));
@@ -1969,7 +1974,8 @@ async function releaseController(tagArg, options = {}) {
1969
1974
  }, exists, "inherit");
1970
1975
  return;
1971
1976
  }
1972
- const languageModel = resolveReleaseModel(config$1, options.model);
1977
+ const modelConfig = resolveModelConfig(config$1.models, options.model ?? config$1.releaseModel ?? config$1.model);
1978
+ const languageModel = resolveLanguageModel(modelConfig);
1973
1979
  const previousTag = getPreviousTag(releases, tag);
1974
1980
  const headSha = await getBranchHeadSha(cwd, branch);
1975
1981
  const commits = await runWithLoading("Loading commits from GitHub", () => listReleaseCommits(cwd, previousTag, headSha));
@@ -1977,7 +1983,7 @@ async function releaseController(tagArg, options = {}) {
1977
1983
  console.log(source_default.dim(`${commits.length} commit(s) since ${previousTag ?? "the first commit"}`));
1978
1984
  let notes = "";
1979
1985
  while (true) {
1980
- notes = await runWithLoading("Generating release notes", () => writeReleaseNotes(cwd, languageModel, config$1, commits));
1986
+ notes = await runWithLoading(`Generating release notes (${modelConfig.key})`, () => writeReleaseNotes(cwd, languageModel, config$1, commits));
1981
1987
  console.log(renderReleaseNotes(notes).trim());
1982
1988
  console.log("");
1983
1989
  if (options.yolo || await acceptGenerated(`Create release ${source_default.yellow.bold(tag)} on ${source_default.yellow.bold(branch)}`, "generate new release notes")) break;
@@ -2066,10 +2072,10 @@ app.command("commit").description("Stage changes, generate a commit message, cre
2066
2072
  }));
2067
2073
  });
2068
2074
  const pr = app.command("pr").description("Create and merge GitHub pull requests.");
2069
- pr.command("create").description("Create a pull request with an AI-generated title and body.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Create the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-w, --web", "Open the pull request in a browser.").action((baseBranch, headBranch, options) => {
2075
+ pr.command("create").description("Create a pull request with an AI-generated title and body.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Create the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-u, --update", "Regenerate the title and body and update the existing pull request.").option("-w, --web", "Open the pull request in a browser.").action((baseBranch, headBranch, options) => {
2070
2076
  handleError(() => createPullRequestController(baseBranch, headBranch, options));
2071
2077
  });
2072
- pr.command("merge").description("Create the pull request if needed, then merge it.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Merge the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-m, --merge", "Merge the commits with the base branch.").option("-r, --rebase", "Rebase the commits onto the base branch.").option("-s, --squash", "Squash the commits into one commit.").option("-w, --web", "Open the pull request in a browser after merging.").action((baseBranch, headBranch, options) => {
2078
+ pr.command("merge").description("Create the pull request if needed, then merge it.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Merge the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-m, --merge", "Merge the commits with the base branch.").option("-r, --rebase", "Rebase the commits onto the base branch.").option("-s, --squash", "Squash the commits into one commit.").option("-u, --update", "Regenerate the title and body and update the existing pull request.").option("-w, --web", "Open the pull request in a browser after merging.").action((baseBranch, headBranch, options) => {
2073
2079
  if ([
2074
2080
  options.merge,
2075
2081
  options.rebase,
package/dist/lib.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as generatePullRequest, D as mergePullRequest, E as getDefaultBranch, M as writeCommitMessage, S as buildPullRequestSystemPrompt, T as findPullRequest, U as DEFAULT_MAX_DIFF_TOKENS, W as getCommitDiff, _ as loadPullRequestContext, a as verifyReleaseCommits, b as submitPullRequest, c as getBranchHeadSha, d as releaseExists, f as buildCompareContext, i as resolveReleaseModel, j as prepareCommit, l as listReleaseCommits, m as fetchPullRequestCompare, n as getPreviousTag, o as writeReleaseNotes, r as publishRelease, s as getRepoRoot, t as bumpVersionTag, u as listReleases, v as parsePullRequestContent, y as resolvePrBranches, z as loadConfig } from "./flow-Dt1FS1vI.js";
1
+ import { C as generatePullRequest, D as mergePullRequest, E as getDefaultBranch, G as DEFAULT_MAX_DIFF_TOKENS, K as getCommitDiff, M as writeCommitMessage, S as buildPullRequestSystemPrompt, T as findPullRequest, _ as loadPullRequestContext, a as verifyReleaseCommits, b as submitPullRequest, c as getBranchHeadSha, d as releaseExists, f as buildCompareContext, i as resolveReleaseModel, j as prepareCommit, l as listReleaseCommits, m as fetchPullRequestCompare, n as getPreviousTag, o as writeReleaseNotes, r as publishRelease, s as getRepoRoot, t as bumpVersionTag, u as listReleases, v as parsePullRequestContent, y as resolvePrBranches, z as loadConfig } from "./flow-BJ8xhhps.js";
2
2
  import "./defineProperty-DZ5JLFN4.js";
3
3
  import "./token-util-CV7QlXpE.js";
4
4
  async function createCommitSession(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gityo",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/NazmusSayad/gityo.git"