@almadar/workspace 0.4.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.
|
@@ -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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { openWorkspace } from './open-workspace.js';
|
|
10
10
|
export { listWorkspaces } from './list-workspaces.js';
|
|
11
|
+
export { deleteWorkspace } from './delete-workspace.js';
|
|
11
12
|
export { openAccount } from './account.js';
|
|
12
13
|
export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, ListWorkspacesOptions, WorkspaceSummary, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
|
|
13
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';
|
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);
|
|
@@ -2300,6 +2312,15 @@ async function listWorkspaces(opts) {
|
|
|
2300
2312
|
out.sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
|
|
2301
2313
|
return out;
|
|
2302
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
|
+
}
|
|
2303
2324
|
var ACCOUNT_DIR = ".almadar";
|
|
2304
2325
|
var CONFIG_FILE = "config.json";
|
|
2305
2326
|
var CREDENTIALS_FILE = "credentials.json";
|
|
@@ -2383,6 +2404,6 @@ async function openAccount(opts = {}) {
|
|
|
2383
2404
|
};
|
|
2384
2405
|
}
|
|
2385
2406
|
|
|
2386
|
-
export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, listWorkspaces, openAccount, openWorkspace };
|
|
2407
|
+
export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, deleteWorkspace, listWorkspaces, openAccount, openWorkspace };
|
|
2387
2408
|
//# sourceMappingURL=index.js.map
|
|
2388
2409
|
//# sourceMappingURL=index.js.map
|