@kamilio/wire 0.1.26 → 0.1.28

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 (44) hide show
  1. package/README.md +3 -1
  2. package/dist/adapters/root.d.ts +6 -2
  3. package/dist/adapters/root.d.ts.map +1 -1
  4. package/dist/adapters/root.js +21 -3
  5. package/dist/adapters/root.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +7 -3
  8. package/dist/cli.js.map +1 -1
  9. package/dist/executable.d.ts.map +1 -1
  10. package/dist/executable.js +5 -4
  11. package/dist/executable.js.map +1 -1
  12. package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
  13. package/node_modules/provider-asana/dist/asana-project.js +2 -1
  14. package/node_modules/provider-asana/dist/asana-project.js.map +1 -1
  15. package/node_modules/provider-asana/dist/asana-sections.d.ts +27 -0
  16. package/node_modules/provider-asana/dist/asana-sections.d.ts.map +1 -0
  17. package/node_modules/provider-asana/dist/asana-sections.js +39 -0
  18. package/node_modules/provider-asana/dist/asana-sections.js.map +1 -0
  19. package/node_modules/provider-asana/dist/asana-task.d.ts +1 -1
  20. package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
  21. package/node_modules/provider-asana/dist/asana-task.js +15 -3
  22. package/node_modules/provider-asana/dist/asana-task.js.map +1 -1
  23. package/node_modules/provider-asana/dist/index.d.ts +1 -0
  24. package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
  25. package/node_modules/provider-asana/dist/index.js +1 -0
  26. package/node_modules/provider-asana/dist/index.js.map +1 -1
  27. package/node_modules/provider-asana/src/asana-project.ts +2 -1
  28. package/node_modules/provider-asana/src/asana-sections.ts +38 -0
  29. package/node_modules/provider-asana/src/asana-task.ts +14 -3
  30. package/node_modules/provider-asana/src/index.ts +1 -0
  31. package/node_modules/provider-zoom/dist/index.d.ts +2 -0
  32. package/node_modules/provider-zoom/dist/index.d.ts.map +1 -1
  33. package/node_modules/provider-zoom/dist/index.js +2 -1
  34. package/node_modules/provider-zoom/dist/index.js.map +1 -1
  35. package/node_modules/provider-zoom/dist/zoom-hub.d.ts +6 -0
  36. package/node_modules/provider-zoom/dist/zoom-hub.d.ts.map +1 -1
  37. package/node_modules/provider-zoom/dist/zoom-hub.js +180 -63
  38. package/node_modules/provider-zoom/dist/zoom-hub.js.map +1 -1
  39. package/node_modules/provider-zoom/src/index.ts +2 -1
  40. package/node_modules/provider-zoom/src/zoom-hub.ts +159 -58
  41. package/package.json +1 -1
  42. package/src/adapters/root.ts +26 -6
  43. package/src/cli.ts +4 -2
  44. package/src/executable.ts +5 -4
@@ -1,13 +1,14 @@
1
1
  import { UserError, defineCommand, defineGroup, S, type Group } from "toolcraft";
2
2
 
3
3
  import { defaultWireBackend, registryPathForBackend, type JsonObject, type FetchedDocument, type InitializedWire, type Resource, type SwitchedWireBackend, type Wire, type WireBackend, type WireResult, type WireWatchSession } from "wire-core";
4
- import type { listAsanaProjects, listAsanaTasks } from "provider-asana";
4
+ import type { listAsanaProjects, listAsanaTasks, moveAsanaTask, showAsanaProject } from "provider-asana";
5
+ import type { zoomProvider } from "provider-zoom";
5
6
  import type { SlackSentMessage } from "provider-slack";
6
7
  import type { Auth, AuthResult, AuthService } from "../auth.js";
7
8
 
8
9
  export type WireRoot = Group;
9
10
  export type TextInputReader = () => Promise<string>;
