@kamilio/wire 0.1.30 → 0.1.32
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/root.d.ts +4 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +12 -1
- package/dist/adapters/root.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +2 -1
- package/dist/executable.js.map +1 -1
- package/node_modules/provider-lattice/dist/browser.d.ts +4 -0
- package/node_modules/provider-lattice/dist/browser.d.ts.map +1 -0
- package/node_modules/provider-lattice/dist/browser.js +31 -0
- package/node_modules/provider-lattice/dist/browser.js.map +1 -0
- package/node_modules/provider-lattice/dist/draft.d.ts +5 -0
- package/node_modules/provider-lattice/dist/draft.d.ts.map +1 -0
- package/node_modules/provider-lattice/dist/draft.js +541 -0
- package/node_modules/provider-lattice/dist/draft.js.map +1 -0
- package/node_modules/provider-lattice/dist/index.d.ts +1 -0
- package/node_modules/provider-lattice/dist/index.d.ts.map +1 -1
- package/node_modules/provider-lattice/dist/index.js +4 -23
- package/node_modules/provider-lattice/dist/index.js.map +1 -1
- package/node_modules/provider-lattice/src/browser.ts +41 -0
- package/node_modules/provider-lattice/src/draft.ts +668 -0
- package/node_modules/provider-lattice/src/index.ts +4 -26
- package/package.json +1 -1
- package/src/adapters/root.ts +13 -2
- package/src/cli.ts +3 -1
- package/src/executable.ts +2 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { browser } from "./browser.js";
|
|
2
|
+
export { latticeReviewDraft, listLatticeReviewRequests, syncLatticeDrafts } from "./draft.js";
|
|
1
3
|
import { defineService, type AddMarkdown, type FetchedDocument, type RuntimeCapabilities } from "wire-core";
|
|
2
4
|
import { richText } from "./markdown.js";
|
|
3
5
|
|
|
@@ -141,29 +143,7 @@ const doc = (title: string, url: string, parts: string[]): FetchedDocument => ({
|
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
async function read(runtime: RuntimeCapabilities, url: URL, add?: AddMarkdown) {
|
|
144
|
-
|
|
145
|
-
const args = [session, "--raw"];
|
|
146
|
-
await runtime.process.execute("hey-browser", [
|
|
147
|
-
"run",
|
|
148
|
-
"--",
|
|
149
|
-
"playwright-cli",
|
|
150
|
-
...args,
|
|
151
|
-
"attach",
|
|
152
|
-
"--extension=chrome",
|
|
153
|
-
]);
|
|
154
|
-
const query = async <T>(fields: string, vars: Record<string, string | null> = {}): Promise<T> => {
|
|
155
|
-
const data = { id: "WireLatticeRead", query: "query WireLatticeRead " + fields, variables: vars };
|
|
156
|
-
const code = `async page=>{const r=await page.request.post(${JSON.stringify(url.origin + "/graphql")},{maxRedirects:0,data:${JSON.stringify(data)}});return r.headers()["content-type"]?.includes("json") ? await r.json() : {errors:[{message:"Lattice HTTP "+r.status()+": sign in to this workspace in Chrome."}]}}`;
|
|
157
|
-
const result = JSON.parse(
|
|
158
|
-
(await runtime.process.execute("playwright-cli", [...args, "run-code", code])).stdout,
|
|
159
|
-
(key, value) =>
|
|
160
|
-
key === "name" && typeof value === "string" ? value.replace(/\s*\(deactivated\)\s*$/i, "") : value,
|
|
161
|
-
);
|
|
162
|
-
if (result.errors?.length)
|
|
163
|
-
throw new Error(result.errors.map((e: { message: string }) => e.message).join("; "));
|
|
164
|
-
return result.data as T;
|
|
165
|
-
};
|
|
166
|
-
try {
|
|
146
|
+
return browser(runtime, url, async (query) => {
|
|
167
147
|
const viewer = (
|
|
168
148
|
await query<{ viewer: { user: Person & { entityId: string } } }>("{ viewer { user { name entityId } } }")
|
|
169
149
|
).viewer.user;
|
|
@@ -484,9 +464,7 @@ async function read(runtime: RuntimeCapabilities, url: URL, add?: AddMarkdown) {
|
|
|
484
464
|
const document = doc("Lattice — " + viewer.name, origin + path, parts);
|
|
485
465
|
const file = index + ".md";
|
|
486
466
|
return finish(file, document);
|
|
487
|
-
}
|
|
488
|
-
await runtime.process.execute("playwright-cli", [...args, "detach"]);
|
|
489
|
-
}
|
|
467
|
+
});
|
|
490
468
|
}
|
|
491
469
|
|
|
492
470
|
export const latticeService = defineService<RuntimeCapabilities>({
|
package/package.json
CHANGED
package/src/adapters/root.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Auth, AuthResult, AuthService } from "../auth.js";
|
|
|
8
8
|
|
|
9
9
|
export type WireRoot = Group;
|
|
10
10
|
export type TextInputReader = () => Promise<string>;
|
|
11
|
-
export type WireRootOptions = Readonly<{ allowPaste: boolean; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
11
|
+
export type WireRootOptions = Readonly<{ allowPaste: boolean; latticeSync?: (url: string | undefined) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
12
12
|
|
|
13
13
|
const authServices = ["asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
14
14
|
const removedCliCommandNames = Object.freeze({
|
|
@@ -587,7 +587,18 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
587
587
|
scope: ["cli", "mcp", "sdk"],
|
|
588
588
|
children: [
|
|
589
589
|
defaultAttach,
|
|
590
|
-
...(latticeRoot ? [defineGroup({ name: "lattice", scope: ["cli"], description: "Read
|
|
590
|
+
...(latticeRoot ? [defineGroup({ name: "lattice", scope: ["cli"], description: "Read reviews and fill your drafts.", children: [
|
|
591
|
+
...([["requests","List open assignments from a Lattice review requests URL.",options.latticeRequests],["template","Print the current review form as editable Markdown.",options.latticeTemplate]] as const).flatMap(([name,description,run]) => run ? [defineCommand({
|
|
592
|
+
name, description, scope:["cli"], positional:["url"], params:S.Object({url:S.String({description:"Lattice review URL."})}), handler:({params})=>userFacing(()=>run(params.url)), render:render<string>(v=>v),
|
|
593
|
+
})] : []),
|
|
594
|
+
...(options.latticeSync ? ["sync","sync-drafts"].map(name=>defineCommand({name,hidden:name==="sync-drafts",description:"Create lattice-drafts-YYYY and save edited answers as drafts. Inside the folder the URL is optional. Placeholders stay local.",scope:["cli"],positional:["url"],
|
|
595
|
+
params:S.Object({url:S.Optional(S.String({description:"Cycle requests URL; required on the first run."}))}),
|
|
596
|
+
handler:({params})=>userFacing(()=>options.latticeSync!(params.url)),render:render<string>(v=>v),
|
|
597
|
+
})) : []),
|
|
598
|
+
...(options.latticeFill ? [defineCommand({name:"fill",description:"Save a review draft without submitting. Use the displayed option, yes/no or true/false for binary choices, or one option per line for multiple selections.",scope:["cli"],positional:["url","file"],
|
|
599
|
+
params:S.Object({url:S.String({description:"Your Lattice review response URL."}),file:S.String({description:"Markdown file with the template’s question headings."})}),
|
|
600
|
+
handler:({params})=>userFacing(()=>options.latticeFill!(params.url,params.file)),render:render<string>(v=>v),
|
|
601
|
+
})] : []),
|
|
591
602
|
defineCommand({ name: "scrape", hidden: true, scope: ["cli"], description: "Download Lattice history.", params: S.Object({}),
|
|
592
603
|
handler: () => userFacing(async () => wire.downloadSource(await latticeRoot(), currentDirectory)), render: wirePresentation.download }),
|
|
593
604
|
] })] : []),
|
package/src/cli.ts
CHANGED
|
@@ -514,6 +514,8 @@ export async function runWireCli(root: WireRoot | WireRootFactory, argv: readonl
|
|
|
514
514
|
if (!version && renderExcessPositionals(normalized)) {
|
|
515
515
|
return;
|
|
516
516
|
}
|
|
517
|
+
const words = positionalWords(normalized);
|
|
518
|
+
const plain = words?.[0] === "lattice" && (words[1] === "template" || words[1] === "requests") && outputFormats(normalized).length === 0;
|
|
517
519
|
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version: string };
|
|
518
|
-
await runCLI(typeof root === "function" ? root(currentDirectory) : root, { version: packageJson.version, rootUsageName: "wire", presets: false, approvals: false, controls: { output: true, debug: true }, argv: normalized });
|
|
520
|
+
await runCLI(typeof root === "function" ? root(currentDirectory) : root, { version: packageJson.version, rootUsageName: "wire", presets: false, approvals: false, controls: { output: true, debug: true }, argv: plain ? [...normalized.slice(0, 2), "--output", "markdown", ...normalized.slice(2)] : normalized });
|
|
519
521
|
}
|
package/src/executable.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
5
5
|
import { addAsanaComment, createAsanaTask, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, lookupAsanaUsers, moveAsanaTask, showAsanaProject, showAsanaTask } from "provider-asana";
|
|
6
6
|
import { sendSlackMessage, editSlackMessage, lookupSlackUsers } from "provider-slack";
|
|
7
7
|
|
|
8
|
+
import { listLatticeReviewRequests, latticeReviewDraft, syncLatticeDrafts } from "provider-lattice";
|
|
8
9
|
import { zoomProvider } from "provider-zoom";
|
|
9
10
|
import { lookupNotionUsers } from "provider-notion";
|
|
10
11
|
|
|
@@ -137,7 +138,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
137
138
|
switchBackend: baseWire.switchBackend,
|
|
138
139
|
});
|
|
139
140
|
const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
|
|
140
|
-
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, 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), {
|
|
141
|
+
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, latticeSync: url => syncLatticeDrafts(runtime,url,currentDirectory), 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), {
|
|
141
142
|
lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
142
143
|
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) },
|
|
143
144
|
}, async () => {
|