@phren/cli 0.0.23 → 0.0.25

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.
@@ -2,6 +2,7 @@ import { buildHookContext, handleGuardSkip, debugLog, appendAuditLog, runtimeFil
2
2
  import { sessionMetricsFile, qualityMarkers, } from "./shared.js";
3
3
  import { autoMergeConflicts, mergeTask, mergeFindings, } from "./shared-content.js";
4
4
  import { runGit } from "./utils.js";
5
+ import { readInstallPreferences } from "./init-preferences.js";
5
6
  import * as fs from "fs";
6
7
  import * as path from "path";
7
8
  import * as os from "os";
@@ -97,6 +98,7 @@ export function getUntrackedProjectNotice(phrenPath, cwd) {
97
98
  ].join("\n");
98
99
  }
99
100
  const SESSION_START_ONBOARDING_MARKER = "session-start-onboarding-v1";
101
+ const SYNC_WARN_MARKER = "sync-broken-warned-v1";
100
102
  function projectHasBootstrapSignals(phrenPath, project) {
101
103
  const projectDir = path.join(phrenPath, project);
102
104
  const findingsPath = path.join(projectDir, "FINDINGS.md");
@@ -624,6 +626,35 @@ export async function handleHookSessionStart() {
624
626
  },
625
627
  });
626
628
  appendAuditLog(phrenPath, "hook_session_start", `pull=${hasRemote ? (pull.ok ? "ok" : "fail") : "skipped-local"} doctor=${doctor.ok ? "ok" : "issues"} maintenance=${maintenanceScheduled ? "scheduled" : "skipped"}`);
629
+ // Sync intent warning: if the user intended sync but remote is missing or pull failed, warn once
630
+ try {
631
+ const syncPrefs = readInstallPreferences(phrenPath);
632
+ const syncBroken = syncPrefs.syncIntent === "sync" && (!hasRemote || !pull.ok);
633
+ if (syncBroken) {
634
+ const syncWarnPath = sessionMarker(phrenPath, SYNC_WARN_MARKER);
635
+ if (!fs.existsSync(syncWarnPath)) {
636
+ const reason = !hasRemote
637
+ ? "no git remote is connected"
638
+ : `pull failed: ${pull.error || "unknown error"}`;
639
+ process.stdout.write([
640
+ "<phren-notice>",
641
+ `Sync is configured but ${reason}. Your phren data is local-only.`,
642
+ `To fix: cd ${phrenPath} && git remote add origin <YOUR_REPO_URL> && git push -u origin main`,
643
+ "<phren-notice>",
644
+ "",
645
+ ].join("\n"));
646
+ try {
647
+ fs.writeFileSync(syncWarnPath, `${startedAt}\n`);
648
+ }
649
+ catch (err) {
650
+ debugLog(`sync-warn marker write failed: ${errorMessage(err)}`);
651
+ }
652
+ }
653
+ }
654
+ }
655
+ catch (err) {
656
+ debugLog(`sync-intent check failed: ${errorMessage(err)}`);
657
+ }
627
658
  // Untracked project detection: suggest `phren add` if CWD looks like a project but isn't tracked
628
659
  try {
629
660
  const notice = getUntrackedProjectNotice(phrenPath, cwd);