@almadar/workspace 0.2.6 → 0.4.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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `listWorkspaces` — enumerate the app-workspaces a user has under a root.
3
+ *
4
+ * The single source for "which projects exist locally": scans
5
+ * `<root>/<userId>/*` for dirs carrying an `app-marker.json` (minted or
6
+ * adopted-as-app workspaces) and reports `{ appId, workDir, name?, updatedAt? }`.
7
+ * Bare-adopted loose files (no marker) are intentionally excluded — they aren't
8
+ * projects. Consumers (apps/builder's offline AppStore, orbital-agent-cli) use
9
+ * this instead of fs-scanning the layout themselves.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import type { ListWorkspacesOptions, WorkspaceSummary } from './types.js';
14
+ export declare function listWorkspaces(opts: ListWorkspacesOptions): Promise<WorkspaceSummary[]>;
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. */
@@ -169,6 +190,26 @@ export interface OpenWorkspaceOptions {
169
190
  */
170
191
  embedder?: EmbedderPort;
171
192
  }
193
+ /** Input for {@link listWorkspaces}. */
194
+ export interface ListWorkspacesOptions {
195
+ /** Workspaces root, e.g. `/workspaces` — user dirs nest under it. */
196
+ root: string;
197
+ /** Owning user id. */
198
+ userId: string;
199
+ /** Storage selector. `'memory'` is for tests; `'local'` is default. */
200
+ backend?: 'local' | 'memory';
201
+ }
202
+ /** One project workspace returned by {@link listWorkspaces}. */
203
+ export interface WorkspaceSummary {
204
+ /** Pinned app id from `.almadar/app-marker.json`. */
205
+ appId: string;
206
+ /** Absolute workspace directory. */
207
+ workDir: string;
208
+ /** Schema display name (`schema.orb` `name`), when present. */
209
+ name?: string;
210
+ /** `schema.orb` mtime if present, else the marker's `createdAt`. */
211
+ updatedAt?: number;
212
+ }
172
213
  /**
173
214
  * The single workspace I/O surface. Every consumer (rabit, apps/builder,
174
215
  * cli, future tools) operates through this. Methods are grouped per
@@ -234,6 +275,14 @@ export interface WorkspaceService {
234
275
  pullIfLinked(): Promise<boolean>;
235
276
  gitStatus(): Promise<GitStatusInfo>;
236
277
  subscribe(observer: WorkspaceObserver): () => void;
278
+ /**
279
+ * Watch a workspace-relative path (file or directory) for EXTERNAL changes —
280
+ * edits made outside this service, e.g. a user editing a `.orb` in another
281
+ * editor (desktop hot-reload). Unlike `subscribe`, which is write-side only.
282
+ * Backend-agnostic: `'local'` uses `fs.watch`; a remote/github backend its own
283
+ * mechanism. Returns an unsubscribe function. Rejects `..` / absolute paths.
284
+ */
285
+ watch(relPath: string, onChange: (event: WorkspaceWatchEvent) => void): () => void;
237
286
  readonly index: WorkspaceIndex;
238
287
  dispose(): Promise<void>;
239
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/workspace",
3
- "version": "0.2.6",
3
+ "version": "0.4.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",