10
- export type WireRootOptions = Readonly<{ allowPaste: boolean }>;
11
+ export type WireRootOptions = Readonly<{ allowPaste: boolean; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
11
12
 
12
13
  const authServices = ["asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
13
14
  const removedCliCommandNames = Object.freeze({
@@ -208,6 +209,7 @@ function wireUserErrorMessage(message: string): boolean {
208
209
  || /^Asana API /.test(message)
209
210
  || /^(GET|POST|PUT|DELETE) \/.* failed: \d+ /.test(message)
210
211
  || /^(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)
212
+ || /^Zoom Hub rate limited; retry after /.test(message)
211
213
  || /^ChatGPT conversation download failed\. Run `wire chatgpt login`\./.test(message)
212
214
  || /^Gmail API .+ failed: HTTP \d+ /.test(message)
213
215
  || /^Slack API [\w.]+ failed: /.test(message)
@@ -419,10 +421,12 @@ function authGroup(service: AuthService, description: string, loginDescription:
419
421
  type AsanaExplorer = {
420
422
  lookup?(query: string): Promise<readonly JsonObject[]>;
421
423
  projects(): ReturnType<typeof listAsanaProjects>;
424
+ project(project: string): ReturnType<typeof showAsanaProject>;
422
425
  tasks(project: string): ReturnType<typeof listAsanaTasks>;
423
426
  show(task: string): Promise<FetchedDocument>;
424
427
  writes?: {
425
- create?(project: string, title: string, body?: string, assignee?: string): Promise<JsonObject>;
428
+ create?(project: string, title: string, section: string, body?: string, assignee?: string): Promise<JsonObject>;
429
+ move(task: string, project: string, section: string): ReturnType<typeof moveAsanaTask>;
426
430
  edit(task: string, fields: JsonObject): Promise<JsonObject>;
427
431
  comment(task: string, body: string): Promise<JsonObject>;
428
432
  editComment(comment: string, body: string): Promise<JsonObject>;
@@ -490,6 +494,11 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
490
494
  `${last ? " " : "│ "}${j === team.projects.length - 1 ? "└──" : "├──"} ${lineText(project.name)} ${project.gid}`)];
491
495
  })),
492
496
  ].join("\n")).join("\n\n") || "No workspaces"),
497
+ }), defineCommand({
498
+ name: "show", description: "Show a project and its sections in project order.", positional: ["project"],
499
+ params: S.Object({ project: S.String({ description: "Asana project ID." }) }),
500
+ handler: ({ params }) => userFacing(() => asana.project(params.project)),
501
+ render: render<Awaited<ReturnType<typeof showAsanaProject>>>((project) => [lineText(project.name), project.permalink_url, "", "Sections:", ...project.sections.map((section) => `- ${lineText(section.name)} ${section.gid}`)].join("\n")),
493
502
  })] }),
494
503
  defineGroup({ name: "tasks", description: "Browse, create, and edit tasks.", children: [defineCommand({
495
504
  name: "list", description: "List tasks in a project, with completion status and task IDs.", positional: ["project"],
@@ -501,15 +510,16 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
501
510
  params: S.Object({ task: S.String({ description: "Asana task ID." }) }),
502
511
  handler: ({ params }) => userFacing(() => asana.show(params.task)), render: wirePresentation.view,
503
512
  }), ...(createTask ? [defineCommand({
504
- name: "create", description: "Create a task in a project.", positional: ["project"],
513
+ name: "create", description: "Create a task in a project section. List sections with wire asana projects show <project>.", positional: ["project"],
505
514
  params: S.Object({
506
515
  project: S.String({ description: "Asana project ID." }),
507
516
  title: S.String({ description: "Task name." }),
517
+ section: S.String({ description: "Section ID or exact section name." }),
508
518
  body: S.Optional(S.String({ description: "Description in Markdown." })),
509
519
  assignee: S.Optional(S.String({ description: "Email, user ID, or me." })),
510
520
  }),
511
- handler: ({ params }) => userFacing(() => createTask(params.project, params.title, params.body, params.assignee)),
512
- render: render<JsonObject>((task) => `Created task ${task["gid"]}: ${task["permalink_url"]}`),
521
+ handler: ({ params }) => userFacing(() => createTask(params.project, params.title, params.section, params.body, params.assignee)),
522
+ render: render<JsonObject>((task) => `Created task ${task["gid"]}: ${task["permalink_url"]}\n${task["warning"] ? `Warning: ${task["warning"]}` : `Section: ${(task["section"] as JsonObject)["name"]}`}`),
513
523
  })] : []), ...(writes ? [defineCommand({
514
524
  name: "edit", description: "Update task properties. Use --fields with a JSON object for other writable Asana properties, including custom_fields keyed by ID.", positional: ["task"],
515
525
  params: S.Object({
@@ -531,6 +541,11 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
531
541
  return writes.edit(task, changes);
532
542
  }),
533
543
  render: render<JsonObject>((task) => `Updated task ${task["gid"]}: ${task["permalink_url"]}`),
544
+ }), defineCommand({
545
+ name: "move", description: "Move a task to a section within one of its projects.", positional: ["task"],
546
+ params: S.Object({ task: S.String({ description: "Asana task ID." }), project: S.String({ description: "Project containing the task." }), section: S.String({ description: "Section name or ID from projects show." }) }),
547
+ handler: ({ params }) => userFacing(() => writes.move(params.task, params.project, params.section)),
548
+ render: render<Awaited<ReturnType<typeof moveAsanaTask>>>((result) => `Task ${result.task} is in ${lineText(result.section.name)} (${result.section.gid}).`),
534
549
  }), defineCommand({
535
550
  name: "comment", description: "Add a Markdown comment to a task.", positional: ["task"],
536
551
  params: S.Object({ task: S.String({ description: "Asana task ID." }), body: S.String({ description: "Comment in Markdown." }) }),
@@ -544,6 +559,11 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
544
559
  render: render<JsonObject>((comment) => `Updated comment ${comment["gid"]}`),
545
560
  })] })] : []),
