@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.
- package/package.json +3 -3
- package/dist/app.js +0 -227
- package/dist/cli.bundle.js.map +0 -7
- package/dist/cli.js +0 -132
- package/dist/commands/add.js +0 -245
- package/dist/commands/agents-run.js +0 -71
- package/dist/commands/auth.js +0 -259
- package/dist/commands/branch.js +0 -1411
- package/dist/commands/claude-sync.js +0 -772
- package/dist/commands/comment.js +0 -568
- package/dist/commands/diff.js +0 -182
- package/dist/commands/index.js +0 -73
- package/dist/commands/init.js +0 -597
- package/dist/commands/ls.js +0 -135
- package/dist/commands/members.js +0 -687
- package/dist/commands/mv.js +0 -282
- package/dist/commands/recover.js +0 -207
- package/dist/commands/rm.js +0 -257
- package/dist/commands/spec.js +0 -386
- package/dist/commands/status.js +0 -296
- package/dist/commands/sync.js +0 -119
- package/dist/commands/trace.js +0 -1752
- package/dist/commands/workspace.js +0 -447
- package/dist/components/conflict-resolution-ui.js +0 -120
- package/dist/components/messages.js +0 -5
- package/dist/components/thread.js +0 -8
- package/dist/config/features.js +0 -83
- package/dist/containers/branches-container.js +0 -140
- package/dist/containers/directory-container.js +0 -92
- package/dist/containers/thread-container.js +0 -214
- package/dist/containers/threads-container.js +0 -27
- package/dist/containers/workspaces-container.js +0 -27
- package/dist/daemon/conflict-resolution.js +0 -172
- package/dist/daemon/content-hash.js +0 -31
- package/dist/daemon/file-sync.js +0 -985
- package/dist/daemon/index.js +0 -203
- package/dist/daemon/mime-types.js +0 -166
- package/dist/daemon/offline-queue.js +0 -211
- package/dist/daemon/path-utils.js +0 -64
- package/dist/daemon/share-policy.js +0 -83
- package/dist/daemon/wasm-errors.js +0 -189
- package/dist/daemon/worker.js +0 -557
- package/dist/daemon-worker.js +0 -258
- package/dist/errors/workspace-errors.js +0 -48
- package/dist/lib/auth-server.js +0 -216
- package/dist/lib/browser.js +0 -35
- package/dist/lib/diff.js +0 -284
- package/dist/lib/formatters.js +0 -204
- package/dist/lib/git.js +0 -137
- package/dist/lib/local-fs.js +0 -201
- package/dist/lib/prompts.js +0 -56
- package/dist/lib/storage.js +0 -213
- package/dist/lib/trace-formatters.js +0 -314
- package/dist/services/add-service.js +0 -554
- package/dist/services/add-validation.js +0 -124
- package/dist/services/automatic-file-tracker.js +0 -303
- package/dist/services/cli-orchestrator.js +0 -227
- package/dist/services/feature-flags.js +0 -187
- package/dist/services/file-import-service.js +0 -283
- package/dist/services/file-transformation-service.js +0 -218
- package/dist/services/logger.js +0 -44
- package/dist/services/mod-config.js +0 -67
- package/dist/services/modignore-service.js +0 -328
- package/dist/services/sync-daemon.js +0 -244
- package/dist/services/thread-notification-service.js +0 -50
- package/dist/services/thread-service.js +0 -147
- package/dist/stores/use-directory-store.js +0 -96
- package/dist/stores/use-threads-store.js +0 -46
- package/dist/stores/use-workspaces-store.js +0 -54
- package/dist/types/add-types.js +0 -99
- package/dist/types/config.js +0 -16
- package/dist/types/index.js +0 -2
- package/dist/types/workspace-connection.js +0 -53
- package/dist/types.js +0 -1
package/dist/commands/ls.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// glassware[type="implementation", id="impl-cli-ls-cmd--05e6cad6", requirements="requirement-cli-ls-cmd--1dc1eaa1,requirement-cli-ls-requires-workspace--e869d236,requirement-cli-ls-filter-path--52fa1bda,requirement-cli-ls-filter-type--5c9fe146,requirement-cli-ls-filter-pattern--4cec491f"]
|
|
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 { formatFileTable, formatFileTree, formatFileJson, formatFilePaths, formatFileLong, getMimeCategory, } from '../lib/formatters.js';
|
|
6
|
-
import { matchGlob } from '../lib/local-fs.js';
|
|
7
|
-
// glassware[type="implementation", id="impl-cli-ls-requires-workspace--0d390a0f", requirements="requirement-cli-ls-requires-workspace--e869d236,requirement-cli-fd-error-no-workspace--1919b4fb"]
|
|
8
|
-
function requireWorkspaceConnection() {
|
|
9
|
-
const currentDir = process.cwd();
|
|
10
|
-
const connection = readWorkspaceConnection(currentDir);
|
|
11
|
-
if (!connection) {
|
|
12
|
-
console.error('Error: Not connected to a workspace.');
|
|
13
|
-
console.error('Run `mod init` to connect this directory first.');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
workspaceId: connection.workspaceId,
|
|
18
|
-
workspaceName: connection.workspaceName,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function parseArgs(args) {
|
|
22
|
-
const options = {
|
|
23
|
-
tree: false,
|
|
24
|
-
json: false,
|
|
25
|
-
long: false,
|
|
26
|
-
quiet: false,
|
|
27
|
-
};
|
|
28
|
-
let path;
|
|
29
|
-
for (let i = 0; i < args.length; i++) {
|
|
30
|
-
const arg = args[i];
|
|
31
|
-
if (arg === '--tree' || arg === '-t') {
|
|
32
|
-
options.tree = true;
|
|
33
|
-
}
|
|
34
|
-
else if (arg === '--json') {
|
|
35
|
-
options.json = true;
|
|
36
|
-
}
|
|
37
|
-
else if (arg === '--long' || arg === '-l') {
|
|
38
|
-
options.long = true;
|
|
39
|
-
}
|
|
40
|
-
else if (arg === '--quiet' || arg === '-q') {
|
|
41
|
-
options.quiet = true;
|
|
42
|
-
}
|
|
43
|
-
else if (arg === '--type' && args[i + 1]) {
|
|
44
|
-
const typeArg = args[i + 1];
|
|
45
|
-
if (typeArg === 'code' || typeArg === 'text' || typeArg === 'data') {
|
|
46
|
-
options.type = typeArg;
|
|
47
|
-
}
|
|
48
|
-
i++;
|
|
49
|
-
}
|
|
50
|
-
else if (arg.startsWith('--type=')) {
|
|
51
|
-
const typeArg = arg.slice('--type='.length);
|
|
52
|
-
if (typeArg === 'code' || typeArg === 'text' || typeArg === 'data') {
|
|
53
|
-
options.type = typeArg;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (arg === '--pattern' && args[i + 1]) {
|
|
57
|
-
options.pattern = args[i + 1];
|
|
58
|
-
i++;
|
|
59
|
-
}
|
|
60
|
-
else if (arg.startsWith('--pattern=')) {
|
|
61
|
-
options.pattern = arg.slice('--pattern='.length);
|
|
62
|
-
}
|
|
63
|
-
else if (!arg.startsWith('-') && !path) {
|
|
64
|
-
path = arg;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { path, options };
|
|
68
|
-
}
|
|
69
|
-
// glassware[type="implementation", id="impl-cli-ls-filter-path--39b6a8c6", requirements="requirement-cli-ls-filter-path--52fa1bda"]
|
|
70
|
-
function filterByPath(files, pathFilter) {
|
|
71
|
-
const normalizedFilter = pathFilter.replace(/\/$/, ''); // Remove trailing slash
|
|
72
|
-
return files.filter(f => f.path.startsWith(normalizedFilter + '/') || f.path === normalizedFilter);
|
|
73
|
-
}
|
|
74
|
-
// glassware[type="implementation", id="impl-cli-ls-filter-type--45ec4f4a", requirements="requirement-cli-ls-filter-type--5c9fe146"]
|
|
75
|
-
function filterByType(files, type) {
|
|
76
|
-
return files.filter(f => getMimeCategory(f.mimeType) === type);
|
|
77
|
-
}
|
|
78
|
-
// glassware[type="implementation", id="impl-cli-ls-filter-pattern--d891ebe5", requirements="requirement-cli-ls-filter-pattern--4cec491f"]
|
|
79
|
-
function filterByPattern(files, pattern) {
|
|
80
|
-
return files.filter(f => matchGlob(f.path, pattern));
|
|
81
|
-
}
|
|
82
|
-
export async function lsCommand(args, repo) {
|
|
83
|
-
const { workspaceId } = requireWorkspaceConnection();
|
|
84
|
-
const { path: pathFilter, options } = parseArgs(args);
|
|
85
|
-
try {
|
|
86
|
-
const modWorkspace = createModWorkspace(repo);
|
|
87
|
-
const workspaceHandle = await modWorkspace.openWorkspace(workspaceId);
|
|
88
|
-
// Fetch all files
|
|
89
|
-
const fileRefs = await workspaceHandle.file.list();
|
|
90
|
-
// Convert to FileInfo
|
|
91
|
-
let files = fileRefs.map(ref => ({
|
|
92
|
-
id: ref.id,
|
|
93
|
-
path: ref.metadata?.path || ref.name,
|
|
94
|
-
name: ref.name,
|
|
95
|
-
size: ref.size,
|
|
96
|
-
mimeType: ref.mimeType,
|
|
97
|
-
updatedAt: ref.updatedAt,
|
|
98
|
-
folderId: ref.folderId,
|
|
99
|
-
}));
|
|
100
|
-
// Apply filters
|
|
101
|
-
if (pathFilter) {
|
|
102
|
-
files = filterByPath(files, pathFilter);
|
|
103
|
-
}
|
|
104
|
-
if (options.type) {
|
|
105
|
-
files = filterByType(files, options.type);
|
|
106
|
-
}
|
|
107
|
-
if (options.pattern) {
|
|
108
|
-
files = filterByPattern(files, options.pattern);
|
|
109
|
-
}
|
|
110
|
-
// Sort by path
|
|
111
|
-
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
112
|
-
// Format output
|
|
113
|
-
let output;
|
|
114
|
-
if (options.json) {
|
|
115
|
-
output = formatFileJson(files);
|
|
116
|
-
}
|
|
117
|
-
else if (options.tree) {
|
|
118
|
-
output = formatFileTree(files);
|
|
119
|
-
}
|
|
120
|
-
else if (options.quiet) {
|
|
121
|
-
output = formatFilePaths(files);
|
|
122
|
-
}
|
|
123
|
-
else if (options.long) {
|
|
124
|
-
output = formatFileLong(files);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
output = formatFileTable(files);
|
|
128
|
-
}
|
|
129
|
-
console.log(output);
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
console.error('Error listing files:', error.message);
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
}
|