@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,182 +0,0 @@
1
- // glassware[type="implementation", id="impl-cli-diff-cmd--2caa2bcb", requirements="requirement-cli-diff-cmd--cfd908be,requirement-cli-diff-requires-workspace--a4b7f1ce,requirement-cli-diff-unified--a9889945,requirement-cli-diff-color--23d3ed12,requirement-cli-diff-stat--364f0431,requirement-cli-diff-direction-default--e6c9d2de,requirement-cli-diff-direction-workspace--dc23c716"]
2
- // spec: packages/mod-cli/specs/file-directory.md
3
- import { createModWorkspace } from '@mod/mod-core';
4
- import { readWorkspaceConnection } from '../lib/storage.js';
5
- import { readLocalFile, localFileExists, isBinaryFile } from '../lib/local-fs.js';
6
- import { computeDiff, formatUnifiedDiff, formatDiffStat, calculateDiffStats, getWorkspaceContent, isBinaryContent, } from '../lib/diff.js';
7
- import path from 'path';
8
- // glassware[type="implementation", id="impl-cli-diff-requires-workspace--257badd4", requirements="requirement-cli-diff-requires-workspace--a4b7f1ce,requirement-cli-fd-error-no-workspace--1919b4fb"]
9
- function requireWorkspaceConnection() {
10
- const currentDir = process.cwd();
11
- const connection = readWorkspaceConnection(currentDir);
12
- if (!connection) {
13
- console.error('Error: Not connected to a workspace.');
14
- console.error('Run `mod init` to connect this directory first.');
15
- process.exit(1);
16
- }
17
- return {
18
- workspaceId: connection.workspaceId,
19
- workspaceName: connection.workspaceName,
20
- workspacePath: connection.path,
21
- };
22
- }
23
- function parseArgs(args) {
24
- const options = {
25
- workspace: false,
26
- stat: false,
27
- noColor: false,
28
- context: 3,
29
- };
30
- let filePath;
31
- for (let i = 0; i < args.length; i++) {
32
- const arg = args[i];
33
- if (arg === '--workspace' || arg === '-w') {
34
- options.workspace = true;
35
- }
36
- else if (arg === '--stat') {
37
- options.stat = true;
38
- }
39
- else if (arg === '--no-color') {
40
- options.noColor = true;
41
- }
42
- else if (arg === '--context' && args[i + 1]) {
43
- options.context = parseInt(args[i + 1], 10) || 3;
44
- i++;
45
- }
46
- else if (arg.startsWith('--context=')) {
47
- options.context = parseInt(arg.slice('--context='.length), 10) || 3;
48
- }
49
- else if (!arg.startsWith('-') && !filePath) {
50
- filePath = arg;
51
- }
52
- }
53
- // Check if terminal supports color
54
- if (!process.stdout.isTTY) {
55
- options.noColor = true;
56
- }
57
- return { filePath, options };
58
- }
59
- // glassware[type="implementation", id="impl-cli-fd-perf-diff--61c6010d", requirements="requirement-cli-fd-perf-diff--43c2078c"]
60
- export async function diffCommand(args, repo) {
61
- const { workspaceId, workspacePath } = requireWorkspaceConnection();
62
- const { filePath, options } = parseArgs(args);
63
- try {
64
- const modWorkspace = createModWorkspace(repo);
65
- const workspaceHandle = await modWorkspace.openWorkspace(workspaceId);
66
- // Get workspace files
67
- const workspaceFiles = await workspaceHandle.file.list();
68
- // If specific file requested, diff only that file
69
- const filesToDiff = filePath
70
- ? workspaceFiles.filter(f => (f.metadata?.path || f.name) === filePath)
71
- : workspaceFiles;
72
- if (filePath && filesToDiff.length === 0) {
73
- console.error(`Error: File not found in workspace: ${filePath}`);
74
- console.error("Run `mod ls` to see workspace files.");
75
- process.exit(1);
76
- }
77
- const diffResults = [];
78
- for (const file of filesToDiff) {
79
- const wsPath = file.metadata?.path || file.name;
80
- const localPath = path.join(workspacePath, wsPath);
81
- // Check if local file exists
82
- const localExists = await localFileExists(localPath);
83
- const localContent = localExists ? await readLocalFile(localPath) : null;
84
- // Get workspace content
85
- let wsContent = '';
86
- try {
87
- const handle = await workspaceHandle.file.get(file.id);
88
- if (handle) {
89
- const doc = handle.doc();
90
- wsContent = getWorkspaceContent(doc?.content);
91
- }
92
- }
93
- catch {
94
- continue; // Skip files we can't load
95
- }
96
- // Skip if no differences
97
- if (localContent === wsContent) {
98
- continue;
99
- }
100
- // Check for binary
101
- const localIsBinary = localContent !== null && (await isBinaryFile(localPath) || isBinaryContent(localContent));
102
- const wsIsBinary = isBinaryContent(wsContent);
103
- if (localIsBinary || wsIsBinary) {
104
- const localStats = localContent !== null ? localContent.length : 0;
105
- const wsStats = wsContent.length;
106
- diffResults.push({
107
- path: wsPath,
108
- additions: 0,
109
- deletions: 0,
110
- diffOutput: `Binary files differ (workspace: ${formatBytes(wsStats)}, local: ${formatBytes(localStats)})`,
111
- isBinary: true,
112
- });
113
- continue;
114
- }
115
- // Compute diff based on direction
116
- let oldContent;
117
- let newContent;
118
- let oldLabel;
119
- let newLabel;
120
- if (options.workspace) {
121
- // Show workspace changes (what would come from workspace)
122
- oldContent = localContent || '';
123
- newContent = wsContent;
124
- oldLabel = `local:${wsPath}`;
125
- newLabel = `workspace:${wsPath}`;
126
- }
127
- else {
128
- // Show local changes (what would go to workspace)
129
- oldContent = wsContent;
130
- newContent = localContent || '';
131
- oldLabel = `workspace:${wsPath}`;
132
- newLabel = `local:${wsPath}`;
133
- }
134
- // Compute unified diff
135
- const hunks = computeDiff(oldContent, newContent, options.context);
136
- if (hunks.length === 0) {
137
- continue; // No differences
138
- }
139
- const stats = calculateDiffStats(hunks);
140
- // Format with color if supported
141
- const diffOutput = formatUnifiedDiff(oldLabel, newLabel, hunks, !options.noColor);
142
- diffResults.push({
143
- path: wsPath,
144
- additions: stats.additions,
145
- deletions: stats.deletions,
146
- diffOutput,
147
- isBinary: false,
148
- });
149
- }
150
- if (diffResults.length === 0) {
151
- console.log('No differences.');
152
- return;
153
- }
154
- // Show diffstat summary if requested
155
- if (options.stat) {
156
- const statOutput = formatDiffStat(diffResults.map(r => ({
157
- path: r.path,
158
- additions: r.additions,
159
- deletions: r.deletions,
160
- })), !options.noColor);
161
- console.log(statOutput);
162
- return;
163
- }
164
- // Output diffs
165
- for (const result of diffResults) {
166
- console.log(result.diffOutput);
167
- console.log('');
168
- }
169
- }
170
- catch (error) {
171
- console.error('Error computing diff:', error.message);
172
- process.exit(1);
173
- }
174
- }
175
- function formatBytes(bytes) {
176
- if (bytes === 0)
177
- return '0 B';
178
- const k = 1024;
179
- const sizes = ['B', 'KB', 'MB', 'GB'];
180
- const i = Math.floor(Math.log(bytes) / Math.log(k));
181
- return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
182
- }
@@ -1,73 +0,0 @@
1
- import { agentsRunCommand } from './agents-run.js';
2
- import { authCommand } from './auth.js';
3
- import { branchCommand } from './branch.js';
4
- import { workspaceCommand } from './workspace.js';
5
- import { claudeSyncCommand } from './claude-sync.js';
6
- import { syncCommand } from './sync.js';
7
- import { initCommand } from './init.js';
8
- import { recoverCommand } from './recover.js';
9
- import { lsCommand } from './ls.js';
10
- import { rmCommand } from './rm.js';
11
- import { mvCommand } from './mv.js';
12
- import { statusCommand } from './status.js';
13
- import { diffCommand } from './diff.js';
14
- import { addCommand } from './add.js';
15
- import { membersCommand } from './members.js';
16
- import { commentCommand } from './comment.js';
17
- import { traceCommand } from './trace.js';
18
- import { FEATURES, isFeatureEnabled } from '../config/features.js';
19
- // Alias for 'mod signin' -> 'mod auth login'
20
- const signinCommand = (args, repo) => {
21
- return authCommand(['login', ...args], repo);
22
- };
23
- const allCommands = {
24
- 'auth': authCommand,
25
- 'signin': signinCommand, // Alias for 'auth login'
26
- 'sync': syncCommand,
27
- 'agents-run': agentsRunCommand,
28
- 'claude-sync': claudeSyncCommand,
29
- 'branch': branchCommand,
30
- 'workspace': workspaceCommand,
31
- 'init': initCommand,
32
- 'recover': recoverCommand,
33
- 'ls': lsCommand,
34
- 'rm': rmCommand,
35
- 'mv': mvCommand,
36
- 'status': statusCommand,
37
- 'diff': diffCommand,
38
- 'add': addCommand,
39
- 'members': membersCommand,
40
- 'comment': commentCommand,
41
- 'trace': traceCommand,
42
- };
43
- const commandFeatureMapping = {
44
- 'auth': FEATURES.AUTH,
45
- 'signin': FEATURES.AUTH, // Alias for 'auth login'
46
- 'sync': FEATURES.WATCH_OPERATIONS,
47
- 'agents-run': FEATURES.AGENT_INTEGRATIONS,
48
- 'claude-sync': FEATURES.AGENT_INTEGRATIONS, // Claude projects sync, separate from file sync daemon
49
- 'branch': FEATURES.WORKSPACE_BRANCHING,
50
- 'workspace': FEATURES.WORKSPACE_MANAGEMENT,
51
- 'init': FEATURES.SYNC_OPERATIONS, // Use existing feature flag for command installation
52
- 'recover': FEATURES.STATUS, // Recovery command always available when status is enabled
53
- 'ls': FEATURES.FILE_OPERATIONS,
54
- 'rm': FEATURES.FILE_OPERATIONS,
55
- 'mv': FEATURES.FILE_OPERATIONS,
56
- 'status': FEATURES.FILE_OPERATIONS,
57
- 'diff': FEATURES.FILE_OPERATIONS,
58
- 'add': FEATURES.FILE_OPERATIONS, // Add files to workspace
59
- 'members': FEATURES.MEMBER_MANAGEMENT, // Workspace member management
60
- 'comment': FEATURES.FILE_OPERATIONS, // Comment metadata operations
61
- 'trace': FEATURES.TRACING, // Trace management and reporting
62
- };
63
- const registry = {};
64
- for (const [commandName, commandHandler] of Object.entries(allCommands)) {
65
- const requiredFeature = commandFeatureMapping[commandName];
66
- if (requiredFeature && isFeatureEnabled(requiredFeature)) {
67
- registry[commandName] = commandHandler;
68
- }
69
- }
70
- export function buildCommandRegistry() {
71
- return registry;
72
- }
73
- export default registry;