@kamilio/wire 0.1.55 → 0.1.57

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 (138) hide show
  1. package/README.md +44 -1
  2. package/dist/adapters/codesignal.d.ts +10 -0
  3. package/dist/adapters/codesignal.d.ts.map +1 -0
  4. package/dist/adapters/codesignal.js +165 -0
  5. package/dist/adapters/codesignal.js.map +1 -0
  6. package/dist/adapters/document-shell.d.ts +7 -0
  7. package/dist/adapters/document-shell.d.ts.map +1 -0
  8. package/dist/adapters/document-shell.js +51 -0
  9. package/dist/adapters/document-shell.js.map +1 -0
  10. package/dist/adapters/root.d.ts.map +1 -1
  11. package/dist/adapters/root.js +74 -8
  12. package/dist/adapters/root.js.map +1 -1
  13. package/dist/auth.d.ts +2 -1
  14. package/dist/auth.d.ts.map +1 -1
  15. package/dist/auth.js +4 -2
  16. package/dist/auth.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +10 -4
  19. package/dist/cli.js.map +1 -1
  20. package/dist/document-shell-engine.mjs +1880 -0
  21. package/dist/executable.d.ts.map +1 -1
  22. package/dist/executable.js +3 -2
  23. package/dist/executable.js.map +1 -1
  24. package/dist/hooks.d.ts.map +1 -1
  25. package/dist/hooks.js +19 -19
  26. package/dist/hooks.js.map +1 -1
  27. package/node_modules/provider-asana/dist/asana-project.d.ts +7 -1
  28. package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
  29. package/node_modules/provider-asana/dist/asana-task.d.ts +7 -1
  30. package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
  31. package/node_modules/provider-asana/dist/index.d.ts +14 -2
  32. package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
  33. package/node_modules/provider-chatgpt/dist/chatgpt.d.ts +7 -1
  34. package/node_modules/provider-chatgpt/dist/chatgpt.d.ts.map +1 -1
  35. package/node_modules/provider-chatgpt/dist/index.d.ts +7 -1
  36. package/node_modules/provider-chatgpt/dist/index.d.ts.map +1 -1
  37. package/node_modules/provider-gmail/dist/gmail.d.ts +7 -1
  38. package/node_modules/provider-gmail/dist/gmail.d.ts.map +1 -1
  39. package/node_modules/provider-gmail/dist/index.d.ts +7 -1
  40. package/node_modules/provider-gmail/dist/index.d.ts.map +1 -1
  41. package/node_modules/provider-google-docs/dist/doc-blocks.d.ts.map +1 -1
  42. package/node_modules/provider-google-docs/dist/doc-blocks.js +6 -2
  43. package/node_modules/provider-google-docs/dist/doc-blocks.js.map +1 -1
  44. package/node_modules/provider-google-docs/dist/google-docs.d.ts +7 -1
  45. package/node_modules/provider-google-docs/dist/google-docs.d.ts.map +1 -1
  46. package/node_modules/provider-google-docs/dist/google-docs.js +31 -10
  47. package/node_modules/provider-google-docs/dist/google-docs.js.map +1 -1
  48. package/node_modules/provider-google-docs/dist/google-forms.d.ts +7 -1
  49. package/node_modules/provider-google-docs/dist/google-forms.d.ts.map +1 -1
  50. package/node_modules/provider-google-docs/dist/index.d.ts +14 -2
  51. package/node_modules/provider-google-docs/dist/index.d.ts.map +1 -1
  52. package/node_modules/provider-google-docs/src/doc-blocks.ts +8 -2
  53. package/node_modules/provider-google-docs/src/google-docs.ts +26 -10
  54. package/node_modules/provider-lattice/dist/index.d.ts +14 -2
  55. package/node_modules/provider-lattice/dist/index.d.ts.map +1 -1
  56. package/node_modules/provider-notion/dist/index.d.ts +7 -1
  57. package/node_modules/provider-notion/dist/index.d.ts.map +1 -1
  58. package/node_modules/provider-notion/dist/notion-sync.d.ts +2 -2
  59. package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
  60. package/node_modules/provider-notion/dist/notion-sync.js +24 -15
  61. package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
  62. package/node_modules/provider-notion/dist/notion.d.ts +7 -1
  63. package/node_modules/provider-notion/dist/notion.d.ts.map +1 -1
  64. package/node_modules/provider-notion/dist/notion.js +1 -1
  65. package/node_modules/provider-notion/dist/notion.js.map +1 -1
  66. package/node_modules/provider-notion/src/notion-sync.ts +23 -15
  67. package/node_modules/provider-notion/src/notion.ts +1 -1
  68. package/node_modules/provider-slack/dist/index.d.ts +7 -1
  69. package/node_modules/provider-slack/dist/index.d.ts.map +1 -1
  70. package/node_modules/provider-slack/dist/slack.d.ts +7 -1
  71. package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
  72. package/node_modules/provider-zoom/dist/index.d.ts +7 -1
  73. package/node_modules/provider-zoom/dist/index.d.ts.map +1 -1
  74. package/node_modules/provider-zoom/dist/zoom-hub.d.ts +7 -1
  75. package/node_modules/provider-zoom/dist/zoom-hub.d.ts.map +1 -1
  76. package/node_modules/wire-core/dist/core/editor-receipts.d.ts +5 -0
  77. package/node_modules/wire-core/dist/core/editor-receipts.d.ts.map +1 -0
  78. package/node_modules/wire-core/dist/core/editor-receipts.js +9 -0
  79. package/node_modules/wire-core/dist/core/editor-receipts.js.map +1 -0
  80. package/node_modules/wire-core/dist/core/model.d.ts +4 -1
  81. package/node_modules/wire-core/dist/core/model.d.ts.map +1 -1
  82. package/node_modules/wire-core/dist/core/owner.d.ts +3 -0
  83. package/node_modules/wire-core/dist/core/owner.d.ts.map +1 -0
  84. package/node_modules/wire-core/dist/core/owner.js +16 -0
  85. package/node_modules/wire-core/dist/core/owner.js.map +1 -0
  86. package/node_modules/wire-core/dist/core/source.d.ts +4 -1
  87. package/node_modules/wire-core/dist/core/source.d.ts.map +1 -1
  88. package/node_modules/wire-core/dist/core/source.js +12 -2
  89. package/node_modules/wire-core/dist/core/source.js.map +1 -1
  90. package/node_modules/wire-core/dist/index.d.ts +1 -1
  91. package/node_modules/wire-core/dist/index.d.ts.map +1 -1
  92. package/node_modules/wire-core/dist/index.js +1 -1
  93. package/node_modules/wire-core/dist/index.js.map +1 -1
  94. package/node_modules/wire-core/dist/operations.d.ts +11 -2
  95. package/node_modules/wire-core/dist/operations.d.ts.map +1 -1
  96. package/node_modules/wire-core/dist/operations.js +399 -31
  97. package/node_modules/wire-core/dist/operations.js.map +1 -1
  98. package/node_modules/wire-core/dist/runtime/cookies.js +1 -1
  99. package/node_modules/wire-core/dist/runtime/cookies.js.map +1 -1
  100. package/node_modules/wire-core/dist/storage/editor-receipts.d.ts +17 -0
  101. package/node_modules/wire-core/dist/storage/editor-receipts.d.ts.map +1 -0
  102. package/node_modules/wire-core/dist/storage/editor-receipts.js +27 -0
  103. package/node_modules/wire-core/dist/storage/editor-receipts.js.map +1 -0
  104. package/node_modules/wire-core/dist/storage/history-integrity.d.ts +4 -0
  105. package/node_modules/wire-core/dist/storage/history-integrity.d.ts.map +1 -0
  106. package/node_modules/wire-core/dist/storage/history-integrity.js +32 -0
  107. package/node_modules/wire-core/dist/storage/history-integrity.js.map +1 -0
  108. package/node_modules/wire-core/dist/storage/history.d.ts +93 -0
  109. package/node_modules/wire-core/dist/storage/history.d.ts.map +1 -0
  110. package/node_modules/wire-core/dist/storage/history.js +450 -0
  111. package/node_modules/wire-core/dist/storage/history.js.map +1 -0
  112. package/node_modules/wire-core/dist/storage/registry.d.ts +2 -2
  113. package/node_modules/wire-core/dist/storage/registry.d.ts.map +1 -1
  114. package/node_modules/wire-core/dist/storage/registry.js +34 -14
  115. package/node_modules/wire-core/dist/storage/registry.js.map +1 -1
  116. package/node_modules/wire-core/dist/storage/workspace.d.ts.map +1 -1
  117. package/node_modules/wire-core/dist/storage/workspace.js +183 -40
  118. package/node_modules/wire-core/dist/storage/workspace.js.map +1 -1
  119. package/node_modules/wire-core/src/core/editor-receipts.ts +8 -0
  120. package/node_modules/wire-core/src/core/model.ts +4 -1
  121. package/node_modules/wire-core/src/core/owner.ts +16 -0
  122. package/node_modules/wire-core/src/core/source.ts +13 -1
  123. package/node_modules/wire-core/src/index.ts +1 -1
  124. package/node_modules/wire-core/src/operations.ts +339 -33
  125. package/node_modules/wire-core/src/runtime/cookies.ts +1 -1
  126. package/node_modules/wire-core/src/storage/editor-receipts.ts +27 -0
  127. package/node_modules/wire-core/src/storage/history-integrity.ts +25 -0
  128. package/node_modules/wire-core/src/storage/history.ts +331 -0
  129. package/node_modules/wire-core/src/storage/registry.ts +22 -15
  130. package/node_modules/wire-core/src/storage/workspace.ts +129 -34
  131. package/package.json +6 -2
  132. package/src/adapters/codesignal.ts +244 -0
  133. package/src/adapters/document-shell.ts +43 -0
  134. package/src/adapters/root.ts +76 -8
  135. package/src/auth.ts +6 -3
  136. package/src/cli.ts +10 -4
  137. package/src/executable.ts +3 -2
  138. package/src/hooks.ts +19 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamilio/wire",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "Attach Notion, Google Docs, Slack, Gmail, Asana, ChatGPT, and Zoom resources as local Markdown you can sync.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -91,7 +91,7 @@
