@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/README.md CHANGED
@@ -57,6 +57,47 @@ wire detach <resource> # download once, then stop tracking it
57
57
  wire watch <file> # sync a file whenever it changes
58
58
  ```
59
59
 
60
+ ## Local editing and history
61
+
62
+ Use a registered document’s Markdown path, resource ID, or URL:
63
+
64
+ ```sh
65
+ wire shell Notes.md 'sed -i "s/Old heading/New heading/" document.md'
66
+ wire status Notes.md
67
+ wire diff Notes.md
68
+ wire history Notes.md
69
+ wire sync Notes.md
70
+ ```
71
+
72
+ The shell gets a private in-memory copy at `/document.md`. Quote the script so redirections run inside that shell. It can read and edit text with commands such as `cat`, `grep`, `sed`, and `printf`. Only the final contents of `/document.md` are saved, and only if the script succeeds and the working copy has not changed. Other virtual files disappear. No commit message or review comment is needed. A running `wire watch` can trigger sync automatically.
73
+
74
+ By default, the Markdown file exactly matches the downloaded document. A history timestamp records when Wire observed the text. It cannot tell when you typed it, capture saves that were replaced before Wire saw them, or tell which revision an old editor window was showing. Saving that window after a download can look like a new edit that reverses the download.
75
+
76
+ If an editor writes to an old open file after Wire replaces it, run `wire history Notes.md`. Wire checks retained files for that document and lists any newly discovered text as a `recovered` revision. Inspect it with `wire diff Notes.md --from working --to REVISION_ID` and copy any changes you want to keep. Discovery leaves both the working file and the remote document alone.
77
+
78
+ For a Google Doc, enable editor receipts when attaching, or repeat attach on its clean registered link:
79
+
80
+ ```sh
81
+ wire attach 'https://docs.google.com/document/d/DOCUMENT_ID/edit' --editor-receipts
82
+ ```
83
+
84
+ Wire adds a local HTML comment to the Markdown. Keep it with the buffer: when an old window saves, Wire uses its receipt to find the revision that window saw. Wire removes the comment before sending content to Google Docs and hides it from `wire diff` and `wire shell`. Editors and hooks that read the file directly see the comment. An absent, invalid, or foreign receipt stops sync and leaves the file intact. Receipts identify an editing base; they do not record keystrokes or prove when an edit happened.
85
+
86
+ If an old editor buffer replaces an unpublished shell draft, `wire sync Notes.md` first combines disjoint paragraph edits when both drafts have a single known common ancestor and the same remote base. If the edits overlap or their ancestry is uncertain, `wire conflicts Notes.md` shows both local revisions. Compare them with `wire diff Notes.md --from editor --to shell`. To combine them, edit the working file and run `wire resolve Notes.md working`; to select one unchanged side, use `editor` or `shell`. Then run `wire sync Notes.md` to merge with the latest remote document.
87
+
88
+ A shell edit is published only if the provider can check that the remote revision still matches. Google Docs supports this with write access. For a Notion page, Sheet, or another provider without this check, Wire keeps the local draft and refuses the upload. You can copy the intended changes into the provider yourself.
89
+
90
+ If sync reports a conflict, compare both saved versions, then choose which content to keep:
91
+
92
+ ```sh
93
+ wire conflicts Notes.md
94
+ wire diff Notes.md --from local --to remote
95
+ wire resolve Notes.md working # use the file after editing it yourself
96
+ wire sync Notes.md
97
+ ```
98
+
99
+ Use `local` or `remote` instead of `working` to select a saved side. Resolution updates the local file. `wire diff` defaults to the last sync versus the working copy. Pass revision IDs from `wire history` to compare older versions.
100
+
60
101
  For a Notion page with subpages, `wire download <url>` saves a directory with an `index.md` for each page. Open the root index and follow the local links. Ordinary links and mentions stay remote. Pages without subpages still download as one Markdown file.
61
102
 
62
103
  Run `wire --help` for the full CLI.
@@ -163,8 +204,10 @@ mkdir -p "docs/$WIRE_SERVICE" && dest="docs/$WIRE_SERVICE/$WIRE_TITLE.md" && mv
163
204
 
164
205
  ## Configuration
165
206
 
166
- Workspace config lives in `.wire/config.json` and applies to Wire plus hooks:
207
+ Workspace config lives in `.wire/config.json` and applies to Wire plus hooks. If you write the config by hand in a new workspace, run `wire init --backend sqlite` (or `files`) before the first sync. Init preserves your config and hooks. If an existing workspace loses its registry, restore it from backup. Wire does not create an empty replacement during sync.
167
208
 
168
209
  ```json
