mellos-mapping 0.22.1 → 0.23.0

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.
@@ -113,6 +113,33 @@ function quitFilePath(defaultFile, pid) {
113
113
  // src/store/migration.ts
114
114
  import { dirname as dirname4, join as join4 } from "node:path";
115
115
  var LEGACY_STATE_FILE_RELATIVE_PATH = join4(".claude", "mellos-mapping.json");
116
+
117
+ // src/store/project.ts
118
+ import { existsSync, realpathSync } from "node:fs";
119
+ import { dirname as dirname5, join as join5, resolve } from "node:path";
120
+ import { homedir, tmpdir } from "node:os";
121
+ function resolveProjectDirectory(cwd, stopAt = [homedir(), tmpdir()]) {
122
+ let start = resolve(cwd);
123
+ try {
124
+ start = realpathSync(start);
125
+ } catch {
126
+ }
127
+ let dir = start;
128
+ const boundaries = new Set(stopAt.map((path) => {
129
+ try {
130
+ return realpathSync(path);
131
+ } catch {
132
+ return resolve(path);
133
+ }
134
+ }));
135
+ while (true) {
136
+ if (dir !== start && boundaries.has(dir)) return start;
137
+ if (existsSync(join5(dir, ".git")) || existsSync(join5(dir, ".mellos", "map.json")) || existsSync(join5(dir, ".mellos", "pages"))) return dir;
138
+ const parent = dirname5(dir);
139
+ if (parent === dir) return start;
140
+ dir = parent;
141
+ }
142
+ }
116
143
  export {
117
144
  FOCUS_FILE_NAME,
118
145
  ID_RULE,
@@ -122,5 +149,6 @@ export {
122
149
  VIEWERS_DIR_NAME,
123
150
  focusFilePath,
124
151
  quitFilePath,
125
- readLiveViewers
152
+ readLiveViewers,
153
+ resolveProjectDirectory
126
154
  };