@mod-computer/cli 0.2.4 → 0.2.5

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.
Files changed (74) hide show
  1. package/package.json +3 -3
  2. package/dist/app.js +0 -227
  3. package/dist/cli.bundle.js.map +0 -7
  4. package/dist/cli.js +0 -132
  5. package/dist/commands/add.js +0 -245
  6. package/dist/commands/agents-run.js +0 -71
  7. package/dist/commands/auth.js +0 -259
  8. package/dist/commands/branch.js +0 -1411
  9. package/dist/commands/claude-sync.js +0 -772
  10. package/dist/commands/comment.js +0 -568
  11. package/dist/commands/diff.js +0 -182
  12. package/dist/commands/index.js +0 -73
  13. package/dist/commands/init.js +0 -597
  14. package/dist/commands/ls.js +0 -135
  15. package/dist/commands/members.js +0 -687
  16. package/dist/commands/mv.js +0 -282
  17. package/dist/commands/recover.js +0 -207
  18. package/dist/commands/rm.js +0 -257
  19. package/dist/commands/spec.js +0 -386
  20. package/dist/commands/status.js +0 -296
  21. package/dist/commands/sync.js +0 -119
  22. package/dist/commands/trace.js +0 -1752
  23. package/dist/commands/workspace.js +0 -447
  24. package/dist/components/conflict-resolution-ui.js +0 -120
  25. package/dist/components/messages.js +0 -5
  26. package/dist/components/thread.js +0 -8
  27. package/dist/config/features.js +0 -83
  28. package/dist/containers/branches-container.js +0 -140
  29. package/dist/containers/directory-container.js +0 -92
  30. package/dist/containers/thread-container.js +0 -214
  31. package/dist/containers/threads-container.js +0 -27
  32. package/dist/containers/workspaces-container.js +0 -27
  33. package/dist/daemon/conflict-resolution.js +0 -172
  34. package/dist/daemon/content-hash.js +0 -31
  35. package/dist/daemon/file-sync.js +0 -985
  36. package/dist/daemon/index.js +0 -203
  37. package/dist/daemon/mime-types.js +0 -166
  38. package/dist/daemon/offline-queue.js +0 -211
  39. package/dist/daemon/path-utils.js +0 -64
  40. package/dist/daemon/share-policy.js +0 -83
  41. package/dist/daemon/wasm-errors.js +0 -189
  42. package/dist/daemon/worker.js +0 -557
  43. package/dist/daemon-worker.js +0 -258
  44. package/dist/errors/workspace-errors.js +0 -48
  45. package/dist/lib/auth-server.js +0 -216
  46. package/dist/lib/browser.js +0 -35
  47. package/dist/lib/diff.js +0 -284
  48. package/dist/lib/formatters.js +0 -204
  49. package/dist/lib/git.js +0 -137
  50. package/dist/lib/local-fs.js +0 -201
  51. package/dist/lib/prompts.js +0 -56
  52. package/dist/lib/storage.js +0 -213
  53. package/dist/lib/trace-formatters.js +0 -314
  54. package/dist/services/add-service.js +0 -554
  55. package/dist/services/add-validation.js +0 -124
  56. package/dist/services/automatic-file-tracker.js +0 -303
  57. package/dist/services/cli-orchestrator.js +0 -227
  58. package/dist/services/feature-flags.js +0 -187
  59. package/dist/services/file-import-service.js +0 -283
  60. package/dist/services/file-transformation-service.js +0 -218
  61. package/dist/services/logger.js +0 -44
  62. package/dist/services/mod-config.js +0 -67
  63. package/dist/services/modignore-service.js +0 -328
  64. package/dist/services/sync-daemon.js +0 -244
  65. package/dist/services/thread-notification-service.js +0 -50
  66. package/dist/services/thread-service.js +0 -147
  67. package/dist/stores/use-directory-store.js +0 -96
  68. package/dist/stores/use-threads-store.js +0 -46
  69. package/dist/stores/use-workspaces-store.js +0 -54
  70. package/dist/types/add-types.js +0 -99
  71. package/dist/types/config.js +0 -16
  72. package/dist/types/index.js +0 -2
  73. package/dist/types/workspace-connection.js +0 -53
  74. package/dist/types.js +0 -1