169
210
  { "backend": "sqlite", "path": "registry.sqlite3", "env": { "WIRE_CUSTOM_VALUE": "example" } }
170
211
  ```
212
+
213
+ `wire switch-db` changes the workspace registry between files and SQLite. If a document operation or another switch is active, retry when it finishes. The destination must be unused; a pre-existing database, directory, or SQLite sidecar is preserved. If a switch is interrupted, `.wire/config.json` identifies the active backend. Inspect the other copy before moving it aside and retrying.
@@ -0,0 +1,10 @@
1
+ import type { FetchedDocument, RuntimeCapabilities } from "wire-core";
2
+ export declare const verifyCodeSignal: (token: string) => Promise<{
3
+ service: "codesignal";
4
+ identity: {
5
+ user_id: string;
6
+ };
7
+ } | null>;
8
+ export declare function codeSignalInterviewId(url: string): string | undefined;
9
+ export declare function previewCodeSignal(runtime: RuntimeCapabilities, id: string): Promise<FetchedDocument>;
10
+ //# sourceMappingURL=codesignal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codesignal.d.ts","sourceRoot":"","sources":["../../src/adapters/codesignal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA8ItE,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM;;;;;SAIzC,CAAC;AA0CN,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,sBAIhD;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,eAAe,CAAC,CA6C1B"}
@@ -0,0 +1,165 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ const loginRequired = "codesignal cookie authentication is missing or expired. Run `wire codesignal login` once; other commands reuse saved cookies.";
3
+ async function session(token, read) {
4
+ const socket = new WebSocket("wss://app.codesignal.com/websocket");
5
+ let sequence = 0;
6
+ const send = (value) => socket.send(JSON.stringify(value));
7
+ const exchange = (start, accept) => new Promise((resolve, reject) => {
8
+ const listeners = new AbortController();
9
+ const finish = () => {
10
+ clearTimeout(timer);
11
+ listeners.abort();
12
+ };
13
+ const fail = () => {
14
+ finish();
15
+ reject(new Error("CodeSignal connection interrupted."));
16
+ };
17
+ const timer = setTimeout(fail, 30000);
18
+ const options = { signal: listeners.signal };
19
+ socket.addEventListener("error", fail, options);
20
+ socket.addEventListener("close", fail, options);
21
+ socket.addEventListener("message", (event) => {
22
+ try {
23
+ const frame = JSON.parse(String(event.data));
24
+ if (frame.msg === "ping") {
25
+ send({ msg: "pong", id: frame.id });
26
+ return;
27
+ }
28
+ const result = accept(frame);
29
+ if (result) {
30
+ finish();
31
+ resolve(result.value);
32
+ }
33
+ }
34
+ catch (error) {
35
+ finish();
36
+ reject(error);
37
+ }
38
+ }, options);
39
+ if (socket.readyState === WebSocket.CONNECTING)
40
+ socket.addEventListener("open", () => send(start), options);
41
+ else
42
+ send(start);
43
+ });
44
+ const call = (name, params) => {
45
+ const id = String(++sequence);
46
+ return exchange({ msg: "method", method: name, params, id }, (f) => f.msg === "result" && f.id === id ? { value: f } : undefined);
47
+ };
48
+ try {
49
+ await exchange({ msg: "connect", version: "1", support: ["1"] }, (f) => f.msg === "connected" ? { value: true } : undefined);
50
+ const login = await call("login", [{ resume: token }]);
51
+ if (login.error)
52
+ return null;
53
+ return await read(login.result.id, async (name, ...params) => {
54
+ const result = await call(name, params);
55
+ if (result.error)
56
+ throw new Error("CodeSignal: " + result.error.reason);
57
+ return result.result;
58
+ }, async (interviewId) => {
59
+ let candidate;
60
+ for (const name of [
61
+ "liveInterviews.byId",
62
+ "liveInterviews.finished.byId",
63
+ ]) {
64
+ const id = String(++sequence);
65
+ await exchange({ msg: "sub", name, params: [interviewId], id }, (f) => {
66
+ if (f.msg === "added" &&
67
+ f.collection === "liveInterviews" &&
68
+ f.id === interviewId)
69
+ candidate = f.fields?.candidateId;
70
+ if (f.msg === "nosub" && f.id === id)
71
+ throw new Error("CodeSignal: " + f.error?.reason);
72
+ return f.msg === "ready" && f.subs?.includes(id)
73
+ ? { value: true }
74
+ : undefined;
75
+ });
76
+ if (candidate)
77
+ break;
78
+ }
79
+ return candidate;
80
+ });
81
+ }
82
+ finally {
83
+ socket.close();
84
+ }
85
+ }
86
+ export const verifyCodeSignal = (token) => session(token, async (user_id) => ({
87
+ service: "codesignal",
88
+ identity: { user_id },
89
+ }));
90
+ function block(value) {
91
+ const fence = "`".repeat(Math.max(3, ...Array.from(value.matchAll(/`+/g), (m) => m[0].length + 1)));
92
+ return fence + "\n" + value + (value.endsWith("\n") ? "" : "\n") + fence;
93
+ }
94
+ function output(events) {
95
+ let terminals = {};
96
+ const runs = [];
97
+ for (const e of events) {
98
+ if (e.action === "setState" && e.terminal)
99
+ terminals = { ...e.terminal.terminalContents };
100
+ if (e.action === "terminalCreate" || e.action === "terminalReset")
101
+ terminals[e.id] = "";
102
+ if (e.action === "terminalDelete")
103
+ delete terminals[e.id];
104
+ if (e.action === "terminalWrite")
105
+ terminals[e.id] = (terminals[e.id] ?? "") + e.command;
106
+ if (e.action === "runResult" && e.testResults) {
107
+ const { compilationLog, output } = JSON.parse(e.testResults);
108
+ runs.push(...[compilationLog, output].filter((v) => typeof v === "string" && v.length > 0));
109
+ }
110
+ }
111
+ const clean = (v) => stripVTControlCharacters(v)
112
+ .replace(/\r\n/g, "\n")
113
+ .replace(/[^\n]*\r/g, "")
114
+ .replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
115
+ return [
116
+ ...Object.entries(terminals).map(([id, v]) => "### Terminal " + id + "\n\n" + block(clean(v))),
117
+ ...runs.map((v) => "### Run output\n\n" + block(clean(v))),
118
+ ];
119
+ }
120
+ export function codeSignalInterviewId(url) {
121
+ return /^https:\/\/app\.codesignal\.com\/live-interview\/([a-zA-Z0-9]+)\/?(?:[?#].*)?$/.exec(url)?.[1];
122
+ }
123
+ export async function previewCodeSignal(runtime, id) {
124
+ const { token } = await runtime.cookies.metadata("codesignal");
125
+ if (!token)
126
+ throw new Error(loginRequired);
127
+ const result = await session(token, async (user, method, interview) => {
128
+ const replayUser = await interview(id);
129
+ const questions = await method("liveInterviewService.getSolutions", id);
130
+ const title = "CodeSignal interview " + id;
131
+ const parts = ["# " + title];
132
+ for (const question of questions) {
133
+ for (const solution of "taskLevels" in question
134
+ ? question.taskLevels
135
+ : [question]) {
136
+ const state = solution.solutions.finalState ?? solution.solutions.submission;
137
+ parts.push("## " + solution.taskDoc.name);
138
+ for (const file of state?.sources ?? [])
139
+ if (!file.isHidden && !file.excluded)
140
+ parts.push("### " + file.path, block(file.source));
141
+ const data = await method("taskRecordingService.getRecording", {
142
+ taskId: solution.taskDoc._id,
143
+ replayUserId: replayUser ?? user,
144
+ context: { mode: "live-interview", liveInterviewId: id, role: null },
145
+ taskLevelId: solution.levelId ?? null,
146
+ executionEnvironment: state?.executionEnvironment,
147
+ clientUserId: user,
148
+ });
149
+ const terminal = output(data?.recording?.events ?? []);
150
+ parts.push(...(terminal.length ? terminal : ["No recorded terminal output."]));
151
+ }
152
+ }
153
+ if (!questions.length)
154
+ parts.push("No saved solutions.");
155
+ return {
156
+ title,
157
+ markdown: parts.join("\n\n") + "\n",
158
+ data: { url: "https://app.codesignal.com/live-interview/" + id },
159
+ };
160
+ });
161
+ if (!result)
162
+ throw new Error(loginRequired);
163
+ return result;
164
+ }
165
+ //# sourceMappingURL=codesignal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codesignal.js","sourceRoot":"","sources":["../../src/adapters/codesignal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,aAAa,GACjB,+HAA+H,CAAC;AAiClI,KAAK,UAAU,OAAO,CACpB,KAAa,EACb,IAIe;IAEf,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACnE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,I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AAC;IACH,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function editDocument(markdown: string, script: string): Promise<{
2
+ edited: string;
3
+ stdout: string;
4
+ stderr: string;
5
+ }>;
6
+ export declare function documentDiff(from: string, to: string, before: string, after: string): Promise<string>;
7
+ //# sourceMappingURL=document-shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-shell.d.ts","sourceRoot":"","sources":["../../src/adapters/document-shell.ts"],"names":[],"mappings":"AASA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;GAkBlE;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa3G"}
@@ -0,0 +1,51 @@
1
+ import { cloudflareWorkerLimits, createMemoryFileSystem, diffCommands, Shell, standardCommands, textProgramCommands } from "#document-shell-engine";
2
+ const encoder = new TextEncoder();
3
+ const documentPath = "/document.md";
4
+ function memoryFilesystem() {
5
+ return createMemoryFileSystem({ maxBytes: 32 * 1024 * 1024, maxFileBytes: 8 * 1024 * 1024, maxRetainedBytes: 64 * 1024 * 1024, maxMetadataUnits: 524288 });
6
+ }
7
+ export async function editDocument(markdown, script) {
8
+ const fs = memoryFilesystem();
9
+ await fs.writeFile(documentPath, encoder.encode(markdown));
10
+ const shell = new Shell({ fs, cwd: "/", limits: cloudflareWorkerLimits }).use(standardCommands()).use(textProgramCommands()).use(diffCommands());
11
+ try {
12
+ const { exitCode, stdout, stderr } = await shell.exec(script);
13
+ if (exitCode !== 0)
14
+ throw new Error(`Shell exited ${exitCode}; no changes saved.\n${[stdout, stderr].filter(Boolean).join("\n")}`.trimEnd());
15
+ const stat = await fs.lstat(documentPath).catch(() => undefined);
16
+ if (stat?.type !== "file")
17
+ throw new Error("Keep /document.md as a regular file; no changes saved.");
18
+ const bytes = await fs.readFile(documentPath);
19
+ if (bytes.includes(0))
20
+ throw new Error("/document.md must contain UTF-8 text; no changes saved.");
21
+ let edited;
22
+ try {
23
+ edited = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
24
+ }
25
+ catch {
26
+ throw new Error("/document.md must contain UTF-8 text; no changes saved.");
27
+ }
28
+ return { edited, stdout, stderr };
29
+ }
30
+ finally {
31
+ await shell.dispose();
32
+ }
33
+ }
34
+ export async function documentDiff(from, to, before, after) {
35
+ if (before === after)
36
+ return "";
37
+ const fs = memoryFilesystem();
38
+ await fs.writeFile("/a", encoder.encode(before));
39
+ await fs.writeFile("/b", encoder.encode(after));
40
+ const shell = new Shell({ fs, cwd: "/", limits: cloudflareWorkerLimits }).use(diffCommands());
41
+ try {
42
+ const result = await shell.exec('diff -u -L "$FROM" -L "$TO" /a /b', { env: { FROM: from, TO: to } });
43
+ if (result.exitCode > 1)
44
+ throw new Error(result.stderr || "Could not compare documents.");
45
+ return result.stdout;
46
+ }
47
+ finally {
48
+ await shell.dispose();
49
+ }
50
+ }
51
+ //# sourceMappingURL=document-shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-shell.js","sourceRoot":"","sources":["../../src/adapters/document-shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEpJ,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,SAAS,gBAAgB;IACvB,OAAO,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,E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;QACzD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KACjE,CAAC;CACH,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,GAAE,eAAsC,EAAE,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAuU/f"}
@@ -1,7 +1,7 @@
1
1
  import { UserError, defineCommand, defineGroup, S } from "toolcraft";
2
2
  import { defaultWireBackend, registryPathForBackend } from "wire-core";
3
3
  import { formatAgenda } from "./calendar.js";
4
- const authServices = ["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"];
4
+ const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"];
5
5
  const removedCliCommandNames = Object.freeze({
6
6
  create: "Use `wire attach <url>` or `wire <url>`.",
7
7
  fetch: "Use `wire download <url>`.",
@@ -134,8 +134,12 @@ function wireUserErrorMessage(message) {
134
134
  || /^Resource path is not registered: /.test(message)
135
135
  || /^Resource (path |identifier |URL )?not found: /.test(message)
136
136
  || /^Ambiguous resource path /.test(message)
137
+ || /^(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)
138
+ || /^((?:Invalid|Missing|Orphaned) Wire editor receipt|Editor receipts require|An older editor buffer|Document already has a different sync owner)/.test(message)
139
+ || /^(Configured Wire registry is missing|Wire storage is busy|Wire switch destination already exists)/.test(message)
140
+ || /^Wire history and tracked Markdown must be on the same filesystem/.test(message)
137
141
  || /^Login not saved$/.test(message)
138
- || /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
142
+ || /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)
139
143
  || /^Asana API /.test(message)
140
144
  || /^(GET|POST|PUT|DELETE) \/.* failed: \d+ /.test(message)
141
145
  || /^(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)
@@ -178,7 +182,7 @@ function wireUserErrorDisplayMessage(message) {
178
182
  const existingWorkspace = /^Wire workspace already initialized with (sqlite|files) registry at ([\s\S]+)\. Existing registries are not overwritten\.$/.exec(message);
179
183
  if (existingWorkspace !== null)
180
184
  return `workspace already initialized\nbackend: ${existingWorkspace[1]}\nregistry: ${lineText(existingWorkspace[2])}\nkept: existing registry`;
181
- 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);
185
+ 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);
182
186
  if (authentication !== null)
183
187
  return `login required\nservice: ${serviceTitle(authentication[2])}\nrun: wire ${authentication[2]} login`;
184
188
  const asanaApi = /^Asana API ([^\s]+) failed: HTTP (\d+)(?: ([\s\S]+))?$/.exec(message);
@@ -322,6 +326,7 @@ function serviceTitle(service) {
322
326
  ashby: "Ashby",
323
327
  asana: "Asana",
324
328
  chatgpt: "ChatGPT",
329
+ codesignal: "CodeSignal",
325
330
  gmail: "Gmail",
326
331
  "google-docs": "Google Docs/Sheets/Slides",
327
332
  notion: "Notion",
@@ -392,7 +397,7 @@ function authGroup(service, description, loginDescription, auth, readInput, opti
392
397
  const login = async (paste) => {
393
398
  if (paste === true && !options.allowPaste)
394
399
  throw new UserError("Cookie paste is CLI-only.");
395
- 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();
400
+ 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();
396
401
  };
397
402
  const title = serviceTitle(service);
398
403
  return defineGroup({ name: service, description, children: [
@@ -402,20 +407,22 @@ function authGroup(service, description, loginDescription, auth, readInput, opti
402
407
  ] });
403
408
  }
404
409
  export function createRoot(wire, currentDirectory, auth, readInput, options = { allowPaste: true }, sendSlack, lookupSlack, editSlack, lookupNotion, asana, latticeRoot) {
405
- const attachFromCliUrl = (url) => {
410
+ const attachFromCliUrl = (url, editorReceipts) => {
406
411
  const removedCommand = removedCliCommandNames[url];
407
412
  if (removedCommand !== undefined)
408
413
  throw new UserError(`Unknown command: ${url}. ${removedCommand}`);
409
414
  if (!/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//.test(url))
410
415
  throw new UserError(`Expected source URL: ${url}`);
411
- return userFacing(() => wire.attach(url, currentDirectory));
416
+ return userFacing(() => wire.attach(url, currentDirectory, editorReceipts));
412
417
  };
413
418
  const defaultAttach = defineCommand({
414
419
  name: "attach",
415
420
  description: "Track a source URL as local Markdown. Shorthand: wire <url>.",
416
421
  positional: ["url"],
417
- params: S.Object({ url: S.String({ description: "Supported source URL to attach." }) }),
418
- handler: ({ params }) => attachFromCliUrl(params.url),
422
+ params: S.Object({ url: S.String({ description: "Supported source URL to attach." }),
423
+ "editor-receipts": S.Optional(S.Boolean({ description: "Google Docs: keep a local Markdown comment identifying the revision each editor buffer saw." })),
424
+ }),
425
+ handler: ({ params }) => attachFromCliUrl(params.url, params["editor-receipts"]),
419
426
  render: wirePresentation.attach,
420
427
  });
421
428
  const preview = defineCommand({
@@ -434,6 +441,8 @@ export function createRoot(wire, currentDirectory, auth, readInput, options = {
434
441
  handler: ({ params }) => userFacing(() => wire.sync(params.resource, currentDirectory)),
435
442
  render: wirePresentation.sync,
436
443
  });
444
+ const resource = S.String({ description: "Registered resource URL, resource ID, or Markdown path." });
445
+ const historyStatusText = (status) => `${status.path}: ${status.conflict ? "conflict" : status.modified ? "local changes" : "clean"}`;
437
446
  const authCommand = (service) => {
438
447
  const title = serviceTitle(service);
439
448
  const group = authGroup(service, `Manage ${title} login.`, "Capture cookies once; normal commands reuse saved cookies.", auth, readInput, options);
@@ -628,6 +637,63 @@ export function createRoot(wire, currentDirectory, auth, readInput, options = {
628
637
  render: wirePresentation.switchBackend,
629
638
  }),
630
639
  sync,
640
+ defineCommand({
641
+ name: "status", scope: ["cli"], description: "Show local changes or conflicts for one tracked document.",
642
+ positional: ["resource"], params: S.Object({ resource }),
643
+ handler: ({ params }) => userFacing(() => wire.historyStatus(params.resource, currentDirectory)),
644
+ render: render(historyStatusText),
645
+ }),
646
+ defineCommand({
647
+ name: "history", scope: ["cli"], description: "List local revisions, newest first.",
648
+ positional: ["resource"], params: S.Object({ resource }),
649
+ handler: ({ params }) => userFacing(() => wire.historyLog(params.resource, currentDirectory)),
650
+ render: render(revisions => revisions.map(r => `${r.id} ${r.at} ${r.kind}`).join("\n") || "No revisions recorded."),
651
+ }),
652
+ defineCommand({
653
+ name: "diff", scope: ["cli"], description: "Compare two versions. Defaults to the last sync and working copy.",
654
+ positional: ["resource"], params: S.Object({ resource,
655
+ from: S.Optional(S.String({ description: "Revision ID, base, working, local, remote, editor, or shell." })),
656
+ to: S.Optional(S.String({ description: "Revision ID, base, working, local, remote, editor, or shell." })),
657
+ }),
658
+ handler: ({ params }) => userFacing(async () => {
659
+ const d = await wire.historyDiff(params.resource, currentDirectory, params.from, params.to);
660
+ const { documentDiff } = await import("./document-shell.js");
661
+ return { from: d.from, to: d.to, diff: await documentDiff(d.from, d.to, d.before, d.after) };
662
+ }),
663
+ render: render(result => result.diff || "No changes."),
664
+ }),
665
+ defineCommand({
666
+ name: "conflicts", scope: ["cli"], description: "Show both saved sides of an unresolved conflict.",
667
+ positional: ["resource"], params: S.Object({ resource }),
668
+ handler: ({ params }) => userFacing(async () => (await wire.historyStatus(params.resource, currentDirectory)).conflict),
669
+ render: render(c => c && "editor" in c ?
670
+ `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 ?
671
+ `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."),
672
+ }),
673
+ defineCommand({
674
+ name: "resolve", scope: ["cli"], description: "Resolve a conflict locally. Sync to publish.",
675
+ positional: ["resource", "choice"], params: S.Object({ resource,
676
+ choice: S.Enum(["local", "remote", "working", "editor", "shell"], { description: "Choose a saved side of the conflict, or working to keep your edited file." }),
677
+ }),
678
+ handler: ({ params }) => userFacing(() => wire.resolveConflict(params.resource, currentDirectory, params.choice)),
679
+ render: render(historyStatusText),
680
+ }),
681
+ defineCommand({
682
+ name: "shell", scope: ["cli"], description: "Run a quoted safe-bash script on /document.md. Successful edits stay local until sync.",
683
+ positional: ["resource", "script"], params: S.Object({ resource,
684
+ script: S.String({ description: "Shell script; /document.md is the only tracked file in the in-memory filesystem." }),
685
+ }),
686
+ handler: ({ params }) => userFacing(async () => {
687
+ const d = await wire.historyDiff(params.resource, currentDirectory, "working", "working");
688
+ const { editDocument } = await import("./document-shell.js");
689
+ const { edited, stdout, stderr } = await editDocument(d.before, params.script).catch(error => { throw new UserError(thrownMessage(error)); });
690
+ const changed = edited !== d.before;
691
+ if (changed)
692
+ await wire.checkpoint(params.resource, currentDirectory, d.before, edited, d.token);
693
+ return { changed, stdout, stderr };
694
+ }),
695
+ render: render(r => [r.stdout.trimEnd(), r.stderr.trimEnd(), r.changed ? "Saved locally. Run wire sync to publish." : "No changes."].filter(Boolean).join("\n")),
696
+ }),
631
697
  defineCommand({
632
698
  name: "download",
633
699
  description: "Download a source URL as local Markdown without tracking it.",