@pxlabz/tasq-cli 0.1.22 → 0.1.24

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/.tasq-skill.md CHANGED
@@ -45,10 +45,13 @@ tasq task create <title> [--team <identifier>] [--description <markdown>]
45
45
  [--priority <priority>] [--project <id>]
46
46
  [--labels <a,b,c>] [--due <YYYY-MM-DD>]
47
47
  [--start <YYYY-MM-DD>] [--parent <ref>]
48
+ [--field <key=value>]…
48
49
  tasq task update <ref> [--title <title>] [--description <markdown>]
49
50
  [--priority <priority>] [--status <name>]
50
51
  [--due <YYYY-MM-DD|none>] [--start <YYYY-MM-DD|none>]
51
- [--parent <ref> | --no-parent]
52
+ [--parent <ref> | --no-parent] [--field <key=value>]…
53
+
54
+ tasq field list [--all]
52
55
 
53
56
  tasq comment add <ref> <body> [--reply-to <commentRef>] [--thread <threadId>]
54
57
  [--mention <name>]…
@@ -59,6 +62,14 @@ tasq time log <ref> <duration> [--day <YYYY-MM-DD>] [--note <text>] [--billable
59
62
  tasq time list <ref>
60
63
  tasq time edit <entryId> [--duration <duration>] [--day <YYYY-MM-DD>] [--note <text> | --no-note] [--billable <yes|no|unset>]
61
64
  tasq time delete <entryId>
65
+ tasq clients hours <client> [--month <YYYY-MM>] [--billable]
66
+ tasq clients billing <client>
67
+ tasq week [--day <YYYY-MM-DD>]
68
+ tasq timesheet show <draftId>
69
+ tasq timesheet save <draftId> --line <task>=<duration>[=<yes|no>[=<reason>]]… [--message <text>]
70
+ tasq timesheet request [--day <YYYY-MM-DD>] | log <draftId> | dismiss <draftId> | reply <draftId> <message> # people
71
+ tasq clients close|reopen <client> --month <YYYY-MM> # admins
72
+ tasq clients invoice <client> --month <YYYY-MM> [--ref <ref>] # admins
62
73
 
63
74
  tasq thread view <threadId>
64
75
  tasq thread context <threadId> [--markdown]
@@ -88,6 +99,8 @@ tasq auth whoami
88
99
 
89
100
  `--parent <ref>` makes the task a subtask of another task on the same team (one level only: a subtask cannot take subtasks, and an archived task cannot be a parent). A subtask's project and phase follow its parent, so `task create` refuses `--parent` together with `--project`; move the parent instead. `--no-parent` on `task update` detaches it and leaves its placement alone. `task view` prints `Parent: <key>` on a subtask and `Subtasks: <done>/<total> done` on a parent.
90
101
 
102
+ Custom fields: `tasq field list` shows each field's key, type, whether it applies to tasks or projects, and a select's option names (`--all` adds archived fields). `--field key=value` sets one on `task create` or `task update`, repeatable, one step per field after the task is written; `update` with only `--field` is fine. A multi-select or people field takes `a,b`; options and people go by name, a person also by email; `key=` clears it. Anything else is read forgivingly by the server (`1,200` is a number, `yes` ticks a checkbox) and a value that cannot fit is refused with the reason. An unknown key is a usage error naming the task fields, before anything is written. `task view` lists the values under `Fields:`.
103
+
91
104
  `--mention` is repeatable and matches a person or agent name exactly, ignoring case; a person also matches by email. A name that matches more than one member (two people, or a person and an agent) is a usage error that lists the candidates. Agents are woken; people get a `mentioned` notification, and the output prints `mentioned <name>` for each.
92
105
 
93
106
  `task view` and `thread view` print every message with its id on the header line, as ` <createdAt> <author> #<id>` with the body indented beneath it. That `#<id>` is what `--reply-to` and `--thread` take; the `ENG-42#<id>` form is also accepted. The parent must be a message on the same task or project.
@@ -98,7 +111,7 @@ A comment goes on a task or a project, never both and never neither: give the ta
98
111
 
99
112
  ## When you are mentioned
100
113
 
101
- `tasq events listen` prints NDJSON — one compact JSON object per line, per event — whatever `--json` says, because it is meant to be read by a loop. Each object carries ids only: `{ id, kind, workspace, taskId, taskKey, projectId, threadId, commentId, releaseId, mentionedBy, deliveryCount, createdAt }`. `kind` is `mention`, `thread_message` or `cycle_closed`; on the first two exactly one of `taskId` and `projectId` is set, and `mentionedBy` carries `{ memberId, type, name }` whose `type` is `user` or `agent`. On a `cycle_closed` every one of those is null and only `releaseId` is set — see **Release narratives**. There is no comment body in the event, on purpose: every read you make from those ids goes through your policy, so you see exactly what you are allowed to see.
114
+ `tasq events listen` prints NDJSON — one compact JSON object per line, per event — whatever `--json` says, because it is meant to be read by a loop. Each object carries ids only: `{ id, kind, workspace, taskId, taskKey, projectId, threadId, commentId, releaseId, mentionedBy, deliveryCount, createdAt }`. `kind` is `mention`, `thread_message`, `cycle_closed`, `timesheet_due` or `timesheet_reply`; on the first two exactly one of `taskId` and `projectId` is set, and `mentionedBy` carries `{ memberId, type, name }` whose `type` is `user` or `agent`. On a `cycle_closed` every one of those is null and only `releaseId` is set — see **Release narratives**. On the two timesheet kinds only `timeDraftId` is set — see **Timesheet drafts**. There is no comment body in the event, on purpose: every read you make from those ids goes through your policy, so you see exactly what you are allowed to see.
102
115
 
103
116
  The loop is:
104
117
 
@@ -164,6 +177,17 @@ Three things to know before you write:
164
177
 
165
178
  `tasq release list --team ENG` is the timeline, newest first; `tasq release view <releaseId>` shows one in full; `tasq release export <releaseId>` prints it as Markdown for a changelog. `examples/release-narrator.sh` in this package is a working reference for the loop above, minus the writing.
166
179
 
180
+ ## Timesheet drafts
181
+
182
+ If a team picked you to draft timesheets, Tasq wakes you with a `timesheet_due` event when a member's day ends (17:30 their time) with work on tasks and no time logged on them, or when they press "Draft my day". The event's `timeDraftId` is the whole payload. You draft; the member decides: nothing becomes time until they log it.
183
+
184
+ 1. **Read the day.** `tasq timesheet show <draftId> --json` gives the draft (`memberId`, `day`, the conversation). The MCP tool `time_draft_get` returns the draft with the member's day: the entries already logged and `unlogged`, each task they commented on or changed without logging time.
185
+ 2. **Draft it.** One line per task: a duration, whether it is billable when you can tell, and a one-line reason drawn from what you read ("2 comments, moved to In review"). Leave out what you can't justify.
186
+ 3. **Save it.** `tasq timesheet save <draftId> --line ENG-12=1h30m=yes=2 comments --line ENG-15=30m --message "Here's your Wednesday."` replaces every line. The member sees it on My week and in their Inbox.
187
+ 4. **Acknowledge.** `tasq events ack <eventId>`.
188
+
189
+ A `timesheet_reply` event means the member answered ("the logo was more like 2h"): read the draft again, the reply is the last message, and save a revised draft. Only the member can log, dismiss or reply; your policy refuses those whatever its preset, and you can only read days of members whose draft you were asked for.
190
+
167
191
  ## Project updates
168
192
 
169
193
  A project update is a health call (`on_track`, `at_risk` or `off_track`) and a Markdown body for the project's client. `<project>` is a project id or its exact name, ignoring case.
package/README.md CHANGED
@@ -27,9 +27,19 @@ TASQ_API_KEY=tq_ag_… TASQ_WORKSPACE=acme tasq task list
27
27
  ```
28
28
  tasq workspace list | use <slug>
29
29
  tasq task list | view <ref> | create | update <ref>
30
+ tasq task create|update … [--field <key=value>]…
31
+ tasq field list [--all]
30
32
  tasq comment add <ref> <body> [--reply-to <commentRef>] [--mention <name>]…
31
33
  tasq time log <ref> <duration> [--day YYYY-MM-DD] [--note <text>] [--billable yes|no]
32
34
  tasq time list <ref> | edit <entryId> [--duration] [--day] [--note | --no-note] [--billable] | delete <entryId>
35
+ tasq clients hours <client> [--month YYYY-MM] [--billable]
36
+ tasq clients billing <client>
37
+ tasq week [--day YYYY-MM-DD]
38
+ tasq timesheet request [--day YYYY-MM-DD] | show <draft> | log <draft> | dismiss <draft> | reply <draft> <message>
39
+ tasq timesheet save <draft> --line TASK=DURATION[=BILLABLE[=REASON]]… [--message <text>]
40
+ tasq clients close <client> --month YYYY-MM
41
+ tasq clients invoice <client> --month YYYY-MM [--ref <reference>]
42
+ tasq clients reopen <client> --month YYYY-MM
33
43
  tasq events listen [--wait <seconds>] [--once]
34
44
  tasq events ack <id>…
35
45
  tasq project list | star <project> | unstar <project>
@@ -42,7 +52,9 @@ tasq auth login | logout
42
52
 
43
53
  `project share` gives a guest (invited from the web app) a project, with comment access unless `--access view`; `project access` changes it and `project unshare` removes it. Admins and the project lead only; an agent key is refused.
44
54
 
45
- `time log` reads a duration as `1h 30m`, `1h30m`, `90m`, `1.5h` or `1:30` (quotes optional) and logs it on today, your local date, unless `--day` says otherwise. One entry is at most 24 hours. `time list` prints each entry with its id, then the total including direct subtasks. Time tracking is member-only: a guest is refused.
55
+ `field list` prints the workspace's custom fields with the key `--field` takes, the type, whether it applies to tasks or projects, and a select's option names; `--all` includes archived ones. `--field key=value` is repeatable on `task create` and `task update` and is set after the task is written, one step per field. A multi-select or people field takes `a,b`; options and people go by name (a person also by email); `key=` clears the field. The action reads the rest forgivingly (`1,200` is a number, `yes` ticks a checkbox) and says why when it cannot. `task view` lists the task's values under `Fields:`.
56
+
57
+ `time log` reads a duration as `1h 30m`, `1h30m`, `90m`, `1.5h` or `1:30` (quotes optional) and logs it on today, your local date, unless `--day` says otherwise. One entry is at most 24 hours. `time list` prints each entry with its id, then the total including direct subtasks. Time tracking is member-only: a guest is refused. `clients hours` reads one month of a client's hours by project and person, and lists entries with no billable flag; it works where a team with a project for that client has Client hours on. `clients billing` lists the client's months with their hours and state; `close`, `invoice` and `reopen` lock, mark and unlock one month where a team has Billing periods on, and only an admin can run them. A closed month refuses every change to its hours until it is reopened. The invoice reference is a label; tasq never computes an amount. `week` prints your Monday-to-Sunday hours, the chosen day's entries, and the tasks you changed or commented on that day without logging time; it works where a team has My week on. `timesheet` covers agent-drafted timesheets: `request` asks your team's drafting agent for a day, `show` prints a draft, `log` logs its ticked lines as your time, `dismiss` sets it aside, and `reply` answers the agent so it drafts again. `save` is the drafting agent's side and replaces the draft's lines; it works where a team has Agent timesheet drafts on and picked that agent.
46
58
 
47
59
  Every command takes `--json` for raw output and `-w, --workspace <slug>` to override the default. Task refs accept either the human key (`ENG-42`) or the UUID.
48
60
 
package/dist/tasq.js CHANGED
@@ -4970,17 +4970,17 @@ var require_layout_manager = __commonJS({
4970
4970
  let alloc = {};
4971
4971
  table2.forEach(function(row, rowIndex) {
4972
4972
  let col = 0;
4973
- row.forEach(function(cell) {
4974
- cell.y = rowIndex;
4975
- cell.x = rowIndex ? next(alloc, col) : col;
4976
- const rowSpan = cell.rowSpan || 1;
4977
- const colSpan = cell.colSpan || 1;
4973
+ row.forEach(function(cell2) {
4974
+ cell2.y = rowIndex;
4975
+ cell2.x = rowIndex ? next(alloc, col) : col;
4976
+ const rowSpan = cell2.rowSpan || 1;
4977
+ const colSpan = cell2.colSpan || 1;
4978
4978
  if (rowSpan > 1) {
4979
4979
  for (let cs = 0; cs < colSpan; cs++) {
4980
- alloc[cell.x + cs] = rowSpan;
4980
+ alloc[cell2.x + cs] = rowSpan;
4981
4981
  }
4982
4982
  }
4983
- col = cell.x + colSpan;
4983
+ col = cell2.x + colSpan;
4984
4984
  });
4985
4985
  Object.keys(alloc).forEach((idx) => {
4986
4986
  alloc[idx]--;
@@ -4991,8 +4991,8 @@ var require_layout_manager = __commonJS({
4991
4991
  function maxWidth(table2) {
4992
4992
  let mw = 0;
4993
4993
  table2.forEach(function(row) {
4994
- row.forEach(function(cell) {
4995
- mw = Math.max(mw, cell.x + (cell.colSpan || 1));
4994
+ row.forEach(function(cell2) {
4995
+ mw = Math.max(mw, cell2.x + (cell2.colSpan || 1));
4996
4996
  });
4997
4997
  });
4998
4998
  return mw;
@@ -5015,11 +5015,11 @@ var require_layout_manager = __commonJS({
5015
5015
  }
5016
5016
  function conflictExists(rows, x3, y3) {
5017
5017
  let i_max = Math.min(rows.length - 1, y3);
5018
- let cell = { x: x3, y: y3 };
5018
+ let cell2 = { x: x3, y: y3 };
5019
5019
  for (let i = 0; i <= i_max; i++) {
5020
5020
  let row = rows[i];
5021
5021
  for (let j2 = 0; j2 < row.length; j2++) {
5022
- if (cellsConflict(cell, row[j2])) {
5022
+ if (cellsConflict(cell2, row[j2])) {
5023
5023
  return true;
5024
5024
  }
5025
5025
  }
@@ -5036,12 +5036,12 @@ var require_layout_manager = __commonJS({
5036
5036
  }
5037
5037
  function addRowSpanCells(table2) {
5038
5038
  table2.forEach(function(row, rowIndex) {
5039
- row.forEach(function(cell) {
5040
- for (let i = 1; i < cell.rowSpan; i++) {
5041
- let rowSpanCell = new RowSpanCell(cell);
5042
- rowSpanCell.x = cell.x;
5043
- rowSpanCell.y = cell.y + i;
5044
- rowSpanCell.colSpan = cell.colSpan;
5039
+ row.forEach(function(cell2) {
5040
+ for (let i = 1; i < cell2.rowSpan; i++) {
5041
+ let rowSpanCell = new RowSpanCell(cell2);
5042
+ rowSpanCell.x = cell2.x;
5043
+ rowSpanCell.y = cell2.y + i;
5044
+ rowSpanCell.colSpan = cell2.colSpan;
5045
5045
  insertCell(rowSpanCell, table2[rowIndex + i]);
5046
5046
  }
5047
5047
  });
@@ -5051,22 +5051,22 @@ var require_layout_manager = __commonJS({
5051
5051
  for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) {
5052
5052
  let cellColumns = cellRows[rowIndex];
5053
5053
  for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) {
5054
- let cell = cellColumns[columnIndex];
5055
- for (let k3 = 1; k3 < cell.colSpan; k3++) {
5054
+ let cell2 = cellColumns[columnIndex];
5055
+ for (let k3 = 1; k3 < cell2.colSpan; k3++) {
5056
5056
  let colSpanCell = new ColSpanCell();
5057
- colSpanCell.x = cell.x + k3;
5058
- colSpanCell.y = cell.y;
5057
+ colSpanCell.x = cell2.x + k3;
5058
+ colSpanCell.y = cell2.y;
5059
5059
  cellColumns.splice(columnIndex + 1, 0, colSpanCell);
5060
5060
  }
5061
5061
  }
5062
5062
  }
5063
5063
  }
5064
- function insertCell(cell, row) {
5064
+ function insertCell(cell2, row) {
5065
5065
  let x3 = 0;
5066
- while (x3 < row.length && row[x3].x < cell.x) {
5066
+ while (x3 < row.length && row[x3].x < cell2.x) {
5067
5067
  x3++;
5068
5068
  }
5069
- row.splice(x3, 0, cell);
5069
+ row.splice(x3, 0, cell2);
5070
5070
  }
5071
5071
  function fillInTable(table2) {
5072
5072
  let h_max = maxHeight(table2);
@@ -5086,11 +5086,11 @@ var require_layout_manager = __commonJS({
5086
5086
  opts.rowSpan++;
5087
5087
  y22++;
5088
5088
  }
5089
- let cell = new Cell(opts);
5090
- cell.x = opts.x;
5091
- cell.y = opts.y;
5092
- warn(`Missing cell at ${cell.y}-${cell.x}.`);
5093
- insertCell(cell, table2[y3]);
5089
+ let cell2 = new Cell(opts);
5090
+ cell2.x = opts.x;
5091
+ cell2.y = opts.y;
5092
+ warn(`Missing cell at ${cell2.y}-${cell2.x}.`);
5093
+ insertCell(cell2, table2[y3]);
5094
5094
  }
5095
5095
  }
5096
5096
  }
@@ -5107,8 +5107,8 @@ var require_layout_manager = __commonJS({
5107
5107
  row = [key, row];
5108
5108
  }
5109
5109
  }
5110
- return row.map(function(cell) {
5111
- return new Cell(cell);
5110
+ return row.map(function(cell2) {
5111
+ return new Cell(cell2);
5112
5112
  });
5113
5113
  });
5114
5114
  }
@@ -5136,11 +5136,11 @@ var require_layout_manager = __commonJS({
5136
5136
  let spanners = [];
5137
5137
  let auto = {};
5138
5138
  table2.forEach(function(row) {
5139
- row.forEach(function(cell) {
5140
- if ((cell[colSpan] || 1) > 1) {
5141
- spanners.push(cell);
5139
+ row.forEach(function(cell2) {
5140
+ if ((cell2[colSpan] || 1) > 1) {
5141
+ spanners.push(cell2);
5142
5142
  } else {
5143
- result[cell[x3]] = Math.max(result[cell[x3]] || 0, cell[desiredWidth] || 0, forcedMin);
5143
+ result[cell2[x3]] = Math.max(result[cell2[x3]] || 0, cell2[desiredWidth] || 0, forcedMin);
5144
5144
  }
5145
5145
  });
5146
5146
  });
@@ -5150,9 +5150,9 @@ var require_layout_manager = __commonJS({
5150
5150
  }
5151
5151
  });
5152
5152
  for (let k3 = spanners.length - 1; k3 >= 0; k3--) {
5153
- let cell = spanners[k3];
5154
- let span = cell[colSpan];
5155
- let col = cell[x3];
5153
+ let cell2 = spanners[k3];
5154
+ let span = cell2[colSpan];
5155
+ let col = cell2[x3];
5156
5156
  let existingWidth = result[col];
5157
5157
  let editableCols = typeof vals[col] === "number" ? 0 : 1;
5158
5158
  if (typeof existingWidth === "number") {
@@ -5163,16 +5163,16 @@ var require_layout_manager = __commonJS({
5163
5163
  }
5164
5164
  }
5165
5165
  } else {
5166
- existingWidth = desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
5166
+ existingWidth = desiredWidth === "desiredWidth" ? cell2.desiredWidth - 1 : 1;
5167
5167
  if (!auto[col] || auto[col] < existingWidth) {
5168
5168
  auto[col] = existingWidth;
5169
5169
  }
5170
5170
  }
5171
- if (cell[desiredWidth] > existingWidth) {
5171
+ if (cell2[desiredWidth] > existingWidth) {
5172
5172
  let i = 0;
5173
- while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
5173
+ while (editableCols > 0 && cell2[desiredWidth] > existingWidth) {
5174
5174
  if (typeof vals[col + i] !== "number") {
5175
- let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
5175
+ let dif = Math.round((cell2[desiredWidth] - existingWidth) / editableCols);
5176
5176
  existingWidth += dif;
5177
5177
  result[col + i] += dif;
5178
5178
  editableCols--;
@@ -5240,15 +5240,15 @@ var require_table = __commonJS({
5240
5240
  }
5241
5241
  let cells = tableLayout.makeTableLayout(array);
5242
5242
  cells.forEach(function(row) {
5243
- row.forEach(function(cell) {
5244
- cell.mergeTableOptions(this.options, cells);
5243
+ row.forEach(function(cell2) {
5244
+ cell2.mergeTableOptions(this.options, cells);
5245
5245
  }, this);
5246
5246
  }, this);
5247
5247
  tableLayout.computeWidths(this.options.colWidths, cells);
5248
5248
  tableLayout.computeHeights(this.options.rowHeights, cells);
5249
5249
  cells.forEach(function(row) {
5250
- row.forEach(function(cell) {
5251
- cell.init(this.options);
5250
+ row.forEach(function(cell2) {
5251
+ cell2.init(this.options);
5252
5252
  }, this);
5253
5253
  }, this);
5254
5254
  let result = [];
@@ -5275,8 +5275,8 @@ var require_table = __commonJS({
5275
5275
  Table2.reset = () => debug.reset();
5276
5276
  function doDraw(row, lineNum, result) {
5277
5277
  let line2 = [];
5278
- row.forEach(function(cell) {
5279
- line2.push(cell.draw(lineNum));
5278
+ row.forEach(function(cell2) {
5279
+ line2.push(cell2.draw(lineNum));
5280
5280
  });
5281
5281
  let str = line2.join("");
5282
5282
  if (str.length) result.push(str);
@@ -6666,6 +6666,62 @@ var TasqClient = class _TasqClient {
6666
6666
  update: (slug, input) => this.dispatch("time.update", slug, input),
6667
6667
  delete: (slug, input) => this.dispatch("time.delete", slug, input)
6668
6668
  };
6669
+ /**
6670
+ * Clients (initiatives) and their hours. Member-only; refused unless a team
6671
+ * with a project for the client has Client hours on.
6672
+ */
6673
+ clients = {
6674
+ /**
6675
+ * One month of a client's hours by billable flag, project and person.
6676
+ * `month` is `YYYY-MM`; `billableOnly` counts billable entries only.
6677
+ */
6678
+ hours: (slug, clientId, month, options = {}) => this.#get(
6679
+ `/workspaces/${encodeURIComponent(slug)}/clients/${encodeURIComponent(clientId)}/hours`,
6680
+ { month, billable: options.billableOnly ? "billable" : "all" }
6681
+ ),
6682
+ /** A client's billing months, newest first, with each one's hours and state. */
6683
+ billing: (slug, clientId) => this.#get(
6684
+ `/workspaces/${encodeURIComponent(slug)}/clients/${encodeURIComponent(clientId)}/billing`
6685
+ )
6686
+ };
6687
+ /** The caller's own time (TM-2, My week). */
6688
+ me = {
6689
+ /**
6690
+ * The caller's Monday-to-Sunday week around `day` (`YYYY-MM-DD`), that
6691
+ * day's entries, and tasks they worked on that day with no time logged.
6692
+ * `tz` is the IANA zone that decides which edits fall on the day.
6693
+ */
6694
+ week: (slug, day, options = {}) => this.#get(
6695
+ `/workspaces/${encodeURIComponent(slug)}/me/week`,
6696
+ options.tz ? { day, tz: options.tz } : { day }
6697
+ )
6698
+ };
6699
+ /**
6700
+ * Agent timesheet drafts (TM-2). The drafting agent reads a draft and the
6701
+ * member's day and saves lines; the member requests, logs, dismisses or
6702
+ * replies. Agent keys are refused the member's side by policy.
6703
+ */
6704
+ timeDrafts = {
6705
+ get: async (slug, draftId2) => (await this.#get(
6706
+ `/workspaces/${encodeURIComponent(slug)}/time-drafts/${encodeURIComponent(draftId2)}`
6707
+ )).draft,
6708
+ /** The member's week around `day`, read by the agent that drafts it. */
6709
+ memberWeek: (slug, memberId, day) => this.#get(
6710
+ `/workspaces/${encodeURIComponent(slug)}/members/${encodeURIComponent(memberId)}/week`,
6711
+ { day }
6712
+ ),
6713
+ request: (slug, input) => this.dispatch("timeDraft.request", slug, input),
6714
+ save: (slug, input) => this.dispatch("timeDraft.save", slug, input),
6715
+ confirm: (slug, input) => this.dispatch("timeDraft.confirm", slug, input),
6716
+ dismiss: (slug, input) => this.dispatch("timeDraft.dismiss", slug, input),
6717
+ reply: (slug, input) => this.dispatch("timeDraft.reply", slug, input)
6718
+ };
6719
+ /** Close, invoice and reopen a client's month (admins only). */
6720
+ billingPeriods = {
6721
+ close: (slug, input) => this.dispatch("billingPeriod.close", slug, input),
6722
+ markInvoiced: (slug, input) => this.dispatch("billingPeriod.markInvoiced", slug, input),
6723
+ reopen: (slug, input) => this.dispatch("billingPeriod.reopen", slug, input)
6724
+ };
6669
6725
  projects = {
6670
6726
  list: async (slug) => (await this.#get(
6671
6727
  `/workspaces/${encodeURIComponent(slug)}/projects`
@@ -6786,6 +6842,19 @@ var TasqClient = class _TasqClient {
6786
6842
  `/workspaces/${encodeURIComponent(slug)}/labels`
6787
6843
  )).labels
6788
6844
  };
6845
+ /**
6846
+ * Custom fields (6.4): the workspace library, archived fields included.
6847
+ * Values are set with `task.setField` and `project.setField`, by field key.
6848
+ */
6849
+ fields = {
6850
+ list: async (slug) => (await this.#get(
6851
+ `/workspaces/${encodeURIComponent(slug)}/fields`
6852
+ )).fields,
6853
+ /** Set a task's value; null, `[]` or `false` clears it. */
6854
+ setTaskValue: (slug, taskId, fieldKey, value) => this.dispatch("task.setField", slug, { taskId, fieldKey, value }),
6855
+ /** Set a project field's value; null clears it. */
6856
+ setProjectValue: (slug, projectId, fieldKey, value) => this.dispatch("project.setField", slug, { projectId, fieldKey, value })
6857
+ };
6789
6858
  agents = {
6790
6859
  policy: (slug, agentId) => this.#get(
6791
6860
  `/workspaces/${encodeURIComponent(slug)}/agents/${encodeURIComponent(agentId)}/policy`
@@ -7004,7 +7073,7 @@ function reportError(error, io2) {
7004
7073
  // package.json
7005
7074
  var package_default = {
7006
7075
  name: "@pxlabz/tasq-cli",
7007
- version: "0.1.22",
7076
+ version: "0.1.24",
7008
7077
  description: "Command-line client for Tasq, for humans and agents alike",
7009
7078
  keywords: [
7010
7079
  "tasq",
@@ -7182,6 +7251,21 @@ function formatProjects(projects) {
7182
7251
  ])
7183
7252
  );
7184
7253
  }
7254
+ function formatFields(fields) {
7255
+ if (fields.length === 0) return "No fields.";
7256
+ return table(
7257
+ ["Key", "Name", "Type", "Applies to", "Options"],
7258
+ fields.map((field) => [
7259
+ field.key,
7260
+ field.archivedAt === null ? field.name : `${field.name} (archived)`,
7261
+ field.type,
7262
+ field.appliesTo,
7263
+ dash(
7264
+ field.options.filter((option) => option.archivedAt === null).map((option) => option.name).join(", ")
7265
+ )
7266
+ ])
7267
+ );
7268
+ }
7185
7269
  function formatInitiatives(initiatives) {
7186
7270
  if (initiatives.length === 0) return "No initiatives.";
7187
7271
  return table(
@@ -7706,6 +7790,14 @@ async function eventsAck(ctx, ids) {
7706
7790
  line(ctx.io, { acked: page.acked });
7707
7791
  }
7708
7792
 
7793
+ // src/commands/field.ts
7794
+ async function fieldList(ctx, options) {
7795
+ const slug = requireWorkspace(ctx.config);
7796
+ const library = await ctx.client.fields.list(slug);
7797
+ const fields = options.all === true ? library : library.filter((field) => field.archivedAt === null);
7798
+ ctx.io.out(ctx.config.json ? jsonOutput(fields) : formatFields(fields));
7799
+ }
7800
+
7709
7801
  // src/project-ref.ts
7710
7802
  var UUID_PATTERN3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7711
7803
  async function resolveProject(client, slug, ref) {
@@ -8174,6 +8266,103 @@ async function threadContext(ctx, threadId, _options = {}) {
8174
8266
  );
8175
8267
  }
8176
8268
 
8269
+ // src/fields.ts
8270
+ var UUID_PATTERN5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8271
+ function parseFieldFlags(flags) {
8272
+ return flags.map((flag) => {
8273
+ const equals = flag.indexOf("=");
8274
+ const key = equals === -1 ? "" : flag.slice(0, equals).trim();
8275
+ if (key === "") {
8276
+ throw new UsageError(
8277
+ `--field takes key=value, such as --field budget=1200. Got "${flag}".`
8278
+ );
8279
+ }
8280
+ const raw = flag.slice(equals + 1).trim();
8281
+ return { key, value: raw === "" ? null : raw };
8282
+ });
8283
+ }
8284
+ function takesList(field) {
8285
+ return field.type === "multi_select" || field.type === "people";
8286
+ }
8287
+ function asPicks(value) {
8288
+ const picks = Array.isArray(value) ? value : String(value).split(",");
8289
+ return picks.map((pick) => pick.trim()).filter((pick) => pick !== "");
8290
+ }
8291
+ function resolvePerson(members, field, ref) {
8292
+ if (UUID_PATTERN5.test(ref)) return ref;
8293
+ const wanted = ref.toLowerCase();
8294
+ const matched = members.filter(
8295
+ (member) => member.role !== "guest" && ((member.name ?? "").toLowerCase() === wanted || member.type === "user" && (member.email ?? "").toLowerCase() === wanted)
8296
+ );
8297
+ const [only] = matched;
8298
+ if (only === void 0) {
8299
+ throw new UsageError(
8300
+ `No member named "${ref}" for ${field.name}. Pass a name, an email or a member id.`
8301
+ );
8302
+ }
8303
+ if (matched.length > 1) {
8304
+ throw new UsageError(
8305
+ `"${ref}" matches ${matched.length} members for ${field.name}. Pass their email or member id.`
8306
+ );
8307
+ }
8308
+ return only.id;
8309
+ }
8310
+ async function resolveFieldEdits(client, slug, edits) {
8311
+ if (edits.length === 0) return [];
8312
+ const library = await client.fields.list(slug);
8313
+ const taskFields = library.filter(
8314
+ (field) => field.appliesTo === "task" && field.archivedAt === null
8315
+ );
8316
+ const settled = edits.map((edit) => {
8317
+ const wanted = edit.key.toLowerCase();
8318
+ const field = taskFields.find((candidate) => candidate.key === wanted);
8319
+ if (field === void 0) {
8320
+ throw new UsageError(
8321
+ taskFields.length === 0 ? `Unknown field "${edit.key}". This workspace has no task fields.` : `Unknown field "${edit.key}". Task fields: ${taskFields.map((candidate) => candidate.key).join(", ")}.`
8322
+ );
8323
+ }
8324
+ if (edit.value === null || !takesList(field)) {
8325
+ return { field, value: edit.value };
8326
+ }
8327
+ const picks = asPicks(edit.value);
8328
+ return { field, value: picks.length === 0 ? null : picks };
8329
+ });
8330
+ const needsMembers = settled.some(
8331
+ (edit) => edit.field.type === "people" && edit.value !== null
8332
+ );
8333
+ const members = needsMembers ? await client.members.list(slug) : [];
8334
+ return settled.map(({ field, value }) => ({
8335
+ key: field.key,
8336
+ value: field.type === "people" && Array.isArray(value) ? value.map((ref) => resolvePerson(members, field, ref)) : value
8337
+ }));
8338
+ }
8339
+ function numberText(field, value) {
8340
+ const number = String(value);
8341
+ if (field.numberFormat === "percent") return `${number}%`;
8342
+ if (field.numberFormat === "currency" && field.currencyCode !== null) {
8343
+ return `${field.currencyCode} ${number}`;
8344
+ }
8345
+ return number;
8346
+ }
8347
+ function fieldValueText(field, value, memberName) {
8348
+ if (value === null) return "\u2014";
8349
+ const optionName = (id) => field.options.find((option) => option.id === id)?.name ?? "Removed option";
8350
+ const picks = Array.isArray(value) ? value : [String(value)];
8351
+ switch (field.type) {
8352
+ case "number":
8353
+ return numberText(field, value);
8354
+ case "checkbox":
8355
+ return value === true ? "yes" : "no";
8356
+ case "single_select":
8357
+ case "multi_select":
8358
+ return picks.map(optionName).join(", ");
8359
+ case "people":
8360
+ return picks.map(memberName).join(", ");
8361
+ default:
8362
+ return String(value);
8363
+ }
8364
+ }
8365
+
8177
8366
  // src/commands/task.ts
8178
8367
  var PRIORITIES = ["urgent", "high", "medium", "low", "none"];
8179
8368
  function priority(value) {
@@ -8234,6 +8423,40 @@ var StepRunner = class {
8234
8423
  return result;
8235
8424
  }
8236
8425
  };
8426
+ async function applyFieldEdits(ctx, slug, steps, taskId, edits) {
8427
+ const lines = [];
8428
+ for (const edit of edits) {
8429
+ const response = await steps.run(
8430
+ `field "${edit.key}"`,
8431
+ () => ctx.client.dispatch("task.setField", slug, {
8432
+ taskId,
8433
+ fieldKey: edit.key,
8434
+ value: edit.value
8435
+ })
8436
+ );
8437
+ const { field, display } = response.result;
8438
+ lines.push(
8439
+ display.value === null ? ` ${field.name}: cleared` : ` ${field.name}: ${display.value}`
8440
+ );
8441
+ }
8442
+ return lines;
8443
+ }
8444
+ async function fieldLines(ctx, slug, task) {
8445
+ if (task.fieldValues.length === 0) return [];
8446
+ const library = await ctx.client.fields.list(slug);
8447
+ const held = library.flatMap((field) => {
8448
+ const item = task.fieldValues.find((value) => value.fieldId === field.id);
8449
+ return item === void 0 ? [] : [{ field, value: item.value }];
8450
+ });
8451
+ const members = held.some(({ field }) => field.type === "people") ? await ctx.client.members.list(slug) : [];
8452
+ const memberName = (memberId) => {
8453
+ const member = members.find((candidate) => candidate.id === memberId);
8454
+ return member?.name ?? member?.email ?? "Someone";
8455
+ };
8456
+ return held.map(
8457
+ ({ field, value }) => ` ${field.name}: ${fieldValueText(field, value, memberName)}`
8458
+ );
8459
+ }
8237
8460
  function filters(options) {
8238
8461
  const entries = Object.entries(options).filter(
8239
8462
  ([, value]) => value !== void 0
@@ -8293,6 +8516,11 @@ async function taskView(ctx, taskRef) {
8293
8516
  `Subtasks: ${task.subtaskProgress.completed}/${task.subtaskProgress.total} done`
8294
8517
  );
8295
8518
  }
8519
+ const fields = await fieldLines(ctx, slug, task);
8520
+ if (fields.length > 0) {
8521
+ ctx.io.out("Fields:");
8522
+ for (const line2 of fields) ctx.io.out(line2);
8523
+ }
8296
8524
  if (task.descriptionMarkdown !== null && task.descriptionMarkdown !== "") {
8297
8525
  ctx.io.out("");
8298
8526
  ctx.io.out(task.descriptionMarkdown);
@@ -8346,6 +8574,11 @@ async function taskCreate(ctx, title, options) {
8346
8574
  const labelNames = options.labels === void 0 || options.labels === "" ? [] : options.labels.split(",").map((name) => name.trim());
8347
8575
  const labelIds = labelNames.length === 0 ? [] : await resolveLabelIds(ctx, slug, labelNames);
8348
8576
  const edits = dateEdits(options);
8577
+ const fieldEdits = await resolveFieldEdits(
8578
+ ctx.client,
8579
+ slug,
8580
+ parseFieldFlags(options.field ?? [])
8581
+ );
8349
8582
  const input = { teamIdentifier, title };
8350
8583
  if (options.description !== void 0) {
8351
8584
  input.descriptionMarkdown = options.description;
@@ -8379,9 +8612,19 @@ async function taskCreate(ctx, title, options) {
8379
8612
  })
8380
8613
  );
8381
8614
  }
8382
- ctx.io.out(
8383
- ctx.config.json ? jsonOutput(created.result) : `Created ${created.result.identifier}: ${task.title}`
8615
+ const fieldOutput = await applyFieldEdits(
8616
+ ctx,
8617
+ slug,
8618
+ steps,
8619
+ task.id,
8620
+ fieldEdits
8384
8621
  );
8622
+ if (ctx.config.json) {
8623
+ ctx.io.out(jsonOutput(created.result));
8624
+ return;
8625
+ }
8626
+ ctx.io.out(`Created ${created.result.identifier}: ${task.title}`);
8627
+ for (const line2 of fieldOutput) ctx.io.out(line2);
8385
8628
  }
8386
8629
  async function resolveStatusId(ctx, slug, teamIdentifier, name) {
8387
8630
  const team = await ctx.client.teams.get(slug, teamIdentifier);
@@ -8397,13 +8640,19 @@ async function resolveStatusId(ctx, slug, teamIdentifier, name) {
8397
8640
  }
8398
8641
  async function taskUpdate(ctx, taskRef, options) {
8399
8642
  const slug = requireWorkspace(ctx.config);
8400
- const changed = Object.values(options).some((value) => value !== void 0);
8643
+ const { field: fieldFlags = [], ...fixed } = options;
8644
+ const changed = fieldFlags.length > 0 || Object.values(fixed).some((value) => value !== void 0);
8401
8645
  if (!changed) {
8402
8646
  throw new UsageError(
8403
- "Nothing to update. Pass at least one of --title, --description, --priority, --status, --due, --start, --parent, --no-parent."
8647
+ "Nothing to update. Pass at least one of --title, --description, --priority, --status, --due, --start, --parent, --no-parent, --field."
8404
8648
  );
8405
8649
  }
8406
8650
  const edits = dateEdits(options);
8651
+ const fieldEdits = await resolveFieldEdits(
8652
+ ctx.client,
8653
+ slug,
8654
+ parseFieldFlags(fieldFlags)
8655
+ );
8407
8656
  const parentTaskId = options.parent === void 0 ? void 0 : options.parent === false ? null : await resolveTaskId(ctx.client, slug, options.parent);
8408
8657
  const taskId = await resolveTaskId(ctx.client, slug, taskRef);
8409
8658
  const task = await ctx.client.tasks.get(slug, taskId);
@@ -8460,10 +8709,20 @@ async function taskUpdate(ctx, taskRef, options) {
8460
8709
  () => ctx.client.dispatch("task.move", slug, { taskId: task.id, statusId })
8461
8710
  );
8462
8711
  }
8463
- const updated = await ctx.client.tasks.get(slug, task.id);
8464
- ctx.io.out(
8465
- ctx.config.json ? jsonOutput(updated) : `Updated ${updated.identifier}: ${updated.title}`
8712
+ const fieldOutput = await applyFieldEdits(
8713
+ ctx,
8714
+ slug,
8715
+ steps,
8716
+ task.id,
8717
+ fieldEdits
8466
8718
  );
8719
+ const updated = await ctx.client.tasks.get(slug, task.id);
8720
+ if (ctx.config.json) {
8721
+ ctx.io.out(jsonOutput(updated));
8722
+ return;
8723
+ }
8724
+ ctx.io.out(`Updated ${updated.identifier}: ${updated.title}`);
8725
+ for (const line2 of fieldOutput) ctx.io.out(line2);
8467
8726
  }
8468
8727
  var APPROVAL_STATE_WORDS = {
8469
8728
  requested: ["requested", "from"],
@@ -8478,7 +8737,7 @@ function approvalLine(approval) {
8478
8737
  }
8479
8738
  return `${state} ${preposition} ${approval.approver.name ?? approval.approver.memberId}`;
8480
8739
  }
8481
- var UUID_PATTERN5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8740
+ var UUID_PATTERN6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8482
8741
  function resolveApprover(members, ref) {
8483
8742
  const wanted = ref.trim().toLowerCase();
8484
8743
  const matched = members.filter(
@@ -8503,7 +8762,7 @@ async function taskRequestApproval(ctx, taskRef, options) {
8503
8762
  throw new UsageError("--approver is required: a person's name, email or member id.");
8504
8763
  }
8505
8764
  const ref = options.approver.trim();
8506
- const approver = UUID_PATTERN5.test(ref) ? { id: ref, name: null } : resolveApprover(await ctx.client.members.list(slug), ref);
8765
+ const approver = UUID_PATTERN6.test(ref) ? { id: ref, name: null } : resolveApprover(await ctx.client.members.list(slug), ref);
8507
8766
  const taskId = await resolveTaskId(ctx.client, slug, taskRef);
8508
8767
  const response = await ctx.client.dispatch("task.requestApproval", slug, {
8509
8768
  taskId,
@@ -8533,7 +8792,7 @@ async function taskDecide(ctx, taskRef, decision) {
8533
8792
  // src/commands/time.ts
8534
8793
  var MAX_ENTRY_MINUTES = 24 * 60;
8535
8794
  var CALENDAR_DATE2 = /^\d{4}-\d{2}-\d{2}$/;
8536
- var UUID_PATTERN6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8795
+ var UUID_PATTERN7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8537
8796
  var BILLABLE_FLAGS = [
8538
8797
  ["yes", "billable"],
8539
8798
  ["no", "non_billable"],
@@ -8584,7 +8843,7 @@ function billableValue(value) {
8584
8843
  }
8585
8844
  function entryId(ref) {
8586
8845
  const trimmed = ref.trim();
8587
- if (!UUID_PATTERN6.test(trimmed)) {
8846
+ if (!UUID_PATTERN7.test(trimmed)) {
8588
8847
  throw new UsageError(
8589
8848
  `"${ref}" is not a time entry id. Run "tasq time list <task>" to see the ids.`
8590
8849
  );
@@ -8670,6 +8929,234 @@ async function timeDelete(ctx, ref) {
8670
8929
  );
8671
8930
  }
8672
8931
 
8932
+ // src/commands/clients.ts
8933
+ var MONTH = /^\d{4}-(0[1-9]|1[0-2])$/;
8934
+ function cell(minutes) {
8935
+ return minutes === 0 ? "\u2013" : formatMinutes(minutes);
8936
+ }
8937
+ function formatClientHours(hours) {
8938
+ const { totals } = hours;
8939
+ const lock = hours.period ? ` \xB7 ${hours.period.state}${hours.period.invoiceRef ? ` ${hours.period.invoiceRef}` : ""}` : "";
8940
+ const lines = [
8941
+ `${hours.name} \xB7 ${hours.month}${hours.billableOnly ? " \xB7 billable only" : ""}${lock}`,
8942
+ hours.billableOnly ? `Billable ${formatMinutes(totals.billable)}` : `Logged ${formatMinutes(totals.total)} \xB7 billable ${formatMinutes(totals.billable)} \xB7 non-billable ${formatMinutes(totals.nonBillable)} \xB7 not set ${formatMinutes(totals.notSet)}`
8943
+ ];
8944
+ for (const project of hours.projects) {
8945
+ lines.push(
8946
+ "",
8947
+ `${project.name}${project.shared ? " (also under another client)" : ""} ${cell(hours.billableOnly ? project.billable : project.total)}`
8948
+ );
8949
+ for (const person of project.people) {
8950
+ lines.push(
8951
+ ` ${person.name ?? "Former member"} ${cell(hours.billableOnly ? person.billable : person.total)}`
8952
+ );
8953
+ }
8954
+ }
8955
+ if (hours.notSetEntries.length > 0) {
8956
+ lines.push("", `${hours.notSetEntries.length} not set:`);
8957
+ for (const entry of hours.notSetEntries) {
8958
+ lines.push(
8959
+ ` ${entry.spentOn} ${entry.identifier} ${formatMinutes(entry.minutes)} ${entry.taskTitle}`
8960
+ );
8961
+ }
8962
+ }
8963
+ return lines.join("\n");
8964
+ }
8965
+ function requireMonth(month) {
8966
+ if (!MONTH.test(month)) {
8967
+ throw new UsageError(`"${month}" is not a month. Use YYYY-MM, like 2026-09.`);
8968
+ }
8969
+ return month;
8970
+ }
8971
+ async function clientHours(ctx, clientRef, options, deps = {}) {
8972
+ const month = requireMonth(options.month ?? (deps.today ?? localToday)().slice(0, 7));
8973
+ const slug = requireWorkspace(ctx.config);
8974
+ const client = await resolveInitiative(ctx, slug, clientRef);
8975
+ const hours = await ctx.client.clients.hours(slug, client.id, month, {
8976
+ billableOnly: options.billable === true
8977
+ });
8978
+ ctx.io.out(ctx.config.json ? jsonOutput(hours) : formatClientHours(hours));
8979
+ }
8980
+ function formatClientBilling(billing) {
8981
+ const lines = [billing.name];
8982
+ for (const month of billing.months) {
8983
+ const state = month.period ? `${month.period.state}${month.period.invoiceRef ? ` ${month.period.invoiceRef}` : ""}` : "open";
8984
+ lines.push(
8985
+ ` ${month.month} ${cell(month.total).padStart(8)} billable ${cell(month.billable).padStart(8)} ${state}`
8986
+ );
8987
+ }
8988
+ return lines.join("\n");
8989
+ }
8990
+ async function clientBilling(ctx, clientRef) {
8991
+ const slug = requireWorkspace(ctx.config);
8992
+ const client = await resolveInitiative(ctx, slug, clientRef);
8993
+ const billing = await ctx.client.clients.billing(slug, client.id);
8994
+ ctx.io.out(ctx.config.json ? jsonOutput(billing) : formatClientBilling(billing));
8995
+ }
8996
+ async function clientBillingPeriod(ctx, action, clientRef, options) {
8997
+ const month = requireMonth(options.month);
8998
+ const slug = requireWorkspace(ctx.config);
8999
+ const client = await resolveInitiative(ctx, slug, clientRef);
9000
+ const input = { clientId: client.id, month };
9001
+ if (action === "close") {
9002
+ const { result: result2 } = await ctx.client.billingPeriods.close(slug, input);
9003
+ ctx.io.out(
9004
+ ctx.config.json ? jsonOutput(result2) : `${client.name} ${month} ${result2.closed ? "closed" : `was already ${result2.period.state}`}.`
9005
+ );
9006
+ return;
9007
+ }
9008
+ if (action === "invoice") {
9009
+ const { result: result2 } = await ctx.client.billingPeriods.markInvoiced(slug, {
9010
+ ...input,
9011
+ invoiceRef: options.ref ?? null
9012
+ });
9013
+ ctx.io.out(
9014
+ ctx.config.json ? jsonOutput(result2) : `${client.name} ${month} marked invoiced${result2.period.invoiceRef ? ` (${result2.period.invoiceRef})` : ""}.`
9015
+ );
9016
+ return;
9017
+ }
9018
+ const { result } = await ctx.client.billingPeriods.reopen(slug, input);
9019
+ ctx.io.out(
9020
+ ctx.config.json ? jsonOutput(result) : `${client.name} ${month} ${result.previous ? "reopened" : "was already open"}.`
9021
+ );
9022
+ }
9023
+
9024
+ // src/commands/timesheet.ts
9025
+ var DAY = /^\d{4}-\d{2}-\d{2}$/;
9026
+ var UUID_PATTERN8 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9027
+ function draftId(ref) {
9028
+ const trimmed = ref.trim();
9029
+ if (!UUID_PATTERN8.test(trimmed)) {
9030
+ throw new UsageError(
9031
+ `"${ref}" is not a draft id. It is the timeDraftId on a timesheet_due or timesheet_reply event.`
9032
+ );
9033
+ }
9034
+ return trimmed;
9035
+ }
9036
+ function formatDraft(draft) {
9037
+ const agent = draft.agent?.name ?? "The agent";
9038
+ const lines = [`${draft.day} \xB7 ${draft.state} \xB7 drafted by ${agent}`];
9039
+ if (draft.lines.length === 0) lines.push(" No lines yet.");
9040
+ for (const line2 of draft.lines) {
9041
+ const tick = line2.entryId ? "logged" : line2.included ? "[x]" : "[ ]";
9042
+ const why = line2.evidence ? ` \xB7 ${line2.evidence}` : "";
9043
+ lines.push(` ${tick} ${line2.identifier} ${formatMinutes(line2.minutes)} ${line2.title}${why}`);
9044
+ }
9045
+ if (draft.messages.length > 0) {
9046
+ lines.push("");
9047
+ for (const message of draft.messages) {
9048
+ lines.push(`${message.authorName ?? "Former member"}: ${message.body}`);
9049
+ }
9050
+ }
9051
+ return lines.join("\n");
9052
+ }
9053
+ async function timesheetRequest(ctx, options, deps = {}) {
9054
+ const day = options.day ?? (deps.today ?? localToday)();
9055
+ if (!DAY.test(day)) {
9056
+ throw new UsageError(`"${day}" is not a day. Use YYYY-MM-DD, like 2026-10-07.`);
9057
+ }
9058
+ const slug = requireWorkspace(ctx.config);
9059
+ const { result } = await ctx.client.timeDrafts.request(slug, { day });
9060
+ ctx.io.out(
9061
+ ctx.config.json ? jsonOutput(result) : result.requested ? `Asked for a draft of ${day} (draft ${result.draft.id})` : `${day} already has a draft (${result.draft.id}, ${result.draft.state})`
9062
+ );
9063
+ }
9064
+ async function timesheetShow(ctx, ref) {
9065
+ const slug = requireWorkspace(ctx.config);
9066
+ const draft = await ctx.client.timeDrafts.get(slug, draftId(ref));
9067
+ ctx.io.out(ctx.config.json ? jsonOutput(draft) : formatDraft(draft));
9068
+ }
9069
+ async function timesheetSave(ctx, ref, options) {
9070
+ const slug = requireWorkspace(ctx.config);
9071
+ const lines = [];
9072
+ for (const raw of options.line ?? []) {
9073
+ const [task, duration, billable, ...evidence] = raw.split("=");
9074
+ if (!task || !duration) {
9075
+ throw new UsageError(
9076
+ `--line takes TASK=DURATION, optionally =BILLABLE=REASON, like ENG-12=1h30m=yes=2 comments. Got "${raw}".`
9077
+ );
9078
+ }
9079
+ const line2 = {
9080
+ taskId: await resolveTaskId(ctx.client, slug, task),
9081
+ minutes: durationMinutes(duration)
9082
+ };
9083
+ if (billable) line2.billable = billableValue(billable);
9084
+ if (evidence.length > 0) line2.evidence = evidence.join("=");
9085
+ lines.push(line2);
9086
+ }
9087
+ const input = { draftId: draftId(ref), lines };
9088
+ if (options.message !== void 0) input.message = options.message;
9089
+ const { result } = await ctx.client.timeDrafts.save(slug, input);
9090
+ ctx.io.out(
9091
+ ctx.config.json ? jsonOutput(result) : `Saved ${lines.length} ${lines.length === 1 ? "line" : "lines"} on the draft for ${result.draft.day}`
9092
+ );
9093
+ }
9094
+ async function timesheetLog(ctx, ref) {
9095
+ const slug = requireWorkspace(ctx.config);
9096
+ const { result } = await ctx.client.timeDrafts.confirm(slug, { draftId: draftId(ref) });
9097
+ const total = result.entries.reduce((sum, entry) => sum + entry.minutes, 0);
9098
+ ctx.io.out(
9099
+ ctx.config.json ? jsonOutput(result) : `Logged ${formatMinutes(total)} in ${result.entries.length} ${result.entries.length === 1 ? "entry" : "entries"} for ${result.draft.day}`
9100
+ );
9101
+ }
9102
+ async function timesheetDismiss(ctx, ref) {
9103
+ const slug = requireWorkspace(ctx.config);
9104
+ const { result } = await ctx.client.timeDrafts.dismiss(slug, { draftId: draftId(ref) });
9105
+ ctx.io.out(
9106
+ ctx.config.json ? jsonOutput(result) : `Dismissed the draft for ${result.draft.day}`
9107
+ );
9108
+ }
9109
+ async function timesheetReply(ctx, ref, words) {
9110
+ const body = words.join(" ").trim();
9111
+ if (body === "") throw new UsageError("Write a reply, like: the logo was more like 2h");
9112
+ const slug = requireWorkspace(ctx.config);
9113
+ const { result } = await ctx.client.timeDrafts.reply(slug, { draftId: draftId(ref), body });
9114
+ ctx.io.out(
9115
+ ctx.config.json ? jsonOutput(result) : `Replied; ${result.draft.state === "waiting" ? "the agent will draft it again" : "saved"}`
9116
+ );
9117
+ }
9118
+
9119
+ // src/commands/week.ts
9120
+ var DAY2 = /^\d{4}-\d{2}-\d{2}$/;
9121
+ var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
9122
+ function formatWeek(week2) {
9123
+ const strip = week2.days.map((one, index) => {
9124
+ const label = `${WEEKDAYS[index]} ${one.minutes === 0 ? "\u2013" : formatMinutes(one.minutes)}`;
9125
+ return one.day === week2.day ? `[${label}]` : label;
9126
+ }).join(" ");
9127
+ const lines = [`Week of ${week2.from} \xB7 ${formatMinutes(week2.totalMinutes)}`, strip, "", week2.day];
9128
+ if (week2.entries.length === 0) lines.push(" Nothing logged.");
9129
+ for (const entry of week2.entries) {
9130
+ lines.push(
9131
+ ` ${entry.identifier} ${formatMinutes(entry.minutes)} ${entry.taskTitle}${entry.locked ? " (locked)" : ""}`
9132
+ );
9133
+ }
9134
+ if (week2.draft && (week2.draft.state === "ready" || week2.draft.state === "waiting")) {
9135
+ const agent = week2.draft.agent?.name ?? "The agent";
9136
+ lines.push(
9137
+ "",
9138
+ week2.draft.state === "ready" ? `${agent} drafted ${week2.draft.lines.length} ${week2.draft.lines.length === 1 ? "line" : "lines"}: tasq timesheet show ${week2.draft.id}` : `${agent} is drafting this day.`
9139
+ );
9140
+ }
9141
+ if (week2.unlogged.length > 0) {
9142
+ lines.push("", "No time yet:");
9143
+ for (const task of week2.unlogged) {
9144
+ lines.push(` ${task.identifier} ${task.title} (${task.reason})`);
9145
+ }
9146
+ }
9147
+ return lines.join("\n");
9148
+ }
9149
+ async function week(ctx, options, deps = {}) {
9150
+ const day = options.day ?? (deps.today ?? localToday)();
9151
+ if (!DAY2.test(day)) {
9152
+ throw new UsageError(`"${day}" is not a day. Use YYYY-MM-DD, like 2026-10-07.`);
9153
+ }
9154
+ const slug = requireWorkspace(ctx.config);
9155
+ const tz = (deps.timeZone ?? (() => Intl.DateTimeFormat().resolvedOptions().timeZone))();
9156
+ const result = await ctx.client.me.week(slug, day, { tz });
9157
+ ctx.io.out(ctx.config.json ? jsonOutput(result) : formatWeek(result));
9158
+ }
9159
+
8673
9160
  // src/commands/update.ts
8674
9161
  import { readFileSync as readFileSync3 } from "fs";
8675
9162
  function isHealth(value) {
@@ -8775,6 +9262,9 @@ async function workspaceUse(ctx, slug) {
8775
9262
  }
8776
9263
 
8777
9264
  // src/program.ts
9265
+ function collect(value, previous) {
9266
+ return [...previous ?? [], value];
9267
+ }
8778
9268
  function contextFor(program2, io2) {
8779
9269
  const flags = program2.opts();
8780
9270
  const config = loadConfig({
@@ -8816,21 +9306,28 @@ function buildProgram(io2) {
8816
9306
  task.command("view").argument("<id>", "task identifier or id").description("Show a task with its comments and activity").action(async (id) => {
8817
9307
  await taskView(contextFor(program2, io2), id);
8818
9308
  });
8819
- task.command("create").argument("<title>", "task title").description("Create a task").option("--team <identifier>", "team identifier").option("--description <markdown>", "description in Markdown").option("--priority <priority>", "urgent | high | medium | low | none").option("--project <id>", "project id").option("--labels <names>", "comma-separated label names").option("--due <date>", "due date, YYYY-MM-DD").option("--start <date>", "start date, YYYY-MM-DD").option("--parent <id>", "parent task identifier or id, making this a subtask").action(
8820
- async (title, options) => {
8821
- await taskCreate(contextFor(program2, io2), title, {
8822
- team: options.team,
8823
- description: options.description,
8824
- priority: options.priority,
8825
- project: options.project,
8826
- labels: options.labels,
8827
- due: options.due,
8828
- start: options.start,
8829
- parent: options.parent
8830
- });
8831
- }
8832
- );
8833
- task.command("update").argument("<id>", "task identifier or id").description("Update a task").option("--title <title>", "new title").option("--description <markdown>", "new description in Markdown").option("--priority <priority>", "urgent | high | medium | low | none").option("--status <name>", "status name on the task's team").option("--due <date>", 'due date, YYYY-MM-DD, or "none" to clear').option("--start <date>", 'start date, YYYY-MM-DD, or "none" to clear').option("--parent <id>", "parent task identifier or id, making this a subtask").option("--no-parent", "detach from its parent task").action(async (id, options) => {
9309
+ task.command("create").argument("<title>", "task title").description("Create a task").option("--team <identifier>", "team identifier").option("--description <markdown>", "description in Markdown").option("--priority <priority>", "urgent | high | medium | low | none").option("--project <id>", "project id").option("--labels <names>", "comma-separated label names").option("--due <date>", "due date, YYYY-MM-DD").option("--start <date>", "start date, YYYY-MM-DD").option("--parent <id>", "parent task identifier or id, making this a subtask").option(
9310
+ "--field <key=value>",
9311
+ "custom field value by key, repeatable; a,b for a multi-select or people field",
9312
+ collect
9313
+ ).action(async (title, options) => {
9314
+ await taskCreate(contextFor(program2, io2), title, {
9315
+ team: options.team,
9316
+ description: options.description,
9317
+ priority: options.priority,
9318
+ project: options.project,
9319
+ labels: options.labels,
9320
+ due: options.due,
9321
+ start: options.start,
9322
+ parent: options.parent,
9323
+ field: options.field
9324
+ });
9325
+ });
9326
+ task.command("update").argument("<id>", "task identifier or id").description("Update a task").option("--title <title>", "new title").option("--description <markdown>", "new description in Markdown").option("--priority <priority>", "urgent | high | medium | low | none").option("--status <name>", "status name on the task's team").option("--due <date>", 'due date, YYYY-MM-DD, or "none" to clear').option("--start <date>", 'start date, YYYY-MM-DD, or "none" to clear').option("--parent <id>", "parent task identifier or id, making this a subtask").option("--no-parent", "detach from its parent task").option(
9327
+ "--field <key=value>",
9328
+ 'custom field value by key, repeatable; "key=" clears it',
9329
+ collect
9330
+ ).action(async (id, options) => {
8834
9331
  await taskUpdate(contextFor(program2, io2), id, {
8835
9332
  title: options.title,
8836
9333
  description: options.description,
@@ -8838,7 +9335,8 @@ function buildProgram(io2) {
8838
9335
  status: options.status,
8839
9336
  due: options.due,
8840
9337
  start: options.start,
8841
- parent: options.parent
9338
+ parent: options.parent,
9339
+ field: options.field
8842
9340
  });
8843
9341
  });
8844
9342
  task.command("request-approval").argument("<id>", "task identifier or id").description("Ask a person to approve a task").requiredOption(
@@ -8858,6 +9356,10 @@ function buildProgram(io2) {
8858
9356
  await taskDecide(contextFor(program2, io2), id, decision);
8859
9357
  });
8860
9358
  }
9359
+ const field = program2.command("field").description("Custom fields: the workspace's field library");
9360
+ field.command("list").description("List the fields, with the keys --field takes").option("--all", "include archived fields").action(async (options) => {
9361
+ await fieldList(contextFor(program2, io2), { all: options.all });
9362
+ });
8861
9363
  const time = program2.command("time").description("Time logged on tasks (members only)");
8862
9364
  time.command("log").argument("<task>", "task identifier or id").argument("<duration...>", "how long: 1h 30m, 90m, 1.5h or 1:30").description("Log time on a task").option("--day <date>", "the day the work was done, YYYY-MM-DD (default: today)").option("--note <text>", "what the time was spent on").option("--billable <yes|no>", "mark the entry billable or not").action(
8863
9365
  async (taskRef, duration, options) => {
@@ -8945,6 +9447,48 @@ function buildProgram(io2) {
8945
9447
  project.command("unshare").argument("<project>", "project id or name").argument("<guest>", "the guest's name, email or member id").description("Stop sharing a project with a guest").action(async (ref, guestRef) => {
8946
9448
  await projectUnshare(contextFor(program2, io2), ref, guestRef);
8947
9449
  });
9450
+ program2.command("week").description("Your week of logged time, a day's entries, and work with no time yet").option("--day <YYYY-MM-DD>", "the day to open (default: today)").action(async (options) => {
9451
+ await week(contextFor(program2, io2), options);
9452
+ });
9453
+ const timesheet = program2.command("timesheet").description("Agent-drafted timesheets: ask for one, read it, log it or answer it");
9454
+ timesheet.command("request").description("Ask your team's agent to draft a day").option("--day <YYYY-MM-DD>", "the day to draft (default: today)").action(async (options) => {
9455
+ await timesheetRequest(contextFor(program2, io2), options);
9456
+ });
9457
+ timesheet.command("show").argument("<draft>", "draft id").description("A draft's lines and its conversation").action(async (ref) => {
9458
+ await timesheetShow(contextFor(program2, io2), ref);
9459
+ });
9460
+ timesheet.command("save").argument("<draft>", "draft id").description("Write a draft's lines, replacing earlier ones (the drafting agent)").option(
9461
+ "--line <TASK=DURATION[=BILLABLE[=REASON]]>",
9462
+ "one line, repeatable: ENG-12=1h30m=yes=2 comments",
9463
+ (value, previous) => [...previous ?? [], value]
9464
+ ).option("--message <text>", "a note to the member").action(async (ref, options) => {
9465
+ await timesheetSave(contextFor(program2, io2), ref, options);
9466
+ });
9467
+ timesheet.command("log").argument("<draft>", "draft id").description("Log every ticked line of your draft").action(async (ref) => {
9468
+ await timesheetLog(contextFor(program2, io2), ref);
9469
+ });
9470
+ timesheet.command("dismiss").argument("<draft>", "draft id").description("Set your draft aside without logging it").action(async (ref) => {
9471
+ await timesheetDismiss(contextFor(program2, io2), ref);
9472
+ });
9473
+ timesheet.command("reply").argument("<draft>", "draft id").argument("<message...>", "what to change").description("Answer the agent; it drafts the day again").action(async (ref, words) => {
9474
+ await timesheetReply(contextFor(program2, io2), ref, words);
9475
+ });
9476
+ const clients = program2.command("clients").description("Clients (initiatives) and their hours (members only)");
9477
+ clients.command("hours").argument("<client>", "client id or name").description("A client's month of hours by project and person").option("--month <YYYY-MM>", "the month to read (default: this month)").option("--billable", "count billable entries only").action(async (clientRef, options) => {
9478
+ await clientHours(contextFor(program2, io2), clientRef, options);
9479
+ });
9480
+ clients.command("billing").argument("<client>", "client id or name").description("A client's billing months: hours and whether each is open, closed or invoiced").action(async (clientRef) => {
9481
+ await clientBilling(contextFor(program2, io2), clientRef);
9482
+ });
9483
+ clients.command("close").argument("<client>", "client id or name").description("Close a client's month so its hours stop changing (admins)").requiredOption("--month <YYYY-MM>", "the month to close").action(async (clientRef, options) => {
9484
+ await clientBillingPeriod(contextFor(program2, io2), "close", clientRef, options);
9485
+ });
9486
+ clients.command("invoice").argument("<client>", "client id or name").description("Mark a client's month invoiced, closing it if open (admins)").requiredOption("--month <YYYY-MM>", "the month that was invoiced").option("--ref <reference>", "the invoice number, to find it elsewhere").action(async (clientRef, options) => {
9487
+ await clientBillingPeriod(contextFor(program2, io2), "invoice", clientRef, options);
9488
+ });
9489
+ clients.command("reopen").argument("<client>", "client id or name").description("Reopen a client's closed or invoiced month (admins)").requiredOption("--month <YYYY-MM>", "the month to reopen").action(async (clientRef, options) => {
9490
+ await clientBillingPeriod(contextFor(program2, io2), "reopen", clientRef, options);
9491
+ });
8948
9492
  const initiative = program2.command("initiative").description("Initiatives: groups of projects across teams");
8949
9493
  initiative.command("list").description("List initiatives, archived ones included").action(run((ctx) => initiativeList(ctx)));
8950
9494
  initiative.command("create").argument("<name>", "initiative name").description("Create an initiative (admins)").action(async (name) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxlabz/tasq-cli",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Command-line client for Tasq, for humans and agents alike",
5
5
  "keywords": [
6
6
  "tasq",