91
91
  "yaml"
92
92
  ],
93
93
  "scripts": {
94
- "build": "tsc -p tsconfig.json && echo 'export { PdfDocument, dictGet } from \"@poe-platform/safe-bash/pdf-ast\"' | esbuild --bundle --platform=node --format=esm --target=node20 --minify --outfile=dist/pdf-reader.mjs && cp -R ../../node_modules/@poe-platform/safe-bash/third-party/pdf-ast/. dist/adapters/pdf-notices/ && echo 'export { convert } from \"@poe-platform/safe-bash/commands/pandoc\"' | esbuild --bundle --platform=node --format=esm --target=node20 --minify --outfile=dist/docx-converter.mjs && cp ../../node_modules/@poe-platform/safe-bash/LICENSE dist/docx-converter.LICENSE",
94
+ "build": "tsc -p tsconfig.json && echo 'export { PdfDocument, dictGet } from \"@poe-platform/safe-bash/pdf-ast\"' | esbuild --bundle --platform=node --format=esm --target=node20 --minify --outfile=dist/pdf-reader.mjs && cp -R ../../node_modules/@poe-platform/safe-bash/third-party/pdf-ast/. dist/adapters/pdf-notices/ && echo 'export { convert } from \"@poe-platform/safe-bash/commands/pandoc\"' | esbuild --bundle --platform=node --format=esm --target=node20 --minify --outfile=dist/docx-converter.mjs && cp ../../node_modules/@poe-platform/safe-bash/LICENSE dist/docx-converter.LICENSE && echo 'export { cloudflareWorkerLimits, createMemoryFileSystem, diffCommands, Shell, standardCommands, textProgramCommands } from \"@poe-platform/safe-bash/core\"' | esbuild --bundle --platform=browser --format=esm --target=es2022 --minify --outfile=dist/document-shell-engine.mjs",
95
95
  "dev-link": "npm link",
96
96
  "prepack": "cp ../../README.md README.md && rm -rf node_modules && mkdir -p node_modules/@mixmark-io node_modules/@xmldom && for package in provider-asana provider-chatgpt provider-gmail provider-google-docs provider-lattice provider-notion provider-slack provider-zoom wire-core; do cp -R ../$package node_modules/$package; done && for package in @mixmark-io/domino @xmldom/xmldom entities turndown marked ajv commander fast-deep-equal fast-string-truncated-width fast-string-width fast-wrap-ansi fast-uri ignore jose jsonc-parser json-schema-traverse pct-encode require-from-string sisteransi smol-toml tiny-stdio-mcp-server toolcraft toolcraft-schema uri-template uri-template-lite yaml; do cp -R ../../node_modules/$package node_modules/$package; done",
97
97
  "postpack": "rm -rf node_modules README.md",
@@ -188,6 +188,10 @@
188
188
  "#docx-converter": {
189
189
  "types": "@poe-platform/safe-bash/commands/pandoc",
190
190
  "default": "./dist/docx-converter.mjs"
191
+ },
192
+ "#document-shell-engine": {
193
+ "types": "@poe-platform/safe-bash/core",
194
+ "default": "./dist/document-shell-engine.mjs"
191
195
  }
192
196
  }
