@zinn-dev/cli 0.44.0 → 0.46.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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/skills/zinn/SKILL.md +7 -9
  4. package/src/actor.d.ts +1 -1
  5. package/src/actor.js +4 -1
  6. package/src/capabilities-schema.d.ts +9 -1
  7. package/src/column-hint.js +1 -3
  8. package/src/database.d.ts +1 -2
  9. package/src/database.js +1 -6
  10. package/src/duration-input.d.ts +7 -0
  11. package/src/duration-input.js +31 -0
  12. package/src/errors.d.ts +26 -0
  13. package/src/errors.js +46 -8
  14. package/src/expected-values.d.ts +48 -0
  15. package/src/expected-values.js +60 -0
  16. package/src/follow.d.ts +9 -0
  17. package/src/follow.js +58 -0
  18. package/src/input.d.ts +0 -8
  19. package/src/input.js +36 -16
  20. package/src/lib.d.ts +7 -3
  21. package/src/lib.js +70 -28
  22. package/src/list-continuation.js +1 -4
  23. package/src/presentation/activity-presentation.d.ts +2 -0
  24. package/src/presentation/activity-presentation.js +60 -3
  25. package/src/presentation/column-presentation.d.ts +9 -4
  26. package/src/presentation/column-presentation.js +29 -12
  27. package/src/presentation/doctor-presentation.d.ts +10 -0
  28. package/src/presentation/doctor-presentation.js +28 -0
  29. package/src/presentation/relation-presentation.js +2 -1
  30. package/src/presentation/skill-status-presentation.d.ts +9 -0
  31. package/src/presentation/skill-status-presentation.js +43 -0
  32. package/src/presentation/task-blame-presentation.d.ts +2 -4
  33. package/src/presentation/task-blame-presentation.js +4 -2
  34. package/src/presentation/task-presentation.d.ts +18 -4
  35. package/src/presentation/task-presentation.js +94 -30
  36. package/src/result-schemas.d.ts +490 -58
  37. package/src/result-schemas.js +97 -2
  38. package/src/results.d.ts +6 -2
  39. package/src/results.js +9 -3
  40. package/src/routes/activity-router.d.ts +16 -5
  41. package/src/routes/activity-router.js +131 -70
  42. package/src/routes/aliases.js +1 -0
  43. package/src/routes/backup-router.d.ts +1 -0
  44. package/src/routes/backup-router.js +4 -3
  45. package/src/routes/capabilities-router.d.ts +1 -0
  46. package/src/routes/capabilities-router.js +1 -1
  47. package/src/routes/comment-router.d.ts +29 -6
  48. package/src/routes/comment-router.js +20 -10
  49. package/src/routes/doctor-router.d.ts +40 -0
  50. package/src/routes/doctor-router.js +83 -0
  51. package/src/routes/info-router.d.ts +1 -0
  52. package/src/routes/info-router.js +1 -1
  53. package/src/routes/label-router.d.ts +44 -6
  54. package/src/routes/label-router.js +27 -10
  55. package/src/routes/migrate-router.d.ts +1 -0
  56. package/src/routes/migrate-router.js +5 -7
  57. package/src/routes/project-router.d.ts +70 -11
  58. package/src/routes/project-router.js +130 -56
  59. package/src/routes/reindex-router.d.ts +1 -0
  60. package/src/routes/reindex-router.js +1 -1
  61. package/src/routes/relation-router.d.ts +3 -0
  62. package/src/routes/relation-router.js +9 -6
  63. package/src/routes/restore-router.d.ts +1 -0
  64. package/src/routes/restore-router.js +5 -6
  65. package/src/routes/router.js +5 -9
  66. package/src/routes/routes.d.ts +517 -35
  67. package/src/routes/routes.js +4 -0
  68. package/src/routes/skill-router.d.ts +76 -0
  69. package/src/routes/skill-router.js +179 -0
  70. package/src/routes/task-router.d.ts +264 -13
  71. package/src/routes/task-router.js +415 -93
  72. package/src/routes/whoami-router.d.ts +1 -0
  73. package/src/routes/whoami-router.js +1 -1
  74. package/src/skill-copies.d.ts +34 -0
  75. package/src/skill-copies.js +109 -0
  76. package/src/telemetry.d.ts +2 -2
  77. package/src/telemetry.js +8 -3
  78. package/src/text-edit.d.ts +2 -2
  79. package/src/text-input.d.ts +19 -1
  80. package/src/text-input.js +26 -5
  81. package/src/types.d.ts +4 -0
  82. package/src/types.js +6 -0
