@kamilio/wire 0.1.68 → 0.1.70
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/adapters/codesignal.d.ts +10 -0
- package/dist/adapters/codesignal.d.ts.map +1 -1
- package/dist/adapters/codesignal.js +178 -6
- package/dist/adapters/codesignal.js.map +1 -1
- package/dist/adapters/root.d.ts +3 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +13 -0
- package/dist/adapters/root.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/executable.js +2 -2
- package/dist/executable.js.map +1 -1
- package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
- package/node_modules/provider-slack/dist/slack.js +37 -14
- package/node_modules/provider-slack/dist/slack.js.map +1 -1
- package/node_modules/provider-slack/src/slack.ts +34 -14
- package/package.json +1 -1
- package/src/adapters/codesignal.ts +178 -9
- package/src/adapters/root.ts +14 -1
- package/src/cli.ts +3 -1
- package/src/executable.ts +2 -2
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { stripVTControlCharacters } from "node:util";
|
|
2
3
|
import type { FetchedDocument, RuntimeCapabilities } from "wire-core";
|
|
3
4
|
|
|
4
5
|
const loginRequired =
|
|
5
6
|
"codesignal cookie authentication is missing or expired. Run `wire codesignal login` once; other commands reuse saved cookies.";
|
|
6
7
|
|
|
8
|
+
type Interview = { candidateId?: string; taskId: string; status: string };
|
|
9
|
+
|
|
7
10
|
type Frame = {
|
|
8
11
|
msg: string;
|
|
9
12
|
id?: string;
|
|
10
13
|
subs?: string[];
|
|
11
14
|
collection?: string;
|
|
12
|
-
fields?:
|
|
15
|
+
fields?: Interview;
|
|
13
16
|
error?: { reason: string };
|
|
14
17
|
result?: unknown;
|
|
15
18
|
};
|
|
@@ -23,7 +26,7 @@ type State = {
|
|
|
23
26
|
executionEnvironment?: string;
|
|
24
27
|
};
|
|
25
28
|
type Solution = {
|
|
26
|
-
taskDoc: { _id: string; name: string };
|
|
29
|
+
taskDoc: { _id: string; name: string; persistentSessionSupport?: boolean; filesystemSupport?: boolean };
|
|
27
30
|
solutions: { finalState?: State; submission?: State };
|
|
28
31
|
levelId?: string;
|
|
29
32
|
};
|
|
@@ -40,7 +43,7 @@ async function session<T>(
|
|
|
40
43
|
read: (
|
|
41
44
|
user: string,
|
|
42
45
|
method: <R>(name: string, ...params: unknown[]) => Promise<R>,
|
|
43
|
-
interview: (id: string) => Promise<
|
|
46
|
+
interview: (id: string) => Promise<Interview | undefined>,
|
|
44
47
|
) => Promise<T>,
|
|
45
48
|
): Promise<T | null> {
|
|
46
49
|
const socket = new WebSocket("wss://app.codesignal.com/websocket");
|
|
@@ -60,7 +63,7 @@ async function session<T>(
|
|
|
60
63
|
finish();
|
|
61
64
|
reject(new Error("CodeSignal connection interrupted."));
|
|
62
65
|
};
|
|
63
|
-
const timer = setTimeout(fail,
|
|
66
|
+
const timer = setTimeout(fail, 60000);
|
|
64
67
|
const options = { signal: listeners.signal };
|
|
65
68
|
socket.addEventListener("error", fail, options);
|
|
66
69
|
socket.addEventListener("close", fail, options);
|
|
@@ -109,7 +112,7 @@ async function session<T>(
|
|
|
109
112
|
return result.result as R;
|
|
110
113
|
},
|
|
111
114
|
async (interviewId) => {
|
|
112
|
-
let
|
|
115
|
+
let current: Interview | undefined;
|
|
113
116
|
for (const name of [
|
|
114
117
|
"liveInterviews.byId",
|
|
115
118
|
"liveInterviews.finished.byId",
|
|
@@ -123,7 +126,7 @@ async function session<T>(
|
|
|
123
126
|
f.collection === "liveInterviews" &&
|
|
124
127
|
f.id === interviewId
|
|
125
128
|
)
|
|
126
|
-
|
|
129
|
+
current = f.fields;
|
|
127
130
|
if (f.msg === "nosub" && f.id === id)
|
|
128
131
|
throw new Error("CodeSignal: " + f.error?.reason);
|
|
129
132
|
return f.msg === "ready" && f.subs?.includes(id)
|
|
@@ -131,9 +134,9 @@ async function session<T>(
|
|
|
131
134
|
: undefined;
|
|
132
135
|
},
|
|
133
136
|
);
|
|
134
|
-
if (
|
|
137
|
+
if (current) break;
|
|
135
138
|
}
|
|
136
|
-
return
|
|
139
|
+
return current;
|
|
137
140
|
},
|
|
138
141
|
);
|
|
139
142
|
} finally {
|
|
@@ -200,7 +203,7 @@ export async function previewCodeSignal(
|
|
|
200
203
|
const { token } = await runtime.cookies.metadata("codesignal");
|
|
201
204
|
if (!token) throw new Error(loginRequired);
|
|
202
205
|
const result = await session(token, async (user, method, interview) => {
|
|
203
|
-
const replayUser = await interview(id);
|
|
206
|
+
const replayUser = (await interview(id))?.candidateId;
|
|
204
207
|
const questions = await method<
|
|
205
208
|
(Solution | { type: "progressive"; taskLevels: Solution[] })[]
|
|
206
209
|
>("liveInterviewService.getSolutions", id);
|
|
@@ -242,3 +245,169 @@ export async function previewCodeSignal(
|
|
|
242
245
|
if (!result) throw new Error(loginRequired);
|
|
243
246
|
return result;
|
|
244
247
|
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
type Method = <R>(name: string, ...params: unknown[]) => Promise<R>;
|
|
251
|
+
type Runner = { runnerId: string; clientToken: string; sessionKey: string; executionEnvironment: string };
|
|
252
|
+
|
|
253
|
+
async function collaboration<T>(runner: Runner, work: (call: Method) => Promise<T>): Promise<T> {
|
|
254
|
+
const socket = new WebSocket(`wss://${runner.runnerId}.ide.codesignal.com/services-lc/websocket?token=${runner.clientToken}`);
|
|
255
|
+
const connectionId = randomUUID();
|
|
256
|
+
let messageNumber = 0;
|
|
257
|
+
let requestId = 0;
|
|
258
|
+
const pending = new Map<number, { resolve: (value: any) => void; reject: (error: Error) => void }>();
|
|
259
|
+
const send = (value: object) => socket.send(JSON.stringify({ connectionId, ...value }));
|
|
260
|
+
const data = (value: object) => send({ messageType: "application-message", messageNumber: messageNumber++, data: value });
|
|
261
|
+
let ready: () => void;
|
|
262
|
+
let failed: (error: Error) => void;
|
|
263
|
+
const connected = new Promise<void>((resolve, reject) => { ready = resolve; failed = reject; });
|
|
264
|
+
const fail = () => {
|
|
265
|
+
const error = new Error("CodeSignal editor connection interrupted.");
|
|
266
|
+
failed(error);
|
|
267
|
+
for (const request of pending.values()) request.reject(error);
|
|
268
|
+
};
|
|
269
|
+
const timer = setTimeout(fail, 60000);
|
|
270
|
+
socket.addEventListener("error", fail);
|
|
271
|
+
socket.addEventListener("close", fail);
|
|
272
|
+
socket.addEventListener("open", () => send({ messageType: "initialization", data: null }));
|
|
273
|
+
socket.addEventListener("message", event => {
|
|
274
|
+
const frame = JSON.parse(String(event.data));
|
|
275
|
+
if (frame.messageType === "handshake-completed") data({ kind: "open", id: 0, path: "/services/collaboration" });
|
|
276
|
+
if (frame.messageType !== "application-message") return;
|
|
277
|
+
send({ messageType: "acknowledgement", messageNumber: frame.messageNumber });
|
|
278
|
+
if (frame.data.kind === "ready") ready();
|
|
279
|
+
if (frame.data.kind === "data") {
|
|
280
|
+
const response = JSON.parse(frame.data.content);
|
|
281
|
+
const request = pending.get(response.id);
|
|
282
|
+
if (!request) return;
|
|
283
|
+
pending.delete(response.id);
|
|
284
|
+
if (response.error) request.reject(new Error("CodeSignal: " + response.error.message));
|
|
285
|
+
else request.resolve(response.result);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
try {
|
|
289
|
+
await connected;
|
|
290
|
+
return await work(<R>(method: string, ...params: unknown[]) => new Promise<R>((resolve, reject) => {
|
|
291
|
+
const id = requestId++;
|
|
292
|
+
pending.set(id, { resolve, reject });
|
|
293
|
+
data({ kind: "data", id: 0, content: JSON.stringify({ jsonrpc: "2.0", id, method, params }) });
|
|
294
|
+
}));
|
|
295
|
+
} finally {
|
|
296
|
+
clearTimeout(timer);
|
|
297
|
+
socket.removeEventListener("close", fail);
|
|
298
|
+
socket.close();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function editor<T>(runtime: RuntimeCapabilities, url: string, work: (runner: Runner, taskId: string, user: string, method: Method, call: Method) => Promise<T>): Promise<T> {
|
|
303
|
+
const id = codeSignalInterviewId(url);
|
|
304
|
+
if (!id) throw new Error("Expected a CodeSignal live-interview URL.");
|
|
305
|
+
const { token } = await runtime.cookies.metadata("codesignal");
|
|
306
|
+
if (!token) throw new Error(loginRequired);
|
|
307
|
+
const result = await session(token, async (user, method, interview) => {
|
|
308
|
+
const current = await interview(id);
|
|
309
|
+
if (!current || current.status === "finished") throw new Error("CodeSignal interview is not active.");
|
|
310
|
+
const solutions = await method<Solution[]>("liveInterviewService.getSolutions", id);
|
|
311
|
+
const solution = solutions.find(s => s.taskDoc?._id === current.taskId);
|
|
312
|
+
if (!solution?.taskDoc.persistentSessionSupport || !solution.taskDoc.filesystemSupport)
|
|
313
|
+
throw new Error("CodeSignal editing and running require a filesystem coding question.");
|
|
314
|
+
const state = solution.solutions.finalState ?? solution.solutions.submission;
|
|
315
|
+
const runner = await method<Runner>("persistentSession.maybeCreate", { taskId: current.taskId },
|
|
316
|
+
{ mode: "live-interview", liveInterviewId: id, role: "interviewer" },
|
|
317
|
+
{ preferredEnvironment: state!.executionEnvironment, language: null }, null);
|
|
318
|
+
return collaboration(runner, call => work(runner, current.taskId, user, method, call));
|
|
319
|
+
});
|
|
320
|
+
if (result === null) throw new Error(loginRequired);
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export async function editCodeSignal(runtime: RuntimeCapabilities, url: string, path: string, source: string) {
|
|
325
|
+
if (!path || path.startsWith("/") || path.split("/").some(p => p === ".." || p === "." || p === ""))
|
|
326
|
+
throw new Error("Expected a file path relative to the CodeSignal project.");
|
|
327
|
+
return editor(runtime, url, async (_runner, _taskId, _user, _method, call) => {
|
|
328
|
+
const uri = "file:///usercode/FILESYSTEM/" + path.split("/").map(encodeURIComponent).join("/");
|
|
329
|
+
const state = await call<{ revisionVersion: number; fileContent: string } | null>("getFileServerState", uri, "utf8");
|
|
330
|
+
if (!state) throw new Error("CodeSignal file does not exist: " + path);
|
|
331
|
+
if (state.fileContent !== source) {
|
|
332
|
+
const operations: (string | number)[] = [];
|
|
333
|
+
if (source.length) operations.push(source);
|
|
334
|
+
if (state.fileContent.length) operations.push(-state.fileContent.length);
|
|
335
|
+
await call("fileCodeChanged", uri, state.revisionVersion, operations);
|
|
336
|
+
await call("saveUpdatedFiles");
|
|
337
|
+
}
|
|
338
|
+
return { url, path };
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function recordRun<T>(runtime: RuntimeCapabilities, url: string, runner: Runner, taskId: string, user: string, method: Method, execute: (executionId: string) => Promise<T>) {
|
|
343
|
+
const id = codeSignalInterviewId(url);
|
|
344
|
+
const { connectionUrl, liveRecordingServerJWT } = await method<{ connectionUrl: string; liveRecordingServerJWT: string }>("liveRecordingService.getConnectionDetails", {
|
|
345
|
+
sessionInfo: { liveInterviewId: id, taskId, mode: 0 }, language: runner.executionEnvironment, executionEnvironment: runner.executionEnvironment,
|
|
346
|
+
});
|
|
347
|
+
const { token } = await runtime.cookies.metadata("codesignal");
|
|
348
|
+
const endpoint = new URL(connectionUrl + "/websocket");
|
|
349
|
+
endpoint.protocol = "wss:";
|
|
350
|
+
const socket = new WebSocket(endpoint);
|
|
351
|
+
const connectionId = randomUUID();
|
|
352
|
+
const signature = randomUUID();
|
|
353
|
+
const executionId = `${Date.now()}-${user}-${taskId}`;
|
|
354
|
+
let version: number;
|
|
355
|
+
let number = 0;
|
|
356
|
+
const waiting = new Map<number, { resolve: () => void; reject: (error: Error) => void }>();
|
|
357
|
+
const initialized = new Promise<void>((resolve, reject) => waiting.set(-1, { resolve, reject }));
|
|
358
|
+
const send = (frame: object) => socket.send(JSON.stringify({ connectionId, ...frame }));
|
|
359
|
+
const fail = () => { for (const pending of waiting.values()) pending.reject(new Error("CodeSignal recording connection interrupted.")); };
|
|
360
|
+
const timer = setTimeout(fail, 60000);
|
|
361
|
+
socket.addEventListener("error", fail);
|
|
362
|
+
socket.addEventListener("close", fail);
|
|
363
|
+
socket.addEventListener("open", () => send({ messageType: "initialization", data: {
|
|
364
|
+
identifiers: { loginToken: token, localId: "user@" + user },
|
|
365
|
+
options: { mode: "live-interview", liveInterviewId: id, role: null, taskId, executionEnvironment: runner.executionEnvironment,
|
|
366
|
+
language: runner.executionEnvironment, signature, sessionId: id + "-" + taskId, liveRecordingServerJWT },
|
|
367
|
+
} }));
|
|
368
|
+
socket.addEventListener("message", event => {
|
|
369
|
+
const frame = JSON.parse(String(event.data));
|
|
370
|
+
if (frame.messageType === "acknowledgement") {
|
|
371
|
+
waiting.get(frame.messageNumber)?.resolve();
|
|
372
|
+
waiting.delete(frame.messageNumber);
|
|
373
|
+
}
|
|
374
|
+
if (frame.messageType === "application-message") {
|
|
375
|
+
send({ messageType: "acknowledgement", messageNumber: frame.messageNumber });
|
|
376
|
+
if (frame.data.type === "init") {
|
|
377
|
+
version = frame.data.message.version;
|
|
378
|
+
waiting.get(-1)!.resolve();
|
|
379
|
+
waiting.delete(-1);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
const record = (event: object) => new Promise<void>((resolve, reject) => {
|
|
384
|
+
const messageNumber = number++;
|
|
385
|
+
waiting.set(messageNumber, { resolve, reject });
|
|
386
|
+
send({ messageType: "application-message", messageNumber, data: { type: "event", data: { signature, version, eventNumber: number, event } } });
|
|
387
|
+
});
|
|
388
|
+
try {
|
|
389
|
+
await initialized;
|
|
390
|
+
await record({ action: "runClicked", onlyCustomTests: false, runMode: "raw", executionId });
|
|
391
|
+
const result = await execute(executionId);
|
|
392
|
+
await record({ action: "runResult", testResults: JSON.stringify(result) });
|
|
393
|
+
return result;
|
|
394
|
+
} finally {
|
|
395
|
+
clearTimeout(timer);
|
|
396
|
+
socket.removeEventListener("close", fail);
|
|
397
|
+
socket.close();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export async function runCodeSignal(runtime: RuntimeCapabilities, url: string) {
|
|
402
|
+
return editor(runtime, url, async (runner, taskId, user, method, call) => {
|
|
403
|
+
await call("saveUpdatedFiles");
|
|
404
|
+
return recordRun(runtime, url, runner, taskId, user, method, executionId =>
|
|
405
|
+
method<{ verdict: string; output: string; compilationLog: string; runTime: number }>("taskService.getRunRawResult", {
|
|
406
|
+
taskId,
|
|
407
|
+
submission: { processedSources: null, sources: [], recordingKey: taskId, executionEnvironment: runner.executionEnvironment, executionEnvironmentTimeLimit: 30000 },
|
|
408
|
+
context: { mode: "live-interview", liveInterviewId: codeSignalInterviewId(url), role: "interviewer" },
|
|
409
|
+
sessionKey: runner.sessionKey,
|
|
410
|
+
executionId,
|
|
411
|
+
}));
|
|
412
|
+
});
|
|
413
|
+
}
|
package/src/adapters/root.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { editCodeSignal, runCodeSignal } from "./codesignal.js";
|
|
1
2
|
import { UserError, defineCommand, defineGroup, S, type Group } from "toolcraft";
|
|
2
3
|
|
|
3
4
|
import { defaultWireBackend, registryPathForBackend, type JsonObject, type FetchedDocument, type InitializedWire, type Resource, type SwitchedWireBackend, type Wire, type WireBackend, type WireResult, type WireWatchSession } from "wire-core";
|
|
@@ -13,7 +14,7 @@ import { formatDocComments, type listDocComments, type changeDocComment } from "
|
|
|
13
14
|
type Comments = { comments?: Awaited<ReturnType<typeof listDocComments>> };
|
|
14
15
|
export type WireRoot = Group;
|
|
15
16
|
export type TextInputReader = () => Promise<string>;
|
|
16
|
-
export type WireRootOptions = Readonly<{ allowPaste: boolean; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
17
|
+
export type WireRootOptions = Readonly<{ allowPaste: boolean; codeSignalEdit?: (url: string, path: string, file: string) => ReturnType<typeof editCodeSignal>; codeSignalRun?: (url: string) => ReturnType<typeof runCodeSignal>; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
17
18
|
|
|
18
19
|
const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
19
20
|
const removedCliCommandNames = Object.freeze({
|
|
@@ -515,6 +516,18 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
515
516
|
const authCommand = (service: (typeof authServices)[number]) => {
|
|
516
517
|
const title = serviceTitle(service);
|
|
517
518
|
const group = authGroup(service, `Manage ${title} login.`, "Capture cookies once; normal commands reuse saved cookies.", auth!, readInput, options);
|
|
519
|
+
if (service === "codesignal" && options.codeSignalEdit && options.codeSignalRun) return defineGroup({ ...group,
|
|
520
|
+
description: "Read, edit, and run live interview code, and manage login.", children: [...group.children,
|
|
521
|
+
defineCommand({ name: "edit", description: "Replace a file in the current filesystem coding question from a local UTF-8 file.", positional: ["url", "path"],
|
|
522
|
+
params: S.Object({ url: S.String(), path: S.String(), file: S.String({ description: "Local UTF-8 file containing the replacement code." }) }),
|
|
523
|
+
handler: ({ params }) => userFacing(() => options.codeSignalEdit!(params.url, params.path, params.file)),
|
|
524
|
+
render: render((v: Awaited<ReturnType<typeof editCodeSignal>>) => "Updated " + v.path),
|
|
525
|
+
}),
|
|
526
|
+
defineCommand({ name: "run", description: "Run the current filesystem coding question and return its verdict and output.", positional: ["url"],
|
|
527
|
+
params: S.Object({ url: S.String() }), handler: ({ params }) => userFacing(() => options.codeSignalRun!(params.url)),
|
|
528
|
+
render: render((v: Awaited<ReturnType<typeof runCodeSignal>>) => ["Verdict: " + v.verdict, v.compilationLog, v.output].filter(Boolean).join("\n")),
|
|
529
|
+
}),
|
|
530
|
+
] });
|
|
518
531
|
if (service === "google-docs" && options.changeDocComment) {
|
|
519
532
|
const thread = S.String({ description: "Google Docs thread URL from --comments." });
|
|
520
533
|
return defineGroup({ ...group, children: [...group.children, defineGroup({ name: "comments", description: "Reply to, resolve, or reopen Google Docs threads.", children:
|
package/src/cli.ts
CHANGED
|
@@ -249,6 +249,7 @@ function excessPositionals(argv: readonly string[]): Readonly<{ commandPath: str
|
|
|
249
249
|
if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
|
|
250
250
|
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
|
|
251
251
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
|
|
252
|
+
if (command === "codesignal" && (words[1] === "edit" || words[1] === "run")) return { commandPath: `codesignal ${words[1]}`, expected: words[1] === "edit" ? 2 : 1, received: words.length - 2 };
|
|
252
253
|
if (command === "claude" && words[1] === "scrape") return { commandPath: "claude scrape", expected: 0, received: words.length - 2 };
|
|
253
254
|
if (command === "gdrive" && (words[1] === "scrape" || words[1] === "preview")) return { commandPath: `gdrive ${words[1]}`, expected: 1, received: words.length - 2 };
|
|
254
255
|
if (command === "zoom" && words[1] === "scrape") return { commandPath: "zoom scrape", expected: 0, received: words.length - 2 };
|
|
@@ -271,6 +272,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
|
|
|
271
272
|
if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
|
|
272
273
|
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
|
|
273
274
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit") && words.length < 4) return { commandPath: `slack ${words[1]}`, name: words.length === 2 ? words[1] === "send" ? "destination" : "url" : "markdown" };
|
|
275
|
+
if (command === "codesignal" && (words[1] === "edit" || words[1] === "run") && words.length < (words[1] === "edit" ? 4 : 3)) return { commandPath: `codesignal ${words[1]}`, name: words.length === 2 ? "url" : "path" };
|
|
274
276
|
if (!(command in fixedCommandPositionals)) return null;
|
|
275
277
|
const positional = fixedCommandPositionals[command as keyof typeof fixedCommandPositionals];
|
|
276
278
|
if (words.length - 1 >= positional.expected || positional.expected === 0) return null;
|
|
@@ -306,7 +308,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
|
|
|
306
308
|
function renderUnknownAuthCommand(argv: readonly string[]): boolean {
|
|
307
309
|
if (hasRootSeparator(argv)) return false;
|
|
308
310
|
const words = positionalWords(argv);
|
|
309
|
-
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
311
|
+
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "codesignal" && ["edit", "run"].includes(words[1]!)) || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
310
312
|
renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
|
|
311
313
|
return true;
|
|
312
314
|
}
|
package/src/executable.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { lookupNotionUsers, shareNotionWithOrg } from "provider-notion";
|
|
|
11
11
|
|
|
12
12
|
import { changeDocComment, listDocComments } from "./adapters/doc-comments.js";
|
|
13
13
|
import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
|
|
14
|
-
import { codeSignalInterviewId, previewCodeSignal } from "./adapters/codesignal.js";
|
|
14
|
+
import { codeSignalInterviewId, editCodeSignal, previewCodeSignal, runCodeSignal } from "./adapters/codesignal.js";
|
|
15
15
|
import { ashby } from "./adapters/ashby.js";
|
|
16
16
|
import { scrapeClaude } from "./adapters/claude.js";
|
|
17
17
|
import { readAgenda } from "./adapters/calendar.js";
|
|
@@ -144,7 +144,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
144
144
|
switchBackend: baseWire.switchBackend,
|
|
145
145
|
});
|
|
146
146
|
const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
|
|
147
|
-
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
147
|
+
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, codeSignalEdit: async (url,path,file) => editCodeSignal(runtime,url,path,await filesystem.readText(resolve(currentDirectory,file))), codeSignalRun: url => runCodeSignal(runtime,url), shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
148
148
|
lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
149
149
|
writes: { move: (task, project, section) => moveAsanaTask(runtime, task, project, section), create: (project, title, section, body, assignee) => createAsanaTask(runtime, project, title, section, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
|
|
150
150
|
}, async () => {
|