@pxlabz/tasq-cli 0.1.23 → 0.1.25
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 +20 -1
- package/README.md +9 -1
- package/dist/tasq.js +375 -49
- package/package.json +1 -1
package/.tasq-skill.md
CHANGED
|
@@ -62,6 +62,14 @@ tasq time log <ref> <duration> [--day <YYYY-MM-DD>] [--note <text>] [--billable
|
|
|
62
62
|
tasq time list <ref>
|
|
63
63
|
tasq time edit <entryId> [--duration <duration>] [--day <YYYY-MM-DD>] [--note <text> | --no-note] [--billable <yes|no|unset>]
|
|
64
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
|
|
65
73
|
|
|
66
74
|
tasq thread view <threadId>
|
|
67
75
|
tasq thread context <threadId> [--markdown]
|
|
@@ -103,7 +111,7 @@ A comment goes on a task or a project, never both and never neither: give the ta
|
|
|
103
111
|
|
|
104
112
|
## When you are mentioned
|
|
105
113
|
|
|
106
|
-
`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 `
|
|
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.
|
|
107
115
|
|
|
108
116
|
The loop is:
|
|
109
117
|
|
|
@@ -169,6 +177,17 @@ Three things to know before you write:
|
|
|
169
177
|
|
|
170
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.
|
|
171
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
|
+
|
|
172
191
|
## Project updates
|
|
173
192
|
|
|
174
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
|
@@ -32,6 +32,14 @@ tasq field list [--all]
|
|
|
32
32
|
tasq comment add <ref> <body> [--reply-to <commentRef>] [--mention <name>]…
|
|
33
33
|
tasq time log <ref> <duration> [--day YYYY-MM-DD] [--note <text>] [--billable yes|no]
|
|
34
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
|
|
35
43
|
tasq events listen [--wait <seconds>] [--once]
|
|
36
44
|
tasq events ack <id>…
|
|
37
45
|
tasq project list | star <project> | unstar <project>
|
|
@@ -46,7 +54,7 @@ tasq auth login | logout
|
|
|
46
54
|
|
|
47
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:`.
|
|
48
56
|
|
|
49
|
-
`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.
|
|
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.
|
|
50
58
|
|
|
51
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.
|
|
52
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(
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
const rowSpan =
|
|
4977
|
-
const colSpan =
|
|
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[
|
|
4980
|
+
alloc[cell2.x + cs] = rowSpan;
|
|
4981
4981
|
}
|
|
4982
4982
|
}
|
|
4983
|
-
col =
|
|
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(
|
|
4995
|
-
mw = Math.max(mw,
|
|
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
|
|
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(
|
|
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(
|
|
5040
|
-
for (let i = 1; i <
|
|
5041
|
-
let rowSpanCell = new RowSpanCell(
|
|
5042
|
-
rowSpanCell.x =
|
|
5043
|
-
rowSpanCell.y =
|
|
5044
|
-
rowSpanCell.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
|
|
5055
|
-
for (let k3 = 1; k3 <
|
|
5054
|
+
let cell2 = cellColumns[columnIndex];
|
|
5055
|
+
for (let k3 = 1; k3 < cell2.colSpan; k3++) {
|
|
5056
5056
|
let colSpanCell = new ColSpanCell();
|
|
5057
|
-
colSpanCell.x =
|
|
5058
|
-
colSpanCell.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(
|
|
5064
|
+
function insertCell(cell2, row) {
|
|
5065
5065
|
let x3 = 0;
|
|
5066
|
-
while (x3 < row.length && row[x3].x <
|
|
5066
|
+
while (x3 < row.length && row[x3].x < cell2.x) {
|
|
5067
5067
|
x3++;
|
|
5068
5068
|
}
|
|
5069
|
-
row.splice(x3, 0,
|
|
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
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
warn(`Missing cell at ${
|
|
5093
|
-
insertCell(
|
|
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(
|
|
5111
|
-
return new 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(
|
|
5140
|
-
if ((
|
|
5141
|
-
spanners.push(
|
|
5139
|
+
row.forEach(function(cell2) {
|
|
5140
|
+
if ((cell2[colSpan] || 1) > 1) {
|
|
5141
|
+
spanners.push(cell2);
|
|
5142
5142
|
} else {
|
|
5143
|
-
result[
|
|
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
|
|
5154
|
-
let span =
|
|
5155
|
-
let col =
|
|
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" ?
|
|
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 (
|
|
5171
|
+
if (cell2[desiredWidth] > existingWidth) {
|
|
5172
5172
|
let i = 0;
|
|
5173
|
-
while (editableCols > 0 &&
|
|
5173
|
+
while (editableCols > 0 && cell2[desiredWidth] > existingWidth) {
|
|
5174
5174
|
if (typeof vals[col + i] !== "number") {
|
|
5175
|
-
let dif = Math.round((
|
|
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(
|
|
5244
|
-
|
|
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(
|
|
5251
|
-
|
|
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(
|
|
5279
|
-
line2.push(
|
|
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`
|
|
@@ -7017,7 +7073,7 @@ function reportError(error, io2) {
|
|
|
7017
7073
|
// package.json
|
|
7018
7074
|
var package_default = {
|
|
7019
7075
|
name: "@pxlabz/tasq-cli",
|
|
7020
|
-
version: "0.1.
|
|
7076
|
+
version: "0.1.25",
|
|
7021
7077
|
description: "Command-line client for Tasq, for humans and agents alike",
|
|
7022
7078
|
keywords: [
|
|
7023
7079
|
"tasq",
|
|
@@ -8873,6 +8929,234 @@ async function timeDelete(ctx, ref) {
|
|
|
8873
8929
|
);
|
|
8874
8930
|
}
|
|
8875
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
|
+
|
|
8876
9160
|
// src/commands/update.ts
|
|
8877
9161
|
import { readFileSync as readFileSync3 } from "fs";
|
|
8878
9162
|
function isHealth(value) {
|
|
@@ -9163,6 +9447,48 @@ function buildProgram(io2) {
|
|
|
9163
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) => {
|
|
9164
9448
|
await projectUnshare(contextFor(program2, io2), ref, guestRef);
|
|
9165
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
|
+
});
|
|
9166
9492
|
const initiative = program2.command("initiative").description("Initiatives: groups of projects across teams");
|
|
9167
9493
|
initiative.command("list").description("List initiatives, archived ones included").action(run((ctx) => initiativeList(ctx)));
|
|
9168
9494
|
initiative.command("create").argument("<name>", "initiative name").description("Create an initiative (admins)").action(async (name) => {
|