546
561
  ] });
562
+ if (service === "zoom" && options.scrapeZoom) return defineGroup({ ...group, children: [...group.children, defineCommand({
563
+ name: "scrape", scope: ["cli"], description: "Sync available Zoom Hub transcripts into ./zoom without deleting existing files.", params: S.Object({}),
564
+ handler: () => userFacing(options.scrapeZoom!),
565
+ render: render<Awaited<ReturnType<typeof zoomProvider.scrape>>>(v => `Zoom: ${v.downloaded} downloaded, ${v.unchanged} unchanged, ${v.unavailable} unavailable, ${v.locallyModified} locally modified.`),
566
+ })] });
547
567
  if (service !== "slack") return users.length === 0 ? group : defineGroup({ ...group, children: [...group.children, ...users] });
548
568
  return defineGroup({ name: "slack", description: "Read Slack channels, DMs, and threads, send Markdown, and manage login.", children: [preview, defaultAttach, sync, ...group.children, ...users, ...(sendSlack === undefined ? [] : [defineCommand({
549
569
  name: "send",
package/src/cli.ts CHANGED
@@ -239,10 +239,11 @@ function excessPositionals(argv: readonly string[]): Readonly<{ commandPath: str
239
239
  if (words === null || words.length === 0) return null;
240
240
  const command = words[0]!;
241
241
  if (command in fixedCommandPositionals) return Object.freeze({ commandPath: command, expected: fixedCommandPositionals[command as keyof typeof fixedCommandPositionals].expected, received: words.length - 1 });
242
- if (command === "asana" && ((words[1] === "projects" && words[2] === "list") || (words[1] === "tasks" && (words[2] === "list" || words[2] === "show")))) return { commandPath: words.slice(0, 3).join(" "), expected: words[1] === "projects" ? 0 : 1, received: words.length - 3 };
242
+ 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 };
243
243
  if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
244
244
  if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
245
245
  if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
246
+ if (command === "zoom" && words[1] === "scrape") return { commandPath: "zoom scrape", expected: 0, received: words.length - 2 };
246
247
  if (authServices.has(command)) {
247
248
  const authCommand = words[1];
248
249
  if (authCommand === undefined || !authCommands.has(authCommand)) return null;
@@ -257,6 +258,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
257
258
  const words = positionalWords(argv);
258
259
  if (words === null || words.length === 0) return null;
259
260
  const command = words[0]!;
261
+ if (command === "asana" && words[1] === "projects" && words[2] === "show" && words.length === 3) return { commandPath: words.join(" "), name: "project" };
260
262
  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" };
261
263
  if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
262
264
  if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
@@ -296,7 +298,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
296
298
  function renderUnknownAuthCommand(argv: readonly string[]): boolean {
297
299
  if (hasRootSeparator(argv)) return false;
298
300
  const words = positionalWords(argv);
299
- if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || 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;
301
+ if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (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;
300
302
  renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
301
303
  return true;
302
304
  }
package/src/executable.ts CHANGED
@@ -2,9 +2,10 @@ import { existsSync, readFileSync, statSync } from "node:fs";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
3
  import { dirname, isAbsolute, join, resolve } from "node:path";
4
4
 
5
- import { addAsanaComment, createAsanaTask, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, lookupAsanaUsers, showAsanaTask } from "provider-asana";
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 { zoomProvider } from "provider-zoom";
8
9
  import { lookupNotionUsers } from "provider-notion";
9
10
 
10
11
  import { createRoot } from "./adapters/root.js";
@@ -130,8 +131,8 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
130
131
  switchBackend: baseWire.switchBackend,
131
132
  });
132
133
  const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
133
- return createRoot(wire, currentDirectory, auth, readStandardInput, options, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
134
- lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
135
- writes: { create: (project, title, body, assignee) => createAsanaTask(runtime, project, title, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
134
+ 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), {
135
+ lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
136
+ 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) },
136
137
  });
137
138
  }