@misterhuydo/sentinel 1.4.72 → 1.4.74

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "message": "Auto-checkpoint at 2026-03-26T18:49:49.152Z",
3
- "checkpoint_at": "2026-03-26T18:49:49.153Z",
2
+ "message": "Auto-checkpoint at 2026-03-26T19:12:24.024Z",
3
+ "checkpoint_at": "2026-03-26T19:12:24.038Z",
4
4
  "active_files": [],
5
5
  "notes": [],
6
6
  "mtime_snapshot": {}
package/lib/add.js CHANGED
@@ -289,24 +289,46 @@ async function addFromGit(gitUrl, workspace) {
289
289
  if (existingAccess.ok) {
290
290
  ok(`${repoSlug}: reachable via existing SSH key — skipping deploy key generation`);
291
291
  } else {
292
+ const keyAlreadyExisted = fs.existsSync(path.join(os.homedir(), '.ssh', `${repoSlug}.key`));
292
293
  const { keyFile: generatedKey } = generateDeployKey(repoSlug);
293
294
  keyFile = generatedKey;
294
- printDeployKeyInstructions(orgRepo, keyFile);
295
-
296
- await prompts({
297
- type: 'text', name: '_', format: () => '',
298
- message: chalk.bold(`Press Enter once you've added the deploy key to GitHub…`),
299
- }, { onCancel: () => process.exit(0) });
300
-
301
- // Validate primary repo with deploy key
302
- const primary = validateAccess(gitUrl, keyFile);
303
- if (!primary.ok) {
304
- console.error(chalk.red(' Cannot reach ' + gitUrl));
305
- if (primary.stderr) console.error(chalk.red(' ' + primary.stderr));
306
- console.error(chalk.yellow(' Check the deploy key has write access, then re-run.'));
307
- process.exit(1);
295
+
296
+ // If key already existed, try it immediately — skip prompt if it works
297
+ if (keyAlreadyExisted) {
298
+ const primary = validateAccess(gitUrl, keyFile);
299
+ if (primary.ok) {
300
+ ok(`${repoSlug}: reachable (reusing existing deploy key)`);
301
+ } else {
302
+ // Key exists but doesn't work (e.g. not yet added to GitHub) — show instructions
303
+ printDeployKeyInstructions(orgRepo, keyFile);
304
+ await prompts({
305
+ type: 'text', name: '_', format: () => '',
306
+ message: chalk.bold(`Press Enter once you've added the deploy key to GitHub…`),
307
+ }, { onCancel: () => process.exit(0) });
308
+ const retry = validateAccess(gitUrl, keyFile);
309
+ if (!retry.ok) {
310
+ console.error(chalk.red(' ✖ Cannot reach ' + gitUrl));
311
+ if (retry.stderr) console.error(chalk.red(' ' + retry.stderr));
312
+ console.error(chalk.yellow(' Check the deploy key has write access, then re-run.'));
313
+ process.exit(1);
314
+ }
315
+ ok(`${repoSlug}: reachable`);
316
+ }
317
+ } else {
318
+ printDeployKeyInstructions(orgRepo, keyFile);
319
+ await prompts({
320
+ type: 'text', name: '_', format: () => '',
321
+ message: chalk.bold(`Press Enter once you've added the deploy key to GitHub…`),
322
+ }, { onCancel: () => process.exit(0) });
323
+ const primary = validateAccess(gitUrl, keyFile);
324
+ if (!primary.ok) {
325
+ console.error(chalk.red(' ✖ Cannot reach ' + gitUrl));
326
+ if (primary.stderr) console.error(chalk.red(' ' + primary.stderr));
327
+ console.error(chalk.yellow(' Check the deploy key has write access, then re-run.'));
328
+ process.exit(1);
329
+ }
330
+ ok(`${repoSlug}: reachable`);
308
331
  }
309
- ok(`${repoSlug}: reachable`);
310
332
  }
311
333
 
312
334
  // ── 2. Clone primary repo and discover additional repos ────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterhuydo/sentinel",
3
- "version": "1.4.72",
3
+ "version": "1.4.74",
4
4
  "description": "Sentinel — Autonomous DevOps Agent installer and manager",
5
5
  "bin": {
6
6
  "sentinel": "./bin/sentinel.js"
@@ -632,13 +632,14 @@ async def _send_startup_email_delayed(cfg, results: dict, delay: int = 300):
632
632
 
633
633
  # ── Config repo polling ──────────────────────────────────────────────────────────────────────────
634
634
 
635
- def _config_repo_git_env() -> dict:
635
+ def _config_repo_git_env(project_dir: Path | None = None) -> dict:
636
636
  """Return env with GIT_SSH_COMMAND pointing to ~/.ssh/<slug>.key if it exists."""
637
637
  env = os.environ.copy()
638
638
  try:
639
+ cwd = str((project_dir or Path(".")).resolve())
639
640
  r = subprocess.run(
640
641
  ["git", "remote", "get-url", "origin"],
641
- capture_output=True, text=True, timeout=5,
642
+ cwd=cwd, capture_output=True, text=True, timeout=5,
642
643
  )
643
644
  remote = r.stdout.strip()
644
645
  # Extract slug: git@github.com:org/repo.git or https://github.com/org/repo.git
@@ -662,7 +663,7 @@ def _poll_config_repo(cfg_loader: ConfigLoader) -> bool:
662
663
  ["git", "pull", "--rebase", "--autostash"],
663
664
  cwd=str(project_dir),
664
665
  capture_output=True, text=True, timeout=30,
665
- env=_config_repo_git_env(),
666
+ env=_config_repo_git_env(project_dir),
666
667
  )
667
668
  if result.returncode != 0:
668
669
  logger.warning("Config repo git pull failed: %s", result.stderr.strip())