@@ -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";
@@ -55,6 +56,7 @@ export declare const relationRouter: {
55
56
  effects: {
56
57
  domain: "read";
57
58
  storage: "normal-open";
59
+ external: never[];
58
60
  };
59
61
  confirmation: {
60
62
  kind: "none";
@@ -83,6 +85,7 @@ export declare const relationRouter: {
83
85
  effects: {
84
86
  domain: "delete";
85
87
  storage: "normal-open";
88
+ external: never[];
86
89
  };
87
90
  confirmation: {
88
91
  kind: "none";
@@ -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, validatePositionals, validateUniqueOptions, } from "../lib.js";
5
+ import { output, diagnostic, confirmAction, confirmationDescription, quit, requireStringOption, validatePositionals, validateTaskKey, validateUniqueOptions, } 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([
@@ -111,7 +111,7 @@ const relationInputs = {
111
111
  export const relationRouter = {
112
112
  create: {
113
113
  summary: "Create a relation, confirming replacement of conflicting links.",
114
- effects: { domain: "replace", storage: "normal-open" },
114
+ effects: { domain: "replace", storage: "normal-open", external: [] },
115
115
  confirmation: {
116
116
  kind: "prompt",
117
117
  description: `Only asks when replacing existing relations. ${confirmationDescription}`,
@@ -168,7 +168,7 @@ Example: zinn task relation create APP-1 APP-2 --type dependency`,
168
168
  },
169
169
  list: {
170
170
  summary: "Show incoming and outgoing relations with connected task keys, columns and titles.",
171
- effects: { domain: "read", storage: "normal-open" },
171
+ effects: { domain: "read", storage: "normal-open", external: [] },
172
172
  confirmation: { kind: "none" },
173
173
  input: relationInputs.list,
174
174
  results: [jsonResult("RelationList")],
@@ -180,7 +180,10 @@ Example: zinn task relation create APP-1 APP-2 --type dependency`,
180
180
  strict: true,
181
181
  });
182
182
  validatePositionals(positionals, relationInputs.list.forms[0]);
183
- output(presentRelations(task.getByKey(positionals[0])), formatRelationList);
183
+ const taskKey = positionals[0];
184
+ validateTaskKey(taskKey);
185
+ const relations = readSnapshot(() => presentRelations(task.getByKey(taskKey)));
186
+ output(relations, formatRelationList);
184
187
  },
185
188
  help: `${generateCommandUsage("task relation list", relationInputs.list)}
186
189
 
@@ -192,7 +195,7 @@ Example: zinn task relation list APP-1`,
192
195
  },
193
196
  delete: {
194
197
  summary: "Remove only the specified relation. No confirmation is required.",
195
- effects: { domain: "delete", storage: "normal-open" },
198
+ effects: { domain: "delete", storage: "normal-open", external: [] },
196
199
  confirmation: { kind: "none" },
197
200
  input: relationInputs.delete,
198
201
  results: [jsonResult("RelationChange")],
@@ -3,6 +3,7 @@ export declare const restoreCommand: {
3
3
  effects: {
4
4
  domain: "replace";
5
5
  storage: "restore";
6
+ external: never[];
6
7
  };
7
8
  confirmation: {
8
9
  kind: "prompt";
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { resolve } from "node:path";
3
- import { backup, RestoreRefusedError, getBackupStorage, isSqliteErrorFamily } from "@zinn-dev/core";
3
+ import { backup, DatabaseChangeAppliedError, RestoreRefusedError, getBackupStorage, isSqliteErrorFamily, } from "@zinn-dev/core";
4
4
  import { jsonResult } from "../results.js";
5
5
  import { reportLockWait } from "../database.js";
6
6
  import { confirmationDescription } from "../lib.js";
@@ -19,7 +19,7 @@ const restoreInputs = {
19
19
  };
20
20
  export const restoreCommand = {
21
21
  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" },
22
+ effects: { domain: "replace", storage: "restore", external: [] },
23
23
  confirmation: { kind: "prompt", description: confirmationDescription },
24
24
  input: restoreInputs.command,
25
25
  results: [jsonResult("Restore")],
@@ -39,7 +39,7 @@ export const restoreCommand = {
39
39
  const isPreconfirmed = values.yes === true;
40
40
  // A backup that would be refused is refused before the prompt.
41
41
  if (!isPreconfirmed) {
42
- backup.check({ ...build, path });
42
+ backup.check({ ...build, path, storage });
43
43
  }
44
44
  const isConfirmed = await askConfirmation(`Replace the database at ${databasePath} with the backup ${path}? The current database is saved to ${backupDirectory} first.`, isPreconfirmed);
45
45
  if (!isConfirmed) {
@@ -61,8 +61,7 @@ export const restoreCommand = {
61
61
  });
62
62
  }
63
63
  catch (error) {
64
- // A refusal attempted nothing, so only a failed restore points at the backups.
65
- if (!(error instanceof RestoreRefusedError)) {
64
+ if (!(error instanceof RestoreRefusedError || error instanceof DatabaseChangeAppliedError)) {
66
65
  const isDamagedDatabase = isSqliteErrorFamily(error, "SQLITE_CORRUPT");
67
66
  if (isDamagedDatabase) {
68
67
  diagnostic(`The database at ${databasePath} is damaged. Nothing was changed. To restore it:\n` +
@@ -84,7 +83,7 @@ Replace the database with the one in a backup file, such as one saved by \`zinn
84
83
  The current database is saved first, in the same place as \`zinn backup\`, and the restore is applied completely or not at all.
85
84
  A backup with an older schema version is restored at that version. Zinn then upgrades it like any older database: by itself, except for ~/.zinn run from a source checkout, which needs \`zinn migrate\`.
86
85
  Restoring onto a missing database creates it inside an existing Zinn folder.
87
- Fails, leaving the database as it is, when the backup has a newer schema version than this Zinn or none at all, is damaged, or is not a Zinn database.
86
+ Fails, leaving the database as it is, when the backup has a newer schema version than this Zinn or none at all, is damaged, is not a Zinn database, is the database itself, or changes after restore checked it.
88
87
  Use --yes to skip the confirmation prompt, for example in scripts or with --json.
89
88
 
90
89
  Example: zinn restore ~/.zinn/backups/2026-10-06T12-30-05Z-cli-0.40.0-1a2b3c4d.sqlite`,
@@ -1,16 +1,16 @@
1
1
  import { parseArgs } from "node:util";
2
- import { routerOptions, helpSpellings, versionSpellings, usageLabel, isAllowLegacyReadFlag, isHelpFlag, isRouterFlag, splitAtOptionSeparator, } from "../input.js";
2
+ import { routerOptions, helpSpellings, versionSpellings, usageLabel, isHelpFlag, isRouterFlag, 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, setLegacyReadAllowed, UsageError, validateUniqueOptions, } from "../lib.js";
8
+ import { boundParserMessage, dashValueHelp, diagnostic, failureMessage, finishRun, isDebugOutputEnabled, isParseArgsError, parseArgsFailure, prepareOutput, quit, 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");
12
12
  }
13
- // --json and --allow-legacy-read can each be given once, like a command's own flags.
13
+ // --json can be given once, like a command's own flags.
14
14
  function validateRouterFlags(routableArgs) {
15
15
  const { tokens } = parseArgs({
16
16
  args: routableArgs.filter(isRouterFlag),
@@ -77,7 +77,6 @@ Options:
77
77
  ${helpSpellings.join(", ")} Show help
78
78
  ${versionSpellings.join(", ")} Show version
79
79
  --json Print command output as JSON
80
- --allow-legacy-read Read a database without a schema version, best effort and read-only
81
80
 
82
81
  Commands:
83
82
  ${formatCommands(parsedRoutes, "")}
@@ -176,9 +175,6 @@ async function route(parsedRoutes, rawArgs, beforeRun) {
176
175
  // Anything after "--" belongs to the command, so "--json" there is search text, not a flag.
177
176
  const { optionWords: routableArgs, passthroughWords: passthroughArgs } = splitAtOptionSeparator(rawArgs);
178
177
  const filteredRoutableArgs = routableArgs.filter((arg) => !isRouterFlag(arg));
179
- if (routableArgs.some(isAllowLegacyReadFlag)) {
180
- setLegacyReadAllowed(true);
181
- }
182
178
  // A help flag asks for help with the command words before it, so nothing after it is read.
183
179
  const helpFlagIndex = filteredRoutableArgs.findIndex(isHelpFlag);
184
180
  const isHelpRequest = helpFlagIndex !== -1;
@@ -248,8 +244,8 @@ async function route(parsedRoutes, rawArgs, beforeRun) {
248
244
  ? undefined
249
245
  : { args: suggestion, route: target.match.command.split(" ") };
250
246
  };
251
- const parserFailure = parseArgsFailure(err, rawArgs, suggestFor, match.command.split(" "));
252
- if (parserFailure !== null) {
247
+ if (isParseArgsError(err)) {
248
+ const parserFailure = parseArgsFailure(err, rawArgs, suggestFor, match.command.split(" "), match.input.options);
253
249
  parserFailure.help = getUsage(match.help);
254
250
  throw parserFailure;
255
251
  }