@kamilio/wire 0.1.70 → 0.1.72
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 +2 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +44 -0
- package/dist/adapters/root.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +14 -6
- package/dist/executable.js.map +1 -1
- package/node_modules/provider-notion/dist/index.d.ts +1 -1
- package/node_modules/provider-notion/dist/index.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/index.js +1 -1
- package/node_modules/provider-notion/dist/index.js.map +1 -1
- package/node_modules/provider-notion/dist/notion-sync.d.ts +21 -0
- package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/notion-sync.js +59 -1
- package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
- package/node_modules/provider-notion/src/index.ts +1 -1
- package/node_modules/provider-notion/src/notion-sync.ts +56 -1
- package/package.json +1 -1
- package/src/adapters/root.ts +45 -1
- package/src/cli.ts +3 -1
- package/src/executable.ts +11 -5
package/src/adapters/root.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { UserError, defineCommand, defineGroup, S, type Group } from "toolcraft"
|
|
|
3
3
|
|
|
4
4
|
import { defaultWireBackend, registryPathForBackend, type JsonObject, type FetchedDocument, type InitializedWire, type Resource, type SwitchedWireBackend, type Wire, type WireBackend, type WireResult, type WireWatchSession } from "wire-core";
|
|
5
5
|
import type { listAsanaProjects, listAsanaTasks, moveAsanaTask, showAsanaProject } from "provider-asana";
|
|
6
|
+
import type { searchNotion } from "provider-notion";
|
|
6
7
|
import type { zoomProvider } from "provider-zoom";
|
|
7
8
|
import type { SlackSentMessage } from "provider-slack";
|
|
8
9
|
import type { Auth, AuthResult, AuthService } from "../auth.js";
|
|
@@ -14,7 +15,7 @@ import { formatDocComments, type listDocComments, type changeDocComment } from "
|
|
|
14
15
|
type Comments = { comments?: Awaited<ReturnType<typeof listDocComments>> };
|
|
15
16
|
export type WireRoot = Group;
|
|
16
17
|
export type TextInputReader = () => Promise<string>;
|
|
17
|
-
export type WireRootOptions = Readonly<{ allowPaste: boolean; codeSignalEdit?: (url: string, path: string, file: string) => ReturnType<typeof editCodeSignal>; codeSignalRun?: (url: string) => ReturnType<typeof runCodeSignal>; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
18
|
+
export type WireRootOptions = Readonly<{ allowPaste: boolean; searchNotion?: (query: string, options: Parameters<typeof searchNotion>[2]) => ReturnType<typeof searchNotion>; codeSignalEdit?: (url: string, path: string, file: string) => ReturnType<typeof editCodeSignal>; codeSignalRun?: (url: string) => ReturnType<typeof runCodeSignal>; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
18
19
|
|
|
19
20
|
const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
20
21
|
const removedCliCommandNames = Object.freeze({
|
|
@@ -554,6 +555,49 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
554
555
|
return service === "slack" ? `${user["id"]} ${user["real_name"] ?? user["name"]} ${profile?.["email"] ?? ""}` : `${user["userId"]} ${user["name"] ?? ""} ${(user["aliases"] as readonly string[] | undefined ?? []).join(", ")}`;
|
|
555
556
|
}).join("\n")),
|
|
556
557
|
})] })];
|
|
558
|
+
if (service === "notion" && options.searchNotion) return defineGroup({ ...group, description: "Search Notion pages, find people, and manage login.", children: [...group.children, ...users, defineCommand({
|
|
559
|
+
name: "search", description: "Search page titles and content with Notion's native matching and ranking. Does not save files.", positional: ["query"],
|
|
560
|
+
params: S.Object({
|
|
561
|
+
query: S.String({ description: "Search text. Use an empty string to search by filters alone." }),
|
|
562
|
+
"created-by": S.Optional(S.Array(S.String(), { description: "Authors: names, exact emails, or Notion user IDs. Repeat for multiple people (OR)." })),
|
|
563
|
+
"edited-by": S.Optional(S.Array(S.String(), { description: "Editors: names, exact emails, or Notion user IDs. Repeat for multiple people (OR)." })),
|
|
564
|
+
"title-only": S.Optional(S.Boolean({ description: "Search page titles only." })),
|
|
565
|
+
in: S.Optional(S.Array(S.String(), { description: "Search within these parent page IDs." })),
|
|
566
|
+
teamspace: S.Optional(S.Array(S.String(), { description: "Filter by Notion teamspace IDs." })),
|
|
567
|
+
"created-after": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Creation range start, YYYY-MM-DD." })),
|
|
568
|
+
"created-before": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Creation range end, YYYY-MM-DD." })),
|
|
569
|
+
"edited-after": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Last-edited range start, YYYY-MM-DD." })),
|
|
570
|
+
"edited-before": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Last-edited range end, YYYY-MM-DD." })),
|
|
571
|
+
"content-status": S.Optional(S.Enum(["all_without_archived", "all_with_archived", "verified_only", "archived_only"], { default: "all_without_archived", description: "Notion content status filter." })),
|
|
572
|
+
sort: S.Optional(S.Enum(["relevance", "lastEdited", "created"], { default: "relevance", description: "Notion sort field." })),
|
|
573
|
+
direction: S.Optional(S.Enum(["asc", "desc"], { default: "desc", description: "Date sort order. Ignored for relevance." })),
|
|
574
|
+
limit: S.Optional(S.Number({ jsonType: "integer", minimum: 1, maximum: 100, default: 20, description: "Maximum results per workspace, 1–100." })),
|
|
575
|
+
space: S.Optional(S.String({ description: "Workspace ID. Searches all accessible workspaces when omitted." })),
|
|
576
|
+
}),
|
|
577
|
+
handler: ({ params }) => userFacing(() => {
|
|
578
|
+
const dateRange = (start: string | undefined, end: string | undefined) => ({
|
|
579
|
+
...(start === undefined ? {} : { starting: { type: "date", start_date: start } }),
|
|
580
|
+
...(end === undefined ? {} : { ending: { type: "date", start_date: end } }),
|
|
581
|
+
});
|
|
582
|
+
const field = params.sort ?? "relevance";
|
|
583
|
+
return options.searchNotion!(params.query, {
|
|
584
|
+
filters: { createdBy: params["created-by"] ?? [], editedBy: params["edited-by"] ?? [], navigableBlockContentOnly: params["title-only"] ?? false,
|
|
585
|
+
ancestors: params.in ?? [], inTeams: params.teamspace ?? [], contentStatusFilter: params["content-status"] ?? "all_without_archived",
|
|
586
|
+
createdTime: dateRange(params["created-after"], params["created-before"]), lastEditedTime: dateRange(params["edited-after"], params["edited-before"]),
|
|
587
|
+
},
|
|
588
|
+
sort: field === "relevance" ? { field } : { field, direction: params.direction ?? "desc" },
|
|
589
|
+
limit: params.limit ?? 20, ...(params.space === undefined ? {} : { spaceId: params.space }),
|
|
590
|
+
});
|
|
591
|
+
}),
|
|
592
|
+
render: render<Awaited<ReturnType<typeof searchNotion>>>((searches) => searches.map((search) => [
|
|
593
|
+
`Workspace ${search.spaceId}: ${search.results.length} returned (Notion total: ${search.total}${search.total === 100 ? "+" : ""})`,
|
|
594
|
+
...search.results.map((page) => [
|
|
595
|
+
`- [${lineText(page.title || "Untitled").replace(/[\\\[\]]/g, "\\$&")}](${page.url})`,
|
|
596
|
+
` Created by ${page.created_by ?? page.created_by_id} · Edited by ${page.last_edited_by ?? page.last_edited_by_id}`,
|
|
597
|
+
...(page.excerpt === "" ? [] : [` ${lineText(page.excerpt)}`]),
|
|
598
|
+
].join("\n")),
|
|
599
|
+
].join("\n\n")).join("\n\n") || "No accessible Notion workspaces"),
|
|
600
|
+
})] });
|
|
557
601
|
const writes = asana?.writes;
|
|
558
602
|
const createTask = writes?.create;
|
|
559
603
|
if (service === "asana" && asana !== undefined) return defineGroup({ ...group, description: "Browse Asana projects, edit tasks and comments, and manage login.", children: [...group.children, ...users,
|
package/src/cli.ts
CHANGED
|
@@ -246,6 +246,7 @@ function excessPositionals(argv: readonly string[]): Readonly<{ commandPath: str
|
|
|
246
246
|
const command = words[0]!;
|
|
247
247
|
if (command in fixedCommandPositionals) return Object.freeze({ commandPath: command, expected: fixedCommandPositionals[command as keyof typeof fixedCommandPositionals].expected, received: words.length - 1 });
|
|
248
248
|
if (command === "asana" && (words[1] === "projects" || words[1] === "tasks") && (words[2] === "list" || words[2] === "show")) return { commandPath: words.slice(0, 3).join(" "), expected: words[1] === "projects" && words[2] === "list" ? 0 : 1, received: words.length - 3 };
|
|
249
|
+
if (command === "notion" && words[1] === "search") return { commandPath: "notion search", expected: 1, received: words.length - 2 };
|
|
249
250
|
if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
|
|
250
251
|
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
|
|
251
252
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
|
|
@@ -269,6 +270,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
|
|
|
269
270
|
const command = words[0]!;
|
|
270
271
|
if (command === "asana" && words[1] === "projects" && words[2] === "show" && words.length === 3) return { commandPath: words.join(" "), name: "project" };
|
|
271
272
|
if (command === "asana" && words[1] === "tasks" && (words[2] === "list" || words[2] === "show") && words.length === 3) return { commandPath: words.join(" "), name: words[2] === "list" ? "project" : "task" };
|
|
273
|
+
if (command === "notion" && words[1] === "search" && words.length < 3) return { commandPath: "notion search", name: "query" };
|
|
272
274
|
if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
|
|
273
275
|
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
|
|
274
276
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit") && words.length < 4) return { commandPath: `slack ${words[1]}`, name: words.length === 2 ? words[1] === "send" ? "destination" : "url" : "markdown" };
|
|
@@ -308,7 +310,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
|
|
|
308
310
|
function renderUnknownAuthCommand(argv: readonly string[]): boolean {
|
|
309
311
|
if (hasRootSeparator(argv)) return false;
|
|
310
312
|
const words = positionalWords(argv);
|
|
311
|
-
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "codesignal" && ["edit", "run"].includes(words[1]!)) || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
313
|
+
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "codesignal" && ["edit", "run"].includes(words[1]!)) || (words[0] === "notion" && words[1] === "search") || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
312
314
|
renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
|
|
313
315
|
return true;
|
|
314
316
|
}
|
package/src/executable.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { sendSlackMessage, editSlackMessage, lookupSlackUsers } from "provider-s
|
|
|
7
7
|
|
|
8
8
|
import { listLatticeReviewRequests, latticeReviewDraft, syncLatticeDrafts } from "provider-lattice";
|
|
9
9
|
import { zoomProvider } from "provider-zoom";
|
|
10
|
-
import { lookupNotionUsers, shareNotionWithOrg } from "provider-notion";
|
|
10
|
+
import { lookupNotionUsers, searchNotion, shareNotionWithOrg } from "provider-notion";
|
|
11
11
|
|
|
12
12
|
import { changeDocComment, listDocComments } from "./adapters/doc-comments.js";
|
|
13
13
|
import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
|
|
@@ -60,9 +60,15 @@ function loadConfiguredEnvironment(environment: NodeEnvironment, currentDirector
|
|
|
60
60
|
const home = environment["HOME"];
|
|
61
61
|
if (home === undefined) throw new Error("Missing required environment variable: HOME");
|
|
62
62
|
const wireRoot = discoverConfiguredWireRoot(currentDirectory, home);
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
63
|
+
let configured = environment;
|
|
64
|
+
for (const root of new Set([join(home, ".wire"), wireRoot])) {
|
|
65
|
+
if (root === undefined) continue;
|
|
66
|
+
const configPath = join(root, "config.json");
|
|
67
|
+
if (!existsSync(configPath) || !statSync(configPath).isFile()) continue;
|
|
68
|
+
const config = JSON.parse(readFileSync(configPath, "utf8")) as WireConfig;
|
|
69
|
+
if (config.env !== undefined) configured = Object.freeze({ ...configured, ...config.env });
|
|
70
|
+
}
|
|
71
|
+
return configured;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
function operationPath(value: string, path: string): string {
|
|
@@ -144,7 +150,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
144
150
|
switchBackend: baseWire.switchBackend,
|
|
145
151
|
});
|
|
146
152
|
const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
|
|
147
|
-
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, codeSignalEdit: async (url,path,file) => editCodeSignal(runtime,url,path,await filesystem.readText(resolve(currentDirectory,file))), codeSignalRun: url => runCodeSignal(runtime,url), shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
153
|
+
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, searchNotion: (query, searchOptions) => searchNotion(runtime, query, searchOptions), codeSignalEdit: async (url,path,file) => editCodeSignal(runtime,url,path,await filesystem.readText(resolve(currentDirectory,file))), codeSignalRun: url => runCodeSignal(runtime,url), shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
148
154
|
lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
149
155
|
writes: { move: (task, project, section) => moveAsanaTask(runtime, task, project, section), create: (project, title, section, body, assignee) => createAsanaTask(runtime, project, title, section, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
|
|
150
156
|
}, async () => {
|