@opvs-ai/cli 0.25.5 → 0.27.0
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/README.md +23 -0
- package/dist/.build-stamp.json +4 -4
- package/dist/commands/code-graph.js +48 -2
- package/dist/commands/code-graph.js.map +1 -1
- package/dist/commands/code.js +142 -2
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/engines.d.ts +49 -0
- package/dist/commands/engines.js +306 -0
- package/dist/commands/engines.js.map +1 -0
- package/dist/commands/files.js +32 -5
- package/dist/commands/files.js.map +1 -1
- package/dist/commands/memory-sync.d.ts +31 -0
- package/dist/commands/memory-sync.js +229 -0
- package/dist/commands/memory-sync.js.map +1 -0
- package/dist/commands/memory.js +89 -0
- package/dist/commands/memory.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opvs engines — switch the build engines on and off (REAS-217).
|
|
3
|
+
*
|
|
4
|
+
* The route is `GET / PUT / DELETE /api/v1/factory/engines-off/{harness}` (built
|
|
5
|
+
* by REAS-216, the switch route that owns the authz and storage). This command
|
|
6
|
+
* is the CLI face of that surface — and only that surface; it does not invent
|
|
7
|
+
* any state the route does not already advertise.
|
|
8
|
+
*
|
|
9
|
+
* OFF has three visible states on screen:
|
|
10
|
+
* - until is null → "OFF" (off until switched on)
|
|
11
|
+
* - until in future → "off until <local>" (timed pause)
|
|
12
|
+
* - until in past → "expired" (a timed pause whose clock ran out;
|
|
13
|
+
* the route drops it on the next call,
|
|
14
|
+
* and the list shows it before that)
|
|
15
|
+
*
|
|
16
|
+
* `--until` accepts four forms. `--reason` is required for `off` because the route
|
|
17
|
+
* records it as the reason the next operator will read.
|
|
18
|
+
*/
|
|
19
|
+
import { createClient } from "@opvs-ai/core";
|
|
20
|
+
import { printJson } from "../lib/format.js";
|
|
21
|
+
/**
|
|
22
|
+
* The list of harness identifiers the route accepts (REAS-216 enumerates them
|
|
23
|
+
* on the server). Help text only — the route is the authority, a typo is a 422
|
|
24
|
+
* with the canonical list it returned, and pinning it on the CLI as a second
|
|
25
|
+
* source of truth invites the two to drift.
|
|
26
|
+
*
|
|
27
|
+
* ⚠️ Two existing CLI commands spell this vocabulary with HYPHENS because their
|
|
28
|
+
* upstream enum (`agentboard BuildProvider`) does. This one is a `factory`
|
|
29
|
+
* harness, and REAS-216's enum is underscored (`claude_code`, `opencode`,
|
|
30
|
+
* `codex`, `pi`, `grok`, `agy`, `cursor`, `openhands`). The two do NOT match —
|
|
31
|
+
* mixing them is the 422 a reader of `--help` should not have to discover.
|
|
32
|
+
*/
|
|
33
|
+
export const HARNESSES = [
|
|
34
|
+
"claude_code",
|
|
35
|
+
"openhands",
|
|
36
|
+
"codex",
|
|
37
|
+
"opencode",
|
|
38
|
+
"pi",
|
|
39
|
+
"grok",
|
|
40
|
+
"agy",
|
|
41
|
+
"cursor",
|
|
42
|
+
];
|
|
43
|
+
const UNTIL_HELP = "When the off-switch flips back on. ISO-8601 (e.g. 2026-10-12T18:00:00Z) is sent as-is. " +
|
|
44
|
+
"+Nh / +Nm is RELATIVE TO NOW (a fixed clock in tests). " +
|
|
45
|
+
"HH:MM is the next such LOCAL time; the CLI sends UTC. " +
|
|
46
|
+
"Omit for off until switched on.";
|
|
47
|
+
const REASON_HELP = 'Free text recorded by the route; the next operator sees it. e.g. "GPT outage, retrying at 18:00Z".';
|
|
48
|
+
const ADMIN_MESSAGE = "Only a human admin of this workspace can switch engines.";
|
|
49
|
+
/** Standardised access to "now". The action handler calls this with no args,
|
|
50
|
+
* the parser accepts an explicit one — letting tests pin the clock. */
|
|
51
|
+
export function now() {
|
|
52
|
+
return new Date();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parse the four `--until` forms into an ISO-8601 UTC string the server stores
|
|
56
|
+
* verbatim. Pure on purpose: the only input is `(raw, now)`; the only output is
|
|
57
|
+
* the ISO string or `null` when `--until` was omitted, or an `Error` on bad
|
|
58
|
+
* input. Pure functions are why the test can fix the clock without standing up
|
|
59
|
+
* the rest of the action.
|
|
60
|
+
*
|
|
61
|
+
* - undefined → null (off until switched on)
|
|
62
|
+
* - "+Nh" | "+Nm" → raw minutes/hours from now
|
|
63
|
+
* - "HH:MM" (24h, local time) → the next such local time; tomorrow if today's HH:MM already passed
|
|
64
|
+
* - ISO-8601 already → passed through (any timezone accepted; we re-emit UTC if it parses)
|
|
65
|
+
*/
|
|
66
|
+
export function parseUntil(raw, nowArg) {
|
|
67
|
+
if (raw === undefined)
|
|
68
|
+
return null;
|
|
69
|
+
const s = raw.trim();
|
|
70
|
+
// Relative: "+2h", "+30m", "+90m", etc. Lowercase only; uppercase is reserved
|
|
71
|
+
// for absolute time forms so a "+2H" typo is caught, not silently applied.
|
|
72
|
+
const rel = /^([+]?)(\d+)([hm])$/.exec(s);
|
|
73
|
+
if (rel) {
|
|
74
|
+
const n = Number(rel[2]);
|
|
75
|
+
const unit = rel[3];
|
|
76
|
+
const ms = unit === "h" ? n * 60 * 60 * 1000 : n * 60 * 1000;
|
|
77
|
+
return new Date(nowArg.getTime() + ms).toISOString();
|
|
78
|
+
}
|
|
79
|
+
// HH:MM in local time — next occurrence. A 25:00 or 12:60 is not a time, and
|
|
80
|
+
// the route does the same validation server-side; the CLI's job here is to
|
|
81
|
+
// exit with a clear message instead of a 422 round-trip.
|
|
82
|
+
const clock = /^(\d{1,2}):(\d{2})$/.exec(s);
|
|
83
|
+
if (clock) {
|
|
84
|
+
const hh = Number(clock[1]);
|
|
85
|
+
const mm = Number(clock[2]);
|
|
86
|
+
if (hh > 23 || mm > 59) {
|
|
87
|
+
throw new Error(`--until '${raw}' is not a valid HH:MM time (got ${hh}:${mm.toString().padStart(2, "0")})`);
|
|
88
|
+
}
|
|
89
|
+
const target = new Date(nowArg);
|
|
90
|
+
target.setHours(hh, mm, 0, 0);
|
|
91
|
+
if (target.getTime() <= nowArg.getTime()) {
|
|
92
|
+
target.setDate(target.getDate() + 1);
|
|
93
|
+
}
|
|
94
|
+
return target.toISOString();
|
|
95
|
+
}
|
|
96
|
+
// ISO-8601 passthrough. `Date` accepts a wide grammar (Z, +02:00, with/without
|
|
97
|
+
// fractional seconds); a string Date rejects with NaN, which we surface.
|
|
98
|
+
const parsed = new Date(s);
|
|
99
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
100
|
+
throw new Error(`--until '${raw}' is not ISO-8601, +Nh/+Nm, or HH:MM. Pass one of those forms.`);
|
|
101
|
+
}
|
|
102
|
+
return parsed.toISOString();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Render the GET reply as a human table.
|
|
106
|
+
*
|
|
107
|
+
* The route's reply carries two lists. `engines_off` is the OFF-ledger: every
|
|
108
|
+
* off-switch the route still remembers, including expired ones (the route drops
|
|
109
|
+
* them on the next call, the table shows them here). `active` is the SUBSET of
|
|
110
|
+
* `engines_off` whose off-switch is in force now (`until` is null or in the
|
|
111
|
+
* future) — so `active` ⊆ harnesses-of(`engines_off`). It is NOT a list of
|
|
112
|
+
* engines that are on. The on-state is the absence of an off-entry.
|
|
113
|
+
*
|
|
114
|
+
* Rows are the union of `HARNESSES` and the harnesses that appear in
|
|
115
|
+
* `engines_off` (a name the CLI does not know about still gets a row).
|
|
116
|
+
* State for a harness that has an `engines_off` entry comes from that entry;
|
|
117
|
+
* otherwise the harness is `ON`. `active` is not consulted — reading it as
|
|
118
|
+
* "currently on" produces duplicate rows (every `active` harness already has an
|
|
119
|
+
* off-row), and the only thing being read off it is the subset relationship the
|
|
120
|
+
* route already encoded in `engines_off`.
|
|
121
|
+
*/
|
|
122
|
+
function renderEnginesTable(data, nowArg) {
|
|
123
|
+
const rows = [];
|
|
124
|
+
const offByHarness = new Map();
|
|
125
|
+
for (const entry of data.engines_off) {
|
|
126
|
+
offByHarness.set(entry.harness, entry);
|
|
127
|
+
}
|
|
128
|
+
const harnesses = new Set([...HARNESSES, ...offByHarness.keys()]);
|
|
129
|
+
for (const harness of [...harnesses].sort((a, b) => a.localeCompare(b))) {
|
|
130
|
+
const entry = offByHarness.get(harness);
|
|
131
|
+
if (entry) {
|
|
132
|
+
rows.push({
|
|
133
|
+
harness,
|
|
134
|
+
state: formatState(entry.until, nowArg),
|
|
135
|
+
reason: entry.reason ?? "",
|
|
136
|
+
setBy: entry.set_by ?? "",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
rows.push({ harness, state: "ON", reason: "", setBy: "" });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (rows.length === 0) {
|
|
144
|
+
console.log("(no engines configured)");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const wHarness = Math.max("harness".length, ...rows.map((r) => r.harness.length));
|
|
148
|
+
const wState = Math.max("state".length, ...rows.map((r) => r.state.length));
|
|
149
|
+
const wReason = Math.max("reason".length, ...rows.map((r) => r.reason.length));
|
|
150
|
+
const wSetBy = Math.max("set by".length, ...rows.map((r) => r.setBy.length));
|
|
151
|
+
const header = [
|
|
152
|
+
"harness".padEnd(wHarness),
|
|
153
|
+
"state".padEnd(wState),
|
|
154
|
+
"reason".padEnd(wReason),
|
|
155
|
+
"set by".padEnd(wSetBy),
|
|
156
|
+
].join(" ");
|
|
157
|
+
const sep = [
|
|
158
|
+
"-".repeat(wHarness),
|
|
159
|
+
"-".repeat(wState),
|
|
160
|
+
"-".repeat(wReason),
|
|
161
|
+
"-".repeat(wSetBy),
|
|
162
|
+
].join(" ");
|
|
163
|
+
console.log(header);
|
|
164
|
+
console.log(sep);
|
|
165
|
+
for (const r of rows) {
|
|
166
|
+
console.log([
|
|
167
|
+
r.harness.padEnd(wHarness),
|
|
168
|
+
r.state.padEnd(wState),
|
|
169
|
+
r.reason.padEnd(wReason),
|
|
170
|
+
r.setBy.padEnd(wSetBy),
|
|
171
|
+
].join(" "));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function formatState(until, nowArg) {
|
|
175
|
+
if (until === null)
|
|
176
|
+
return "OFF";
|
|
177
|
+
const t = new Date(until);
|
|
178
|
+
if (Number.isNaN(t.getTime()))
|
|
179
|
+
return "OFF";
|
|
180
|
+
if (t.getTime() <= nowArg.getTime())
|
|
181
|
+
return "expired";
|
|
182
|
+
return `off until ${t.toLocaleString(undefined, { hour12: false })}`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Translate an error thrown by the client into the human message this command
|
|
186
|
+
* emits. The route says a 403 is "only an admin can switch engines" — that is
|
|
187
|
+
* the wording every other client reads, so the CLI carries it verbatim rather
|
|
188
|
+
* than rephrasing. A 422 is the route's own message; the CLI never invents its
|
|
189
|
+
* own vocabulary for a server-side refusal.
|
|
190
|
+
*/
|
|
191
|
+
function describeApiError(err) {
|
|
192
|
+
if (!err || typeof err !== "object")
|
|
193
|
+
return null;
|
|
194
|
+
const e = err;
|
|
195
|
+
if (e.status === 403) {
|
|
196
|
+
return { message: ADMIN_MESSAGE, exitCode: 1 };
|
|
197
|
+
}
|
|
198
|
+
if (typeof e.detail === "string" && e.detail) {
|
|
199
|
+
return { message: e.detail, exitCode: 1 };
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
export function registerEnginesCommands(program) {
|
|
204
|
+
const engines = program
|
|
205
|
+
.command("engines")
|
|
206
|
+
.description("Switch build engines on and off for this workspace");
|
|
207
|
+
engines
|
|
208
|
+
.command("list")
|
|
209
|
+
.description("Show which engines are on, off, expired, or timed")
|
|
210
|
+
.option("--json", "Print the raw JSON from /api/v1/factory/engines-off instead of the table")
|
|
211
|
+
.action(async (opts) => {
|
|
212
|
+
const wsSlug = program.opts().workspace;
|
|
213
|
+
try {
|
|
214
|
+
const client = createClient(wsSlug);
|
|
215
|
+
const res = await client.get("/api/v1/factory/engines-off");
|
|
216
|
+
const data = (await res.json());
|
|
217
|
+
if (opts.json) {
|
|
218
|
+
printJson(data);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
renderEnginesTable(data, now());
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
const described = describeApiError(err);
|
|
225
|
+
if (described) {
|
|
226
|
+
console.error(described.message);
|
|
227
|
+
process.exit(described.exitCode);
|
|
228
|
+
}
|
|
229
|
+
const e = err;
|
|
230
|
+
console.error(`Error: ${e.detail || "Failed to list engines"}`);
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
engines
|
|
235
|
+
.command("off <harness>")
|
|
236
|
+
.description("Switch an engine off. --reason is required; --until defaults to 'until switched on'.")
|
|
237
|
+
.requiredOption("--reason <text>", REASON_HELP)
|
|
238
|
+
.option("--until <when>", UNTIL_HELP)
|
|
239
|
+
.action(async (harness, opts) => {
|
|
240
|
+
const wsSlug = program.opts().workspace;
|
|
241
|
+
let untilIso;
|
|
242
|
+
try {
|
|
243
|
+
untilIso = parseUntil(opts.until, now());
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
247
|
+
console.error(msg);
|
|
248
|
+
process.exit(1);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const client = createClient(wsSlug);
|
|
253
|
+
const res = await client.put(`/api/v1/factory/engines-off/${encodeURIComponent(harness)}`, {
|
|
254
|
+
until: untilIso,
|
|
255
|
+
reason: opts.reason,
|
|
256
|
+
});
|
|
257
|
+
const data = (await res.json());
|
|
258
|
+
if (opts.until === undefined || (opts.until && opts.until.trim() === "")) {
|
|
259
|
+
// No --until (or empty): just confirm in one line. Re-printing the
|
|
260
|
+
// whole table is what `--json` is for.
|
|
261
|
+
const entry = data.engines_off.find((e) => e.harness === harness);
|
|
262
|
+
console.log(`${harness}: OFF (${entry?.reason ?? opts.reason}) until ${entry && entry.until ? entry.until : "switched on"}`);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
renderEnginesTable(data, now());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
const described = describeApiError(err);
|
|
270
|
+
if (described) {
|
|
271
|
+
console.error(described.message);
|
|
272
|
+
process.exit(described.exitCode);
|
|
273
|
+
}
|
|
274
|
+
const e = err;
|
|
275
|
+
console.error(`Error: ${e.detail || "Failed to switch engine off"}`);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
engines
|
|
280
|
+
.command("on <harness>")
|
|
281
|
+
.description("Switch an engine back on (DELETE on /api/v1/factory/engines-off/{harness})")
|
|
282
|
+
.action(async (harness) => {
|
|
283
|
+
const wsSlug = program.opts().workspace;
|
|
284
|
+
try {
|
|
285
|
+
const client = createClient(wsSlug);
|
|
286
|
+
await client.delete(`/api/v1/factory/engines-off/${encodeURIComponent(harness)}`);
|
|
287
|
+
console.log(`${harness}: ON`);
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
const described = describeApiError(err);
|
|
291
|
+
if (described) {
|
|
292
|
+
console.error(described.message);
|
|
293
|
+
process.exit(described.exitCode);
|
|
294
|
+
}
|
|
295
|
+
const e = err;
|
|
296
|
+
console.error(`Error: ${e.detail || "Failed to switch engine on"}`);
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
// Engine group help: list valid harnesses once. The route does not change
|
|
301
|
+
// often, and a fixed list keeps `--help` honest without putting a copy in
|
|
302
|
+
// every subcommand.
|
|
303
|
+
engines.addHelpText("after", `\nValid harnesses: ${HARNESSES.join(", ")}.\n` +
|
|
304
|
+
`Note: claude_code, opencode, and codex use UNDERSCORES — the route's enum, not the --provider values elsewhere in this CLI.`);
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=engines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/commands/engines.ts"],"names":[],"mappings":"AAAA;;;;;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AM,MAAM,CAAC,MAAM,CAAC,+BAA+B,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAClF,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBACjC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,CAAC,GAAG,GAA0B,CAAC;YACrC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,IAAI,4BAA4B,EAAE,CAAC,CAAC;YACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,0EAA0E;IAC1E,0EAA0E;IAC1E,oBAAoB;IACpB,OAAO,CAAC,WAAW,CACjB,OAAO,EACP,sBAAsB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;QAC7C,6HAA6H,CAChI,CAAC;AACJ,CAAC"}
|
package/dist/commands/files.js
CHANGED
|
@@ -6,6 +6,31 @@ import { basename } from "node:path";
|
|
|
6
6
|
import { getEffectiveConfig, createClient } from "@opvs-ai/core";
|
|
7
7
|
import { buildUrl, printResponse, printJson } from "../lib/format.js";
|
|
8
8
|
import { confirmOrExit, YES_HELP } from "../lib/confirm.js";
|
|
9
|
+
// Keep in sync with the server's FileType enum
|
|
10
|
+
// (apps/spideragent/packages/agentboard/api/app/models/file_attachment.py):
|
|
11
|
+
// these are the seven types the server accepts on `file_type`.
|
|
12
|
+
const FILE_TYPES = [
|
|
13
|
+
"attachment",
|
|
14
|
+
"result",
|
|
15
|
+
"input",
|
|
16
|
+
"document",
|
|
17
|
+
"image",
|
|
18
|
+
"data",
|
|
19
|
+
"other",
|
|
20
|
+
];
|
|
21
|
+
// `screenshot` is a legacy CLI alias; the server never accepted it. Keep
|
|
22
|
+
// mapping it to `image` so existing scripts and muscle memory keep working.
|
|
23
|
+
const FILE_TYPE_ALIASES = {
|
|
24
|
+
screenshot: "image",
|
|
25
|
+
};
|
|
26
|
+
function resolveFileType(raw, fallback = "attachment") {
|
|
27
|
+
const value = raw ?? fallback;
|
|
28
|
+
const resolved = FILE_TYPE_ALIASES[value] ?? value;
|
|
29
|
+
if (!FILE_TYPES.includes(resolved)) {
|
|
30
|
+
throw new Error(`Unknown --type "${raw}". Accepted types: ${FILE_TYPES.join(", ")}.`);
|
|
31
|
+
}
|
|
32
|
+
return resolved;
|
|
33
|
+
}
|
|
9
34
|
export function registerFileCommands(program) {
|
|
10
35
|
const files = program.command("files").description("Task file attachments");
|
|
11
36
|
files
|
|
@@ -29,12 +54,13 @@ export function registerFileCommands(program) {
|
|
|
29
54
|
files
|
|
30
55
|
.command("upload <taskId> <path>")
|
|
31
56
|
.description("Upload a file to a task")
|
|
32
|
-
.option("--type <type>", "File type: attachment, result,
|
|
57
|
+
.option("--type <type>", "File type: attachment, result, input, document, image, data, other", "attachment")
|
|
33
58
|
.option("--description <desc>", "File description")
|
|
34
59
|
.action(async (taskId, filePath, opts) => {
|
|
35
60
|
const wsSlug = program.opts().workspace;
|
|
36
61
|
const cfg = getEffectiveConfig(wsSlug);
|
|
37
62
|
try {
|
|
63
|
+
const fileType = resolveFileType(opts.type);
|
|
38
64
|
const fileData = readFileSync(filePath);
|
|
39
65
|
const fileName = basename(filePath);
|
|
40
66
|
// Build multipart form data manually
|
|
@@ -45,7 +71,7 @@ export function registerFileCommands(program) {
|
|
|
45
71
|
parts.push(fileData);
|
|
46
72
|
parts.push(Buffer.from("\r\n"));
|
|
47
73
|
// file_type part
|
|
48
|
-
parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="file_type"\r\n\r\n${
|
|
74
|
+
parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="file_type"\r\n\r\n${fileType}\r\n`));
|
|
49
75
|
// description part
|
|
50
76
|
if (opts.description) {
|
|
51
77
|
parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="description"\r\n\r\n${opts.description}\r\n`));
|
|
@@ -66,13 +92,14 @@ export function registerFileCommands(program) {
|
|
|
66
92
|
files
|
|
67
93
|
.command("attach-url <taskId> <url>")
|
|
68
94
|
.description("Attach an external URL to a task (YouTube, Vimeo, Loom, image, or any link — OG metadata is fetched server-side)")
|
|
69
|
-
.option("--type <type>", "File type: attachment, result,
|
|
95
|
+
.option("--type <type>", "File type: attachment, result, input, document, image, data, other", "attachment")
|
|
70
96
|
.option("--description <desc>", "Attachment description")
|
|
71
97
|
.action(async (taskId, url, opts) => {
|
|
72
98
|
const wsSlug = program.opts().workspace;
|
|
73
99
|
try {
|
|
100
|
+
const fileType = resolveFileType(opts.type);
|
|
74
101
|
const client = createClient(wsSlug);
|
|
75
|
-
const body = { url, file_type:
|
|
102
|
+
const body = { url, file_type: fileType };
|
|
76
103
|
if (opts.description)
|
|
77
104
|
body.description = opts.description;
|
|
78
105
|
const res = await client.post(`/api/v1/board/tasks/${taskId}/files/url`, body);
|
|
@@ -81,7 +108,7 @@ export function registerFileCommands(program) {
|
|
|
81
108
|
}
|
|
82
109
|
catch (err) {
|
|
83
110
|
const e = err;
|
|
84
|
-
console.error(`Error: ${e.detail || "Failed to attach URL"}`);
|
|
111
|
+
console.error(`Error: ${e.detail || e.message || "Failed to attach URL"}`);
|
|
85
112
|
process.exit(1);
|
|
86
113
|
}
|
|
87
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM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UAAU,CAAC,CAAC,MAAM,IAAI,yBAAyB,EAAE,CAAC,CAAC;YACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,KAAK;SACF,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,iFAAiF,CAAC;SAC9F,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC;SAC7B,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAuB,EAAE,EAAE;QACxD,MAAM,aAAa,CAAC,eAAe,MAAM,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,sCAAsC,CAAC,CAAC;QAChG,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC;QACxC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACpC,MAAM,MAAM,CAAC,MAAM,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;YACrD,OAAO,CAAC,GAAG,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,GAA0B,CAAC;YACrC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,IAAI,uBAAuB,EAAE,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `opvs memory sync` — upload one bounded repository-knowledge snapshot.
|
|
3
|
+
*
|
|
4
|
+
* Git supplies both the repository facts and ignore matching. That keeps this
|
|
5
|
+
* walker aligned with what a developer considers part of the checkout,
|
|
6
|
+
* including nested .gitignore files, without maintaining a second glob parser.
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from "commander";
|
|
9
|
+
export interface KnowledgeFile {
|
|
10
|
+
path: string;
|
|
11
|
+
sha256: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
export interface KnowledgeSnapshot {
|
|
15
|
+
repo: string;
|
|
16
|
+
branch: string;
|
|
17
|
+
commit: string;
|
|
18
|
+
project_id: string;
|
|
19
|
+
files: KnowledgeFile[];
|
|
20
|
+
truncated: {
|
|
21
|
+
reason: string;
|
|
22
|
+
} | null;
|
|
23
|
+
}
|
|
24
|
+
export interface MemorySyncOptions {
|
|
25
|
+
project: string;
|
|
26
|
+
branch?: string;
|
|
27
|
+
dryRun?: boolean;
|
|
28
|
+
allowDirty?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function collectKnowledgeSnapshot(directory: string | undefined, options: Pick<MemorySyncOptions, "project" | "branch" | "allowDirty">): KnowledgeSnapshot;
|
|
31
|
+
export declare function registerMemorySyncCommand(memory: Command, program: Command): void;
|