@almadar/workspace 0.3.0 → 0.4.1
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.
- package/dist/__tests__/list-workspaces.test.d.ts +1 -0
- package/dist/delete-workspace.d.ts +14 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/backends/local.d.ts +3 -0
- package/dist/internal/backends/memory.d.ts +3 -0
- package/dist/internal/types.d.ts +8 -0
- package/dist/list-workspaces.d.ts +14 -0
- package/dist/types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `deleteWorkspace` — remove a user's app-workspace dir by appId.
|
|
3
|
+
*
|
|
4
|
+
* Locates the workspace via its `app-marker.json` (reuse `findLocalWorkspaceDir`)
|
|
5
|
+
* and removes the tree. Idempotent: returns `false` if no matching workspace.
|
|
6
|
+
* Keeps workspace lifecycle inside the package (consumers don't fs-scan/rm the
|
|
7
|
+
* layout themselves).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { ListWorkspacesOptions } from './types.js';
|
|
12
|
+
export declare function deleteWorkspace(opts: ListWorkspacesOptions & {
|
|
13
|
+
appId: string;
|
|
14
|
+
}): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* `src/internal/`.
|
|
8
8
|
*/
|
|
9
9
|
export { openWorkspace } from './open-workspace.js';
|
|
10
|
+
export { listWorkspaces } from './list-workspaces.js';
|
|
11
|
+
export { deleteWorkspace } from './delete-workspace.js';
|
|
10
12
|
export { openAccount } from './account.js';
|
|
11
|
-
export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
|
|
13
|
+
export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, ListWorkspacesOptions, WorkspaceSummary, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
|
|
12
14
|
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
15
|
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,9 @@ var LocalBackend = class {
|
|
|
50
50
|
async chmod(absPath, mode) {
|
|
51
51
|
await fs.promises.chmod(absPath, mode);
|
|
52
52
|
}
|
|
53
|
+
async rm(absPath, opts) {
|
|
54
|
+
await fs.promises.rm(absPath, { recursive: opts?.recursive ?? false, force: true });
|
|
55
|
+
}
|
|
53
56
|
watch(absPath, onChange) {
|
|
54
57
|
let watcher;
|
|
55
58
|
let timer;
|
|
@@ -172,6 +175,15 @@ var MemoryBackend = class {
|
|
|
172
175
|
return () => {
|
|
173
176
|
};
|
|
174
177
|
}
|
|
178
|
+
async rm(absPath, opts) {
|
|
179
|
+
this.files.delete(absPath);
|
|
180
|
+
this.dirs.delete(absPath);
|
|
181
|
+
if (opts?.recursive) {
|
|
182
|
+
const prefix = absPath.endsWith("/") ? absPath : absPath + "/";
|
|
183
|
+
for (const k of [...this.files.keys()]) if (k.startsWith(prefix)) this.files.delete(k);
|
|
184
|
+
for (const d of [...this.dirs]) if (d.startsWith(prefix)) this.dirs.delete(d);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
175
187
|
// Test helpers
|
|
176
188
|
getAll() {
|
|
177
189
|
return new Map(this.files);
|
|
@@ -760,8 +772,8 @@ function tokenizeSpec(spec) {
|
|
|
760
772
|
for (const p of pages) {
|
|
761
773
|
const obj = asJsonObject2(p);
|
|
762
774
|
if (!obj) continue;
|
|
763
|
-
const
|
|
764
|
-
if (typeof
|
|
775
|
+
const path11 = obj["path"];
|
|
776
|
+
if (typeof path11 === "string") pushTokens(tokens, path11);
|
|
765
777
|
}
|
|
766
778
|
}
|
|
767
779
|
const ruleOverlay = asJsonObject2(params["ruleOverlay"]);
|
|
@@ -2262,6 +2274,53 @@ async function resolveLifecycle(backend, opts) {
|
|
|
2262
2274
|
const workDir = mintSessionDir(opts.root, opts.userId);
|
|
2263
2275
|
return { workDir, appId: opts.appId };
|
|
2264
2276
|
}
|
|
2277
|
+
async function listWorkspaces(opts) {
|
|
2278
|
+
const backend = opts.backend === "memory" ? new MemoryBackend() : new LocalBackend();
|
|
2279
|
+
const userDir = path2.join(opts.root, opts.userId);
|
|
2280
|
+
if (!backend.exists(userDir)) return [];
|
|
2281
|
+
let entries;
|
|
2282
|
+
try {
|
|
2283
|
+
entries = await backend.readdir(userDir);
|
|
2284
|
+
} catch {
|
|
2285
|
+
return [];
|
|
2286
|
+
}
|
|
2287
|
+
const out = [];
|
|
2288
|
+
for (const entry of entries) {
|
|
2289
|
+
const workDir = path2.join(userDir, entry);
|
|
2290
|
+
try {
|
|
2291
|
+
if (!(await backend.stat(workDir)).isDirectory) continue;
|
|
2292
|
+
} catch {
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
const marker = readAppMarker(backend, workDir);
|
|
2296
|
+
if (!marker) continue;
|
|
2297
|
+
const summary = { appId: marker.appId, workDir, updatedAt: marker.createdAt };
|
|
2298
|
+
const sf = schemaFile(workDir);
|
|
2299
|
+
if (backend.exists(sf)) {
|
|
2300
|
+
try {
|
|
2301
|
+
const parsed = JSON.parse(backend.readFileSync(sf));
|
|
2302
|
+
if (typeof parsed.name === "string") summary.name = parsed.name;
|
|
2303
|
+
} catch {
|
|
2304
|
+
}
|
|
2305
|
+
try {
|
|
2306
|
+
summary.updatedAt = (await backend.stat(sf)).mtimeMs;
|
|
2307
|
+
} catch {
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
out.push(summary);
|
|
2311
|
+
}
|
|
2312
|
+
out.sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
|
|
2313
|
+
return out;
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
// src/delete-workspace.ts
|
|
2317
|
+
async function deleteWorkspace(opts) {
|
|
2318
|
+
const backend = opts.backend === "memory" ? new MemoryBackend() : new LocalBackend();
|
|
2319
|
+
const workDir = await findLocalWorkspaceDir(backend, opts.root, opts.userId, opts.appId);
|
|
2320
|
+
if (!workDir) return false;
|
|
2321
|
+
await backend.rm(workDir, { recursive: true });
|
|
2322
|
+
return true;
|
|
2323
|
+
}
|
|
2265
2324
|
var ACCOUNT_DIR = ".almadar";
|
|
2266
2325
|
var CONFIG_FILE = "config.json";
|
|
2267
2326
|
var CREDENTIALS_FILE = "credentials.json";
|
|
@@ -2345,6 +2404,6 @@ async function openAccount(opts = {}) {
|
|
|
2345
2404
|
};
|
|
2346
2405
|
}
|
|
2347
2406
|
|
|
2348
|
-
export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, openAccount, openWorkspace };
|
|
2407
|
+
export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, deleteWorkspace, listWorkspaces, openAccount, openWorkspace };
|
|
2349
2408
|
//# sourceMappingURL=index.js.map
|
|
2350
2409
|
//# sourceMappingURL=index.js.map
|