@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.
@@ -21,4 +21,5 @@ export declare class LocalBackend implements WorkspaceBackend {
21
21
  }>;
22
22
  rename(srcAbs: string, dstAbs: string): Promise<void>;
23
23
  chmod(absPath: string, mode: number): Promise<void>;
24
+ watch(absPath: string, onChange: (kind: 'change' | 'rename') => void): () => void;
24
25
  }
@@ -22,6 +22,7 @@ export declare class MemoryBackend implements WorkspaceBackend {
22
22
  }>;
23
23
  rename(srcAbs: string, dstAbs: string): Promise<void>;
24
24
  chmod(): Promise<void>;
25
+ watch(): () => void;
25
26
  getAll(): Map<string, string>;
26
27
  clear(): void;
27
28
  }
@@ -37,6 +37,15 @@ export interface WorkspaceBackend {
37
37
  rename(srcAbs: string, dstAbs: string): Promise<void>;
38
38
  /** Set file mode bits (e.g. `0o600` for a secrets file). No-op on backends without a real fs. */
39
39
  chmod(absPath: string, mode: number): Promise<void>;
40
+ /**
41
+ * Watch an absolute path (file or directory) for EXTERNAL changes — edits
42
+ * made outside this service (a user editing a `.orb` in another editor, a
43
+ * remote sync landing). Returns a closer that stops watching. The `'local'`
44
+ * backend implements this with `fs.watch`; backends without a real fs
45
+ * (memory) may no-op. A future remote/github backend implements it its own
46
+ * way (poll/webhook) — consumers never see the difference.
47
+ */
48
+ watch(absPath: string, onChange: (kind: 'change' | 'rename') => void): () => void;
40
49
  }
41
50
  /**
42
51
  * The persisted marker that pins an `appId` to a workspace dir on disk.
package/dist/service.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  import type { JsonObject, JsonValue } from '@almadar/core';
10
- import type { FileTreeNode, GitHubConfig, GitStatusInfo, WorkspaceObserver, WorkspaceService } from './types.js';
10
+ import type { FileTreeNode, GitHubConfig, GitStatusInfo, WorkspaceObserver, WorkspaceService, WorkspaceWatchEvent } from './types.js';
11
11
  import type { WorkspaceBackend } from './internal/types.js';
12
12
  import { SinkManager } from './internal/sink-manager.js';
13
13
  import { GitClient } from './internal/git-client.js';
@@ -85,6 +85,7 @@ export declare class WorkspaceServiceImpl implements WorkspaceService {
85
85
  pullIfLinked(): Promise<boolean>;
86
86
  gitStatus(): Promise<GitStatusInfo>;
87
87
  subscribe(observer: WorkspaceObserver): () => void;
88
+ watch(relPath: string, onChange: (event: WorkspaceWatchEvent) => void): () => void;
88
89
  dispose(): Promise<void>;
89
90
  }
90
91
  export {};
package/dist/types.d.ts CHANGED
@@ -98,6 +98,18 @@ export type WorkspaceWriteEvent = {
98
98
  kind: 'workspace-index-manifest';
99
99
  content: JsonObject;
100
100
  };
101
+ /**
102
+ * Emitted by {@link WorkspaceService.watch} when storage changes underneath the
103
+ * service — an edit made OUTSIDE this service (another editor, a remote sync).
104
+ * Distinct from {@link WorkspaceObserver}, which fires on writes the service
105
+ * itself performs.
106
+ */
107
+ export interface WorkspaceWatchEvent {
108
+ /** Workspace-relative POSIX path that changed. */
109
+ relPath: string;
110
+ /** `'change'` = content edited; `'rename'` = created / deleted / moved. */
111
+ kind: 'change' | 'rename';
112
+ }
101
113
  /**
102
114
  * Caller-supplied backend used when the local cache misses but the
103
115
  * workspace state lives somewhere addressable (Firestore, S3, etc.).
@@ -153,6 +165,15 @@ export interface OpenWorkspaceOptions {
153
165
  appId?: string;
154
166
  /** Adopt an existing absolute workDir as-is. */
155
167
  adopt?: string;
168
+ /**
169
+ * Bare adopt — use the adopted dir WITHOUT scaffolding it: no `.almadar/`
170
+ * skeleton, no mint templates, no app-marker, no index warm. For opening a
171
+ * loose external file in place (desktop file-centric editing): read / write /
172
+ * watch the file via the sandboxed relPath (its basename), leaving zero litter
173
+ * in the user's directory. Only meaningful together with `adopt`; ignored
174
+ * otherwise.
175
+ */
176
+ bare?: boolean;
156
177
  /** Clone-on-resume / push-on-dispose configuration. */
157
178
  github?: GitHubConfig;
158
179
  /** Fallback fetcher used when the local cache misses. */
@@ -234,6 +255,14 @@ export interface WorkspaceService {
234
255
  pullIfLinked(): Promise<boolean>;
235
256
  gitStatus(): Promise<GitStatusInfo>;
236
257
  subscribe(observer: WorkspaceObserver): () => void;
258
+ /**
259
+ * Watch a workspace-relative path (file or directory) for EXTERNAL changes —
260
+ * edits made outside this service, e.g. a user editing a `.orb` in another
261
+ * editor (desktop hot-reload). Unlike `subscribe`, which is write-side only.
262
+ * Backend-agnostic: `'local'` uses `fs.watch`; a remote/github backend its own
263
+ * mechanism. Returns an unsubscribe function. Rejects `..` / absolute paths.
264
+ */
265
+ watch(relPath: string, onChange: (event: WorkspaceWatchEvent) => void): () => void;
237
266
  readonly index: WorkspaceIndex;
238
267
  dispose(): Promise<void>;
239
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/workspace",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "Storage-agnostic workspace primitives shared by Almadar consumers. One service, six exports, hidden paths, single observer. See docs/Almadar_Workspace.md.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",