@mod-computer/cli 0.2.3 → 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 (75) hide show
  1. package/dist/cli.bundle.js +216 -36371
  2. package/package.json +3 -3
  3. package/dist/app.js +0 -227
  4. package/dist/cli.bundle.js.map +0 -7
  5. package/dist/cli.js +0 -132
  6. package/dist/commands/add.js +0 -245
  7. package/dist/commands/agents-run.js +0 -71
  8. package/dist/commands/auth.js +0 -259
  9. package/dist/commands/branch.js +0 -1411
  10. package/dist/commands/claude-sync.js +0 -772
  11. package/dist/commands/comment.js +0 -568
  12. package/dist/commands/diff.js +0 -182
  13. package/dist/commands/index.js +0 -73
  14. package/dist/commands/init.js +0 -597
  15. package/dist/commands/ls.js +0 -135
  16. package/dist/commands/members.js +0 -687
  17. package/dist/commands/mv.js +0 -282
  18. package/dist/commands/recover.js +0 -207
  19. package/dist/commands/rm.js +0 -257
  20. package/dist/commands/spec.js +0 -386
  21. package/dist/commands/status.js +0 -296
  22. package/dist/commands/sync.js +0 -119
  23. package/dist/commands/trace.js +0 -1752
  24. package/dist/commands/workspace.js +0 -447
  25. package/dist/components/conflict-resolution-ui.js +0 -120
  26. package/dist/components/messages.js +0 -5
  27. package/dist/components/thread.js +0 -8
  28. package/dist/config/features.js +0 -83
  29. package/dist/containers/branches-container.js +0 -140
  30. package/dist/containers/directory-container.js +0 -92
  31. package/dist/containers/thread-container.js +0 -214
  32. package/dist/containers/threads-container.js +0 -27
  33. package/dist/containers/workspaces-container.js +0 -27
  34. package/dist/daemon/conflict-resolution.js +0 -172
  35. package/dist/daemon/content-hash.js +0 -31
  36. package/dist/daemon/file-sync.js +0 -985
  37. package/dist/daemon/index.js +0 -203
  38. package/dist/daemon/mime-types.js +0 -166
  39. package/dist/daemon/offline-queue.js +0 -211
  40. package/dist/daemon/path-utils.js +0 -64
  41. package/dist/daemon/share-policy.js +0 -83
  42. package/dist/daemon/wasm-errors.js +0 -189
  43. package/dist/daemon/worker.js +0 -557
  44. package/dist/daemon-worker.js +0 -258
  45. package/dist/errors/workspace-errors.js +0 -48
  46. package/dist/lib/auth-server.js +0 -216
  47. package/dist/lib/browser.js +0 -35
  48. package/dist/lib/diff.js +0 -284
  49. package/dist/lib/formatters.js +0 -204
  50. package/dist/lib/git.js +0 -137
  51. package/dist/lib/local-fs.js +0 -201
  52. package/dist/lib/prompts.js +0 -56
  53. package/dist/lib/storage.js +0 -213
  54. package/dist/lib/trace-formatters.js +0 -314
  55. package/dist/services/add-service.js +0 -554
  56. package/dist/services/add-validation.js +0 -124
  57. package/dist/services/automatic-file-tracker.js +0 -303
  58. package/dist/services/cli-orchestrator.js +0 -227
  59. package/dist/services/feature-flags.js +0 -187
  60. package/dist/services/file-import-service.js +0 -283
  61. package/dist/services/file-transformation-service.js +0 -218
  62. package/dist/services/logger.js +0 -44
  63. package/dist/services/mod-config.js +0 -67
  64. package/dist/services/modignore-service.js +0 -328
  65. package/dist/services/sync-daemon.js +0 -244
  66. package/dist/services/thread-notification-service.js +0 -50
  67. package/dist/services/thread-service.js +0 -147
  68. package/dist/stores/use-directory-store.js +0 -96
  69. package/dist/stores/use-threads-store.js +0 -46
  70. package/dist/stores/use-workspaces-store.js +0 -54
  71. package/dist/types/add-types.js +0 -99
  72. package/dist/types/config.js +0 -16
  73. package/dist/types/index.js +0 -2
  74. package/dist/types/workspace-connection.js +0 -53
  75. 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
- }