hermes-git 0.2.1 → 0.2.3

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 +85 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22092,6 +22092,30 @@ async function getRepoState() {
22092
22092
  throw new Error("Not a Git repository or Git is not installed");
22093
22093
  }
22094
22094
  }
22095
+ async function isGitInstalled() {
22096
+ try {
22097
+ await execAsync2("git --version");
22098
+ return true;
22099
+ } catch {
22100
+ return false;
22101
+ }
22102
+ }
22103
+ async function isGitRepository() {
22104
+ try {
22105
+ await execAsync2("git rev-parse --git-dir");
22106
+ return true;
22107
+ } catch {
22108
+ return false;
22109
+ }
22110
+ }
22111
+ async function hasCommits() {
22112
+ try {
22113
+ await execAsync2("git rev-parse HEAD");
22114
+ return true;
22115
+ } catch {
22116
+ return false;
22117
+ }
22118
+ }
22095
22119
  async function executeGitCommand(command) {
22096
22120
  try {
22097
22121
  const { stdout, stderr } = await execAsync2(command);
@@ -25387,11 +25411,46 @@ function worktreeCommand(program2) {
25387
25411
  import { writeFile as writeFile3, mkdir as mkdir2 } from "fs/promises";
25388
25412
  import { existsSync as existsSync3 } from "fs";
25389
25413
  import path from "path";
25414
+ import { exec as exec3 } from "child_process";
25415
+ import { promisify as promisify3 } from "util";
25416
+ var execAsync3 = promisify3(exec3);
25390
25417
  function initCommand(program2) {
25391
25418
  program2.command("init").description("Initialize Hermes configuration for this repository").option("--quick", "Skip interactive prompts, use defaults").action(async (options) => {
25392
25419
  try {
25393
25420
  console.log(`\uD83E\uDEBD Initializing Hermes for this repository...
25394
25421
  `);
25422
+ if (!await isGitInstalled()) {
25423
+ console.error("❌ Error: Git is not installed");
25424
+ console.log("Please install Git and try again.");
25425
+ process.exit(1);
25426
+ }
25427
+ const isRepo = await isGitRepository();
25428
+ if (!isRepo) {
25429
+ console.log(`⚠️ This directory is not a Git repository.
25430
+ `);
25431
+ if (options.quick) {
25432
+ console.log("Running: git init");
25433
+ await execAsync3("git init");
25434
+ console.log(`✓ Git repository initialized
25435
+ `);
25436
+ } else {
25437
+ const { initGit } = await esm_default12.prompt([
25438
+ {
25439
+ type: "confirm",
25440
+ name: "initGit",
25441
+ message: "Would you like to initialize a Git repository?",
25442
+ default: true
25443
+ }
25444
+ ]);
25445
+ if (!initGit) {
25446
+ console.log("Cancelled. Please run this command in a Git repository.");
25447
+ process.exit(1);
25448
+ }
25449
+ await execAsync3("git init");
25450
+ console.log(`✓ Git repository initialized
25451
+ `);
25452
+ }
25453
+ }
25395
25454
  if (existsSync3(".hermes/config.json")) {
25396
25455
  const { overwrite } = await esm_default12.prompt([
25397
25456
  {
@@ -25406,12 +25465,24 @@ function initCommand(program2) {
25406
25465
  return;
25407
25466
  }
25408
25467
  }
25409
- const repoState = await getRepoState();
25468
+ let currentBranch = "main";
25469
+ const hasAnyCommits = await hasCommits();
25470
+ if (hasAnyCommits) {
25471
+ const repoState = await getRepoState();
25472
+ currentBranch = repoState.currentBranch;
25473
+ } else {
25474
+ try {
25475
+ const { stdout } = await execAsync3("git config --get init.defaultBranch");
25476
+ currentBranch = stdout.trim() || "main";
25477
+ } catch {
25478
+ currentBranch = "main";
25479
+ }
25480
+ }
25410
25481
  let config;
25411
25482
  if (options.quick) {
25412
- config = createDefaultConfig(repoState.currentBranch);
25483
+ config = createDefaultConfig(currentBranch);
25413
25484
  } else {
25414
- config = await interactiveConfig(repoState);
25485
+ config = await interactiveConfig({ currentBranch });
25415
25486
  }
25416
25487
  await mkdir2(".hermes", { recursive: true });
25417
25488
  await writeFile3(".hermes/config.json", JSON.stringify(config, null, 2));
@@ -25422,9 +25493,15 @@ function initCommand(program2) {
25422
25493
  displaySuccess("Hermes initialized successfully!");
25423
25494
  console.log(`
25424
25495
  \uD83D\uDCC4 Configuration saved to .hermes/config.json`);
25425
- console.log(`\uD83D\uDCA1 Tip: Commit .hermes/config.json to share with your team
25496
+ if (!hasAnyCommits) {
25497
+ console.log('\uD83D\uDCA1 Tip: Make your first commit, then try: hermes start "your first feature"');
25498
+ } else {
25499
+ console.log(`\uD83D\uDCA1 Tip: Commit .hermes/config.json to share with your team
25426
25500
  `);
25427
- console.log(" Features enabled:");
25501
+ console.log('\uD83D\uDE80 Try: hermes start "your first feature"');
25502
+ }
25503
+ console.log(`
25504
+ ✨ Features enabled:`);
25428
25505
  if (config.preferences.autoBackup) {
25429
25506
  console.log(" • Auto-backup before risky operations");
25430
25507
  }
@@ -25435,7 +25512,6 @@ function initCommand(program2) {
25435
25512
  console.log(` • ${config.integrations.tickets} integration`);
25436
25513
  }
25437
25514
  console.log();
25438
- console.log('\uD83D\uDE80 Try: hermes start "your first feature"');
25439
25515
  } catch (error) {
25440
25516
  console.error("❌ Error:", error instanceof Error ? error.message : error);
25441
25517
  process.exit(1);
@@ -25470,7 +25546,7 @@ function createDefaultConfig(currentBranch) {
25470
25546
  }
25471
25547
  };
25472
25548
  }
25473
- async function interactiveConfig(repoState) {
25549
+ async function interactiveConfig(repoInfo) {
25474
25550
  console.log(`\uD83D\uDCDD Let's set up Hermes for your project.
25475
25551
  `);
25476
25552
  const answers = await esm_default12.prompt([
@@ -25484,7 +25560,7 @@ async function interactiveConfig(repoState) {
25484
25560
  type: "input",
25485
25561
  name: "mainBranch",
25486
25562
  message: "Main branch name:",
25487
- default: repoState.currentBranch === "master" ? "master" : "main"
25563
+ default: repoInfo.currentBranch === "master" ? "master" : "main"
25488
25564
  },
25489
25565
  {
25490
25566
  type: "input",
@@ -25735,7 +25811,7 @@ Project-specific:`);
25735
25811
 
25736
25812
  // src/index.ts
25737
25813
  var program2 = new Command;
25738
- program2.name("hermes").description("\uD83E\uDEBD Intent-driven Git, guided by AI").version("0.2.0");
25814
+ program2.name("hermes").description("\uD83E\uDEBD Intent-driven Git, guided by AI").version("0.2.3");
25739
25815
  initCommand(program2);
25740
25816
  planCommand(program2);
25741
25817
  startCommand(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-git",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Intent-driven Git, guided by AI. Turn natural language into safe, explainable Git operations.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",