@@ -1,83 +0,0 @@
1
- // glassware[type="implementation", id="impl-cli-share-policy--044307eb", specifications="specification-spec-no-permissive-bootstrap--2fc35117,specification-spec-strict-allowlist--44f56951,specification-spec-user-doc-init--f355cebf,specification-spec-workspace-allowlist--e668c367,specification-spec-file-allowlist--1bf67504,specification-spec-folder-allowlist--1cc8923c,specification-spec-cleanup-allowlist--9f816ed3,specification-spec-export-share-policy--4371539e,specification-spec-export-workspace-connect--431e5527"]
2
- /**
3
- * CLI SharePolicy - strict allowlist approach (aligned with mod-app-new browser).
4
- * NO permissive bootstrap - all documents must be explicitly added to allowlist.
5
- * Prevents CLI from accumulating docs from all workspaces.
6
- */
7
- // Set of document IDs we're allowed to sync
8
- const allowedDocs = new Set();
9
- // Track logged denials (one log per doc)
10
- const deniedLogged = new Set();
11
- /**
12
- * SharePolicy for CLI: strict allowlist, NO permissive bootstrap.
13
- * Only sync docs explicitly added to allowedDocs set.
14
- */
15
- export const cliSharePolicy = async (_peerId, documentId) => {
16
- if (!documentId)
17
- return false;
18
- // STRICT: Only allow documents explicitly in allowlist
19
- // NO permissive bootstrap (aligned with mod-app-new browser approach)
20
- const allowed = allowedDocs.has(documentId);
21
- if (!allowed && !deniedLogged.has(documentId)) {
22
- deniedLogged.add(documentId);
23
- // Debug log removed - not user-facing
24
- }
25
- return allowed;
26
- };
27
- /**
28
- * Add user document to allowlist on authentication.
29
- * Call during auth flow, BEFORE repo operations.
30
- */
31
- export function addUserToSharePolicy(userDocId) {
32
- allowedDocs.add(userDocId);
33
- }
34
- /**
35
- * Add workspace to allowlist when connecting.
36
- * Call BEFORE repo.find(workspaceId).
37
- */
38
- export function addWorkspaceToSharePolicy(workspaceId) {
39
- allowedDocs.add(workspaceId);
40
- }
41
- /**
42
- * Add a single file document to the sharePolicy.
43
- * Call when a file is tracked for sync.
44
- */
45
- export function addFileToSharePolicy(fileId) {
46
- allowedDocs.add(fileId);
47
- }
48
- /**
49
- * Add multiple file/folder documents to the sharePolicy.
50
- * Call BEFORE loading file documents.
51
- */
52
- export function addFilesToSharePolicy(fileIds) {
53
- fileIds.forEach(id => allowedDocs.add(id));
54
- }
55
- /**
56
- * Remove a single file document from the sharePolicy.
57
- * Call when a file is deleted.
58
- */
59
- export function removeFileFromSharePolicy(fileId) {
60
- allowedDocs.delete(fileId);
61
- }
62
- /**
63
- * Remove workspace and all associated documents from allowlist.
64
- * Call when disconnecting from a workspace.
65
- */
66
- export function removeWorkspaceFromSharePolicy(workspaceId, fileIds, folderIds) {
67
- allowedDocs.delete(workspaceId);
68
- fileIds.forEach(id => allowedDocs.delete(id));
69
- folderIds.forEach(id => allowedDocs.delete(id));
70
- }
71
- /**
72
- * Get count of allowed docs (for debugging/testing).
73
- */
74
- export function getSharePolicyDocCount() {
75
- return allowedDocs.size;
76
- }
77
- /**
78
- * Reset sharePolicy state (for testing).
79
- */
80
- export function resetSharePolicyState() {
81
- allowedDocs.clear();
82
- deniedLogged.clear();
83
- }
@@ -1,189 +0,0 @@
1
- // glassware[type="implementation", id="impl-wasm-errors--8c42ad5f", requirements="requirement-cli-sync-wasm-detect--5517bb61,requirement-cli-sync-wasm-recover--ca8c0cb6"]
2
- /**
3
- * WASM error handling utilities for Automerge operations.
4
- * Detects WASM panics and provides graceful error recovery.
5
- */
6
- /**
7
- * Patterns that indicate a WASM panic error.
8
- */
9
- const WASM_ERROR_PATTERNS = [
10
- 'panic',
11
- 'recursive use of an object',
12
- 'unsafe aliasing',
13
- 'RuntimeError',
14
- 'unreachable',
15
- 'memory access out of bounds',
16
- 'table index is out of bounds',
17
- 'indirect call signature mismatch',
18
- ];
19
- /**
20
- * Check if an error is a WASM panic error.
21
- * @param err - The error to check
22
- * @returns true if the error is a WASM panic
23
- */
24
- export function isWasmError(err) {
25
- if (!err)
26
- return false;
27
- const message = String(err?.message || err || '');
28
- const name = String(err?.name || '');
29
- const stack = String(err?.stack || '');
30
- const combined = `${name} ${message} ${stack}`.toLowerCase();
31
- return WASM_ERROR_PATTERNS.some(pattern => combined.includes(pattern.toLowerCase()));
32
- }
33
- /**
34
- * Log a WASM error with document context.
35
- * @param documentId - The document ID that caused the error
36
- * @param err - The error that occurred
37
- */
38
- export function logWasmError(documentId, err) {
39
- const timestamp = new Date().toISOString();
40
- const message = err?.message || String(err);
41
- const stack = err?.stack || '';
42
- console.error(`[WASM] ${timestamp} Error in document ${documentId}:`, message);
43
- if (stack) {
44
- console.error(`[WASM] Stack:`, stack);
45
- }
46
- }
47
- /**
48
- * WasmErrorRecovery - manages retry logic for WASM errors.
49
- */
50
- export class WasmErrorRecovery {
51
- constructor(options = {}) {
52
- this.retryQueue = new Map();
53
- this.processInterval = null;
54
- this.maxRetries = options.maxRetries ?? 3;
55
- this.baseDelayMs = options.baseDelayMs ?? 100;
56
- this.log = options.logger ?? console.log;
57
- }
58
- /**
59
- * Execute an operation with WASM error recovery.
60
- * @param documentId - Document ID for the operation
61
- * @param operation - The operation to execute
62
- * @returns Result of the operation, or null if all retries failed
63
- */
64
- async executeWithRecovery(documentId, operation) {
65
- try {
66
- return await operation();
67
- }
68
- catch (err) {
69
- if (isWasmError(err)) {
70
- logWasmError(documentId, err);
71
- this.queueRetry(documentId, operation, err);
72
- return null;
73
- }
74
- throw err; // Re-throw non-WASM errors
75
- }
76
- }
77
- /**
78
- * Queue an operation for retry.
79
- */
80
- queueRetry(documentId, operation, error) {
81
- const existing = this.retryQueue.get(documentId);
82
- if (existing && existing.attempts >= this.maxRetries) {
83
- this.log(`[wasm-recovery] Giving up on ${documentId} after ${this.maxRetries} attempts`);
84
- this.retryQueue.delete(documentId);
85
- return;
86
- }
87
- this.retryQueue.set(documentId, {
88
- documentId,
89
- operation,
90
- attempts: (existing?.attempts ?? 0) + 1,
91
- lastError: error,
92
- createdAt: existing?.createdAt ?? new Date().toISOString(),
93
- });
94
- this.log(`[wasm-recovery] Queued retry for ${documentId} (attempt ${(existing?.attempts ?? 0) + 1})`);
95
- }
96
- /**
97
- * Process the retry queue, attempting to execute queued operations.
98
- */
99
- async processRetryQueue() {
100
- let succeeded = 0;
101
- let failed = 0;
102
- const entries = Array.from(this.retryQueue.values());
103
- for (const entry of entries) {
104
- if (entry.attempts >= this.maxRetries) {
105
- this.log(`[wasm-recovery] Max retries reached for ${entry.documentId}`);
106
- this.retryQueue.delete(entry.documentId);
107
- failed++;
108
- continue;
109
- }
110
- // Exponential backoff delay
111
- const delay = this.baseDelayMs * Math.pow(2, entry.attempts - 1);
112
- await sleep(delay);
113
- try {
114
- await entry.operation();
115
- this.retryQueue.delete(entry.documentId);
116
- succeeded++;
117
- this.log(`[wasm-recovery] Retry succeeded for ${entry.documentId}`);
118
- }
119
- catch (err) {
120
- if (isWasmError(err)) {
121
- entry.attempts++;
122
- entry.lastError = err;
123
- logWasmError(entry.documentId, err);
124
- }
125
- else {
126
- // Non-WASM error, remove from queue
127
- this.retryQueue.delete(entry.documentId);
128
- failed++;
129
- this.log(`[wasm-recovery] Non-WASM error for ${entry.documentId}, removing from queue`);
130
- }
131
- }
132
- }
133
- return {
134
- succeeded,
135
- failed,
136
- remaining: this.retryQueue.size,
137
- };
138
- }
139
- /**
140
- * Start periodic processing of the retry queue.
141
- * @param intervalMs - How often to process the queue (default: 1000ms)
142
- */
143
- startPeriodicProcessing(intervalMs = 1000) {
144
- if (this.processInterval) {
145
- return; // Already running
146
- }
147
- this.processInterval = setInterval(async () => {
148
- if (this.retryQueue.size > 0) {
149
- await this.processRetryQueue();
150
- }
151
- }, intervalMs);
152
- this.log(`[wasm-recovery] Started periodic processing every ${intervalMs}ms`);
153
- }
154
- /**
155
- * Stop periodic processing.
156
- */
157
- stopPeriodicProcessing() {
158
- if (this.processInterval) {
159
- clearInterval(this.processInterval);
160
- this.processInterval = null;
161
- this.log('[wasm-recovery] Stopped periodic processing');
162
- }
163
- }
164
- /**
165
- * Get the number of pending retries.
166
- */
167
- getPendingCount() {
168
- return this.retryQueue.size;
169
- }
170
- /**
171
- * Get all pending retry entries (for debugging).
172
- */
173
- getPendingEntries() {
174
- return Array.from(this.retryQueue.values());
175
- }
176
- /**
177
- * Clear all pending retries.
178
- */
179
- clearPending() {
180
- this.retryQueue.clear();
181
- this.log('[wasm-recovery] Cleared all pending retries');
182
- }
183
- }
184
- /**
185
- * Sleep helper for backoff delays.
186
- */
187
- function sleep(ms) {
188
- return new Promise(resolve => setTimeout(resolve, ms));
189
- }