@almadar/workspace 0.2.6 → 0.3.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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@
8
8
  */
9
9
  export { openWorkspace } from './open-workspace.js';
10
10
  export { openAccount } from './account.js';
11
- export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, OpenWorkspaceOptions, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
11
+ export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
12
12
  export type { WorkspaceIndex, EmbedderPort, ResolveResult, ResolveOptions, TraitRefEmit, WorkspaceIndexStats, OrbitalIndexEntry, ExtraTraitIdentity, RetrievalResult, RetrievalOptions, RecentlyEditedOptions, EventEdge, EntityBinding, RuleBinding, RecencyEntry, IntentMaps, ComposedMaps, BM25Document, BM25Table, BM25Options, WorkspaceIndexManifest, } from './workspace-index/types.js';
13
13
  export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, } from './workspace-index/types.js';
package/dist/index.js CHANGED
@@ -50,6 +50,24 @@ var LocalBackend = class {
50
50
  async chmod(absPath, mode) {
51
51
  await fs.promises.chmod(absPath, mode);
52
52
  }
53
+ watch(absPath, onChange) {
54
+ let watcher;
55
+ let timer;
56
+ try {
57
+ watcher = fs.watch(absPath, (eventType) => {
58
+ if (timer) clearTimeout(timer);
59
+ timer = setTimeout(() => {
60
+ timer = void 0;
61
+ onChange(eventType === "rename" ? "rename" : "change");
62
+ }, 75);
63
+ });
64
+ } catch {
65
+ }
66
+ return () => {
67
+ if (timer) clearTimeout(timer);
68
+ watcher?.close();
69
+ };
70
+ }
53
71
  };
54
72
 
55
73
  // src/internal/backends/memory.ts
@@ -150,6 +168,10 @@ var MemoryBackend = class {
150
168
  }
151
169
  async chmod() {
152
170
  }
171
+ watch() {
172
+ return () => {
173
+ };
174
+ }
153
175
  // Test helpers
154
176
  getAll() {
155
177
  return new Map(this.files);
@@ -2049,6 +2071,10 @@ var WorkspaceServiceImpl = class {
2049
2071
  subscribe(observer) {
2050
2072
  return this.sinks.subscribe(observer);
2051
2073
  }
2074
+ watch(relPath, onChange) {
2075
+ const abs = sandboxedPath(this.workDir, relPath);
2076
+ return this.backend.watch(abs, (kind) => onChange({ relPath, kind }));
2077
+ }
2052
2078
  // === Disposal ===
2053
2079
  async dispose() {
2054
2080
  const pending = Array.from(this.writeQueue.values());
@@ -2166,28 +2192,31 @@ async function openWorkspaceInternal(opts) {
2166
2192
  const backend = opts.backend === "memory" ? new MemoryBackend() : new LocalBackend();
2167
2193
  const sinks = new SinkManager();
2168
2194
  const resolved = await resolveLifecycle(backend, opts);
2169
- await ensureSkeleton(backend, resolved.workDir);
2170
- await writeMintTemplatesIfMissing(
2171
- backend,
2172
- resolved.workDir,
2173
- opts.userId,
2174
- opts.projectName ?? "Untitled",
2175
- resolved.appId
2176
- );
2177
- if (resolved.appId !== void 0) {
2178
- const existing = readAppMarker(backend, resolved.workDir);
2179
- if (!existing || existing.appId !== resolved.appId) {
2180
- const marker = {
2181
- appId: resolved.appId,
2182
- userId: opts.userId,
2183
- createdAt: existing?.createdAt ?? Date.now()
2184
- };
2185
- if (opts.github?.repoUrl) marker.repoUrl = opts.github.repoUrl;
2186
- await writeAppMarker(backend, resolved.workDir, marker);
2195
+ const bare = opts.bare === true && opts.adopt !== void 0;
2196
+ if (!bare) {
2197
+ await ensureSkeleton(backend, resolved.workDir);
2198
+ await writeMintTemplatesIfMissing(
2199
+ backend,
2200
+ resolved.workDir,
2201
+ opts.userId,
2202
+ opts.projectName ?? "Untitled",
2203
+ resolved.appId
2204
+ );
2205
+ if (resolved.appId !== void 0) {
2206
+ const existing = readAppMarker(backend, resolved.workDir);
2207
+ if (!existing || existing.appId !== resolved.appId) {
2208
+ const marker = {
2209
+ appId: resolved.appId,
2210
+ userId: opts.userId,
2211
+ createdAt: existing?.createdAt ?? Date.now()
2212
+ };
2213
+ if (opts.github?.repoUrl) marker.repoUrl = opts.github.repoUrl;
2214
+ await writeAppMarker(backend, resolved.workDir, marker);
2215
+ }
2187
2216
  }
2188
2217
  }
2189
2218
  let git;
2190
- if (opts.github && opts.backend !== "memory") {
2219
+ if (!bare && opts.github && opts.backend !== "memory") {
2191
2220
  git = await ensureGitInit(backend, resolved.workDir);
2192
2221
  }
2193
2222
  const service = new WorkspaceServiceImpl({
@@ -2199,7 +2228,9 @@ async function openWorkspaceInternal(opts) {
2199
2228
  git,
2200
2229
  github: opts.github
2201
2230
  });
2202
- await service.index.warm();
2231
+ if (!bare) {
2232
+ await service.index.warm();
2233
+ }
2203
2234
  return service;
2204
2235
  }
2205
2236
  async function resolveLifecycle(backend, opts) {