193
197
  }
@@ -0,0 +1,244 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ import type { FetchedDocument, RuntimeCapabilities } from "wire-core";
3
+
4
+ const loginRequired =
5
+ "codesignal cookie authentication is missing or expired. Run `wire codesignal login` once; other commands reuse saved cookies.";
6
+
7
+ type Frame = {
8
+ msg: string;
9
+ id?: string;
10
+ subs?: string[];
11
+ collection?: string;
12
+ fields?: { candidateId?: string };
13
+ error?: { reason: string };
14
+ result?: unknown;
15
+ };
16
+ type State = {
17
+ sources?: {
18
+ path: string;
19
+ source: string;
20
+ isHidden?: boolean;
21
+ excluded?: boolean;
22
+ }[];
23
+ executionEnvironment?: string;
24
+ };
25
+ type Solution = {
26
+ taskDoc: { _id: string; name: string };
27
+ solutions: { finalState?: State; submission?: State };
28
+ levelId?: string;
29
+ };
30
+ type RecordingEvent = {
31
+ action: string;
32
+ id: string;
33
+ command: string;
34
+ terminal?: { terminalContents: Record<string, string> };
35
+ testResults: string;
36
+ };
37
+
38
+ async function session<T>(
39
+ token: string,
40
+ read: (
41
+ user: string,
42
+ method: <R>(name: string, ...params: unknown[]) => Promise<R>,
43
+ interview: (id: string) => Promise<string | undefined>,
44
+ ) => Promise<T>,
45
+ ): Promise<T | null> {
46
+ const socket = new WebSocket("wss://app.codesignal.com/websocket");
47
+ let sequence = 0;
48
+ const send = (value: object) => socket.send(JSON.stringify(value));
49
+ const exchange = <R>(
50
+ start: object,
51
+ accept: (frame: Frame) => { value: R } | undefined,
52
+ ) =>
53
+ new Promise<R>((resolve, reject) => {
54
+ const listeners = new AbortController();
55
+ const finish = () => {
56
+ clearTimeout(timer);
57
+ listeners.abort();
58
+ };
59
+ const fail = () => {
60
+ finish();
61
+ reject(new Error("CodeSignal connection interrupted."));
62
+ };
63
+ const timer = setTimeout(fail, 30000);
64
+ const options = { signal: listeners.signal };
65
+ socket.addEventListener("error", fail, options);
66
+ socket.addEventListener("close", fail, options);
67
+ socket.addEventListener(
68
+ "message",
69
+ (event) => {
70
+ try {
71
+ const frame = JSON.parse(String(event.data)) as Frame;
72
+ if (frame.msg === "ping") {
73
+ send({ msg: "pong", id: frame.id });
74
+ return;
75
+ }
76
+ const result = accept(frame);
77
+ if (result) {
78
+ finish();
79
+ resolve(result.value);
80
+ }
81
+ } catch (error) {
82
+ finish();
83
+ reject(error);
84
+ }
85
+ },
86
+ options,
87
+ );
88
+ if (socket.readyState === WebSocket.CONNECTING)
89
+ socket.addEventListener("open", () => send(start), options);
90
+ else send(start);
91
+ });
92
+ const call = (name: string, params: unknown[]) => {
93
+ const id = String(++sequence);
94
+ return exchange({ msg: "method", method: name, params, id }, (f) =>
95
+ f.msg === "result" && f.id === id ? { value: f } : undefined,
96
+ );
97
+ };
98
+ try {
99
+ await exchange({ msg: "connect", version: "1", support: ["1"] }, (f) =>
100
+ f.msg === "connected" ? { value: true } : undefined,
101
+ );
102
+ const login = await call("login", [{ resume: token }]);
103
+ if (login.error) return null;
104
+ return await read(
105
+ (login.result as { id: string }).id,
106
+ async <R>(name: string, ...params: unknown[]) => {
107
+ const result = await call(name, params);
108
+ if (result.error) throw new Error("CodeSignal: " + result.error.reason);
109
+ return result.result as R;
110
+ },
111
+ async (interviewId) => {
112
+ let candidate: string | undefined;
113
+ for (const name of [
114
+ "liveInterviews.byId",
115
+ "liveInterviews.finished.byId",
116
+ ]) {
117
+ const id = String(++sequence);
118
+ await exchange(
119
+ { msg: "sub", name, params: [interviewId], id },
120
+ (f) => {
121
+ if (
122
+ f.msg === "added" &&
123
+ f.collection === "liveInterviews" &&
124
+ f.id === interviewId
125
+ )
126
+ candidate = f.fields?.candidateId;
127
+ if (f.msg === "nosub" && f.id === id)
128
+ throw new Error("CodeSignal: " + f.error?.reason);
129
+ return f.msg === "ready" && f.subs?.includes(id)
130
+ ? { value: true }
131
+ : undefined;
132
+ },
133
+ );
134
+ if (candidate) break;
135
+ }
136
+ return candidate;
137
+ },
138
+ );
139
+ } finally {
140
+ socket.close();
141
+ }
142
+ }
143
+
144
+ export const verifyCodeSignal = (token: string) =>
145
+ session(token, async (user_id) => ({
146
+ service: "codesignal" as const,
147
+ identity: { user_id },
148
+ }));
149
+
150
+ function block(value: string) {
151
+ const fence = "`".repeat(
152
+ Math.max(3, ...Array.from(value.matchAll(/`+/g), (m) => m[0].length + 1)),
153
+ );
154
+ return fence + "\n" + value + (value.endsWith("\n") ? "" : "\n") + fence;
155
+ }
156
+
157
+ function output(events: RecordingEvent[]) {
158
+ let terminals: Record<string, string> = {};
159
+ const runs: string[] = [];
160
+ for (const e of events) {
161
+ if (e.action === "setState" && e.terminal)
162
+ terminals = { ...e.terminal.terminalContents };
163
+ if (e.action === "terminalCreate" || e.action === "terminalReset")
164
+ terminals[e.id] = "";
165
+ if (e.action === "terminalDelete") delete terminals[e.id];
166
+ if (e.action === "terminalWrite")
167
+ terminals[e.id] = (terminals[e.id] ?? "") + e.command;
168
+ if (e.action === "runResult" && e.testResults) {
169
+ const { compilationLog, output } = JSON.parse(e.testResults);
170
+ runs.push(
171
+ ...[compilationLog, output].filter(
172
+ (v): v is string => typeof v === "string" && v.length > 0,
173
+ ),
174
+ );
175
+ }
176
+ }
177
+ const clean = (v: string) =>
178
+ stripVTControlCharacters(v)
179
+ .replace(/\r\n/g, "\n")
180
+ .replace(/[^\n]*\r/g, "")
181
+ .replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
182
+ return [
183
+ ...Object.entries(terminals).map(
184
+ ([id, v]) => "### Terminal " + id + "\n\n" + block(clean(v)),
185
+ ),
186
+ ...runs.map((v) => "### Run output\n\n" + block(clean(v))),
187
+ ];
188
+ }
189
+
190
+ export function codeSignalInterviewId(url: string) {
191
+ return /^https:\/\/app\.codesignal\.com\/live-interview\/([a-zA-Z0-9]+)\/?(?:[?#].*)?$/.exec(
192
+ url,
193
+ )?.[1];
194
+ }
195
+
196
+ export async function previewCodeSignal(
197
+ runtime: RuntimeCapabilities,
198
+ id: string,
199
+ ): Promise<FetchedDocument> {
200
+ const { token } = await runtime.cookies.metadata("codesignal");
201
+ if (!token) throw new Error(loginRequired);
202
+ const result = await session(token, async (user, method, interview) => {
203
+ const replayUser = await interview(id);
204
+ const questions = await method<
205
+ (Solution | { type: "progressive"; taskLevels: Solution[] })[]
206
+ >("liveInterviewService.getSolutions", id);
207
+ const title = "CodeSignal interview " + id;
208
+ const parts = ["# " + title];
209
+ for (const question of questions) {
210
+ for (const solution of "taskLevels" in question
211
+ ? question.taskLevels
212
+ : [question]) {
213
+ const state =
214
+ solution.solutions.finalState ?? solution.solutions.submission;
215
+ parts.push("## " + solution.taskDoc.name);
216
+ for (const file of state?.sources ?? [])
217
+ if (!file.isHidden && !file.excluded)
218
+ parts.push("### " + file.path, block(file.source));
219
+ const data = await method<{
220
+ recording: { events: RecordingEvent[] } | null;
221
+ } | null>("taskRecordingService.getRecording", {
222
+ taskId: solution.taskDoc._id,
223
+ replayUserId: replayUser ?? user,
224
+ context: { mode: "live-interview", liveInterviewId: id, role: null },
225
+ taskLevelId: solution.levelId ?? null,
226
+ executionEnvironment: state?.executionEnvironment,
227
+ clientUserId: user,
228
+ });
229
+ const terminal = output(data?.recording?.events ?? []);
230
+ parts.push(
231
+ ...(terminal.length ? terminal : ["No recorded terminal output."]),
232
+ );
233
+ }
234
+ }
235
+ if (!questions.length) parts.push("No saved solutions.");
236
+ return {
237
+ title,
238
+ markdown: parts.join("\n\n") + "\n",
239
+ data: { url: "https://app.codesignal.com/live-interview/" + id },
240
+ };
241
+ });
242
+ if (!result) throw new Error(loginRequired);
243
+ return result;
244
+ }
@@ -0,0 +1,43 @@
1
+ import { cloudflareWorkerLimits, createMemoryFileSystem, diffCommands, Shell, standardCommands, textProgramCommands } from "#document-shell-engine";
2
+
3
+ const encoder = new TextEncoder();
4
+ const documentPath = "/document.md";
5
+
6
+ function memoryFilesystem() {
7
+ return createMemoryFileSystem({ maxBytes: 32 * 1024 * 1024, maxFileBytes: 8 * 1024 * 1024, maxRetainedBytes: 64 * 1024 * 1024, maxMetadataUnits: 524288 });
8
+ }
9
+
10
+ export async function editDocument(markdown: string, script: string) {
11
+ const fs = memoryFilesystem();
12
+ await fs.writeFile(documentPath, encoder.encode(markdown));
13
+ const shell = new Shell({ fs, cwd: "/", limits: cloudflareWorkerLimits }).use(standardCommands()).use(textProgramCommands()).use(diffCommands());
14
+ try {
15
+ const { exitCode, stdout, stderr } = await shell.exec(script);
16
+ if (exitCode !== 0) throw new Error(`Shell exited ${exitCode}; no changes saved.\n${[stdout, stderr].filter(Boolean).join("\n")}`.trimEnd());
17
+ const stat = await fs.lstat(documentPath).catch(() => undefined);
18
+ if (stat?.type !== "file") throw new Error("Keep /document.md as a regular file; no changes saved.");
19
+ const bytes = await fs.readFile(documentPath);
20
+ if (bytes.includes(0)) throw new Error("/document.md must contain UTF-8 text; no changes saved.");
21
+ let edited: string;
22
+ try { edited = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes); }
23
+ catch { throw new Error("/document.md must contain UTF-8 text; no changes saved."); }
24
+ return { edited, stdout, stderr };
25
+ } finally {
26
+ await shell.dispose();
27
+ }
28
+ }
29
+
30
+ export async function documentDiff(from: string, to: string, before: string, after: string): Promise<string> {
31
+ if (before === after) return "";
32
+ const fs = memoryFilesystem();
33
+ await fs.writeFile("/a", encoder.encode(before));
34
+ await fs.writeFile("/b", encoder.encode(after));
35
+ const shell = new Shell({ fs, cwd: "/", limits: cloudflareWorkerLimits }).use(diffCommands());
36
+ try {
37
+ const result = await shell.exec('diff -u -L "$FROM" -L "$TO" /a /b', { env: { FROM: from, TO: to } });
38
+ if (result.exitCode > 1) throw new Error(result.stderr || "Could not compare documents.");
39
+ return result.stdout;
40
+ } finally {
41
+ await shell.dispose();
42
+ }
43
+ }
@@ -12,7 +12,7 @@ export type WireRoot = Group;
12
12
  export type TextInputReader = () => Promise<string>;
13
13
  export type WireRootOptions = Readonly<{ allowPaste: boolean; 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> }>;
14
14
 
15
- const authServices = ["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
15
+ const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
16
16
  const removedCliCommandNames = Object.freeze({
17
17
  create: "Use `wire attach <url>` or `wire <url>`.",
18
18
  fetch: "Use `wire download <url>`.",
@@ -206,8 +206,12 @@ function wireUserErrorMessage(message: string): boolean {
206
206
  || /^Resource path is not registered: /.test(message)
207
207
  || /^Resource (path |identifier |URL )?not found: /.test(message)
208
208
  || /^Ambiguous resource path /.test(message)
209
+ || /^(Unresolved Wire conflict|Working file changed since the conflict|Stale shell edit|No saved conflict|Unknown document revision|No saved (?:base|local|remote) revision|Linked Markdown is missing|Another Wire operation owns this document|Local file changed during (?:sync|detach)|This registry does not provide durable document history|This provider cannot conditionally publish|Resolve and sync the Wire draft before detaching|Notion cannot condition a save|Google Sheets cannot condition a save)/.test(message)
210
+ || /^((?:Invalid|Missing|Orphaned) Wire editor receipt|Editor receipts require|An older editor buffer|Document already has a different sync owner)/.test(message)
211
+ || /^(Configured Wire registry is missing|Wire storage is busy|Wire switch destination already exists)/.test(message)
212
+ || /^Wire history and tracked Markdown must be on the same filesystem/.test(message)
209
213
  || /^Login not saved$/.test(message)
210
- || /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
214
+ || /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|codesignal|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
211
215
  || /^Asana API /.test(message)
212
216
  || /^(GET|POST|PUT|DELETE) \/.* failed: \d+ /.test(message)
213
217
  || /^(Invalid Asana project heading|Asana section appears|Asana milestone appears|Asana task appears|Asana subtask appears|Unsupported Asana Markdown|Duplicate Asana identity|Missing Asana project heading|Asana project identity changed|Unknown Asana identity|Conflicting Asana edits)/.test(message)
@@ -249,7 +253,7 @@ function wireUserErrorDisplayMessage(message: string): string {
249
253
  if (unsupportedSource !== null) return `unsupported source\nurl: ${lineText(unsupportedSource[1]!)}\nsupported: Asana, ChatGPT, Gmail, Google Docs/Sheets/Slides/Forms, Notion, Slack, Zoom`;
250
254
  const existingWorkspace = /^Wire workspace already initialized with (sqlite|files) registry at ([\s\S]+)\. Existing registries are not overwritten\.$/.exec(message);
251
255
  if (existingWorkspace !== null) return `workspace already initialized\nbackend: ${existingWorkspace[1]!}\nregistry: ${lineText(existingWorkspace[2]!)}\nkept: existing registry`;
252
- const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
256
+ const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (ashby|asana|chatgpt|codesignal|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
253
257
  if (authentication !== null) return `login required\nservice: ${serviceTitle(authentication[2] as AuthService)}\nrun: wire ${authentication[2]} login`;
254
258
  const asanaApi = /^Asana API ([^\s]+) failed: HTTP (\d+)(?: ([\s\S]+))?$/.exec(message);
255
259
  if (asanaApi !== null) return `api failed\nservice: Asana\nrequest: ${lineText(asanaApi[1]!)}\nstatus: HTTP ${asanaApi[2]!}${asanaApi[3] === undefined ? "" : `\ndetail: ${lineText(asanaApi[3]!)}`}`;
@@ -351,6 +355,7 @@ function serviceTitle(service: AuthService): string {
351
355
  ashby: "Ashby",
352
356
  asana: "Asana",
353
357
  chatgpt: "ChatGPT",
358
+ codesignal: "CodeSignal",
354
359
  gmail: "Gmail",
355
360
  "google-docs": "Google Docs/Sheets/Slides",
356
361
  notion: "Notion",
@@ -414,7 +419,7 @@ export const wirePresentation: WirePresentation = Object.freeze({
414
419
  function authGroup(service: AuthService, description: string, loginDescription: string, auth: Auth, readInput: TextInputReader | undefined, options: WireRootOptions): Group {
415
420
  const login = async (paste: boolean | undefined) => {
416
421
  if (paste === true && !options.allowPaste) throw new UserError("Cookie paste is CLI-only.");
417
- return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "ashby" ? auth.extractAshby() : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
422
+ return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "ashby" ? auth.extractAshby() : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "codesignal" ? auth.extractCodeSignal() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
418
423
  };
419
424
  const title = serviceTitle(service);
420
425
  return defineGroup({ name: service, description, children: [
@@ -440,18 +445,20 @@ type AsanaExplorer = {
440
445
  };
441
446
 
442
447
  export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, readInput?: TextInputReader, options: WireRootOptions = { allowPaste: true }, sendSlack?: (destination: string, markdown: string) => Promise<SlackSentMessage>, lookupSlack?: (query: string) => Promise<readonly JsonObject[]>, editSlack?: (url: string, markdown: string) => Promise<SlackSentMessage>, lookupNotion?: (query: string) => Promise<readonly JsonObject[]>, asana?: AsanaExplorer, latticeRoot?: () => Promise<string>): WireRoot {
443
- const attachFromCliUrl = (url: string) => {
448
+ const attachFromCliUrl = (url: string, editorReceipts?: boolean) => {
444
449
  const removedCommand = removedCliCommandNames[url as keyof typeof removedCliCommandNames];
445
450
  if (removedCommand !== undefined) throw new UserError(`Unknown command: ${url}. ${removedCommand}`);
446
451
  if (!/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//.test(url)) throw new UserError(`Expected source URL: ${url}`);
447
- return userFacing(() => wire.attach(url, currentDirectory));
452
+ return userFacing(() => wire.attach(url, currentDirectory, editorReceipts));
448
453
  };
449
454
  const defaultAttach = defineCommand({
450
455
  name: "attach",
451
456
  description: "Track a source URL as local Markdown. Shorthand: wire <url>.",
452
457
  positional: ["url"],
453
- params: S.Object({ url: S.String({ description: "Supported source URL to attach." }) }),
454
- handler: ({ params }) => attachFromCliUrl(params.url),
458
+ params: S.Object({ url: S.String({ description: "Supported source URL to attach." }),
459
+ "editor-receipts": S.Optional(S.Boolean({ description: "Google Docs: keep a local Markdown comment identifying the revision each editor buffer saw." })),
460
+ }),
461
+ handler: ({ params }) => attachFromCliUrl(params.url, params["editor-receipts"]),
455
462
  render: wirePresentation.attach,
456
463
  });
457
464
  const preview = defineCommand({
@@ -470,6 +477,9 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
470
477
  handler: ({ params }) => userFacing(() => wire.sync(params.resource, currentDirectory)),
471
478
  render: wirePresentation.sync,
472
479
  });
480
+ const resource = S.String({ description: "Registered resource URL, resource ID, or Markdown path." });
481
+ const historyStatusText = (status: Awaited<ReturnType<Wire["historyStatus"]>>) =>
482
+ `${status.path}: ${status.conflict ? "conflict" : status.modified ? "local changes" : "clean"}`;
473
483
  const authCommand = (service: (typeof authServices)[number]) => {
474
484
  const title = serviceTitle(service);
475
485
  const group = authGroup(service, `Manage ${title} login.`, "Capture cookies once; normal commands reuse saved cookies.", auth!, readInput, options);
@@ -659,6 +669,64 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
659
669
  render: wirePresentation.switchBackend,
660
670
  }),
661
671
  sync,
672
+ defineCommand({
673
+ name: "status", scope: ["cli"], description: "Show local changes or conflicts for one tracked document.",
674
+ positional: ["resource"], params: S.Object({ resource }),
675
+ handler: ({ params }) => userFacing(() => wire.historyStatus(params.resource, currentDirectory)),
676
+ render: render(historyStatusText),
677
+ }),
678
+ defineCommand({
679
+ name: "history", scope: ["cli"], description: "List local revisions, newest first.",
680
+ positional: ["resource"], params: S.Object({ resource }),
681
+ handler: ({ params }) => userFacing(() => wire.historyLog(params.resource, currentDirectory)),
682
+ render: render<Awaited<ReturnType<Wire["historyLog"]>>>(revisions =>
683
+ revisions.map(r => `${r.id} ${r.at} ${r.kind}`).join("\n") || "No revisions recorded."),
684
+ }),
685
+ defineCommand({
686
+ name: "diff", scope: ["cli"], description: "Compare two versions. Defaults to the last sync and working copy.",
687
+ positional: ["resource"], params: S.Object({ resource,
688
+ from: S.Optional(S.String({ description: "Revision ID, base, working, local, remote, editor, or shell." })),
689
+ to: S.Optional(S.String({ description: "Revision ID, base, working, local, remote, editor, or shell." })),
690
+ }),
691
+ handler: ({ params }) => userFacing(async () => {
692
+ const d = await wire.historyDiff(params.resource, currentDirectory, params.from, params.to);
693
+ const { documentDiff } = await import("./document-shell.js");
694
+ return { from: d.from, to: d.to, diff: await documentDiff(d.from, d.to, d.before, d.after) };
695
+ }),
696
+ render: render<{ diff: string }>(result => result.diff || "No changes."),
697
+ }),
698
+ defineCommand({
699
+ name: "conflicts", scope: ["cli"], description: "Show both saved sides of an unresolved conflict.",
700
+ positional: ["resource"], params: S.Object({ resource }),
701
+ handler: ({ params }) => userFacing(async () => (await wire.historyStatus(params.resource, currentDirectory)).conflict),
702
+ render: render<Awaited<ReturnType<Wire["historyStatus"]>>["conflict"]>(c => c && "editor" in c ?
703
+ `editor: ${c.editor}\nshell: ${c.shell}\nCompare with wire diff <resource> --from editor --to shell. Edit the working file and resolve working, or choose editor or shell.` : c ?
704
+ `base: ${c.base}\nlocal: ${c.local}\nremote: ${c.remote}\nCompare with wire diff <resource> --from local --to remote, then wire resolve <resource> <choice>.` : "No conflicts."),
705
+ }),
706
+ defineCommand({
707
+ name: "resolve", scope: ["cli"], description: "Resolve a conflict locally. Sync to publish.",
708
+ positional: ["resource", "choice"], params: S.Object({ resource,
709
+ choice: S.Enum(["local", "remote", "working", "editor", "shell"] as const, { description: "Choose a saved side of the conflict, or working to keep your edited file." }),
710
+ }),
711
+ handler: ({ params }) => userFacing(() => wire.resolveConflict(params.resource, currentDirectory, params.choice)),
712
+ render: render(historyStatusText),
713
+ }),
714
+ defineCommand({
715
+ name: "shell", scope: ["cli"], description: "Run a quoted safe-bash script on /document.md. Successful edits stay local until sync.",
716
+ positional: ["resource", "script"], params: S.Object({ resource,
717
+ script: S.String({ description: "Shell script; /document.md is the only tracked file in the in-memory filesystem." }),
718
+ }),
719
+ handler: ({ params }) => userFacing(async () => {
720
+ const d = await wire.historyDiff(params.resource, currentDirectory, "working", "working");
721
+ const { editDocument } = await import("./document-shell.js");
722
+ const { edited, stdout, stderr } = await editDocument(d.before, params.script).catch(error => { throw new UserError(thrownMessage(error)); });
723
+ const changed = edited !== d.before;
724
+ if (changed) await wire.checkpoint(params.resource, currentDirectory, d.before, edited, d.token);
725
+ return { changed, stdout, stderr };
726
+ }),
727
+ render: render<{ changed: boolean; stdout: string; stderr: string }>(r =>
728
+ [r.stdout.trimEnd(), r.stderr.trimEnd(), r.changed ? "Saved locally. Run wire sync to publish." : "No changes."].filter(Boolean).join("\n")),
729
+ }),
662
730
  defineCommand({
663
731
  name: "download",
664
732
  description: "Download a source URL as local Markdown without tracking it.",
package/src/auth.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { parsePastedCookieMetadata, parsePastedCookies, type ChromeCookieExtraction, type ChromeCookieResult, type Cookie, type NodeEnvironment, type RuntimeCapabilities } from "wire-core";
2
2
 
3
+ import { verifyCodeSignal } from "./adapters/codesignal.js";
3
4
  import { ashbySession } from "./adapters/ashby.js";
4
5
 
5
- export type AuthService = "ashby" | "asana" | "chatgpt" | "gmail" | "google-docs" | "notion" | "slack" | "zoom";
6
+ export type AuthService = "ashby" | "asana" | "chatgpt" | "codesignal" | "gmail" | "google-docs" | "notion" | "slack" | "zoom";
6
7
  export type CookieAuthService = AuthService;
7
8
 
8
9
  export interface AuthResult {
@@ -232,6 +233,7 @@ export interface Auth {
232
233
  readonly extractAshby: () => Promise<AuthResult>;
233
234
  readonly extractAsana: () => Promise<AuthResult>;
234
235
  readonly extractChatgpt: () => Promise<AuthResult>;
236
+ readonly extractCodeSignal: () => Promise<AuthResult>;
235
237
  readonly extractGmail: () => Promise<AuthResult>;
236
238
  readonly extractGoogleDocs: () => Promise<AuthResult>;
237
239
  readonly extractNotion: () => Promise<AuthResult>;
@@ -242,8 +244,8 @@ export interface Auth {
242
244
  export type CookieExtractor = (environment: NodeEnvironment, extraction: ChromeCookieExtraction) => Promise<ChromeCookieResult>;
243
245
 
244
246
  export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvironment, extractCookies: CookieExtractor): Auth {
245
- const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ ashby: ".ashbyhq.com", asana: ".asana.com", chatgpt: ".chatgpt.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
246
- const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "ashby" ? ashbySession(runtime,cookies).then(q=>q("query { sessionUser { id } }")).then(d=>d.sessionUser ? {service,identity:{user_id:d.sessionUser.id}} : null).catch(()=>null) : service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
247
+ const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ ashby: ".ashbyhq.com", asana: ".asana.com", chatgpt: ".chatgpt.com", codesignal: ".codesignal.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
248
+ const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "codesignal" ? (metadata.token ? verifyCodeSignal(metadata.token) : null) : service === "ashby" ? ashbySession(runtime,cookies).then(q=>q("query { sessionUser { id } }")).then(d=>d.sessionUser ? {service,identity:{user_id:d.sessionUser.id}} : null).catch(()=>null) : service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
247
249
  const verifyCookieState = async (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => {
248
250
  if (service === "zoom") return verifyZoomCookieState(runtime, cookies, metadata);
249
251
  return Object.freeze({ result: await verifyCookies(service, cookies, metadata), cookies, metadata, changed: false });
@@ -292,6 +294,7 @@ export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvir
292
294
  extractAshby: () => extract("ashby", "https://app.ashbyhq.com/", ["ashbyhq.com"], values => values.length > 0),
293
295
  extractAsana: () => extract("asana", "https://app.asana.com/", ["asana.com"], (values) => values.some((cookie) => cookie.domain === ".asana.com" || cookie.domain.endsWith(".asana.com"))),
294
296
  extractChatgpt: () => extract("chatgpt", "https://chatgpt.com/", ["chatgpt.com", "openai.com"], (values) => values.some((cookie) => cookie.name === "oai-did") && values.some((cookie) => cookie.name === "__Secure-next-auth.session-token" || cookie.name === "__Secure-next-auth.session-token.0"), undefined, true),
297
+ extractCodeSignal: () => extract("codesignal", "https://app.codesignal.com/", ["codesignal.com"], () => true, `(() => { const token = location.origin === "https://app.codesignal.com" && localStorage.getItem("Meteor.loginToken"); return token ? {token} : {}; })()`),
295
298
  extractGmail: () => extract("gmail", "https://mail.google.com/mail/u/0/", ["google.com"], googleReady),
296
299
  extractGoogleDocs: () => extract("google-docs", "https://docs.google.com/", ["google.com"], googleReady),
297
300
  extractNotion: () => extract("notion", "https://www.notion.so/login", ["notion.so", "notion.com"], requiredReady(["token_v2", "notion_user_id", "notion_users"])),
package/src/cli.ts CHANGED
@@ -110,6 +110,12 @@ function normalizeBareDebugArgv(argv: readonly string[]): readonly string[] {
110
110
 
111
111
  const fixedCommandPositionals = Object.freeze({
112
112
  attach: Object.freeze({ expected: 1, name: "url" }),
113
+ conflicts: Object.freeze({ expected: 1, name: "resource" }),
114
+ diff: Object.freeze({ expected: 1, name: "resource" }),
115
+ history: Object.freeze({ expected: 1, name: "resource" }),
116
+ resolve: Object.freeze({ expected: 2, name: "choice" }),
117
+ shell: Object.freeze({ expected: 2, name: "script" }),
118
+ status: Object.freeze({ expected: 1, name: "resource" }),
113
119
  detach: Object.freeze({ expected: 1, name: "resource" }),
114
120
  download: Object.freeze({ expected: 1, name: "url" }),
115
121
  init: Object.freeze({ expected: 0, name: "" }),
@@ -120,7 +126,7 @@ const fixedCommandPositionals = Object.freeze({
120
126
  "sync-all": Object.freeze({ expected: 0, name: "" }),
121
127
  watch: Object.freeze({ expected: 1, name: "file" }),
122
128
  });
123
- const authServices = new Set(["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"]);
129
+ const authServices = new Set(["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"]);
124
130
  const slackResourceCommands = new Set(["preview", "attach", "sync"]);
125
131
  const authCommands = new Set(["login", "logout", "status"]);
126
132
  const removedCommandNames = Object.freeze({
@@ -142,7 +148,7 @@ function isSourceUrl(value: string): boolean {
142
148
  }
143
149
 
144
150
  function isSourceLikeWithoutScheme(value: string): boolean {
145
- return /^(docs\.google\.com|mail\.google\.com|app\.asana\.com|chatgpt\.com|chat\.openai\.com|hub\.zoom\.us|www\.notion\.so|notion\.so|app\.notion\.com|[^/\s]+\.notion\.site|[^/\s]+\.slack\.com)(?:[/?:#]|$)/.test(value);
151
+ return /^(docs\.google\.com|mail\.google\.com|app\.asana\.com|chatgpt\.com|app\.codesignal\.com|chat\.openai\.com|hub\.zoom\.us|www\.notion\.so|notion\.so|app\.notion\.com|[^/\s]+\.notion\.site|[^/\s]+\.slack\.com)(?:[/?:#]|$)/.test(value);
146
152
  }
147
153
 
148
154
  function expectedSourceMessage(prefix: string, value: string): string {
@@ -222,7 +228,7 @@ function positionalWords(argv: readonly string[]): readonly string[] | null {
222
228
  continue;
223
229
  } else if (arg === "--output" || (arg === "--backend" && words[0] === "init") || (arg === "--debug" && argv[index + 1] !== undefined && debugModeNames.has(argv[index + 1]!))) {
224
230
  index += 1;
225
- } else if (arg === "--debug" || (arg === "--paste" && authServices.has(words[0]!) && words[1] === "login") || arg.startsWith("--debug=") || arg.startsWith("--output=") || (arg.startsWith("--backend=") && words[0] === "init")) {
231
+ } else if ((arg === "--editor-receipts" && (words[0] === "attach" || (words[0] && isSourceUrl(words[0])))) || arg === "--debug" || (arg === "--paste" && authServices.has(words[0]!) && words[1] === "login") || arg.startsWith("--debug=") || arg.startsWith("--output=") || (arg.startsWith("--backend=") && words[0] === "init")) {
226
232
  continue;
227
233
  } else if (arg.startsWith("-")) {
228
234
  return null;
@@ -267,7 +273,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
267
273
  if (!(command in fixedCommandPositionals)) return null;
268
274
  const positional = fixedCommandPositionals[command as keyof typeof fixedCommandPositionals];
269
275
  if (words.length - 1 >= positional.expected || positional.expected === 0) return null;
270
- return Object.freeze({ commandPath: command, name: positional.name });
276
+ return Object.freeze({ commandPath: command, name: words.length === 1 && positional.expected === 2 ? "resource" : positional.name });
271
277
  }
272
278
 
273
279
  function renderMissingPositionals(argv: readonly string[]): boolean {
package/src/executable.ts CHANGED
@@ -10,6 +10,7 @@ import { zoomProvider } from "provider-zoom";
10
10
  import { lookupNotionUsers } from "provider-notion";
11
11
 
12
12
  import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
13
+ import { codeSignalInterviewId, previewCodeSignal } from "./adapters/codesignal.js";
13
14
  import { ashby } from "./adapters/ashby.js";
14
15
  import { readAgenda } from "./adapters/calendar.js";
15
16
  import { createRoot } from "./adapters/root.js";
@@ -124,9 +125,9 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
124
125
  });
125
126
  const configuredWire = Object.freeze({
126
127
  ...baseWire,
127
- attach: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.attach(url, path); },
128
+ attach: async (url: string, path: string, editorReceipts?: boolean) => { activeConfigurationPath = path; return baseWire.attach(url, path, editorReceipts); },
128
129
  create: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.create(url, path); },
129
- view: async (url: string) => { activeConfigurationPath = currentDirectory; return baseWire.view(url); },
130
+ view: async (url: string) => { activeConfigurationPath = currentDirectory; const id = codeSignalInterviewId(url); return id ? previewCodeSignal(runtime, id) : baseWire.view(url); },
130
131
  downloadSource: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.downloadSource(url, path); },
131
132
  sync: async (value: string, path: string) => { activeConfigurationPath = operationPath(value, path); return baseWire.sync(value, path); },
132
133
  download: async (value: string, path: string) => { activeConfigurationPath = operationPath(value, path); return baseWire.download(value, path); },