@pxlabz/tasq-cli 0.1.20 → 0.1.22
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 +5 -0
- package/README.md +4 -0
- package/dist/tasq.js +231 -1
- package/package.json +1 -1
package/.tasq-skill.md
CHANGED
|
@@ -55,6 +55,11 @@ tasq comment add <ref> <body> [--reply-to <commentRef>] [--thread <threadId>]
|
|
|
55
55
|
tasq comment add --project <id|name> <body> [--reply-to <commentRef>]
|
|
56
56
|
[--thread <threadId>] [--mention <name>]…
|
|
57
57
|
|
|
58
|
+
tasq time log <ref> <duration> [--day <YYYY-MM-DD>] [--note <text>] [--billable <yes|no>]
|
|
59
|
+
tasq time list <ref>
|
|
60
|
+
tasq time edit <entryId> [--duration <duration>] [--day <YYYY-MM-DD>] [--note <text> | --no-note] [--billable <yes|no|unset>]
|
|
61
|
+
tasq time delete <entryId>
|
|
62
|
+
|
|
58
63
|
tasq thread view <threadId>
|
|
59
64
|
tasq thread context <threadId> [--markdown]
|
|
60
65
|
|
package/README.md
CHANGED
|
@@ -28,6 +28,8 @@ TASQ_API_KEY=tq_ag_… TASQ_WORKSPACE=acme tasq task list
|
|
|
28
28
|
tasq workspace list | use <slug>
|
|
29
29
|
tasq task list | view <ref> | create | update <ref>
|
|
30
30
|
tasq comment add <ref> <body> [--reply-to <commentRef>] [--mention <name>]…
|
|
31
|
+
tasq time log <ref> <duration> [--day YYYY-MM-DD] [--note <text>] [--billable yes|no]
|
|
32
|
+
tasq time list <ref> | edit <entryId> [--duration] [--day] [--note | --no-note] [--billable] | delete <entryId>
|
|
31
33
|
tasq events listen [--wait <seconds>] [--once]
|
|
32
34
|
tasq events ack <id>…
|
|
33
35
|
tasq project list | star <project> | unstar <project>
|
|
@@ -40,6 +42,8 @@ tasq auth login | logout
|
|
|
40
42
|
|
|
41
43
|
`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.
|
|
42
44
|
|
|
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.
|
|
46
|
+
|
|
43
47
|
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.
|
|
44
48
|
|
|
45
49
|
### Mentions and replies
|
package/dist/tasq.js
CHANGED
|
@@ -6639,6 +6639,33 @@ var TasqClient = class _TasqClient {
|
|
|
6639
6639
|
*/
|
|
6640
6640
|
decide: (slug, taskId, decision) => this.dispatch("task.decide", slug, { taskId, decision })
|
|
6641
6641
|
};
|
|
6642
|
+
/**
|
|
6643
|
+
* Time tracking: whole minutes on a task for a day, no running timer.
|
|
6644
|
+
* Everything here is member-level; a guest credential is refused. Turn a
|
|
6645
|
+
* typed duration into minutes with `parseDuration`.
|
|
6646
|
+
*/
|
|
6647
|
+
time = {
|
|
6648
|
+
/** A task's entries, newest day first, and its total with direct subtasks. */
|
|
6649
|
+
forTask: (slug, taskId) => this.#get(
|
|
6650
|
+
`/workspaces/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(taskId)}/time`
|
|
6651
|
+
),
|
|
6652
|
+
/**
|
|
6653
|
+
* Time on a project's tasks between two inclusive `YYYY-MM-DD` days, by
|
|
6654
|
+
* person and day. The API reads at most 92 days at a time.
|
|
6655
|
+
*/
|
|
6656
|
+
forProject: (slug, projectId, range) => this.#get(
|
|
6657
|
+
`/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}/time`,
|
|
6658
|
+
{ from: range.from, to: range.to }
|
|
6659
|
+
),
|
|
6660
|
+
/**
|
|
6661
|
+
* Log minutes on a task for a day. `memberId` defaults to the caller;
|
|
6662
|
+
* logging for someone else is an admin's job.
|
|
6663
|
+
*/
|
|
6664
|
+
log: (slug, input) => this.dispatch("time.log", slug, input),
|
|
6665
|
+
/** Change an entry; omitted fields are left alone, `note: null` clears it. */
|
|
6666
|
+
update: (slug, input) => this.dispatch("time.update", slug, input),
|
|
6667
|
+
delete: (slug, input) => this.dispatch("time.delete", slug, input)
|
|
6668
|
+
};
|
|
6642
6669
|
projects = {
|
|
6643
6670
|
list: async (slug) => (await this.#get(
|
|
6644
6671
|
`/workspaces/${encodeURIComponent(slug)}/projects`
|
|
@@ -6872,6 +6899,30 @@ var TasqClient = class _TasqClient {
|
|
|
6872
6899
|
}
|
|
6873
6900
|
};
|
|
6874
6901
|
|
|
6902
|
+
// ../sdk/src/time.ts
|
|
6903
|
+
var DURATION_FORMS = "1h 30m, 1h30m, 90m, 1.5h, 1:30 or a bare number of hours";
|
|
6904
|
+
function parseDuration(raw) {
|
|
6905
|
+
const value = raw.trim().toLowerCase().replace(/\s+/g, "");
|
|
6906
|
+
if (!value) return null;
|
|
6907
|
+
let match = value.match(/^(\d{1,2}):([0-5]\d)$/);
|
|
6908
|
+
if (match) return Number(match[1]) * 60 + Number(match[2]);
|
|
6909
|
+
match = value.match(/^(\d+(?:\.\d+)?)h$/);
|
|
6910
|
+
if (match) return Math.round(Number(match[1]) * 60);
|
|
6911
|
+
match = value.match(/^(\d+)m(?:in|ins)?$/);
|
|
6912
|
+
if (match) return Number(match[1]);
|
|
6913
|
+
match = value.match(/^(\d+)h(\d+)m?(?:in|ins)?$/);
|
|
6914
|
+
if (match) return Number(match[1]) * 60 + Number(match[2]);
|
|
6915
|
+
match = value.match(/^(\d+(?:\.\d+)?)$/);
|
|
6916
|
+
if (match) return Math.round(Number(match[1]) * 60);
|
|
6917
|
+
return null;
|
|
6918
|
+
}
|
|
6919
|
+
function formatMinutes(minutes) {
|
|
6920
|
+
const hours = Math.floor(minutes / 60);
|
|
6921
|
+
const rest = minutes % 60;
|
|
6922
|
+
if (hours === 0) return `${rest}m`;
|
|
6923
|
+
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
6924
|
+
}
|
|
6925
|
+
|
|
6875
6926
|
// ../sdk/src/types.ts
|
|
6876
6927
|
var PROJECT_HEALTH_VALUES = [
|
|
6877
6928
|
"on_track",
|
|
@@ -6953,7 +7004,7 @@ function reportError(error, io2) {
|
|
|
6953
7004
|
// package.json
|
|
6954
7005
|
var package_default = {
|
|
6955
7006
|
name: "@pxlabz/tasq-cli",
|
|
6956
|
-
version: "0.1.
|
|
7007
|
+
version: "0.1.22",
|
|
6957
7008
|
description: "Command-line client for Tasq, for humans and agents alike",
|
|
6958
7009
|
keywords: [
|
|
6959
7010
|
"tasq",
|
|
@@ -7194,6 +7245,20 @@ function formatWorkspaces(workspaces) {
|
|
|
7194
7245
|
])
|
|
7195
7246
|
);
|
|
7196
7247
|
}
|
|
7248
|
+
function formatTimeEntries(entries) {
|
|
7249
|
+
if (entries.length === 0) return "No time logged.";
|
|
7250
|
+
return table(
|
|
7251
|
+
["Day", "Time", "Who", "Billable", "Note", "Entry"],
|
|
7252
|
+
entries.map((entry) => [
|
|
7253
|
+
entry.day,
|
|
7254
|
+
entry.duration,
|
|
7255
|
+
entry.who,
|
|
7256
|
+
dash(entry.billable),
|
|
7257
|
+
dash(entry.note),
|
|
7258
|
+
entry.id
|
|
7259
|
+
])
|
|
7260
|
+
);
|
|
7261
|
+
}
|
|
7197
7262
|
function line(io2, value) {
|
|
7198
7263
|
io2.out(JSON.stringify(value));
|
|
7199
7264
|
}
|
|
@@ -8465,6 +8530,146 @@ async function taskDecide(ctx, taskRef, decision) {
|
|
|
8465
8530
|
);
|
|
8466
8531
|
}
|
|
8467
8532
|
|
|
8533
|
+
// src/commands/time.ts
|
|
8534
|
+
var MAX_ENTRY_MINUTES = 24 * 60;
|
|
8535
|
+
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;
|
|
8537
|
+
var BILLABLE_FLAGS = [
|
|
8538
|
+
["yes", "billable"],
|
|
8539
|
+
["no", "non_billable"],
|
|
8540
|
+
["unset", "not_set"]
|
|
8541
|
+
];
|
|
8542
|
+
var BILLABLE_WORDS = {
|
|
8543
|
+
billable: "billable",
|
|
8544
|
+
non_billable: "non-billable",
|
|
8545
|
+
not_set: ""
|
|
8546
|
+
};
|
|
8547
|
+
function localToday(now = /* @__PURE__ */ new Date()) {
|
|
8548
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
8549
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
8550
|
+
return `${now.getFullYear()}-${month}-${day}`;
|
|
8551
|
+
}
|
|
8552
|
+
function durationMinutes(raw) {
|
|
8553
|
+
const minutes = parseDuration(raw);
|
|
8554
|
+
if (minutes === null) {
|
|
8555
|
+
throw new UsageError(
|
|
8556
|
+
`"${raw}" is not a duration. Use ${DURATION_FORMS}.`
|
|
8557
|
+
);
|
|
8558
|
+
}
|
|
8559
|
+
if (minutes < 1) {
|
|
8560
|
+
throw new UsageError("Log at least one minute.");
|
|
8561
|
+
}
|
|
8562
|
+
if (minutes > MAX_ENTRY_MINUTES) {
|
|
8563
|
+
throw new UsageError(
|
|
8564
|
+
`One entry is at most 24 hours; "${raw}" is ${formatMinutes(minutes)}. Split it across days.`
|
|
8565
|
+
);
|
|
8566
|
+
}
|
|
8567
|
+
return minutes;
|
|
8568
|
+
}
|
|
8569
|
+
function calendarDay(value) {
|
|
8570
|
+
if (!CALENDAR_DATE2.test(value)) {
|
|
8571
|
+
throw new UsageError(`--day takes a YYYY-MM-DD date. Got "${value}".`);
|
|
8572
|
+
}
|
|
8573
|
+
return value;
|
|
8574
|
+
}
|
|
8575
|
+
function billableValue(value) {
|
|
8576
|
+
const wanted = value.trim().toLowerCase();
|
|
8577
|
+
const matched = BILLABLE_FLAGS.find(([flag]) => flag === wanted);
|
|
8578
|
+
if (matched === void 0) {
|
|
8579
|
+
throw new UsageError(
|
|
8580
|
+
`--billable takes yes, no or unset. Got "${value}".`
|
|
8581
|
+
);
|
|
8582
|
+
}
|
|
8583
|
+
return matched[1];
|
|
8584
|
+
}
|
|
8585
|
+
function entryId(ref) {
|
|
8586
|
+
const trimmed = ref.trim();
|
|
8587
|
+
if (!UUID_PATTERN6.test(trimmed)) {
|
|
8588
|
+
throw new UsageError(
|
|
8589
|
+
`"${ref}" is not a time entry id. Run "tasq time list <task>" to see the ids.`
|
|
8590
|
+
);
|
|
8591
|
+
}
|
|
8592
|
+
return trimmed;
|
|
8593
|
+
}
|
|
8594
|
+
async function timeLog(ctx, taskRef, duration, options, deps = {}) {
|
|
8595
|
+
const slug = requireWorkspace(ctx.config);
|
|
8596
|
+
const minutes = durationMinutes(duration);
|
|
8597
|
+
const spentOn = options.day === void 0 ? (deps.today ?? localToday)() : calendarDay(options.day);
|
|
8598
|
+
const billable = options.billable === void 0 ? void 0 : billableValue(options.billable);
|
|
8599
|
+
const taskId = await resolveTaskId(ctx.client, slug, taskRef);
|
|
8600
|
+
const input = { taskId, minutes, spentOn };
|
|
8601
|
+
if (options.note !== void 0) input.note = options.note;
|
|
8602
|
+
if (billable !== void 0) input.billable = billable;
|
|
8603
|
+
const { result } = await ctx.client.time.log(slug, input);
|
|
8604
|
+
ctx.io.out(
|
|
8605
|
+
ctx.config.json ? jsonOutput(result) : `Logged ${formatMinutes(minutes)} on ${taskRef} for ${spentOn} (entry ${result.entry.id})`
|
|
8606
|
+
);
|
|
8607
|
+
}
|
|
8608
|
+
function entryWho(entry) {
|
|
8609
|
+
if (entry.member === null) return "(former member)";
|
|
8610
|
+
return entry.member.name ?? entry.member.memberId;
|
|
8611
|
+
}
|
|
8612
|
+
async function timeList(ctx, taskRef) {
|
|
8613
|
+
const slug = requireWorkspace(ctx.config);
|
|
8614
|
+
const taskId = await resolveTaskId(ctx.client, slug, taskRef);
|
|
8615
|
+
const time = await ctx.client.time.forTask(slug, taskId);
|
|
8616
|
+
if (ctx.config.json) {
|
|
8617
|
+
ctx.io.out(jsonOutput(time));
|
|
8618
|
+
return;
|
|
8619
|
+
}
|
|
8620
|
+
ctx.io.out(
|
|
8621
|
+
formatTimeEntries(
|
|
8622
|
+
time.entries.map((entry) => ({
|
|
8623
|
+
id: entry.id,
|
|
8624
|
+
day: entry.spentOn,
|
|
8625
|
+
duration: formatMinutes(entry.minutes),
|
|
8626
|
+
who: entryWho(entry),
|
|
8627
|
+
billable: BILLABLE_WORDS[entry.billable],
|
|
8628
|
+
note: entry.note ?? ""
|
|
8629
|
+
}))
|
|
8630
|
+
)
|
|
8631
|
+
);
|
|
8632
|
+
const subtaskMinutes = time.totalMinutes - time.ownMinutes;
|
|
8633
|
+
ctx.io.out(
|
|
8634
|
+
subtaskMinutes > 0 ? `Total: ${formatMinutes(time.totalMinutes)} (${formatMinutes(time.ownMinutes)} on ${taskRef}, ${formatMinutes(subtaskMinutes)} on subtasks)` : `Total: ${formatMinutes(time.totalMinutes)}`
|
|
8635
|
+
);
|
|
8636
|
+
for (const subtask of time.subtasks) {
|
|
8637
|
+
ctx.io.out(
|
|
8638
|
+
` ${subtask.identifier} ${formatMinutes(subtask.minutes)} ${subtask.title}`
|
|
8639
|
+
);
|
|
8640
|
+
}
|
|
8641
|
+
}
|
|
8642
|
+
async function timeEdit(ctx, ref, options) {
|
|
8643
|
+
const slug = requireWorkspace(ctx.config);
|
|
8644
|
+
const id = entryId(ref);
|
|
8645
|
+
const minutes = options.duration === void 0 ? void 0 : durationMinutes(options.duration);
|
|
8646
|
+
const spentOn = options.day === void 0 ? void 0 : calendarDay(options.day);
|
|
8647
|
+
const billable = options.billable === void 0 ? void 0 : billableValue(options.billable);
|
|
8648
|
+
const note = options.note === void 0 ? void 0 : options.note === false ? null : options.note;
|
|
8649
|
+
if (minutes === void 0 && spentOn === void 0 && billable === void 0 && note === void 0) {
|
|
8650
|
+
throw new UsageError(
|
|
8651
|
+
"Nothing to change. Pass --duration, --day, --note, --no-note or --billable."
|
|
8652
|
+
);
|
|
8653
|
+
}
|
|
8654
|
+
const input = { entryId: id };
|
|
8655
|
+
if (minutes !== void 0) input.minutes = minutes;
|
|
8656
|
+
if (spentOn !== void 0) input.spentOn = spentOn;
|
|
8657
|
+
if (note !== void 0) input.note = note;
|
|
8658
|
+
if (billable !== void 0) input.billable = billable;
|
|
8659
|
+
const { result } = await ctx.client.time.update(slug, input);
|
|
8660
|
+
ctx.io.out(
|
|
8661
|
+
ctx.config.json ? jsonOutput(result) : `Updated time entry ${id}: ${formatMinutes(result.entry.minutes)} on ${result.entry.spentOn}`
|
|
8662
|
+
);
|
|
8663
|
+
}
|
|
8664
|
+
async function timeDelete(ctx, ref) {
|
|
8665
|
+
const slug = requireWorkspace(ctx.config);
|
|
8666
|
+
const id = entryId(ref);
|
|
8667
|
+
const { result } = await ctx.client.time.delete(slug, { entryId: id });
|
|
8668
|
+
ctx.io.out(
|
|
8669
|
+
ctx.config.json ? jsonOutput(result) : `Deleted time entry ${id} (${formatMinutes(result.entry.minutes)} on ${result.entry.spentOn})`
|
|
8670
|
+
);
|
|
8671
|
+
}
|
|
8672
|
+
|
|
8468
8673
|
// src/commands/update.ts
|
|
8469
8674
|
import { readFileSync as readFileSync3 } from "fs";
|
|
8470
8675
|
function isHealth(value) {
|
|
@@ -8653,6 +8858,31 @@ function buildProgram(io2) {
|
|
|
8653
8858
|
await taskDecide(contextFor(program2, io2), id, decision);
|
|
8654
8859
|
});
|
|
8655
8860
|
}
|
|
8861
|
+
const time = program2.command("time").description("Time logged on tasks (members only)");
|
|
8862
|
+
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
|
+
async (taskRef, duration, options) => {
|
|
8864
|
+
await timeLog(
|
|
8865
|
+
contextFor(program2, io2),
|
|
8866
|
+
taskRef,
|
|
8867
|
+
duration.join(" "),
|
|
8868
|
+
options
|
|
8869
|
+
);
|
|
8870
|
+
}
|
|
8871
|
+
);
|
|
8872
|
+
time.command("list").argument("<task>", "task identifier or id").description("List a task's time entries and its total with subtasks").action(async (taskRef) => {
|
|
8873
|
+
await timeList(contextFor(program2, io2), taskRef);
|
|
8874
|
+
});
|
|
8875
|
+
time.command("edit").argument("<entryId>", "time entry id, as `tasq time list` prints it").description("Change a time entry").option("--duration <duration>", "new duration: 1h 30m, 90m, 1.5h or 1:30").option("--day <date>", "new day, YYYY-MM-DD").option("--note <text>", "new note").option("--no-note", "clear the note").option("--billable <yes|no>", "mark the entry billable or not").action(async (entryId2, options) => {
|
|
8876
|
+
await timeEdit(contextFor(program2, io2), entryId2, {
|
|
8877
|
+
duration: options.duration,
|
|
8878
|
+
day: options.day,
|
|
8879
|
+
note: options.note,
|
|
8880
|
+
billable: options.billable
|
|
8881
|
+
});
|
|
8882
|
+
});
|
|
8883
|
+
time.command("delete").argument("<entryId>", "time entry id, as `tasq time list` prints it").description("Delete a time entry").action(async (entryId2) => {
|
|
8884
|
+
await timeDelete(contextFor(program2, io2), entryId2);
|
|
8885
|
+
});
|
|
8656
8886
|
const comment = program2.command("comment").description("Task and project comments");
|
|
8657
8887
|
comment.command("add").argument("<taskRefOrBody>", "task identifier or id, or the body with --project").argument("[body]", "comment body, when a task was given").description("Add a comment to a task or a project").usage("[options] <taskRef> <body>\n tasq comment add [options] --project <projectRef> <body>").option("--project <projectRef>", "project id or name, instead of a task").option("--reply-to <commentRef>", "comment id, or ENG-42#<id>, to reply to").option("--thread <threadId>", "thread root id, an alias for --reply-to").option(
|
|
8658
8888
|
"--mention <name>",
|