@desplega.ai/agent-fs 0.1.2
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/dist/__tests__/api-client.test.d.ts +2 -0
- package/dist/__tests__/api-client.test.d.ts.map +1 -0
- package/dist/__tests__/api-client.test.js +86 -0
- package/dist/__tests__/api-client.test.js.map +1 -0
- package/dist/__tests__/param-mapping.test.d.ts +2 -0
- package/dist/__tests__/param-mapping.test.d.ts.map +1 -0
- package/dist/__tests__/param-mapping.test.js +53 -0
- package/dist/__tests__/param-mapping.test.js.map +1 -0
- package/dist/api-client.d.ts +11 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +56 -0
- package/dist/api-client.js.map +1 -0
- package/dist/cli.js +280 -0
- package/dist/commands/auth.d.ts +4 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +81 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/comment.d.ts +4 -0
- package/dist/commands/comment.d.ts.map +1 -0
- package/dist/commands/comment.js +161 -0
- package/dist/commands/comment.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +3 -0
- package/dist/commands/config-cmd.d.ts.map +1 -0
- package/dist/commands/config-cmd.js +147 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/daemon.d.ts +3 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +33 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/docs.d.ts +3 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +13 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/drive.d.ts +4 -0
- package/dist/commands/drive.d.ts.map +1 -0
- package/dist/commands/drive.js +86 -0
- package/dist/commands/drive.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +20 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/onboard.d.ts +3 -0
- package/dist/commands/onboard.d.ts.map +1 -0
- package/dist/commands/onboard.js +229 -0
- package/dist/commands/onboard.js.map +1 -0
- package/dist/commands/ops.d.ts +4 -0
- package/dist/commands/ops.d.ts.map +1 -0
- package/dist/commands/ops.js +99 -0
- package/dist/commands/ops.js.map +1 -0
- package/dist/embedded.d.ts +5 -0
- package/dist/embedded.d.ts.map +1 -0
- package/dist/embedded.js +59 -0
- package/dist/embedded.js.map +1 -0
- package/dist/formatters.d.ts +11 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +257 -0
- package/dist/formatters.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
- package/src/index.ts +90 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pretty-print formatters for CLI output.
|
|
3
|
+
* Each op has a formatter that takes the result object and returns a human-friendly string.
|
|
4
|
+
* MCP always returns JSON — these formatters are CLI-only.
|
|
5
|
+
*/
|
|
6
|
+
// --- Helpers ---
|
|
7
|
+
function formatSize(bytes) {
|
|
8
|
+
if (bytes < 1024)
|
|
9
|
+
return `${bytes} B`;
|
|
10
|
+
if (bytes < 1024 * 1024)
|
|
11
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
12
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
13
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
14
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
15
|
+
}
|
|
16
|
+
function formatDate(d) {
|
|
17
|
+
if (!d)
|
|
18
|
+
return "-";
|
|
19
|
+
const date = typeof d === "string" ? new Date(d) : d;
|
|
20
|
+
if (isNaN(date.getTime()))
|
|
21
|
+
return String(d);
|
|
22
|
+
return date.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "Z");
|
|
23
|
+
}
|
|
24
|
+
function padRight(s, len) {
|
|
25
|
+
return s.length >= len ? s : s + " ".repeat(len - s.length);
|
|
26
|
+
}
|
|
27
|
+
function padLeft(s, len) {
|
|
28
|
+
return s.length >= len ? s : " ".repeat(len - s.length) + s;
|
|
29
|
+
}
|
|
30
|
+
// --- Per-op formatters ---
|
|
31
|
+
function formatLs(result) {
|
|
32
|
+
const entries = result.entries ?? [];
|
|
33
|
+
if (entries.length === 0)
|
|
34
|
+
return "(empty directory)";
|
|
35
|
+
// Compute column widths
|
|
36
|
+
const nameW = Math.max(4, ...entries.map((e) => String(e.name).length));
|
|
37
|
+
const typeW = Math.max(4, ...entries.map((e) => String(e.type).length));
|
|
38
|
+
const sizeW = Math.max(4, ...entries.map((e) => formatSize(e.size ?? 0).length));
|
|
39
|
+
const header = padRight("NAME", nameW) +
|
|
40
|
+
" " +
|
|
41
|
+
padRight("TYPE", typeW) +
|
|
42
|
+
" " +
|
|
43
|
+
padLeft("SIZE", sizeW) +
|
|
44
|
+
" " +
|
|
45
|
+
"MODIFIED";
|
|
46
|
+
const lines = entries.map((e) => padRight(e.name, nameW) +
|
|
47
|
+
" " +
|
|
48
|
+
padRight(e.type, typeW) +
|
|
49
|
+
" " +
|
|
50
|
+
padLeft(formatSize(e.size ?? 0), sizeW) +
|
|
51
|
+
" " +
|
|
52
|
+
formatDate(e.modifiedAt));
|
|
53
|
+
return [header, ...lines].join("\n");
|
|
54
|
+
}
|
|
55
|
+
function formatCat(result) {
|
|
56
|
+
const content = result.content ?? "";
|
|
57
|
+
const lines = content.split("\n");
|
|
58
|
+
// Remove trailing empty line from split if content ends with newline
|
|
59
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") {
|
|
60
|
+
lines.pop();
|
|
61
|
+
}
|
|
62
|
+
const offset = result.offset ?? 1;
|
|
63
|
+
const width = String(offset + lines.length - 1).length;
|
|
64
|
+
return lines
|
|
65
|
+
.map((line, i) => `${padLeft(String(offset + i), width)} ${line}`)
|
|
66
|
+
.join("\n");
|
|
67
|
+
}
|
|
68
|
+
function formatStat(result) {
|
|
69
|
+
const pairs = [
|
|
70
|
+
["Path", result.path ?? "-"],
|
|
71
|
+
["Size", formatSize(result.size ?? 0)],
|
|
72
|
+
["Content-Type", result.contentType ?? "-"],
|
|
73
|
+
["Author", result.author ?? "-"],
|
|
74
|
+
["Version", result.currentVersion != null ? String(result.currentVersion) : "-"],
|
|
75
|
+
["Created", formatDate(result.createdAt)],
|
|
76
|
+
["Modified", formatDate(result.modifiedAt)],
|
|
77
|
+
["Deleted", result.isDeleted ? "yes" : "no"],
|
|
78
|
+
];
|
|
79
|
+
if (result.embeddingStatus) {
|
|
80
|
+
pairs.push(["Embedding", result.embeddingStatus]);
|
|
81
|
+
}
|
|
82
|
+
const labelW = Math.max(...pairs.map(([k]) => k.length));
|
|
83
|
+
return pairs.map(([k, v]) => `${padRight(k + ":", labelW + 1)} ${v}`).join("\n");
|
|
84
|
+
}
|
|
85
|
+
function formatLog(result) {
|
|
86
|
+
const versions = result.versions ?? [];
|
|
87
|
+
if (versions.length === 0)
|
|
88
|
+
return "(no version history)";
|
|
89
|
+
return versions
|
|
90
|
+
.map((v) => {
|
|
91
|
+
const parts = [`v${v.version} ${formatDate(v.createdAt)} ${v.author ?? "-"} [${v.operation}]`];
|
|
92
|
+
if (v.message)
|
|
93
|
+
parts.push(` ${v.message}`);
|
|
94
|
+
if (v.diffSummary)
|
|
95
|
+
parts.push(` ${v.diffSummary}`);
|
|
96
|
+
return parts.join("\n");
|
|
97
|
+
})
|
|
98
|
+
.join("\n\n");
|
|
99
|
+
}
|
|
100
|
+
function formatWrite(result) {
|
|
101
|
+
return `\u2713 wrote ${result.path} (v${result.version}, ${formatSize(result.size ?? 0)})`;
|
|
102
|
+
}
|
|
103
|
+
function formatEdit(result) {
|
|
104
|
+
return `\u2713 edited ${result.path} (v${result.version}, ${result.changes} change${result.changes !== 1 ? "s" : ""})`;
|
|
105
|
+
}
|
|
106
|
+
function formatAppend(result) {
|
|
107
|
+
return `\u2713 appended (v${result.version}, ${formatSize(result.size ?? 0)})`;
|
|
108
|
+
}
|
|
109
|
+
function formatRm(result) {
|
|
110
|
+
return result.deleted
|
|
111
|
+
? `\u2713 deleted ${result.path}`
|
|
112
|
+
: `(not found: ${result.path})`;
|
|
113
|
+
}
|
|
114
|
+
function formatMv(result) {
|
|
115
|
+
return `\u2713 moved ${result.from} -> ${result.to} (v${result.version})`;
|
|
116
|
+
}
|
|
117
|
+
function formatCp(result) {
|
|
118
|
+
return `\u2713 copied ${result.from} -> ${result.to} (v${result.version})`;
|
|
119
|
+
}
|
|
120
|
+
function formatTree(result) {
|
|
121
|
+
const tree = result.tree ?? [];
|
|
122
|
+
if (tree.length === 0)
|
|
123
|
+
return "(empty)";
|
|
124
|
+
const lines = [];
|
|
125
|
+
function walk(entries, prefix) {
|
|
126
|
+
for (let i = 0; i < entries.length; i++) {
|
|
127
|
+
const entry = entries[i];
|
|
128
|
+
const isLast = i === entries.length - 1;
|
|
129
|
+
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
130
|
+
const suffix = entry.type === "directory" ? "/" : "";
|
|
131
|
+
lines.push(`${prefix}${connector}${entry.name}${suffix}`);
|
|
132
|
+
if (entry.children && entry.children.length > 0) {
|
|
133
|
+
const childPrefix = prefix + (isLast ? " " : "\u2502 ");
|
|
134
|
+
walk(entry.children, childPrefix);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
walk(tree, "");
|
|
139
|
+
return lines.join("\n");
|
|
140
|
+
}
|
|
141
|
+
function formatGrep(result) {
|
|
142
|
+
const matches = result.matches ?? [];
|
|
143
|
+
if (matches.length === 0)
|
|
144
|
+
return "(no matches)";
|
|
145
|
+
return matches
|
|
146
|
+
.map((m) => `${m.path}:${m.lineNumber}: ${m.content}`)
|
|
147
|
+
.join("\n");
|
|
148
|
+
}
|
|
149
|
+
function formatFts(result) {
|
|
150
|
+
const matches = result.matches ?? [];
|
|
151
|
+
if (matches.length === 0) {
|
|
152
|
+
return result.hint ? `(no matches) ${result.hint}` : "(no matches)";
|
|
153
|
+
}
|
|
154
|
+
const lines = matches.map((m) => `${m.path} (rank: ${typeof m.rank === "number" ? m.rank.toFixed(2) : m.rank})\n ${m.snippet}`);
|
|
155
|
+
if (result.hint)
|
|
156
|
+
lines.push(`\nhint: ${result.hint}`);
|
|
157
|
+
return lines.join("\n\n");
|
|
158
|
+
}
|
|
159
|
+
function formatSearch(result) {
|
|
160
|
+
const results = result.results ?? [];
|
|
161
|
+
if (results.length === 0)
|
|
162
|
+
return "(no results)";
|
|
163
|
+
return results
|
|
164
|
+
.map((r) => `${r.path} (score: ${typeof r.score === "number" ? r.score.toFixed(3) : r.score})` +
|
|
165
|
+
(r.author ? ` by ${r.author}` : "") +
|
|
166
|
+
`\n ${r.snippet}`)
|
|
167
|
+
.join("\n\n");
|
|
168
|
+
}
|
|
169
|
+
function formatGlob(result) {
|
|
170
|
+
const matches = result.matches ?? [];
|
|
171
|
+
if (matches.length === 0)
|
|
172
|
+
return "(no matches)";
|
|
173
|
+
return matches
|
|
174
|
+
.map((m) => `${m.path} ${formatSize(m.size ?? 0)} ${formatDate(m.modifiedAt)}`)
|
|
175
|
+
.join("\n");
|
|
176
|
+
}
|
|
177
|
+
function formatDiff(result) {
|
|
178
|
+
const changes = result.changes ?? [];
|
|
179
|
+
if (changes.length === 0)
|
|
180
|
+
return "(no changes)";
|
|
181
|
+
return changes
|
|
182
|
+
.map((c) => {
|
|
183
|
+
const prefix = c.type === "add" ? "+" : c.type === "remove" ? "-" : " ";
|
|
184
|
+
const lineNum = c.lineNumber != null ? `${c.lineNumber}: ` : "";
|
|
185
|
+
return `${prefix} ${lineNum}${c.content}`;
|
|
186
|
+
})
|
|
187
|
+
.join("\n");
|
|
188
|
+
}
|
|
189
|
+
function formatTail(result) {
|
|
190
|
+
// tail returns CatResult, same format as cat
|
|
191
|
+
return formatCat(result);
|
|
192
|
+
}
|
|
193
|
+
function formatRevert(result) {
|
|
194
|
+
return `\u2713 reverted to v${result.revertedTo} (new version: v${result.version})`;
|
|
195
|
+
}
|
|
196
|
+
function formatRecent(result) {
|
|
197
|
+
const entries = result.entries ?? [];
|
|
198
|
+
if (entries.length === 0)
|
|
199
|
+
return "(no recent activity)";
|
|
200
|
+
return entries
|
|
201
|
+
.map((e) => `${e.path} v${e.version} ${formatDate(e.createdAt)} ${e.author ?? "-"} [${e.operation}]` +
|
|
202
|
+
(e.message ? `\n ${e.message}` : ""))
|
|
203
|
+
.join("\n\n");
|
|
204
|
+
}
|
|
205
|
+
function formatReindex(result) {
|
|
206
|
+
const parts = [];
|
|
207
|
+
parts.push(`reindexed: ${result.reindexed ?? 0}`);
|
|
208
|
+
if (result.failed)
|
|
209
|
+
parts.push(`failed: ${result.failed}`);
|
|
210
|
+
if (result.skipped)
|
|
211
|
+
parts.push(`skipped: ${result.skipped}`);
|
|
212
|
+
return parts.join(", ");
|
|
213
|
+
}
|
|
214
|
+
// --- Formatter registry ---
|
|
215
|
+
const formatters = {
|
|
216
|
+
ls: formatLs,
|
|
217
|
+
cat: formatCat,
|
|
218
|
+
stat: formatStat,
|
|
219
|
+
log: formatLog,
|
|
220
|
+
write: formatWrite,
|
|
221
|
+
edit: formatEdit,
|
|
222
|
+
append: formatAppend,
|
|
223
|
+
rm: formatRm,
|
|
224
|
+
mv: formatMv,
|
|
225
|
+
cp: formatCp,
|
|
226
|
+
tree: formatTree,
|
|
227
|
+
grep: formatGrep,
|
|
228
|
+
fts: formatFts,
|
|
229
|
+
search: formatSearch,
|
|
230
|
+
glob: formatGlob,
|
|
231
|
+
diff: formatDiff,
|
|
232
|
+
tail: formatTail,
|
|
233
|
+
revert: formatRevert,
|
|
234
|
+
recent: formatRecent,
|
|
235
|
+
reindex: formatReindex,
|
|
236
|
+
};
|
|
237
|
+
function formatResult(opName, result) {
|
|
238
|
+
const formatter = formatters[opName];
|
|
239
|
+
if (formatter) {
|
|
240
|
+
return formatter(result);
|
|
241
|
+
}
|
|
242
|
+
// Fallback: JSON for unknown ops
|
|
243
|
+
return JSON.stringify(result, null, 2);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Single entry point for all CLI output.
|
|
247
|
+
* If json is true, outputs raw JSON. Otherwise, uses the pretty-print formatter.
|
|
248
|
+
*/
|
|
249
|
+
export function outputResult(opName, result, json) {
|
|
250
|
+
if (json) {
|
|
251
|
+
console.log(JSON.stringify(result, null, 2));
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
console.log(formatResult(opName, result));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kBAAkB;AAElB,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC;AAED,SAAS,UAAU,CAAC,CAA4B;IAC9C,IAAI,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACnB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,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,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;CACvB,CAAC;AAEF,SAAS,YAAY,CAAC,MAAc,EAAE,MAAW;IAC/C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,iCAAiC;IACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,MAAW,EAAE,IAAa;IACrE,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { getConfig, listUserOrgs, getUserByApiKey, VERSION } from "@/core";
|
|
4
|
+
import { ApiClient } from "./api-client.js";
|
|
5
|
+
import { registerOpCommands } from "./commands/ops.js";
|
|
6
|
+
import { authCommands } from "./commands/auth.js";
|
|
7
|
+
import { daemonCommands } from "./commands/daemon.js";
|
|
8
|
+
import { configCommands } from "./commands/config-cmd.js";
|
|
9
|
+
import { driveCommands } from "./commands/drive.js";
|
|
10
|
+
import { initCommand } from "./commands/init.js";
|
|
11
|
+
import { onboardCommand } from "./commands/onboard.js";
|
|
12
|
+
import { commentCommands } from "./commands/comment.js";
|
|
13
|
+
import { docsCommand } from "./commands/docs.js";
|
|
14
|
+
const program = new Command();
|
|
15
|
+
program
|
|
16
|
+
.name("agent-fs")
|
|
17
|
+
.description("Agent-first filesystem backed by S3")
|
|
18
|
+
.version(VERSION)
|
|
19
|
+
.option("--org <orgId>", "Override org context")
|
|
20
|
+
.option("--drive <driveId>", "Override drive context")
|
|
21
|
+
.option("--json", "Output raw JSON");
|
|
22
|
+
const client = new ApiClient();
|
|
23
|
+
// Resolve the default org ID
|
|
24
|
+
function getOrgId() {
|
|
25
|
+
const orgId = program.opts().org;
|
|
26
|
+
if (orgId)
|
|
27
|
+
return orgId;
|
|
28
|
+
// Try to resolve from config
|
|
29
|
+
const config = getConfig();
|
|
30
|
+
if (config.auth.apiKey) {
|
|
31
|
+
try {
|
|
32
|
+
const { createDatabase } = require("@/core");
|
|
33
|
+
const db = createDatabase();
|
|
34
|
+
const user = getUserByApiKey(db, config.auth.apiKey);
|
|
35
|
+
if (user) {
|
|
36
|
+
const orgs = listUserOrgs(db, user.id);
|
|
37
|
+
if (orgs.length > 0)
|
|
38
|
+
return orgs[0].id;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// If DB isn't available, let the server handle it
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.error("Error: No org context. Use --org or run 'agent-fs auth register'");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
// Register commands — docs first so it appears at top of --help
|
|
49
|
+
program.addCommand(docsCommand());
|
|
50
|
+
registerOpCommands(program, client, getOrgId);
|
|
51
|
+
program.addCommand(authCommands(client));
|
|
52
|
+
program.addCommand(daemonCommands());
|
|
53
|
+
program.addCommand(configCommands());
|
|
54
|
+
program.addCommand(driveCommands(client));
|
|
55
|
+
program.addCommand(initCommand());
|
|
56
|
+
program.addCommand(onboardCommand());
|
|
57
|
+
program.addCommand(commentCommands(client, getOrgId));
|
|
58
|
+
// MCP command
|
|
59
|
+
program
|
|
60
|
+
.command("mcp")
|
|
61
|
+
.description("Start MCP server (stdio)")
|
|
62
|
+
.action(async () => {
|
|
63
|
+
await import("@/mcp/index.js");
|
|
64
|
+
});
|
|
65
|
+
// Server command (foreground dev mode)
|
|
66
|
+
program
|
|
67
|
+
.command("server")
|
|
68
|
+
.description("Run server in foreground (dev mode)")
|
|
69
|
+
.action(async () => {
|
|
70
|
+
await import("@/server/index.js");
|
|
71
|
+
});
|
|
72
|
+
// Show global options in subcommand help
|
|
73
|
+
const globalHelp = `
|
|
74
|
+
Global Options:
|
|
75
|
+
--org <orgId> Override org context
|
|
76
|
+
--drive <driveId> Override drive context
|
|
77
|
+
--json Output raw JSON
|
|
78
|
+
`;
|
|
79
|
+
for (const cmd of program.commands) {
|
|
80
|
+
cmd.addHelpText("after", globalHelp);
|
|
81
|
+
}
|
|
82
|
+
program.parse();
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OA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QAAQ,CAAC;KACjB,WAAW,CAAC,qCAAqC,CAAC;KAClD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEL,yCAAyC;AACzC,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AACF,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACvC,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@desplega.ai/agent-fs",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Agent-first filesystem backed by S3",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/desplega-ai/agent-fs"
|
|
10
|
+
},
|
|
11
|
+
"keywords": ["agent", "filesystem", "s3", "mcp", "cli"],
|
|
12
|
+
"engines": {
|
|
13
|
+
"bun": ">=1.2.0"
|
|
14
|
+
},
|
|
15
|
+
"main": "src/index.ts",
|
|
16
|
+
"types": "src/index.ts",
|
|
17
|
+
"bin": {
|
|
18
|
+
"agent-fs": "src/index.ts"
|
|
19
|
+
},
|
|
20
|
+
"files": ["dist"],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build:npm": "bun build src/index.ts --outfile dist/cli.js --target bun --packages external --minify",
|
|
23
|
+
"prepublishOnly": "bun run build:npm"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@desplega.ai/agent-fs-core": "0.1.0",
|
|
27
|
+
"@desplega.ai/agent-fs-server": "0.1.0",
|
|
28
|
+
"@desplega.ai/agent-fs-mcp": "0.1.0",
|
|
29
|
+
"commander": "^14.0.3",
|
|
30
|
+
"@aws-sdk/client-s3": "^3.750.0",
|
|
31
|
+
"@google/genai": "^1.45.0",
|
|
32
|
+
"chonkie": "^0.3.0",
|
|
33
|
+
"diff": "^8.0.3",
|
|
34
|
+
"drizzle-orm": "^0.44.0",
|
|
35
|
+
"node-llama-cpp": "^3.17.1",
|
|
36
|
+
"openai": "^6.29.0",
|
|
37
|
+
"sqlite-vec": "^0.1.6",
|
|
38
|
+
"zod": "^3.24.0",
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
40
|
+
"hono": "^4.12.8"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { getConfig, listUserOrgs, getUserByApiKey, VERSION } from "@/core";
|
|
4
|
+
import { ApiClient } from "./api-client.js";
|
|
5
|
+
import { registerOpCommands } from "./commands/ops.js";
|
|
6
|
+
import { authCommands } from "./commands/auth.js";
|
|
7
|
+
import { daemonCommands } from "./commands/daemon.js";
|
|
8
|
+
import { configCommands } from "./commands/config-cmd.js";
|
|
9
|
+
import { driveCommands } from "./commands/drive.js";
|
|
10
|
+
import { initCommand } from "./commands/init.js";
|
|
11
|
+
import { onboardCommand } from "./commands/onboard.js";
|
|
12
|
+
import { commentCommands } from "./commands/comment.js";
|
|
13
|
+
import { docsCommand } from "./commands/docs.js";
|
|
14
|
+
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name("agent-fs")
|
|
19
|
+
.description("Agent-first filesystem backed by S3")
|
|
20
|
+
.version(VERSION)
|
|
21
|
+
.option("--org <orgId>", "Override org context")
|
|
22
|
+
.option("--drive <driveId>", "Override drive context")
|
|
23
|
+
.option("--json", "Output raw JSON");
|
|
24
|
+
|
|
25
|
+
const client = new ApiClient();
|
|
26
|
+
|
|
27
|
+
// Resolve the default org ID
|
|
28
|
+
function getOrgId(): string {
|
|
29
|
+
const orgId = program.opts().org;
|
|
30
|
+
if (orgId) return orgId;
|
|
31
|
+
|
|
32
|
+
// Try to resolve from config
|
|
33
|
+
const config = getConfig();
|
|
34
|
+
if (config.auth.apiKey) {
|
|
35
|
+
try {
|
|
36
|
+
const { createDatabase } = require("@/core");
|
|
37
|
+
const db = createDatabase();
|
|
38
|
+
const user = getUserByApiKey(db, config.auth.apiKey);
|
|
39
|
+
if (user) {
|
|
40
|
+
const orgs = listUserOrgs(db, user.id);
|
|
41
|
+
if (orgs.length > 0) return orgs[0].id;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
// If DB isn't available, let the server handle it
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.error("Error: No org context. Use --org or run 'agent-fs auth register'");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Register commands — docs first so it appears at top of --help
|
|
53
|
+
program.addCommand(docsCommand());
|
|
54
|
+
registerOpCommands(program, client, getOrgId);
|
|
55
|
+
program.addCommand(authCommands(client));
|
|
56
|
+
program.addCommand(daemonCommands());
|
|
57
|
+
program.addCommand(configCommands());
|
|
58
|
+
program.addCommand(driveCommands(client));
|
|
59
|
+
program.addCommand(initCommand());
|
|
60
|
+
program.addCommand(onboardCommand());
|
|
61
|
+
program.addCommand(commentCommands(client, getOrgId));
|
|
62
|
+
|
|
63
|
+
// MCP command
|
|
64
|
+
program
|
|
65
|
+
.command("mcp")
|
|
66
|
+
.description("Start MCP server (stdio)")
|
|
67
|
+
.action(async () => {
|
|
68
|
+
await import("@/mcp/index.js");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Server command (foreground dev mode)
|
|
72
|
+
program
|
|
73
|
+
.command("server")
|
|
74
|
+
.description("Run server in foreground (dev mode)")
|
|
75
|
+
.action(async () => {
|
|
76
|
+
await import("@/server/index.js");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Show global options in subcommand help
|
|
80
|
+
const globalHelp = `
|
|
81
|
+
Global Options:
|
|
82
|
+
--org <orgId> Override org context
|
|
83
|
+
--drive <driveId> Override drive context
|
|
84
|
+
--json Output raw JSON
|
|
85
|
+
`;
|
|
86
|
+
for (const cmd of program.commands) {
|
|
87
|
+
cmd.addHelpText("after", globalHelp);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
program.parse();
|