@kamilio/wire 0.1.21 → 0.1.23

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 (72) hide show
  1. package/README.md +15 -0
  2. package/dist/adapters/root.d.ts +12 -1
  3. package/dist/adapters/root.d.ts.map +1 -1
  4. package/dist/adapters/root.js +61 -1
  5. package/dist/adapters/root.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +5 -1
  8. package/dist/cli.js.map +1 -1
  9. package/dist/executable.d.ts.map +1 -1
  10. package/dist/executable.js +5 -1
  11. package/dist/executable.js.map +1 -1
  12. package/node_modules/@xmldom/xmldom/CHANGELOG.md +1132 -0
  13. package/node_modules/@xmldom/xmldom/LICENSE +8 -0
  14. package/node_modules/@xmldom/xmldom/SECURITY.md +50 -0
  15. package/node_modules/@xmldom/xmldom/index.d.ts +1843 -0
  16. package/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +3 -0
  17. package/node_modules/@xmldom/xmldom/lib/conventions.js +429 -0
  18. package/node_modules/@xmldom/xmldom/lib/dom-parser.js +591 -0
  19. package/node_modules/@xmldom/xmldom/lib/dom.js +3759 -0
  20. package/node_modules/@xmldom/xmldom/lib/entities.js +2171 -0
  21. package/node_modules/@xmldom/xmldom/lib/errors.js +205 -0
  22. package/node_modules/@xmldom/xmldom/lib/grammar.js +559 -0
  23. package/node_modules/@xmldom/xmldom/lib/index.js +41 -0
  24. package/node_modules/@xmldom/xmldom/lib/sax.js +983 -0
  25. package/node_modules/@xmldom/xmldom/package.json +77 -0
  26. package/node_modules/@xmldom/xmldom/readme.md +366 -0
  27. package/node_modules/marked/LICENSE.md +44 -0
  28. package/node_modules/marked/README.md +107 -0
  29. package/node_modules/marked/bin/main.js +284 -0
  30. package/node_modules/marked/bin/marked.js +16 -0
  31. package/node_modules/marked/lib/marked.d.ts +759 -0
  32. package/node_modules/marked/lib/marked.esm.js +72 -0
  33. package/node_modules/marked/lib/marked.esm.js.map +7 -0
  34. package/node_modules/marked/lib/marked.umd.js +74 -0
  35. package/node_modules/marked/lib/marked.umd.js.map +7 -0
  36. package/node_modules/marked/man/marked.1 +113 -0
  37. package/node_modules/marked/man/marked.1.md +93 -0
  38. package/node_modules/marked/package.json +103 -0
  39. package/node_modules/provider-asana/dist/asana-explore.d.ts +23 -0
  40. package/node_modules/provider-asana/dist/asana-explore.d.ts.map +1 -0
  41. package/node_modules/provider-asana/dist/asana-explore.js +26 -0
  42. package/node_modules/provider-asana/dist/asana-explore.js.map +1 -0
  43. package/node_modules/provider-asana/dist/asana-http.d.ts +3 -1
  44. package/node_modules/provider-asana/dist/asana-http.d.ts.map +1 -1
  45. package/node_modules/provider-asana/dist/asana-http.js +38 -0
  46. package/node_modules/provider-asana/dist/asana-http.js.map +1 -1
  47. package/node_modules/provider-asana/dist/asana-markdown.d.ts +5 -0
  48. package/node_modules/provider-asana/dist/asana-markdown.d.ts.map +1 -0
  49. package/node_modules/provider-asana/dist/asana-markdown.js +127 -0
  50. package/node_modules/provider-asana/dist/asana-markdown.js.map +1 -0
  51. package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
  52. package/node_modules/provider-asana/dist/asana-project.js +1 -39
  53. package/node_modules/provider-asana/dist/asana-project.js.map +1 -1
  54. package/node_modules/provider-asana/dist/asana-task.d.ts +17 -1
  55. package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
  56. package/node_modules/provider-asana/dist/asana-task.js +104 -21
  57. package/node_modules/provider-asana/dist/asana-task.js.map +1 -1
  58. package/node_modules/provider-asana/dist/index.d.ts +2 -1
  59. package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
  60. package/node_modules/provider-asana/dist/index.js +2 -1
  61. package/node_modules/provider-asana/dist/index.js.map +1 -1
  62. package/node_modules/provider-asana/package.json +2 -0
  63. package/node_modules/provider-asana/src/asana-explore.ts +29 -0
  64. package/node_modules/provider-asana/src/asana-http.ts +37 -1
  65. package/node_modules/provider-asana/src/asana-markdown.ts +113 -0
  66. package/node_modules/provider-asana/src/asana-project.ts +1 -37
  67. package/node_modules/provider-asana/src/asana-task.ts +91 -20
  68. package/node_modules/provider-asana/src/index.ts +2 -1
  69. package/package.json +12 -6
  70. package/src/adapters/root.ts +70 -1
  71. package/src/cli.ts +3 -1
  72. package/src/executable.ts +5 -1
