gityo 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +54 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1710,7 +1710,7 @@ function useColor() {
1710
1710
  if (process$1.env.FORCE_COLOR || process$1.env.CLICOLOR_FORCE !== void 0) return true;
1711
1711
  }
1712
1712
  new Command();
1713
- var version$4 = "1.1.0";
1713
+ var version$4 = "1.1.1";
1714
1714
  const keybindingLookup = new Set(["emacs", "vim"]);
1715
1715
  function isKeybinding(value) {
1716
1716
  return keybindingLookup.has(value);
@@ -228698,11 +228698,11 @@ const SUPPORTED_PROVIDERS = {
228698
228698
  };
228699
228699
  const PROVIDER_NPM_PACKAGES = Object.keys(SUPPORTED_PROVIDERS);
228700
228700
  function resolveModelConfig(models, modelKey) {
228701
- const modelConfig = models?.[modelKey];
228701
+ const modelKeys = Object.keys(models ?? {});
228702
+ 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.");
228703
+ const modelConfig = models[modelKey ?? modelKeys[0]];
228702
228704
  if (modelConfig) return modelConfig;
228703
- const availableModels = Object.keys(models ?? {}).join(", ");
228704
- if (availableModels.length === 0) throw new Error("No models configured. Edit your config file to add a model — run `gityo config` to see where.");
228705
- throw new Error(`Model '${modelKey}' is not configured. Available models: ${availableModels}.`);
228705
+ throw new Error(`Model '${modelKey}' is not configured. Available models: ${modelKeys.join(", ")}.`);
228706
228706
  }
228707
228707
  function resolveLanguageModel(modelConfig) {
228708
228708
  const envVarNames = Array.isArray(modelConfig.apiKeyEnv) ? modelConfig.apiKeyEnv : [modelConfig.apiKeyEnv];
@@ -228807,6 +228807,10 @@ const instructionSchema = union$4([string$5().min(1), object$3({ path: string$5(
228807
228807
  const configSchema = object$3({
228808
228808
  $schema: url$3(),
228809
228809
  models: record$3(string$5().min(1), modelSchema),
228810
+ model: string$5().min(1),
228811
+ prModel: string$5().min(1),
228812
+ commitModel: string$5().min(1),
228813
+ releaseModel: string$5().min(1),
228810
228814
  commitInstructions: instructionSchema,
228811
228815
  commitStyle: string$5().min(1),
228812
228816
  commitStyles: record$3(string$5().min(1), instructionSchema),
@@ -228829,6 +228833,10 @@ function resolveConfig(input$3) {
228829
228833
  const parsed = configSchema.parse(input$3);
228830
228834
  return {
228831
228835
  models: parsed.models,
228836
+ model: parsed.model,
228837
+ prModel: parsed.prModel,
228838
+ commitModel: parsed.commitModel,
228839
+ releaseModel: parsed.releaseModel,
228832
228840
  commitStyle: parsed.commitStyle,
228833
228841
  commitStyles: parsed.commitStyles,
228834
228842
  commitInstructions: parsed.commitInstructions,
@@ -228962,7 +228970,7 @@ const MAX_TOC_LINES$1 = 500;
228962
228970
  async function mainController(options = {}) {
228963
228971
  const { git, liveGit } = await getGit();
228964
228972
  const config$5 = await loadConfig((await git.revparse(["--show-toplevel"])).trim());
228965
- const modelKey = options.model ?? "default";
228973
+ const modelKey = options.model ?? config$5.commitModel ?? config$5.model;
228966
228974
  const languageModel = resolveLanguageModel(resolveModelConfig(config$5.models, modelKey));
228967
228975
  const styleKey = options.style ?? config$5.commitStyle ?? "default";
228968
228976
  const style = await resolveStyle(styleKey, config$5.commitStyles);
@@ -236181,7 +236189,7 @@ async function resolvePrBranches(baseArg, headArg) {
236181
236189
  }
236182
236190
  async function loadPullRequestContext(options = {}) {
236183
236191
  const config$5 = await loadConfig(await getRepoRoot$1());
236184
- const languageModel = resolveLanguageModel(resolveModelConfig(config$5.models, options.modelKey ?? "default"));
236192
+ const languageModel = resolveLanguageModel(resolveModelConfig(config$5.models, options.modelKey ?? config$5.prModel ?? config$5.model));
236185
236193
  const titleStyleKey = options.titleStyle ?? config$5.prTitleStyle ?? "default";
236186
236194
  const titleStyle = config$5.prTitleStyles?.[titleStyleKey] ?? PR_TITLE_STYLES[titleStyleKey];
236187
236195
  if (!titleStyle) {
@@ -236761,12 +236769,16 @@ const renderReleaseNotes = createRenderer({
236761
236769
  listIndent: 2
236762
236770
  });
236763
236771
  async function releaseController(tagArg, options = {}) {
236764
- if (options.yolo && tagArg === void 0) throw new Error("A release tag is required with --yolo.");
236772
+ if (options.bump && tagArg !== void 0) throw new Error(`Use either a release tag or --${options.bump}, not both.`);
236773
+ if (options.yolo && tagArg === void 0 && !options.bump) throw new Error("A release tag or --major, --minor, or --patch is required with --yolo.");
236765
236774
  const config$5 = await loadConfig(await getRepoRoot());
236766
- const languageModel = resolveLanguageModel(resolveModelConfig(config$5.models, options.model ?? "default"));
236775
+ const languageModel = resolveLanguageModel(resolveModelConfig(config$5.models, options.model ?? config$5.releaseModel ?? config$5.model));
236767
236776
  const releases = await listReleases(100);
236768
236777
  let tag = tagArg?.trim() ?? "";
236769
- if (tagArg === void 0) {
236778
+ if (options.bump) {
236779
+ tag = bumpVersionTag(releases.slice(0, 3).map((release) => release.tagName), options.bump);
236780
+ console.log(source_default.dim(`Release tag: ${tag}`));
236781
+ } else if (tagArg === void 0) {
236770
236782
  printRecentReleases(releases.slice(0, 5).reverse());
236771
236783
  tag = (await dist_default$1({
236772
236784
  message: "Release tag",
@@ -236813,6 +236825,21 @@ async function releaseController(tagArg, options = {}) {
236813
236825
  notes
236814
236826
  });
236815
236827
  }
236828
+ function bumpVersionTag(recentTags, bump) {
236829
+ const versionPattern = /^(v?)(\d+)\.(\d+)\.(\d+)$/;
236830
+ const invalidTags = recentTags.filter((tag) => !versionPattern.test(tag));
236831
+ if (invalidTags.length > 0) throw new Error(`Recent release tags must be MAJOR.MINOR.PATCH versions to use --${bump}: ${invalidTags.join(", ")}`);
236832
+ const match = versionPattern.exec(recentTags[0] ?? "");
236833
+ if (!match) throw new Error(`No previous release found to apply --${bump} to.`);
236834
+ const prefix = match[1];
236835
+ const major = Number(match[2]);
236836
+ const minor = Number(match[3]);
236837
+ const patch = Number(match[4]);
236838
+ if (bump === "major") return `${prefix}${major + 1}.0.0`;
236839
+ if (bump === "minor") return `${prefix}${major}.${minor + 1}.0`;
236840
+ if (bump === "patch") return `${prefix}${major}.${minor}.${patch + 1}`;
236841
+ throw new Error(`Unknown version bump '${bump}'.`);
236842
+ }
236816
236843
  function printRecentReleases(releases) {
236817
236844
  if (releases.length === 0) return;
236818
236845
  const longestTag = Math.max(...releases.map((release) => release.tagName.length));
@@ -236861,7 +236888,7 @@ function handleError(fn$1) {
236861
236888
  }
236862
236889
  });
236863
236890
  }
236864
- const app = new Command().enablePositionalOptions().name("gityo").description("Stage changes, generate a commit message, create a commit, and run a post-commit git command.").option("-i, --input <input>", "Use the provided input as the commit message.").option("-s, --style <style>", "Commit message style key to use (defaults to \"default\").").option("--model <model>", "Model key from config to use (defaults to \"default\").").option("-g, --generate", "Generate a commit message and commit without asking.").option("-p, --post", "Run the post-commit git command without asking.").option("-S, --staged", "Commit only staged files. Fails if nothing is staged.").option("-A, --all", "Commit all changes, not just staged files.").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").version(`v${version$4}`, "-v, --version", "Show the current version.").action((options) => {
236891
+ const app = new Command().enablePositionalOptions().name("gityo").description("Stage changes, generate a commit message, create a commit, and run a post-commit git command.").option("-i, --input <input>", "Use the provided input as the commit message.").option("-s, --style <style>", "Commit message style key to use (defaults to \"default\").").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-g, --generate", "Generate a commit message and commit without asking.").option("-p, --post", "Run the post-commit git command without asking.").option("-S, --staged", "Commit only staged files. Fails if nothing is staged.").option("-A, --all", "Commit all changes, not just staged files.").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").version(`v${version$4}`, "-v, --version", "Show the current version.").action((options) => {
236865
236892
  if (options.generate && options.input) {
236866
236893
  console.error("Cannot use --generate and --input together.");
236867
236894
  process.exit(1);
@@ -236875,7 +236902,7 @@ const app = new Command().enablePositionalOptions().name("gityo").description("S
236875
236902
  scope: options.all ? "everything" : options.staged ? "staged-only" : "staged-or-changes"
236876
236903
  }));
236877
236904
  });
236878
- app.command("commit").description("Stage changes, generate a commit message, create a commit, and run a post-commit git command.").option("-i, --input <input>", "Use the provided input as the commit message.").option("-s, --style <style>", "Commit message style key to use (defaults to \"default\").").option("--model <model>", "Model key from config to use (defaults to \"default\").").option("-g, --generate", "Generate a commit message and commit without asking.").option("-p, --post", "Run the post-commit git command without asking.").option("-S, --staged", "Commit only staged files. Fails if nothing is staged.").option("-A, --all", "Commit all changes, not just staged files.").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").action((options) => {
236905
+ app.command("commit").description("Stage changes, generate a commit message, create a commit, and run a post-commit git command.").option("-i, --input <input>", "Use the provided input as the commit message.").option("-s, --style <style>", "Commit message style key to use (defaults to \"default\").").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-g, --generate", "Generate a commit message and commit without asking.").option("-p, --post", "Run the post-commit git command without asking.").option("-S, --staged", "Commit only staged files. Fails if nothing is staged.").option("-A, --all", "Commit all changes, not just staged files.").option("-y, --yolo", "Skip all questions, and generate message, commit, run post command. [Will fail if no model available]").action((options) => {
236879
236906
  if (options.generate && options.input) {
236880
236907
  console.error("Cannot use --generate and --input together.");
236881
236908
  process.exit(1);
@@ -236890,10 +236917,10 @@ app.command("commit").description("Stage changes, generate a commit message, cre
236890
236917
  }));
236891
236918
  });
236892
236919
  const pr = app.command("pr").description("Create and merge GitHub pull requests.");
236893
- 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 (defaults to \"default\").").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) => {
236920
+ 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) => {
236894
236921
  handleError(() => createPullRequestController(baseBranch, headBranch, options));
236895
236922
  });
236896
- 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 (defaults to \"default\").").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.").action((baseBranch, headBranch, options) => {
236923
+ 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.").action((baseBranch, headBranch, options) => {
236897
236924
  if ([
236898
236925
  options.merge,
236899
236926
  options.rebase,
@@ -236907,8 +236934,19 @@ pr.command("merge").description("Create the pull request if needed, then merge i
236907
236934
  mergeMethod: options.merge ? "merge" : options.rebase ? "rebase" : options.squash ? "squash" : void 0
236908
236935
  }));
236909
236936
  });
236910
- app.command("release").description("Create a GitHub release with AI-generated release notes.").argument("[tag]", "Release tag to create (asks when omitted).").option("--model <model>", "Model key from config to use (defaults to \"default\").").option("-y, --yolo", "Create the release without asking for confirmation (requires a tag).").option("-f, --force", "Recreate the release without asking if it already exists.").action((tag, options) => {
236911
- handleError(() => releaseController(tag, options));
236937
+ app.command("release").description("Create a GitHub release with AI-generated release notes.").argument("[tag]", "Release tag to create (asks when omitted).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-y, --yolo", "Create the release without asking for confirmation (requires a tag).").option("-f, --force", "Recreate the release without asking if it already exists.").option("--major", "Bump the major version of the latest release.").option("--minor", "Bump the minor version of the latest release.").option("--patch", "Bump the patch version of the latest release.").action((tag, options) => {
236938
+ if ([
236939
+ options.major,
236940
+ options.minor,
236941
+ options.patch
236942
+ ].filter(Boolean).length > 1) {
236943
+ console.error("Use only one of --major, --minor, or --patch.");
236944
+ process.exit(1);
236945
+ }
236946
+ handleError(() => releaseController(tag, {
236947
+ ...options,
236948
+ bump: options.major ? "major" : options.minor ? "minor" : options.patch ? "patch" : void 0
236949
+ }));
236912
236950
  });
236913
236951
  app.command("config").description("Show where to manage your gityo configuration.").action(() => {
236914
236952
  handleError(showConfigController);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gityo",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/NazmusSayad/gityo.git"