@zinn-dev/cli 0.45.0 → 0.47.0
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/README.md +1 -1
- package/package.json +3 -3
- package/skills/zinn/SKILL.md +2 -2
- package/src/actor.d.ts +1 -1
- package/src/actor.js +4 -1
- package/src/capabilities-schema.d.ts +78 -0
- package/src/capabilities-schema.js +44 -0
- package/src/capabilities.d.ts +2 -0
- package/src/capabilities.js +2 -0
- package/src/column-hint.js +2 -9
- package/src/errors.d.ts +5 -0
- package/src/errors.js +19 -5
- package/src/input.d.ts +30 -0
- package/src/input.js +18 -0
- package/src/lib.d.ts +75 -6
- package/src/lib.js +121 -33
- package/src/presentation/activity-presentation.d.ts +2 -1
- package/src/presentation/activity-presentation.js +23 -6
- package/src/presentation/color.d.ts +12 -0
- package/src/presentation/color.js +12 -0
- package/src/presentation/doctor-presentation.d.ts +7 -1
- package/src/presentation/doctor-presentation.js +6 -2
- package/src/presentation/project-presentation.d.ts +4 -1
- package/src/presentation/project-presentation.js +18 -0
- package/src/presentation/relation-presentation.js +8 -20
- package/src/presentation/section.d.ts +7 -4
- package/src/presentation/section.js +21 -7
- package/src/presentation/skill-status-presentation.d.ts +9 -0
- package/src/presentation/skill-status-presentation.js +43 -0
- package/src/presentation/task-blame-presentation.d.ts +3 -1
- package/src/presentation/task-blame-presentation.js +7 -5
- package/src/presentation/task-presentation.d.ts +28 -5
- package/src/presentation/task-presentation.js +120 -42
- package/src/result-schemas.d.ts +230 -14
- package/src/result-schemas.js +52 -0
- package/src/routes/activity-router.d.ts +5 -3
- package/src/routes/activity-router.js +44 -33
- package/src/routes/backup-router.d.ts +1 -0
- package/src/routes/backup-router.js +6 -12
- package/src/routes/capabilities-router.d.ts +1 -0
- package/src/routes/capabilities-router.js +3 -10
- package/src/routes/comment-router.d.ts +7 -6
- package/src/routes/comment-router.js +18 -66
- package/src/routes/doctor-router.d.ts +1 -0
- package/src/routes/doctor-router.js +35 -62
- package/src/routes/info-router.d.ts +1 -0
- package/src/routes/info-router.js +3 -10
- package/src/routes/label-router.d.ts +5 -0
- package/src/routes/label-router.js +11 -48
- package/src/routes/migrate-router.d.ts +1 -0
- package/src/routes/migrate-router.js +7 -16
- package/src/routes/project-router.d.ts +10 -0
- package/src/routes/project-router.js +42 -121
- package/src/routes/reindex-router.d.ts +1 -0
- package/src/routes/reindex-router.js +3 -10
- package/src/routes/relation-router.d.ts +13 -4
- package/src/routes/relation-router.js +15 -23
- package/src/routes/restore-router.d.ts +1 -0
- package/src/routes/restore-router.js +5 -15
- package/src/routes/router.js +33 -12
- package/src/routes/routes.d.ts +142 -32
- package/src/routes/skill-router.d.ts +53 -2
- package/src/routes/skill-router.js +103 -35
- package/src/routes/task-router.d.ts +61 -28
- package/src/routes/task-router.js +224 -263
- package/src/routes/whoami-router.d.ts +1 -0
- package/src/routes/whoami-router.js +3 -10
- package/src/skill-copies.d.ts +34 -0
- package/src/skill-copies.js +109 -0
- package/src/telemetry.d.ts +2 -2
- package/src/telemetry.js +11 -7
- package/src/types.d.ts +9 -1
- package/src/types.js +6 -0
- package/src/views.d.ts +117 -0
- package/src/views.js +54 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import {
|
|
3
|
-
import { column, project, columnCategorySchema, columnOrderSchema, columnDeleteSchema, projectCreateSchema, projectEditSchema, } from "@zinn-dev/core";
|
|
2
|
+
import { column, project, readSnapshot, columnCategorySchema, columnOrderSchema, columnDeleteSchema, projectCreateSchema, projectEditSchema, } from "@zinn-dev/core";
|
|
4
3
|
import { CliError } from "../errors.js";
|
|
5
4
|
import { generateCommandUsage, getOptionInputs, noInput, violatesConstraint } from "../input.js";
|
|
6
|
-
import { confirmationDescription, canPrompt, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit,
|
|
5
|
+
import { confirmationDescription, canPrompt, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, parseCommandArgs, validateOrderForms, requireStringOption, } from "../lib.js";
|
|
7
6
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
8
7
|
import { expectedValueFlags } from "../expected-values.js";
|
|
9
8
|
import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
10
9
|
import { formatColumnList, presentColumn, presentColumnTaskCounts, } from "../presentation/column-presentation.js";
|
|
11
|
-
import { formatProjectList, presentProject } from "../presentation/project-presentation.js";
|
|
12
|
-
import {
|
|
10
|
+
import { formatProjectDetail, formatProjectList, presentProject, } from "../presentation/project-presentation.js";
|
|
11
|
+
import { readTerminalProps } from "../presentation/color.js";
|
|
13
12
|
import { currentActor } from "../actor.js";
|
|
14
13
|
import { checkDefaultProject, chooseProjectKey, resolveProjectKey, requiredProjectDescription, } from "../project.js";
|
|
15
14
|
const projectEditConstraint = {
|
|
@@ -195,20 +194,12 @@ const projectInputs = {
|
|
|
195
194
|
export const projectRouter = {
|
|
196
195
|
create: {
|
|
197
196
|
summary: "Create a project with the default columns.",
|
|
198
|
-
effects: { domain: "create", storage: "normal-open" },
|
|
197
|
+
effects: { domain: "create", storage: "normal-open", external: [] },
|
|
199
198
|
confirmation: { kind: "none" },
|
|
200
199
|
input: projectInputs.create,
|
|
201
200
|
results: [jsonResult("Project")],
|
|
202
201
|
run: async (args) => {
|
|
203
|
-
const { values, positionals
|
|
204
|
-
args,
|
|
205
|
-
options: projectInputs.create.options,
|
|
206
|
-
allowPositionals: true,
|
|
207
|
-
strict: true,
|
|
208
|
-
tokens: true,
|
|
209
|
-
});
|
|
210
|
-
validateUniqueOptions(tokens, projectInputs.create.options);
|
|
211
|
-
validatePositionals(positionals, projectInputs.create.forms[0]);
|
|
202
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.create);
|
|
212
203
|
const projectKey = positionals[0];
|
|
213
204
|
checkFieldsBeforeText(projectCreateSchema, { key: projectKey, name: values.name });
|
|
214
205
|
const description = await resolveTextInput(values.description, values["description-file"], "--description");
|
|
@@ -236,18 +227,12 @@ Example: zinn project create MDR --name 'Macrodata Refinement'`,
|
|
|
236
227
|
},
|
|
237
228
|
list: {
|
|
238
229
|
summary: "List projects with active and archived task counts.",
|
|
239
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
230
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
240
231
|
confirmation: { kind: "none" },
|
|
241
232
|
input: projectInputs.list,
|
|
242
233
|
results: [jsonResult("ProjectList")],
|
|
243
234
|
run: (args) => {
|
|
244
|
-
|
|
245
|
-
options: projectInputs.list.options,
|
|
246
|
-
args,
|
|
247
|
-
allowPositionals: true,
|
|
248
|
-
strict: true,
|
|
249
|
-
});
|
|
250
|
-
validatePositionals(positionals, projectInputs.list.forms[0]);
|
|
235
|
+
parseCommandArgs(args, projectInputs.list);
|
|
251
236
|
const projects = project
|
|
252
237
|
.getAllWithTaskCounts()
|
|
253
238
|
.map((entry) => ({ ...presentProject(entry), taskCounts: entry.taskCounts }));
|
|
@@ -263,44 +248,28 @@ Example: zinn project list`,
|
|
|
263
248
|
},
|
|
264
249
|
view: {
|
|
265
250
|
summary: "Show a project with its description and the number of tasks in each column.",
|
|
266
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
251
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
267
252
|
confirmation: { kind: "none" },
|
|
268
253
|
input: projectInputs.view,
|
|
269
254
|
results: [jsonResult("ProjectView")],
|
|
270
255
|
run: (args) => {
|
|
271
|
-
const { positionals } =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const projectMatch = project.getByKey(projectKey);
|
|
280
|
-
if (projectMatch == null) {
|
|
281
|
-
throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
|
|
282
|
-
}
|
|
283
|
-
const taskCounts = column.getTaskCountsByProjectKey(projectMatch.key);
|
|
284
|
-
const presentedProject = {
|
|
285
|
-
...presentProject(projectMatch),
|
|
286
|
-
columns: presentColumnTaskCounts(taskCounts),
|
|
287
|
-
archivedTaskCount: taskCounts.archivedTaskCount,
|
|
288
|
-
};
|
|
289
|
-
output(presentedProject, (viewedProject) => {
|
|
290
|
-
// The full description follows as its own section, so the row leaves out the preview.
|
|
291
|
-
const sections = [formatProjectList([viewedProject], { showsDescriptionPreview: false })];
|
|
292
|
-
if (viewedProject.description != null) {
|
|
293
|
-
sections.push(formatSection("Description", viewedProject.description));
|
|
294
|
-
}
|
|
295
|
-
if (viewedProject.columns.length > 0) {
|
|
296
|
-
const columnTaskCounts = formatColumnList(viewedProject.columns, {
|
|
297
|
-
showsTaskCounts: true,
|
|
298
|
-
archivedTaskCount: viewedProject.archivedTaskCount,
|
|
299
|
-
});
|
|
300
|
-
sections.push(formatSection("Columns", columnTaskCounts));
|
|
256
|
+
const { positionals } = parseCommandArgs(args, projectInputs.view);
|
|
257
|
+
const projectChoice = chooseProjectKey(positionals[0], { required: true });
|
|
258
|
+
const projectKey = projectChoice.key;
|
|
259
|
+
const presentedProject = readSnapshot(() => {
|
|
260
|
+
checkDefaultProject(projectChoice);
|
|
261
|
+
const projectMatch = project.getByKey(projectKey);
|
|
262
|
+
if (projectMatch == null) {
|
|
263
|
+
throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
|
|
301
264
|
}
|
|
302
|
-
|
|
265
|
+
const taskCounts = column.getTaskCountsByProjectKey(projectMatch.key);
|
|
266
|
+
return {
|
|
267
|
+
...presentProject(projectMatch),
|
|
268
|
+
columns: presentColumnTaskCounts(taskCounts),
|
|
269
|
+
archivedTaskCount: taskCounts.archivedTaskCount,
|
|
270
|
+
};
|
|
303
271
|
});
|
|
272
|
+
output(presentedProject, (presented) => formatProjectDetail(presented, readTerminalProps()));
|
|
304
273
|
},
|
|
305
274
|
help: `${generateCommandUsage("project view", projectInputs.view)}
|
|
306
275
|
|
|
@@ -312,20 +281,12 @@ Example: zinn project view MDR`,
|
|
|
312
281
|
},
|
|
313
282
|
edit: {
|
|
314
283
|
summary: "Change the supplied project fields. At least one edit flag is required.",
|
|
315
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
284
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
316
285
|
confirmation: { kind: "none" },
|
|
317
286
|
input: projectInputs.edit,
|
|
318
287
|
results: [jsonResult("ProjectChange")],
|
|
319
288
|
run: async (args) => {
|
|
320
|
-
const { values, positionals
|
|
321
|
-
args,
|
|
322
|
-
options: projectInputs.edit.options,
|
|
323
|
-
allowPositionals: true,
|
|
324
|
-
strict: true,
|
|
325
|
-
tokens: true,
|
|
326
|
-
});
|
|
327
|
-
validateUniqueOptions(tokens, projectInputs.edit.options);
|
|
328
|
-
validatePositionals(positionals, projectInputs.edit.forms[0]);
|
|
289
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.edit);
|
|
329
290
|
const projectChoice = chooseProjectKey(positionals[0], { required: true });
|
|
330
291
|
const expected = projectExpectations.parseValues(values);
|
|
331
292
|
checkFieldsBeforeText(projectEditSchema, {
|
|
@@ -372,7 +333,7 @@ Examples:
|
|
|
372
333
|
},
|
|
373
334
|
delete: {
|
|
374
335
|
summary: "Permanently delete a project and all of its columns and tasks after confirmation.",
|
|
375
|
-
effects: { domain: "delete", storage: "normal-open" },
|
|
336
|
+
effects: { domain: "delete", storage: "normal-open", external: [] },
|
|
376
337
|
confirmation: {
|
|
377
338
|
kind: "project-delete",
|
|
378
339
|
description: `${confirmationDescription} When the project key is omitted, deleting the configured default project always requires a terminal prompt; --yes is ignored.`,
|
|
@@ -380,15 +341,7 @@ Examples:
|
|
|
380
341
|
input: projectInputs.delete,
|
|
381
342
|
results: [jsonResult("Project")],
|
|
382
343
|
run: async (args) => {
|
|
383
|
-
const { values, positionals
|
|
384
|
-
args,
|
|
385
|
-
options: projectInputs.delete.options,
|
|
386
|
-
allowPositionals: true,
|
|
387
|
-
strict: true,
|
|
388
|
-
tokens: true,
|
|
389
|
-
});
|
|
390
|
-
validateUniqueOptions(tokens, projectInputs.delete.options);
|
|
391
|
-
validatePositionals(positionals, projectInputs.delete.forms[0]);
|
|
344
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.delete);
|
|
392
345
|
const typedProjectKey = positionals[0];
|
|
393
346
|
const projectKey = resolveProjectKey(typedProjectKey, { required: true });
|
|
394
347
|
try {
|
|
@@ -435,20 +388,12 @@ Example: zinn project delete MDR`,
|
|
|
435
388
|
column: {
|
|
436
389
|
create: {
|
|
437
390
|
summary: "Add a column at the end of a project's board.",
|
|
438
|
-
effects: { domain: "create", storage: "normal-open" },
|
|
391
|
+
effects: { domain: "create", storage: "normal-open", external: [] },
|
|
439
392
|
confirmation: { kind: "none" },
|
|
440
393
|
input: projectInputs.column_create,
|
|
441
394
|
results: [jsonResult("Column")],
|
|
442
395
|
run: (args) => {
|
|
443
|
-
const { values, positionals
|
|
444
|
-
options: projectInputs.column_create.options,
|
|
445
|
-
args,
|
|
446
|
-
allowPositionals: true,
|
|
447
|
-
strict: true,
|
|
448
|
-
tokens: true,
|
|
449
|
-
});
|
|
450
|
-
validateUniqueOptions(tokens, projectInputs.column_create.options);
|
|
451
|
-
validatePositionals(positionals, projectInputs.column_create.forms[0]);
|
|
396
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.column_create);
|
|
452
397
|
const category = requireStringOption(projectInputs.column_create.options.category, values.category, "category", `Provide the column's category with --category: ${columnCategoryValues}`);
|
|
453
398
|
const createdColumn = column.create({
|
|
454
399
|
projectKey: positionals[0],
|
|
@@ -471,20 +416,17 @@ Example: zinn project column create MDR Boardlog --category backlog`,
|
|
|
471
416
|
},
|
|
472
417
|
list: {
|
|
473
418
|
summary: "List a project's columns in board order with their unarchived task counts.",
|
|
474
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
419
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
475
420
|
confirmation: { kind: "none" },
|
|
476
421
|
input: projectInputs.column_list,
|
|
477
422
|
results: [jsonResult("ColumnList")],
|
|
478
423
|
run: (args) => {
|
|
479
|
-
const { positionals } =
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
424
|
+
const { positionals } = parseCommandArgs(args, projectInputs.column_list);
|
|
425
|
+
const projectChoice = chooseProjectKey(positionals[0], { required: true });
|
|
426
|
+
const columns = readSnapshot(() => {
|
|
427
|
+
checkDefaultProject(projectChoice);
|
|
428
|
+
return presentColumnTaskCounts(column.getTaskCountsByProjectKey(projectChoice.key));
|
|
484
429
|
});
|
|
485
|
-
validatePositionals(positionals, projectInputs.column_list.forms[0]);
|
|
486
|
-
const projectKey = resolveProjectKey(positionals[0], { required: true });
|
|
487
|
-
const columns = presentColumnTaskCounts(column.getTaskCountsByProjectKey(projectKey));
|
|
488
430
|
output(columns, (presentedColumns) => formatColumnList(presentedColumns, {
|
|
489
431
|
showsTaskCounts: true,
|
|
490
432
|
}));
|
|
@@ -498,7 +440,7 @@ Example: zinn project column list MDR`,
|
|
|
498
440
|
},
|
|
499
441
|
edit: {
|
|
500
442
|
summary: "Rename a column or change its category.",
|
|
501
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
443
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
502
444
|
confirmation: {
|
|
503
445
|
kind: "prompt",
|
|
504
446
|
description: `Only asks when changing the category of a column that holds tasks. ${confirmationDescription}`,
|
|
@@ -506,15 +448,7 @@ Example: zinn project column list MDR`,
|
|
|
506
448
|
input: projectInputs.column_edit,
|
|
507
449
|
results: [jsonResult("ColumnChange")],
|
|
508
450
|
run: async (args) => {
|
|
509
|
-
const { values, positionals
|
|
510
|
-
args,
|
|
511
|
-
options: projectInputs.column_edit.options,
|
|
512
|
-
allowPositionals: true,
|
|
513
|
-
strict: true,
|
|
514
|
-
tokens: true,
|
|
515
|
-
});
|
|
516
|
-
validateUniqueOptions(tokens, projectInputs.column_edit.options);
|
|
517
|
-
validatePositionals(positionals, projectInputs.column_edit.forms[0]);
|
|
451
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.column_edit);
|
|
518
452
|
if (violatesConstraint(columnEditConstraint, getOptionInputs(values))) {
|
|
519
453
|
quit("Provide an edit flag: --name or --category", undefined, { field: [] });
|
|
520
454
|
}
|
|
@@ -551,17 +485,12 @@ Examples:
|
|
|
551
485
|
},
|
|
552
486
|
order: {
|
|
553
487
|
summary: "Change a column's position on the project's board.",
|
|
554
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
488
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
555
489
|
confirmation: { kind: "none" },
|
|
556
490
|
input: projectInputs.column_order,
|
|
557
491
|
results: [jsonResult("ColumnChange")],
|
|
558
492
|
run: (args) => {
|
|
559
|
-
const { positionals } =
|
|
560
|
-
options: projectInputs.column_order.options,
|
|
561
|
-
args,
|
|
562
|
-
allowPositionals: true,
|
|
563
|
-
strict: true,
|
|
564
|
-
});
|
|
493
|
+
const { positionals } = parseCommandArgs(args, projectInputs.column_order);
|
|
565
494
|
const form = validateOrderForms(positionals, projectInputs.column_order.forms);
|
|
566
495
|
const projectKey = positionals[0];
|
|
567
496
|
const columnName = positionals[1];
|
|
@@ -593,20 +522,12 @@ Example: zinn project column order MDR Review before Doing`,
|
|
|
593
522
|
},
|
|
594
523
|
delete: {
|
|
595
524
|
summary: "Delete an empty project column after confirmation.",
|
|
596
|
-
effects: { domain: "delete", storage: "normal-open" },
|
|
525
|
+
effects: { domain: "delete", storage: "normal-open", external: [] },
|
|
597
526
|
confirmation: { kind: "prompt", description: confirmationDescription },
|
|
598
527
|
input: projectInputs.column_delete,
|
|
599
528
|
results: [jsonResult("Column")],
|
|
600
529
|
run: async (args) => {
|
|
601
|
-
const { values, positionals
|
|
602
|
-
args,
|
|
603
|
-
options: projectInputs.column_delete.options,
|
|
604
|
-
allowPositionals: true,
|
|
605
|
-
strict: true,
|
|
606
|
-
tokens: true,
|
|
607
|
-
});
|
|
608
|
-
validateUniqueOptions(tokens, projectInputs.column_delete.options);
|
|
609
|
-
validatePositionals(positionals, projectInputs.column_delete.forms[0]);
|
|
530
|
+
const { values, positionals } = parseCommandArgs(args, projectInputs.column_delete);
|
|
610
531
|
const props = columnDeleteSchema.parse({
|
|
611
532
|
projectKey: positionals[0],
|
|
612
533
|
columnName: positionals[1],
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { reindex } from "@zinn-dev/core";
|
|
4
3
|
import { reportLockWait } from "../database.js";
|
|
5
4
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
6
|
-
import { output,
|
|
5
|
+
import { output, parseCommandArgs } from "../lib.js";
|
|
7
6
|
export const reindexCommand = {
|
|
8
7
|
summary: "Rebuild the search index that `zinn task search` uses from the tasks and their comments, archived tasks included.",
|
|
9
|
-
effects: { domain: "none", storage: "reindex" },
|
|
8
|
+
effects: { domain: "none", storage: "reindex", external: [] },
|
|
10
9
|
confirmation: { kind: "none" },
|
|
11
10
|
input: noInput,
|
|
12
11
|
results: [jsonResult("Reindex")],
|
|
13
12
|
run: (args) => {
|
|
14
|
-
|
|
15
|
-
options: noInput.options,
|
|
16
|
-
args,
|
|
17
|
-
strict: true,
|
|
18
|
-
allowPositionals: true,
|
|
19
|
-
});
|
|
20
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
13
|
+
parseCommandArgs(args, noInput);
|
|
21
14
|
const result = reindex.run({ onWait: reportLockWait });
|
|
22
15
|
output(result, (r) => {
|
|
23
16
|
const noun = r.taskCount === 1 ? "task" : "tasks";
|
|
@@ -4,6 +4,7 @@ export declare const relationRouter: {
|
|
|
4
4
|
effects: {
|
|
5
5
|
domain: "replace";
|
|
6
6
|
storage: "normal-open";
|
|
7
|
+
external: never[];
|
|
7
8
|
};
|
|
8
9
|
confirmation: {
|
|
9
10
|
kind: "prompt";
|
|
@@ -19,7 +20,7 @@ export declare const relationRouter: {
|
|
|
19
20
|
readonly required: true;
|
|
20
21
|
readonly value: {
|
|
21
22
|
readonly kind: "enum";
|
|
22
|
-
readonly choices: ("
|
|
23
|
+
readonly choices: ("dependency" | "subtask" | "duplicate" | "related")[];
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
};
|
|
@@ -45,7 +46,10 @@ export declare const relationRouter: {
|
|
|
45
46
|
};
|
|
46
47
|
results: import("../results.js").CommandResult[];
|
|
47
48
|
guessedFlags: {
|
|
48
|
-
[k: string]: (args: Array<string>) =>
|
|
49
|
+
[k: string]: (args: Array<string>) => {
|
|
50
|
+
args: string[];
|
|
51
|
+
guidance: string;
|
|
52
|
+
} | undefined;
|
|
49
53
|
};
|
|
50
54
|
run: (args: string[]) => Promise<void>;
|
|
51
55
|
help: string;
|
|
@@ -55,6 +59,7 @@ export declare const relationRouter: {
|
|
|
55
59
|
effects: {
|
|
56
60
|
domain: "read";
|
|
57
61
|
storage: "normal-open";
|
|
62
|
+
external: never[];
|
|
58
63
|
};
|
|
59
64
|
confirmation: {
|
|
60
65
|
kind: "none";
|
|
@@ -83,6 +88,7 @@ export declare const relationRouter: {
|
|
|
83
88
|
effects: {
|
|
84
89
|
domain: "delete";
|
|
85
90
|
storage: "normal-open";
|
|
91
|
+
external: never[];
|
|
86
92
|
};
|
|
87
93
|
confirmation: {
|
|
88
94
|
kind: "none";
|
|
@@ -94,7 +100,7 @@ export declare const relationRouter: {
|
|
|
94
100
|
readonly required: true;
|
|
95
101
|
readonly value: {
|
|
96
102
|
readonly kind: "enum";
|
|
97
|
-
readonly choices: ("
|
|
103
|
+
readonly choices: ("dependency" | "subtask" | "duplicate" | "related")[];
|
|
98
104
|
};
|
|
99
105
|
};
|
|
100
106
|
};
|
|
@@ -120,7 +126,10 @@ export declare const relationRouter: {
|
|
|
120
126
|
};
|
|
121
127
|
results: import("../results.js").CommandResult[];
|
|
122
128
|
guessedFlags: {
|
|
123
|
-
[k: string]: (args: Array<string>) =>
|
|
129
|
+
[k: string]: (args: Array<string>) => {
|
|
130
|
+
args: string[];
|
|
131
|
+
guidance: string;
|
|
132
|
+
} | undefined;
|
|
124
133
|
};
|
|
125
134
|
run: (args: string[]) => void;
|
|
126
135
|
help: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import { relation, relationTypeSchema, task } from "@zinn-dev/core";
|
|
2
|
+
import { readSnapshot, relation, relationTypeSchema, task } from "@zinn-dev/core";
|
|
3
3
|
import { jsonResult } from "../results.js";
|
|
4
4
|
import { generateCommandUsage, taskKeyPositional } from "../input.js";
|
|
5
|
-
import { output, diagnostic, confirmAction, confirmationDescription, quit, requireStringOption,
|
|
5
|
+
import { output, diagnostic, confirmAction, confirmationDescription, quit, requireStringOption, parseCommandArgs, validateTaskKey, } from "../lib.js";
|
|
6
6
|
import { currentActor } from "../actor.js";
|
|
7
7
|
import { formatRelationChange, formatRelationList, presentRelations, presentRelationChange, } from "../presentation/relation-presentation.js";
|
|
8
8
|
const guessedRelationTypes = new Map([
|
|
@@ -40,21 +40,16 @@ function relationFlagSuggestions(action) {
|
|
|
40
40
|
if (cannotSuggestRelation) {
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
args: ["task", "relation", action, positionals[0], guessed.value, "--type", type],
|
|
45
|
+
guidance: `Pass both task keys as positional arguments and use --type ${type}.`,
|
|
46
|
+
};
|
|
44
47
|
};
|
|
45
48
|
return Object.fromEntries([...guessedRelationTypes.keys()].map((name) => [`--${name}`, suggest]));
|
|
46
49
|
}
|
|
47
50
|
function parseRelationArgs(args, action) {
|
|
48
51
|
const input = relationInputs[action];
|
|
49
|
-
const { values, positionals
|
|
50
|
-
args,
|
|
51
|
-
options: input.options,
|
|
52
|
-
allowPositionals: true,
|
|
53
|
-
strict: true,
|
|
54
|
-
tokens: true,
|
|
55
|
-
});
|
|
56
|
-
validateUniqueOptions(tokens, input.options);
|
|
57
|
-
validatePositionals(positionals, input.forms[0]);
|
|
52
|
+
const { values, positionals } = parseCommandArgs(args, input);
|
|
58
53
|
const type = requireStringOption(relationPairInput.options.type, values.type, "type", `--type must be one of these: ${relationPairInput.options.type.value.choices.join(", ")}`);
|
|
59
54
|
const typeResult = relationTypeSchema.safeParse(type);
|
|
60
55
|
if (!typeResult.success) {
|
|
@@ -111,7 +106,7 @@ const relationInputs = {
|
|
|
111
106
|
export const relationRouter = {
|
|
112
107
|
create: {
|
|
113
108
|
summary: "Create a relation, confirming replacement of conflicting links.",
|
|
114
|
-
effects: { domain: "replace", storage: "normal-open" },
|
|
109
|
+
effects: { domain: "replace", storage: "normal-open", external: [] },
|
|
115
110
|
confirmation: {
|
|
116
111
|
kind: "prompt",
|
|
117
112
|
description: `Only asks when replacing existing relations. ${confirmationDescription}`,
|
|
@@ -168,19 +163,16 @@ Example: zinn task relation create APP-1 APP-2 --type dependency`,
|
|
|
168
163
|
},
|
|
169
164
|
list: {
|
|
170
165
|
summary: "Show incoming and outgoing relations with connected task keys, columns and titles.",
|
|
171
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
166
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
172
167
|
confirmation: { kind: "none" },
|
|
173
168
|
input: relationInputs.list,
|
|
174
169
|
results: [jsonResult("RelationList")],
|
|
175
170
|
run: (args) => {
|
|
176
|
-
const { positionals } =
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
182
|
-
validatePositionals(positionals, relationInputs.list.forms[0]);
|
|
183
|
-
output(presentRelations(task.getByKey(positionals[0])), formatRelationList);
|
|
171
|
+
const { positionals } = parseCommandArgs(args, relationInputs.list);
|
|
172
|
+
const taskKey = positionals[0];
|
|
173
|
+
validateTaskKey(taskKey);
|
|
174
|
+
const relations = readSnapshot(() => presentRelations(task.getByKey(taskKey)));
|
|
175
|
+
output(relations, formatRelationList);
|
|
184
176
|
},
|
|
185
177
|
help: `${generateCommandUsage("task relation list", relationInputs.list)}
|
|
186
178
|
|
|
@@ -192,7 +184,7 @@ Example: zinn task relation list APP-1`,
|
|
|
192
184
|
},
|
|
193
185
|
delete: {
|
|
194
186
|
summary: "Remove only the specified relation. No confirmation is required.",
|
|
195
|
-
effects: { domain: "delete", storage: "normal-open" },
|
|
187
|
+
effects: { domain: "delete", storage: "normal-open", external: [] },
|
|
196
188
|
confirmation: { kind: "none" },
|
|
197
189
|
input: relationInputs.delete,
|
|
198
190
|
results: [jsonResult("RelationChange")],
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
1
|
import { resolve } from "node:path";
|
|
3
|
-
import { backup, RestoreRefusedError, getBackupStorage, isSqliteErrorFamily } from "@zinn-dev/core";
|
|
2
|
+
import { backup, DatabaseChangeAppliedError, RestoreRefusedError, getBackupStorage, isSqliteErrorFamily, } from "@zinn-dev/core";
|
|
4
3
|
import { jsonResult } from "../results.js";
|
|
5
4
|
import { reportLockWait } from "../database.js";
|
|
6
5
|
import { confirmationDescription } from "../lib.js";
|
|
7
6
|
import { generateCommandUsage } from "../input.js";
|
|
8
|
-
import { askConfirmation, diagnostic, output,
|
|
7
|
+
import { askConfirmation, diagnostic, output, parseCommandArgs, } from "../lib.js";
|
|
9
8
|
import packageJson from "../../package.json" with { type: "json" };
|
|
10
9
|
const build = { client: "cli", version: packageJson.version };
|
|
11
10
|
const restoreInputs = {
|
|
@@ -19,20 +18,12 @@ const restoreInputs = {
|
|
|
19
18
|
};
|
|
20
19
|
export const restoreCommand = {
|
|
21
20
|
summary: "Replace the database with the one in a backup file, such as one saved by `zinn backup` or by an upgrade, after confirmation.",
|
|
22
|
-
effects: { domain: "replace", storage: "restore" },
|
|
21
|
+
effects: { domain: "replace", storage: "restore", external: [] },
|
|
23
22
|
confirmation: { kind: "prompt", description: confirmationDescription },
|
|
24
23
|
input: restoreInputs.command,
|
|
25
24
|
results: [jsonResult("Restore")],
|
|
26
25
|
run: async (args) => {
|
|
27
|
-
const { positionals, values
|
|
28
|
-
args,
|
|
29
|
-
strict: true,
|
|
30
|
-
allowPositionals: true,
|
|
31
|
-
tokens: true,
|
|
32
|
-
options: restoreInputs.command.options,
|
|
33
|
-
});
|
|
34
|
-
validateUniqueOptions(tokens, restoreInputs.command.options);
|
|
35
|
-
validatePositionals(positionals, restoreInputs.command.forms[0]);
|
|
26
|
+
const { positionals, values } = parseCommandArgs(args, restoreInputs.command);
|
|
36
27
|
const path = resolve(positionals[0]);
|
|
37
28
|
const storage = getBackupStorage();
|
|
38
29
|
const { databasePath, backupDirectory } = storage;
|
|
@@ -61,8 +52,7 @@ export const restoreCommand = {
|
|
|
61
52
|
});
|
|
62
53
|
}
|
|
63
54
|
catch (error) {
|
|
64
|
-
|
|
65
|
-
if (!(error instanceof RestoreRefusedError)) {
|
|
55
|
+
if (!(error instanceof RestoreRefusedError || error instanceof DatabaseChangeAppliedError)) {
|
|
66
56
|
const isDamagedDatabase = isSqliteErrorFamily(error, "SQLITE_CORRUPT");
|
|
67
57
|
if (isDamagedDatabase) {
|
|
68
58
|
diagnostic(`The database at ${databasePath} is damaged. Nothing was changed. To restore it:\n` +
|
package/src/routes/router.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import { routerOptions, helpSpellings, versionSpellings, usageLabel, isHelpFlag, isRouterFlag, splitAtOptionSeparator, } from "../input.js";
|
|
2
|
+
import { routerOptions, helpSpellings, versionSpellings, usageLabel, isHelpFlag, isRouterFlag, optionAliasEntries, parseArgsOptions, splitAtOptionSeparator, } from "../input.js";
|
|
3
3
|
import { getCommandAliases } from "./aliases.js";
|
|
4
4
|
import { classifyFailure, CliError } from "../errors.js";
|
|
5
5
|
import { quotedColumnHint } from "../column-hint.js";
|
|
6
6
|
import { formatCell } from "../presentation/row-layout.js";
|
|
7
7
|
import { formatOverview } from "../overview.js";
|
|
8
|
-
import { boundParserMessage, dashValueHelp, diagnostic, failureMessage, finishRun, isDebugOutputEnabled, isParseArgsError, parseArgsFailure, prepareOutput, quit, renderFailure, UsageError, validateUniqueOptions, } from "../lib.js";
|
|
8
|
+
import { boundParserMessage, dashValueHelp, diagnostic, failureMessage, finishRun, isDebugOutputEnabled, isParseArgsError, parseArgsFailure, prepareOutput, quit, renameFlag, renderFailure, UsageError, validateUniqueOptions, } from "../lib.js";
|
|
9
9
|
import { noteMatchedRun, noteParseArgsThrew, noteUnmatchedRun } from "../telemetry.js";
|
|
10
10
|
function getIsRunnable(obj) {
|
|
11
11
|
return Object.hasOwn(obj, "run");
|
|
@@ -24,13 +24,21 @@ function validateRouterFlags(routableArgs) {
|
|
|
24
24
|
function getUsage(help) {
|
|
25
25
|
return help.split("\n\n")[0];
|
|
26
26
|
}
|
|
27
|
-
function getCommandHelp(help, aliases) {
|
|
28
|
-
|
|
27
|
+
function getCommandHelp(help, aliases, options) {
|
|
28
|
+
const aliasLines = [];
|
|
29
|
+
if (aliases.length > 0) {
|
|
30
|
+
aliasLines.push(`Alias: ${aliases.map((path) => `zinn ${path.join(" ")}`).join(", ")}`);
|
|
31
|
+
}
|
|
32
|
+
const optionAliases = optionAliasEntries(options);
|
|
33
|
+
if (optionAliases.length > 0) {
|
|
34
|
+
const spellings = optionAliases.map(([alias, name]) => `--${alias} for --${name}`);
|
|
35
|
+
aliasLines.push(`Option aliases: ${spellings.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
if (aliasLines.length === 0) {
|
|
29
38
|
return help;
|
|
30
39
|
}
|
|
31
40
|
const [usage, ...details] = help.split("\n\n");
|
|
32
|
-
|
|
33
|
-
return [usage, aliasLine, ...details].join("\n\n");
|
|
41
|
+
return [usage, aliasLines.join("\n"), ...details].join("\n\n");
|
|
34
42
|
}
|
|
35
43
|
function toCommand(args) {
|
|
36
44
|
return args.join(" ");
|
|
@@ -160,7 +168,7 @@ export function parseRoutes(routesDef, prefix) {
|
|
|
160
168
|
...definition,
|
|
161
169
|
command: combinedRoute,
|
|
162
170
|
aliases,
|
|
163
|
-
help: getCommandHelp(definition.help, aliases),
|
|
171
|
+
help: getCommandHelp(definition.help, aliases, definition.input.options),
|
|
164
172
|
});
|
|
165
173
|
}
|
|
166
174
|
else {
|
|
@@ -170,6 +178,19 @@ export function parseRoutes(routesDef, prefix) {
|
|
|
170
178
|
}
|
|
171
179
|
return routeDefinitions;
|
|
172
180
|
}
|
|
181
|
+
function correctGuessedFlag(match, flag, args) {
|
|
182
|
+
const selectsTaskColumn = match.command.startsWith("task ") && "column" in match.input.options;
|
|
183
|
+
if (flag === "--status" && selectsTaskColumn) {
|
|
184
|
+
return {
|
|
185
|
+
args: [
|
|
186
|
+
...match.command.split(" "),
|
|
187
|
+
...renameFlag(args, parseArgsOptions(match.input.options), "status", "column"),
|
|
188
|
+
],
|
|
189
|
+
guidance: "Use --column instead.",
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return match.guessedFlags?.[flag]?.(args);
|
|
193
|
+
}
|
|
173
194
|
async function route(parsedRoutes, rawArgs, beforeRun) {
|
|
174
195
|
prepareOutput(rawArgs);
|
|
175
196
|
// Anything after "--" belongs to the command, so "--json" there is search text, not a flag.
|
|
@@ -235,17 +256,17 @@ async function route(parsedRoutes, rawArgs, beforeRun) {
|
|
|
235
256
|
}
|
|
236
257
|
}
|
|
237
258
|
const suggestFor = (flag) => {
|
|
238
|
-
const suggestion = match
|
|
259
|
+
const suggestion = correctGuessedFlag(match, flag, commandArgs);
|
|
239
260
|
if (suggestion === undefined) {
|
|
240
261
|
return undefined;
|
|
241
262
|
}
|
|
242
|
-
const target = findCommand(parsedRoutes, suggestion);
|
|
263
|
+
const target = findCommand(parsedRoutes, suggestion.args);
|
|
243
264
|
return target === undefined
|
|
244
265
|
? undefined
|
|
245
|
-
: {
|
|
266
|
+
: { ...suggestion, route: target.match.command.split(" ") };
|
|
246
267
|
};
|
|
247
|
-
|
|
248
|
-
|
|
268
|
+
if (isParseArgsError(err)) {
|
|
269
|
+
const parserFailure = parseArgsFailure(err, rawArgs, suggestFor, match.command.split(" "), parseArgsOptions(match.input.options));
|
|
249
270
|
parserFailure.help = getUsage(match.help);
|
|
250
271
|
throw parserFailure;
|
|
251
272
|
}
|