@@ -1,4 +1,5 @@
1
- import { asanaHttp } from "./asana-http.js";
1
+ import { asanaMarkdown, asanaRichText } from "./asana-markdown.js";
2
+ import { asanaHttp, request } from "./asana-http.js";
2
3
  import { defineService } from "wire-core";
3
4
  import type { JsonObject, JsonValue } from "wire-core";
4
5
  import type { RuntimeCapabilities } from "wire-core";
@@ -37,7 +38,7 @@ async function asana(runtime: RuntimeCapabilities, path: string, parameters: Rea
37
38
 
38
39
  async function fetchTask(runtime: RuntimeCapabilities, identifier: string): Promise<JsonObject> {
39
40
  return object((await asana(runtime, `/tasks/${identifier}`, {
40
- opt_fields: "gid,name,notes,completed,completed_at,created_at,modified_at,due_on,due_at,permalink_url,assignee,assignee.name,assignee.email,memberships.project.gid,memberships.project.name,memberships.section.name,projects.name,tags.name",
41
+ opt_fields: "gid,name,notes,html_notes,completed,completed_at,created_at,modified_at,due_on,due_at,permalink_url,assignee,assignee.name,assignee.email,memberships.project.gid,memberships.project.name,memberships.section.name,projects.name,tags.name,start_on,start_at,resource_subtype,approval_status,custom_type.name,custom_type_status_option.name,custom_fields.name,custom_fields.resource_subtype,custom_fields.display_value,custom_fields.is_value_read_only,custom_fields.enabled,custom_fields.enum_options.name,custom_fields.enum_options.enabled,custom_fields.text_value,custom_fields.html_text_value,custom_fields.number_value,custom_fields.enum_value.name,custom_fields.multi_enum_values.name,custom_fields.date_value,custom_fields.people_value.name,custom_fields.reference_value.name",
41
42
  }))["data"]!);
42
43
  }
43
44
 
@@ -45,7 +46,7 @@ async function fetchStories(runtime: RuntimeCapabilities, identifier: string): P
45
46
  const stories: JsonValue[] = [];
46
47
  let offset: string | undefined;
47
48
  do {
48
- const parameters: Record<string, string> = { limit: "100", opt_fields: "gid,type,text,created_at,created_by.name,created_by.email,resource_subtype" };
49
+ const parameters: Record<string, string> = { limit: "100", opt_fields: "gid,type,text,html_text,is_editable,comment_gid,anchor_gid,created_at,created_by.name,created_by.email,resource_subtype" };
49
50
  if (offset !== undefined) parameters["offset"] = offset;
50
51
  const page = await asana(runtime, `/tasks/${identifier}/stories`, parameters);
51
52
  stories.push(...page["data"] as readonly JsonValue[]);
@@ -73,21 +74,91 @@ export const asanaTaskService = defineService<RuntimeCapabilities>({
73
74
  parse: (url) => {
74
75
  return Object.freeze({ service: "asana-task", identifier: taskIdentifier(url)!, type: "task" });
75
76
  },
76
- fetch: async (runtime, _url, source) => {
77
- const task = await fetchTask(runtime, source.identifier);
78
- const stories = await fetchStories(runtime, source.identifier);
79
- const assignee = task["assignee"] as JsonObject | null;
80
- const lines = [`# ${task["name"] as string}`, "", `- Source: ${task["permalink_url"] as string}`, `- Completed: ${task["completed"] as boolean ? "True" : "False"}`];
81
- if (assignee !== null) lines.push(`- Assignee: ${assignee["name"] as string}`);
82
- lines.push("", task["notes"] as string);
83
- if (stories.length > 0) {
84
- lines.push("", "## Activity", "");
85
- for (const value of stories) {
86
- const story = object(value);
87
- const createdBy = story["created_by"] as JsonObject | null;
88
- lines.push(`- ${story["created_at"] as string} — ${createdBy === null ? "System" : createdBy["name"] as string}: ${story["text"] as string}`);
89
- }
90
- }
91
- return Object.freeze({ title: task["name"] as string, markdown: `${lines.join("\n").trimEnd()}\n`, data: { task, stories } });
92
- },
77
+ fetch: (runtime, _url, source) => showAsanaTask(runtime, source.identifier),
93
78
  });
79
+
80
+ export async function showAsanaTask(runtime: RuntimeCapabilities, identifier: string) {
81
+ if (!/^\d+$/.test(identifier)) throw new Error("Expected a numeric Asana task ID.");
82
+ const task = await fetchTask(runtime, identifier);
83
+ const stories = await fetchStories(runtime, identifier);
84
+ const assignee = task["assignee"] as JsonObject | null;
85
+ const lines = [`# ${task["name"] as string}`, "", `- Source: ${task["permalink_url"] as string}`, `- Completed: ${task["completed"] as boolean ? "True" : "False"}`];
86
+ if (assignee !== null) lines.push(`- Assignee: ${assignee["name"]}${assignee["email"] ? ` <${assignee["email"]}>` : ""}`);
87
+ for (const [label, value] of [
88
+ ["Starts", task["start_at"] ?? task["start_on"]], ["Due", task["due_at"] ?? task["due_on"]],
89
+ ["Approval", task["resource_subtype"] === "approval" ? task["approval_status"] : null],
90
+ ["Task type", (task["custom_type"] as JsonObject | null)?.["name"]],
91
+ ["Status", (task["custom_type_status_option"] as JsonObject | null)?.["name"]],
92
+ ]) if (value) lines.push(`- ${label}: ${value}`);
93
+ const bodyMarkdown = task["html_notes"] ? asanaMarkdown(task["html_notes"] as string) : task["notes"] as string;
94
+ lines.push("", bodyMarkdown);
95
+ const fields = task["custom_fields"] as readonly JsonObject[] | undefined;
96
+ if (fields?.length) {
97
+ lines.push("", "## Custom fields", "");
98
+ for (const field of fields) {
99
+ const readOnly = field["is_value_read_only"] || field["enabled"] === false;
100
+ lines.push(`- ${field["name"]} (${field["gid"]}, ${field["resource_subtype"]}${readOnly ? ", read-only" : ""}): ${field["html_text_value"] ? asanaMarkdown(field["html_text_value"] as string) : field["display_value"] ?? "—"}`);
101
+ }
102
+ }
103
+ const comments: string[] = [];
104
+ const activity: string[] = [];
105
+ const storyData = stories.map((value) => {
106
+ const story = object(value);
107
+ const isComment = story["type"] === "comment" || story["resource_subtype"] === "comment_added";
108
+ const author = (story["created_by"] as JsonObject | null)?.["name"] ?? "System";
109
+ const id = isComment ? ` [${story["gid"]}${story["is_editable"] ? ", editable" : ""}]` : "";
110
+ if (isComment) {
111
+ const body = story["html_text"] ? asanaMarkdown(story["html_text"] as string) : story["text"] ?? "";
112
+ comments.push(`**${author}** · ${story["created_at"]}${id}\n\n${body}`);
113
+ return { ...story, body_markdown: body };
114
+ }
115
+ activity.push(`- ${story["created_at"]} — ${author}: ${story["text"] ?? ""}`);
116
+ return story;
117
+ });
118
+ if (comments.length) lines.push("", "## Comments", "", comments.join("\n\n"));
119
+ if (activity.length) lines.push("", "## Activity", "", ...activity);
120
+ return Object.freeze({ title: task["name"] as string, markdown: `${lines.join("\n").trimEnd()}\n`, data: { task: { ...task, body_markdown: bodyMarkdown }, stories: storyData } });
121
+ }
122
+
123
+ export async function editAsanaTask(runtime: RuntimeCapabilities, task: string, fields: JsonObject): Promise<JsonObject> {
124
+ if (!/^\d+$/.test(task)) throw new Error("Expected a numeric Asana task ID.");
125
+ if (!Object.keys(fields).length) throw new Error("No task fields to update.");
126
+ const data = { ...fields };
127
+ if ("html_notes" in data || "html_custom_fields" in data) throw new Error("Use Markdown in notes or custom_fields instead of HTML.");
128
+ if ("notes" in data) {
129
+ if (typeof data["notes"] !== "string") throw new Error("Task notes must be Markdown text.");
130
+ data["html_notes"] = asanaRichText(data["notes"], "task");
131
+ delete data["notes"];
132
+ }
133
+ const custom = data["custom_fields"];
134
+ if (custom && typeof custom === "object" && !Array.isArray(custom) && Object.values(custom).some(v => typeof v === "string")) {
135
+ const schema = object((await asana(runtime, `/tasks/${task}`, { opt_fields: "custom_fields.resource_subtype" }))["data"]!);
136
+ const values: Record<string, JsonValue> = { ...custom as JsonObject };
137
+ const rich: Record<string, string> = {};
138
+ for (const field of schema["custom_fields"] as readonly JsonObject[]) {
139
+ const key = field["gid"] as string;
140
+ const value = values[key];
141
+ if (field["resource_subtype"] !== "text" || typeof value !== "string") continue;
142
+ rich[key] = asanaRichText(value, "field");
143
+ delete values[key];
144
+ }
145
+ if (Object.keys(rich).length) {
146
+ data["html_custom_fields"] = rich;
147
+ if (Object.keys(values).length) data["custom_fields"] = values;
148
+ else delete data["custom_fields"];
149
+ }
150
+ }
151
+ return object((await request(runtime, "PUT", `/tasks/${task}`, { opt_fields: "name,permalink_url" }, data))["data"]!);
152
+ }
153
+
154
+ export async function addAsanaComment(runtime: RuntimeCapabilities, task: string, body: string): Promise<JsonObject> {
155
+ if (!/^\d+$/.test(task)) throw new Error("Expected a numeric Asana task ID.");
156
+ if (!body.trim()) throw new Error("Comment body cannot be empty.");
157
+ return object((await request(runtime, "POST", `/tasks/${task}/stories`, { opt_fields: "text" }, { html_text: asanaRichText(body, "comment") }))["data"]!);
158
+ }
159
+
160
+ export async function editAsanaComment(runtime: RuntimeCapabilities, comment: string, body: string): Promise<JsonObject> {
161
+ if (!/^\d+$/.test(comment)) throw new Error("Expected a numeric Asana comment ID.");
162
+ if (!body.trim()) throw new Error("Comment body cannot be empty.");
163
+ return object((await request(runtime, "PUT", `/stories/${comment}`, { opt_fields: "text" }, { html_text: asanaRichText(body, "comment") }))["data"]!);
164
+ }
@@ -2,7 +2,8 @@ import { asanaProjectService } from "./asana-project.js";
2
2
  import { asanaTaskService } from "./asana-task.js";
3
3
 
4
4
  export { asanaProjectService } from "./asana-project.js";
5
- export { asanaTaskService } from "./asana-task.js";
5
+ export { listAsanaProjects, listAsanaTasks } from "./asana-explore.js";
6
+ export { addAsanaComment, asanaTaskService, editAsanaComment, editAsanaTask, showAsanaTask } from "./asana-task.js";
6
7
  export { asanaChanges, asanaConflicts, asanaDocument, asanaSnapshot, parseAsanaMarkdown, renderAsanaMarkdown } from "./asana-sync.js";
7
8
  export type { AsanaChange, AsanaDocument, AsanaEntity } from "./asana-sync.js";
8
9
  export const asanaProvider = Object.freeze({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamilio/wire",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
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",
@@ -54,17 +54,19 @@
54
54
  "src"
55
55
  ],
56
56
  "bundledDependencies": [
57
+ "@xmldom/xmldom",
57
58
  "ajv",
58
59
  "commander",
59
60
  "fast-deep-equal",
60
61
  "fast-string-truncated-width",
61
62
  "fast-string-width",
62
- "fast-wrap-ansi",
63
63
  "fast-uri",
64
+ "fast-wrap-ansi",
64
65
  "ignore",
65
66
  "jose",
66
- "jsonc-parser",
67
67
  "json-schema-traverse",
68
+ "jsonc-parser",
69
+ "marked",
68
70
  "pct-encode",
69
71
  "provider-asana",
70
72
  "provider-chatgpt",
@@ -87,13 +89,14 @@
87
89
  "scripts": {
88
90
  "build": "tsc -p tsconfig.json",
89
91
  "dev-link": "npm link",
90
- "prepack": "cp ../../README.md README.md && rm -rf node_modules && mkdir -p node_modules && for package in provider-asana provider-chatgpt provider-gmail provider-google-docs provider-notion provider-slack provider-zoom wire-core; do cp -R ../$package node_modules/$package; done && for package in 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",
92
+ "prepack": "cp ../../README.md README.md && rm -rf node_modules && mkdir -p node_modules/@xmldom && for package in provider-asana provider-chatgpt provider-gmail provider-google-docs provider-notion provider-slack provider-zoom wire-core; do cp -R ../$package node_modules/$package; done && for package in @xmldom/xmldom 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",
91
93
  "postpack": "rm -rf node_modules README.md",
92
94
  "test": "node --test --test-concurrency=1 test/**/*.test.mjs",
93
95
  "typecheck": "tsc -p tsconfig.json --noEmit",
94
96
  "check": "npm run typecheck && npm run build && npm test"
95
97
  },
96
98
  "dependencies": {
99
+ "@xmldom/xmldom": "^0.9.12",
97
100
  "ajv": "^8.20.0",
98
101
  "commander": "^14.0.3",
99
102
  "fast-deep-equal": "^3.1.3",
@@ -105,6 +108,7 @@
105
108
  "jose": "^6.1.2",
106
109
  "json-schema-traverse": "^1.0.0",
107
110
  "jsonc-parser": "^3.3.1",
111
+ "marked": "^17.0.6",
108
112
  "pct-encode": "^1.0.3",
109
113
  "provider-asana": "0.1.0",
110
114
  "provider-chatgpt": "0.1.0",
@@ -132,17 +136,19 @@
132
136
  "node": ">=20"
133
137
  },
134
138
  "bundleDependencies": [
139
+ "@xmldom/xmldom",
135
140
  "ajv",
136
141
  "commander",
137
142
  "fast-deep-equal",
138
143
  "fast-string-truncated-width",
139
144
  "fast-string-width",
140
- "fast-wrap-ansi",
141
145
  "fast-uri",
146
+ "fast-wrap-ansi",
142
147
  "ignore",
143
148
  "jose",
144
- "jsonc-parser",
145
149
  "json-schema-traverse",
150
+ "jsonc-parser",
151
+ "marked",
146
152
  "pct-encode",
147
153
  "provider-asana",
148
154
  "provider-chatgpt",
@@ -1,6 +1,7 @@
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
5
  import type { SlackSentMessage } from "provider-slack";
5
6
  import type { Auth, AuthResult, AuthService } from "../auth.js";
6
7
 
@@ -415,7 +416,18 @@ function authGroup(service: AuthService, description: string, loginDescription:
415
416
  ] });
416
417
  }
417
418
 
418
- 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[]>): WireRoot {
419
+ type AsanaExplorer = {
420
+ projects(): ReturnType<typeof listAsanaProjects>;
421
+ tasks(project: string): ReturnType<typeof listAsanaTasks>;
422
+ show(task: string): Promise<FetchedDocument>;
423
+ writes?: {
424
+ edit(task: string, fields: JsonObject): Promise<JsonObject>;
425
+ comment(task: string, body: string): Promise<JsonObject>;
426
+ editComment(comment: string, body: string): Promise<JsonObject>;
427
+ };
428
+ };
429
+
430
+ 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): WireRoot {
419
431
  const attachFromCliUrl = (url: string) => {
420
432
  const removedCommand = removedCliCommandNames[url as keyof typeof removedCliCommandNames];
421
433
  if (removedCommand !== undefined) throw new UserError(`Unknown command: ${url}. ${removedCommand}`);
@@ -449,6 +461,63 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
449
461
  const authCommand = (service: (typeof authServices)[number]) => {
450
462
  const title = serviceTitle(service);
451
463
  const group = authGroup(service, `Manage ${title} login.`, "Capture cookies once; normal commands reuse saved cookies.", auth!, readInput, options);
464
+ const writes = asana?.writes;
465
+ if (service === "asana" && asana !== undefined) return defineGroup({ ...group, description: "Browse Asana projects, edit tasks and comments, and manage login.", children: [...group.children,
466
+ defineGroup({ name: "projects", description: "Browse projects.", children: [defineCommand({
467
+ name: "list", description: "List active projects by workspace and team.", params: S.Object({}),
468
+ handler: () => userFacing(() => asana.projects()),
469
+ render: render<Awaited<ReturnType<typeof listAsanaProjects>>>((workspaces) => workspaces.map((workspace) => [
470
+ lineText(workspace.name),
471
+ ...(workspace.teams.length === 0 ? [" (no active projects)"] : workspace.teams.flatMap((team, i) => {
472
+ const last = i === workspace.teams.length - 1;
473
+ return [`${last ? "└──" : "├──"} ${lineText(team.name)}`, ...team.projects.map((project, j) =>
474
+ `${last ? " " : "│ "}${j === team.projects.length - 1 ? "└──" : "├──"} ${lineText(project.name)} ${project.gid}`)];
475
+ })),
476
+ ].join("\n")).join("\n\n") || "No workspaces"),
477
+ })] }),
478
+ defineGroup({ name: "tasks", description: "Browse and edit tasks.", children: [defineCommand({
479
+ name: "list", description: "List tasks in a project, with completion status and task IDs.", positional: ["project"],
480
+ params: S.Object({ project: S.String({ description: "Asana project ID." }) }),
481
+ handler: ({ params }) => userFacing(() => asana.tasks(params.project)),
482
+ render: render<Awaited<ReturnType<typeof listAsanaTasks>>>((tasks) => tasks.map((task) => `- [${task.completed ? "x" : " "}] ${lineText(task.name)} ${task.gid}`).join("\n") || "No tasks"),
483
+ }), defineCommand({
484
+ name: "show", description: "Show a task's properties, custom field IDs, Markdown description, comments, and activity.", positional: ["task"],
485
+ params: S.Object({ task: S.String({ description: "Asana task ID." }) }),
486
+ handler: ({ params }) => userFacing(() => asana.show(params.task)), render: wirePresentation.view,
487
+ }), ...(writes ? [defineCommand({
488
+ 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"],
489
+ params: S.Object({
490
+ task: S.String({ description: "Asana task ID." }),
491
+ title: S.Optional(S.String({ description: "New task name." })),
492
+ body: S.Optional(S.String({ description: "New description in Markdown." })),
493
+ assignee: S.Optional(S.String({ description: "Email, user ID, or me." })),
494
+ due: S.Optional(S.String({ description: "Due date (YYYY-MM-DD)." })),
495
+ fields: S.Optional(S.Json()),
496
+ }),
497
+ handler: ({ params: { task, fields, title, body, assignee, due } }) => userFacing(async () => {
498
+ if (fields !== undefined && (!fields || typeof fields !== "object" || Array.isArray(fields))) throw new UserError("--fields requires a JSON object.");
499
+ const changes = { ...fields };
500
+ for (const [key, value] of Object.entries({ name: title, notes: body, assignee, due_on: due })) {
501
+ if (value === undefined) continue;
502
+ if (Object.hasOwn(changes, key)) throw new UserError(`Task field specified twice: ${key}.`);
503
+ changes[key] = value;
504
+ }
505
+ return writes.edit(task, changes);
506
+ }),
507
+ render: render<JsonObject>((task) => `Updated task ${task["gid"]}: ${task["permalink_url"]}`),
508
+ }), defineCommand({
509
+ name: "comment", description: "Add a Markdown comment to a task.", positional: ["task"],
510
+ params: S.Object({ task: S.String({ description: "Asana task ID." }), body: S.String({ description: "Comment in Markdown." }) }),
511
+ handler: ({ params }) => userFacing(() => writes.comment(params.task, params.body)),
512
+ render: render<JsonObject>((comment) => `Added comment ${comment["gid"]}`),
513
+ })] : [])] }),
514
+ ...(writes ? [defineGroup({ name: "comments", description: "Edit Asana comments.", children: [defineCommand({
515
+ name: "edit", description: "Replace an editable comment using its story ID from tasks show.", positional: ["comment"],
516
+ params: S.Object({ comment: S.String({ description: "Comment ID from tasks show." }), body: S.String({ description: "Replacement comment in Markdown." }) }),
517
+ handler: ({ params }) => userFacing(() => writes.editComment(params.comment, params.body)),
518
+ render: render<JsonObject>((comment) => `Updated comment ${comment["gid"]}`),
519
+ })] })] : []),
520
+ ] });
452
521
  const lookup = service === "slack" ? lookupSlack : service === "notion" ? lookupNotion : undefined;
453
522
  const users = lookup === undefined ? [] : [defineGroup({ name: "users", description: "Find people by email or name.", children: [defineCommand({
454
523
  name: "lookup",
package/src/cli.ts CHANGED
@@ -239,6 +239,7 @@ 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
243
  if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
243
244
  if ((command === "slack" || command === "notion") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
244
245
  if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
@@ -256,6 +257,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
256
257
  const words = positionalWords(argv);
257
258
  if (words === null || words.length === 0) return null;
258
259
  const command = words[0]!;
260
+ 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" };
259
261
  if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
260
262
  if ((command === "slack" || command === "notion") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
261
263
  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" };
@@ -294,7 +296,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
294
296
  function renderUnknownAuthCommand(argv: readonly string[]): boolean {
295
297
  if (hasRootSeparator(argv)) return false;
296
298
  const words = positionalWords(argv);
297
- if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "slack" || words[0] === "notion") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
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[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
298
300
  renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
299
301
  return true;
300
302
  }
package/src/executable.ts CHANGED
@@ -2,6 +2,7 @@ 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, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, showAsanaTask } from "provider-asana";
5
6
  import { sendSlackMessage, editSlackMessage, lookupSlackUsers } from "provider-slack";
6
7
 
7
8
  import { lookupNotionUsers } from "provider-notion";
@@ -129,5 +130,8 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
129
130
  switchBackend: baseWire.switchBackend,
130
131
  });
131
132
  const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
132
- 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));
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
+ projects: () => listAsanaProjects(runtime), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
135
+ writes: { edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
136
+ });
133
137
  }