@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
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ The command-line interface for [Zinn](https://zinn.sh), local kanban and task ma
|
|
|
11
11
|
npm i -g @zinn-dev/cli
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Requires [Node.js](https://nodejs.org/) 24.
|
|
14
|
+
Requires [Node.js](https://nodejs.org/) 24.16.0 or newer. See [Install](https://zinn.sh/docs/installation) for package setup and upgrade instructions.
|
|
15
15
|
|
|
16
16
|
## Use
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinn-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "A kanban workflow in the terminal. Experimental.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://zinn.sh",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
],
|
|
36
36
|
"type": "module",
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=24.
|
|
38
|
+
"node": ">=24.16.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"zod": "4.6.7",
|
|
42
|
-
"@zinn-dev/core": "0.
|
|
42
|
+
"@zinn-dev/core": "0.36.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"ajv": "8.20.0"
|
package/skills/zinn/SKILL.md
CHANGED
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
it, repository instructions mention it, zinn.local.json exists, or a Zinn task
|
|
8
8
|
key is referenced.
|
|
9
9
|
metadata:
|
|
10
|
-
zinn-cli-reviewed-version: "0.
|
|
10
|
+
zinn-cli-reviewed-version: "0.47.0"
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# Work with a Zinn board
|
|
@@ -40,7 +40,7 @@ When implementation and appropriate verification are complete, add a concise out
|
|
|
40
40
|
|
|
41
41
|
Discover exact commands and flags with `zinn --help` and `zinn <command> --help`. Follow the installed help if it differs from this skill; the skill and CLI can be updated separately. Use `--json` when consuming results programmatically. Check command exit status: errors go to stderr, and empty stdout from a failed command is not an empty successful result.
|
|
42
42
|
|
|
43
|
-
If the installed CLI lacks a command or option this skill uses, tell the user that this skill and their CLI differ, and that `zinn skill install` installs the skill that matches their CLI. Continue with what the installed help offers.
|
|
43
|
+
If the installed CLI lacks a command or option this skill uses, tell the user that this skill and their CLI differ, and that `zinn skill install` installs the skill that matches their CLI. For a copy inside the project, such as `.agents/skills/zinn`, they run `zinn skill install --project` in that project. Continue with what the installed help offers.
|
|
44
44
|
|
|
45
45
|
`ZINN_AGENT`, `ZINN_MODEL`, and `ZINN_EFFORT` can declare the agent, model, and effort of the execution making a change when automatic detection or host integration does not provide them. Use only known values; leave unknown values unset.
|
|
46
46
|
|
package/src/actor.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export declare function readExecutionIdentity(env: Env): {
|
|
|
10
10
|
};
|
|
11
11
|
/** Generic flags establish an unnamed agent only when no identifying marker follows. */
|
|
12
12
|
export declare function detectAgent(env: Env): Actor | null;
|
|
13
|
-
export declare function resolveActor(env: Env): Actor;
|
|
13
|
+
export declare function resolveActor(env: Env, directory?: string): Actor;
|
|
14
14
|
export declare function currentActor(): Actor;
|
|
15
15
|
export {};
|
package/src/actor.js
CHANGED
|
@@ -100,7 +100,10 @@ function readGitConfig(key, env) {
|
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
export function resolveActor(env) {
|
|
103
|
+
export function resolveActor(env, directory = process.cwd()) {
|
|
104
|
+
return { ...resolveIdentity(env), directory };
|
|
105
|
+
}
|
|
106
|
+
function resolveIdentity(env) {
|
|
104
107
|
const agent = detectAgent(env);
|
|
105
108
|
if (agent != null) {
|
|
106
109
|
return agent;
|
|
@@ -12,6 +12,7 @@ export declare const capabilitiesSchema: z.ZodObject<{
|
|
|
12
12
|
string: "string";
|
|
13
13
|
boolean: "boolean";
|
|
14
14
|
}>;
|
|
15
|
+
aliases: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
15
16
|
short: z.ZodOptional<z.ZodString>;
|
|
16
17
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
17
18
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
|
|
@@ -57,6 +58,7 @@ export declare const capabilitiesSchema: z.ZodObject<{
|
|
|
57
58
|
string: "string";
|
|
58
59
|
boolean: "boolean";
|
|
59
60
|
}>;
|
|
61
|
+
aliases: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
60
62
|
short: z.ZodOptional<z.ZodString>;
|
|
61
63
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
62
64
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
|
|
@@ -122,6 +124,10 @@ export declare const capabilitiesSchema: z.ZodObject<{
|
|
|
122
124
|
restore: "restore";
|
|
123
125
|
inspect: "inspect";
|
|
124
126
|
}>;
|
|
127
|
+
external: z.ZodArray<z.ZodEnum<{
|
|
128
|
+
files: "files";
|
|
129
|
+
network: "network";
|
|
130
|
+
}>>;
|
|
125
131
|
}, z.core.$strict>;
|
|
126
132
|
confirmation: z.ZodObject<{
|
|
127
133
|
kind: z.ZodEnum<{
|
|
@@ -159,6 +165,78 @@ export declare const capabilitiesSchema: z.ZodObject<{
|
|
|
159
165
|
exitCode: z.ZodLiteral<1>;
|
|
160
166
|
stream: z.ZodLiteral<"stderr">;
|
|
161
167
|
}, z.core.$strict>;
|
|
168
|
+
views: z.ZodObject<{
|
|
169
|
+
version: z.ZodLiteral<"1.0">;
|
|
170
|
+
taskDetail: z.ZodObject<{
|
|
171
|
+
sections: z.ZodArray<z.ZodObject<{
|
|
172
|
+
id: z.ZodString;
|
|
173
|
+
rank: z.ZodNumber;
|
|
174
|
+
heading: z.ZodOptional<z.ZodString>;
|
|
175
|
+
short: z.ZodOptional<z.ZodEnum<{
|
|
176
|
+
keys: "keys";
|
|
177
|
+
firstParagraph: "firstParagraph";
|
|
178
|
+
countAndLatest: "countAndLatest";
|
|
179
|
+
}>>;
|
|
180
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
181
|
+
role: z.ZodString;
|
|
182
|
+
rank: z.ZodNumber;
|
|
183
|
+
label: z.ZodOptional<z.ZodString>;
|
|
184
|
+
}, z.core.$strict>>>;
|
|
185
|
+
onRequest: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
}, z.core.$strict>>;
|
|
187
|
+
}, z.core.$strict>;
|
|
188
|
+
words: z.ZodObject<{
|
|
189
|
+
relations: z.ZodObject<{
|
|
190
|
+
dependency: z.ZodObject<{
|
|
191
|
+
outgoing: z.ZodString;
|
|
192
|
+
incoming: z.ZodString;
|
|
193
|
+
}, z.core.$strict>;
|
|
194
|
+
subtask: z.ZodObject<{
|
|
195
|
+
outgoing: z.ZodString;
|
|
196
|
+
incoming: z.ZodString;
|
|
197
|
+
}, z.core.$strict>;
|
|
198
|
+
duplicate: z.ZodObject<{
|
|
199
|
+
outgoing: z.ZodString;
|
|
200
|
+
incoming: z.ZodString;
|
|
201
|
+
}, z.core.$strict>;
|
|
202
|
+
related: z.ZodString;
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
priorities: z.ZodObject<{
|
|
205
|
+
urgent: z.ZodObject<{
|
|
206
|
+
word: z.ZodString;
|
|
207
|
+
initial: z.ZodString;
|
|
208
|
+
}, z.core.$strict>;
|
|
209
|
+
high: z.ZodObject<{
|
|
210
|
+
word: z.ZodString;
|
|
211
|
+
initial: z.ZodString;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
medium: z.ZodObject<{
|
|
214
|
+
word: z.ZodString;
|
|
215
|
+
initial: z.ZodString;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
low: z.ZodObject<{
|
|
218
|
+
word: z.ZodString;
|
|
219
|
+
initial: z.ZodString;
|
|
220
|
+
}, z.core.$strict>;
|
|
221
|
+
}, z.core.$strict>;
|
|
222
|
+
}, z.core.$strict>;
|
|
223
|
+
glyphs: z.ZodObject<{
|
|
224
|
+
claimHolder: z.ZodObject<{
|
|
225
|
+
thisSession: z.ZodObject<{
|
|
226
|
+
glyph: z.ZodString;
|
|
227
|
+
words: z.ZodString;
|
|
228
|
+
}, z.core.$strict>;
|
|
229
|
+
otherHolder: z.ZodObject<{
|
|
230
|
+
glyph: z.ZodString;
|
|
231
|
+
words: z.ZodString;
|
|
232
|
+
}, z.core.$strict>;
|
|
233
|
+
unknownOwnership: z.ZodObject<{
|
|
234
|
+
glyph: z.ZodString;
|
|
235
|
+
words: z.ZodString;
|
|
236
|
+
}, z.core.$strict>;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
}, z.core.$strict>;
|
|
239
|
+
}, z.core.$strict>;
|
|
162
240
|
schemas: z.ZodObject<{
|
|
163
241
|
$schema: z.ZodLiteral<"http://json-schema.org/draft-07/schema#">;
|
|
164
242
|
definitions: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
@@ -2,7 +2,50 @@ import { z } from "zod";
|
|
|
2
2
|
import { commandInputSchema, inputOptionsSchema, invocation } from "./input.js";
|
|
3
3
|
import { commandResultSchema, resultReferenceSchema } from "./results.js";
|
|
4
4
|
import { commandEffectsSchema, commandConfirmationSchema } from "./types.js";
|
|
5
|
+
import { views } from "./views.js";
|
|
5
6
|
export const jsonValueSchema = z.json();
|
|
7
|
+
const viewRank = z.number().int().nonnegative();
|
|
8
|
+
const viewItemSchema = z.strictObject({
|
|
9
|
+
role: z.string(),
|
|
10
|
+
rank: viewRank,
|
|
11
|
+
label: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const viewSectionSchema = z.strictObject({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
rank: viewRank,
|
|
16
|
+
heading: z.string().optional(),
|
|
17
|
+
short: z.enum(["firstParagraph", "keys", "countAndLatest"]).optional(),
|
|
18
|
+
items: z.array(viewItemSchema).optional(),
|
|
19
|
+
onRequest: z.boolean().optional(),
|
|
20
|
+
});
|
|
21
|
+
const relationWordsSchema = z.strictObject({ outgoing: z.string(), incoming: z.string() });
|
|
22
|
+
const priorityWordsSchema = z.strictObject({ word: z.string(), initial: z.string() });
|
|
23
|
+
const claimHolderGlyphSchema = z.strictObject({ glyph: z.string(), words: z.string() });
|
|
24
|
+
const viewsSchema = z.strictObject({
|
|
25
|
+
version: z.literal(views.version),
|
|
26
|
+
taskDetail: z.strictObject({ sections: z.array(viewSectionSchema).min(1) }),
|
|
27
|
+
words: z.strictObject({
|
|
28
|
+
relations: z.strictObject({
|
|
29
|
+
dependency: relationWordsSchema,
|
|
30
|
+
subtask: relationWordsSchema,
|
|
31
|
+
duplicate: relationWordsSchema,
|
|
32
|
+
related: z.string(),
|
|
33
|
+
}),
|
|
34
|
+
priorities: z.strictObject({
|
|
35
|
+
urgent: priorityWordsSchema,
|
|
36
|
+
high: priorityWordsSchema,
|
|
37
|
+
medium: priorityWordsSchema,
|
|
38
|
+
low: priorityWordsSchema,
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
glyphs: z.strictObject({
|
|
42
|
+
claimHolder: z.strictObject({
|
|
43
|
+
thisSession: claimHolderGlyphSchema,
|
|
44
|
+
otherHolder: claimHolderGlyphSchema,
|
|
45
|
+
unknownOwnership: claimHolderGlyphSchema,
|
|
46
|
+
}),
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
6
49
|
export const capabilitiesSchema = z.strictObject({
|
|
7
50
|
manifestVersion: z.literal(1),
|
|
8
51
|
cli: z.strictObject({ name: z.string(), version: z.string() }),
|
|
@@ -51,6 +94,7 @@ export const capabilitiesSchema = z.strictObject({
|
|
|
51
94
|
exitCode: z.literal(1),
|
|
52
95
|
stream: z.literal("stderr"),
|
|
53
96
|
}),
|
|
97
|
+
views: viewsSchema,
|
|
54
98
|
schemas: z.strictObject({
|
|
55
99
|
$schema: z.literal("http://json-schema.org/draft-07/schema#"),
|
|
56
100
|
// Schema documents contain JSON values rather than another manifest instance.
|
package/src/capabilities.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ParsedRoute } from "./types.js";
|
|
2
2
|
import { invocation } from "./input.js";
|
|
3
3
|
import { generateResultSchemas } from "./result-schemas.js";
|
|
4
|
+
import { views } from "./views.js";
|
|
4
5
|
export type Capabilities = {
|
|
5
6
|
manifestVersion: 1;
|
|
6
7
|
cli: {
|
|
@@ -16,6 +17,7 @@ export type Capabilities = {
|
|
|
16
17
|
exitCode: 1;
|
|
17
18
|
stream: "stderr";
|
|
18
19
|
};
|
|
20
|
+
views: typeof views;
|
|
19
21
|
schemas: ReturnType<typeof generateResultSchemas>;
|
|
20
22
|
};
|
|
21
23
|
export declare function getCapabilitySummary(): {
|
package/src/capabilities.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { invocation } from "./input.js";
|
|
2
2
|
import { generateResultSchemas } from "./result-schemas.js";
|
|
3
3
|
import { parsedRoutes } from "./routes/routes.js";
|
|
4
|
+
import { views } from "./views.js";
|
|
4
5
|
import packageJson from "../package.json" with { type: "json" };
|
|
5
6
|
export function getCapabilitySummary() {
|
|
6
7
|
return {
|
|
@@ -25,6 +26,7 @@ export function generateCapabilities() {
|
|
|
25
26
|
results,
|
|
26
27
|
})),
|
|
27
28
|
error: { schemaRef: "#/schemas/definitions/ErrorEnvelope", exitCode: 1, stream: "stderr" },
|
|
29
|
+
views,
|
|
28
30
|
schemas: generateResultSchemas(),
|
|
29
31
|
};
|
|
30
32
|
}
|
package/src/column-hint.js
CHANGED
|
@@ -2,7 +2,7 @@ import { parseArgs } from "node:util";
|
|
|
2
2
|
import { column, columnCreateSchema, parseTaskKey } from "@zinn-dev/core";
|
|
3
3
|
import { classifyFailure } from "./errors.js";
|
|
4
4
|
import { routerOptions, getOptionInputs, isRouterFlag, splitAtOptionSeparator, violatesConstraint, } from "./input.js";
|
|
5
|
-
import { formatCommand,
|
|
5
|
+
import { formatCommand, parseOptionArgs, UsageError } from "./lib.js";
|
|
6
6
|
import { chooseProjectKey } from "./project.js";
|
|
7
7
|
function isEligible(error, command) {
|
|
8
8
|
const failure = classifyFailure(error);
|
|
@@ -77,14 +77,7 @@ export function quotedColumnHint(error, route, rawArgs, routeWordCount) {
|
|
|
77
77
|
}
|
|
78
78
|
const args = rawArgs.slice(argumentStart);
|
|
79
79
|
const options = { ...route.input.options, ...routerOptions };
|
|
80
|
-
const { tokens, values } =
|
|
81
|
-
args,
|
|
82
|
-
options,
|
|
83
|
-
allowPositionals: true,
|
|
84
|
-
strict: true,
|
|
85
|
-
tokens: true,
|
|
86
|
-
});
|
|
87
|
-
validateUniqueOptions(tokens, options);
|
|
80
|
+
const { tokens, values } = parseOptionArgs(args, options);
|
|
88
81
|
const optionInputs = getOptionInputs(values);
|
|
89
82
|
const hasMissingOption = Object.entries(route.input.options).some(([name, option]) => option.required && values[name] === undefined);
|
|
90
83
|
const hasInvalidChoice = Object.entries(route.input.options).some(([name, option]) => {
|
package/src/errors.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare const errorDetailsSchema: z.ZodObject<{
|
|
|
58
58
|
unmarked_database: "unmarked_database";
|
|
59
59
|
newer_database: "newer_database";
|
|
60
60
|
older_database: "older_database";
|
|
61
|
+
migration_paused: "migration_paused";
|
|
61
62
|
invalid_backup: "invalid_backup";
|
|
62
63
|
busy: "busy";
|
|
63
64
|
locked: "locked";
|
|
@@ -78,6 +79,7 @@ export declare const errorDetailsSchema: z.ZodObject<{
|
|
|
78
79
|
databasePath: z.ZodOptional<z.ZodString>;
|
|
79
80
|
backupDirectory: z.ZodOptional<z.ZodString>;
|
|
80
81
|
backupPath: z.ZodOptional<z.ZodString>;
|
|
82
|
+
applied: z.ZodOptional<z.ZodLiteral<true>>;
|
|
81
83
|
schemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
82
84
|
supportedSchemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
83
85
|
expectedColumn: z.ZodOptional<z.ZodString>;
|
|
@@ -155,6 +157,7 @@ export declare const errorDocumentSchema: z.ZodObject<{
|
|
|
155
157
|
unmarked_database: "unmarked_database";
|
|
156
158
|
newer_database: "newer_database";
|
|
157
159
|
older_database: "older_database";
|
|
160
|
+
migration_paused: "migration_paused";
|
|
158
161
|
invalid_backup: "invalid_backup";
|
|
159
162
|
busy: "busy";
|
|
160
163
|
locked: "locked";
|
|
@@ -175,6 +178,7 @@ export declare const errorDocumentSchema: z.ZodObject<{
|
|
|
175
178
|
databasePath: z.ZodOptional<z.ZodString>;
|
|
176
179
|
backupDirectory: z.ZodOptional<z.ZodString>;
|
|
177
180
|
backupPath: z.ZodOptional<z.ZodString>;
|
|
181
|
+
applied: z.ZodOptional<z.ZodLiteral<true>>;
|
|
178
182
|
schemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
179
183
|
supportedSchemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
180
184
|
expectedColumn: z.ZodOptional<z.ZodString>;
|
|
@@ -206,6 +210,7 @@ export declare class CliError extends Error {
|
|
|
206
210
|
readonly suggestedRoute?: Array<string> | undefined;
|
|
207
211
|
/** The process exit code, when it is not the usual 1 */
|
|
208
212
|
exitCode?: number;
|
|
213
|
+
omitTextHelp: boolean;
|
|
209
214
|
constructor(message: string, code?: ErrorCode, details?: ErrorDetails | undefined, help?: string | undefined, suggestedRoute?: Array<string> | undefined, cause?: unknown);
|
|
210
215
|
}
|
|
211
216
|
/** Recovery text and its single suggested route, when one is identified. */
|
package/src/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { CoreError, ReadOnlyDatabaseError, SqliteError, TextEditMatchError, isSqliteErrorFamily, } from "@zinn-dev/core";
|
|
2
|
+
import { AutomaticUpgradePausedError, CoreError, ReadOnlyDatabaseError, SqliteError, TextEditMatchError, isSqliteErrorFamily, } from "@zinn-dev/core";
|
|
3
3
|
import { formatLocalTime } from "./presentation/time.js";
|
|
4
4
|
export const errorCodeSchema = z.enum([
|
|
5
5
|
"invalid_input",
|
|
@@ -60,6 +60,7 @@ export const errorDetailsSchema = z.strictObject({
|
|
|
60
60
|
"unmarked_database",
|
|
61
61
|
"newer_database",
|
|
62
62
|
"older_database",
|
|
63
|
+
"migration_paused",
|
|
63
64
|
"invalid_backup",
|
|
64
65
|
"busy",
|
|
65
66
|
"locked",
|
|
@@ -81,6 +82,7 @@ export const errorDetailsSchema = z.strictObject({
|
|
|
81
82
|
databasePath: z.string().optional(),
|
|
82
83
|
backupDirectory: z.string().optional(),
|
|
83
84
|
backupPath: z.string().optional(),
|
|
85
|
+
applied: z.literal(true).optional(),
|
|
84
86
|
schemaVersion: z.number().int().nonnegative().optional(),
|
|
85
87
|
supportedSchemaVersion: z.number().int().nonnegative().optional(),
|
|
86
88
|
expectedColumn: z.string().optional(),
|
|
@@ -118,6 +120,7 @@ export class CliError extends Error {
|
|
|
118
120
|
suggestedRoute;
|
|
119
121
|
/** The process exit code, when it is not the usual 1 */
|
|
120
122
|
exitCode;
|
|
123
|
+
omitTextHelp = false;
|
|
121
124
|
constructor(message, code = "invalid_input", details, help, suggestedRoute, cause) {
|
|
122
125
|
super(message, cause === undefined ? undefined : { cause });
|
|
123
126
|
this.code = code;
|
|
@@ -138,6 +141,15 @@ export function recoveryHint(error) {
|
|
|
138
141
|
if (error instanceof ReadOnlyDatabaseError && error.reason === "older") {
|
|
139
142
|
return { suffix: ". Run `zinn migrate` to upgrade it.", suggestedRoute: ["migrate"] };
|
|
140
143
|
}
|
|
144
|
+
if (error instanceof CoreError && error.facts.reason === "migration_paused") {
|
|
145
|
+
return { suffix: ". Run `zinn migrate` to retry.", suggestedRoute: ["migrate"] };
|
|
146
|
+
}
|
|
147
|
+
if (error instanceof AutomaticUpgradePausedError) {
|
|
148
|
+
return {
|
|
149
|
+
suffix: ". Run `zinn migrate` to retry after fixing the cause.",
|
|
150
|
+
suggestedRoute: ["migrate"],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
141
153
|
if (error instanceof TextEditMatchError && error.matchCount > 1) {
|
|
142
154
|
return { suffix: " Use --all to replace every match." };
|
|
143
155
|
}
|
|
@@ -236,6 +248,7 @@ function publicDetails(facts) {
|
|
|
236
248
|
databasePath: facts.databasePath,
|
|
237
249
|
backupDirectory: facts.backupDirectory,
|
|
238
250
|
backupPath: facts.backupPath,
|
|
251
|
+
applied: facts.applied,
|
|
239
252
|
schemaVersion: facts.schemaVersion,
|
|
240
253
|
supportedSchemaVersion: facts.supportedSchemaVersion,
|
|
241
254
|
expectedColumn: facts.expectedColumn,
|
|
@@ -245,7 +258,7 @@ function publicDetails(facts) {
|
|
|
245
258
|
};
|
|
246
259
|
return Object.fromEntries(Object.entries(details).filter(([, value]) => value !== undefined));
|
|
247
260
|
}
|
|
248
|
-
function nativeFailure(error) {
|
|
261
|
+
function nativeFailure(error, hasStorageContext) {
|
|
249
262
|
const code = "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
250
263
|
if (code === undefined) {
|
|
251
264
|
return undefined;
|
|
@@ -253,11 +266,12 @@ function nativeFailure(error) {
|
|
|
253
266
|
const reason = error instanceof SqliteError
|
|
254
267
|
? sqliteReasons.find(([primary]) => isSqliteErrorFamily(error, primary))?.[1]
|
|
255
268
|
: osReasons[code];
|
|
256
|
-
|
|
269
|
+
const isStorageCause = hasStorageContext && "syscall" in error && typeof error.syscall === "string";
|
|
270
|
+
if (reason === undefined && !isStorageCause) {
|
|
257
271
|
return undefined;
|
|
258
272
|
}
|
|
259
273
|
return {
|
|
260
|
-
reason,
|
|
274
|
+
...(reason === undefined ? {} : { reason }),
|
|
261
275
|
...("path" in error && typeof error.path === "string" ? { path: error.path } : {}),
|
|
262
276
|
cause: {
|
|
263
277
|
code,
|
|
@@ -299,7 +313,7 @@ export function classifyFailure(error) {
|
|
|
299
313
|
},
|
|
300
314
|
};
|
|
301
315
|
}
|
|
302
|
-
const native = nativeFailure(current);
|
|
316
|
+
const native = nativeFailure(current, classified?.code === "storage");
|
|
303
317
|
if (classified?.code === "storage" && current instanceof SqliteError) {
|
|
304
318
|
classified.details = {
|
|
305
319
|
...native,
|
package/src/input.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const inputOptionSchema: z.ZodObject<{
|
|
|
12
12
|
string: "string";
|
|
13
13
|
boolean: "boolean";
|
|
14
14
|
}>;
|
|
15
|
+
aliases: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
15
16
|
short: z.ZodOptional<z.ZodString>;
|
|
16
17
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
17
18
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
|
|
@@ -31,6 +32,7 @@ export declare const inputOptionsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
|
31
32
|
string: "string";
|
|
32
33
|
boolean: "boolean";
|
|
33
34
|
}>;
|
|
35
|
+
aliases: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
34
36
|
short: z.ZodOptional<z.ZodString>;
|
|
35
37
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
36
38
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
|
|
@@ -96,6 +98,7 @@ export declare const commandInputSchema: z.ZodObject<{
|
|
|
96
98
|
string: "string";
|
|
97
99
|
boolean: "boolean";
|
|
98
100
|
}>;
|
|
101
|
+
aliases: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
99
102
|
short: z.ZodOptional<z.ZodString>;
|
|
100
103
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
101
104
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
|
|
@@ -151,6 +154,33 @@ export type InputForm = z.infer<typeof inputFormSchema>;
|
|
|
151
154
|
export type InputReference = z.infer<typeof inputReferenceSchema>;
|
|
152
155
|
export type InputConstraint = z.infer<typeof inputConstraintSchema>;
|
|
153
156
|
export type CommandInput = z.infer<typeof commandInputSchema>;
|
|
157
|
+
export declare function optionAliasEntries(options: InputOptions): (readonly [string, string])[];
|
|
158
|
+
/** Lets `parseArgs` recognize and tokenize the spelling the caller used */
|
|
159
|
+
export declare function parseArgsOptions(options: InputOptions, aliases?: (readonly [string, string])[]): {
|
|
160
|
+
[x: string]: {
|
|
161
|
+
type: "string" | "boolean";
|
|
162
|
+
aliases?: readonly string[] | undefined;
|
|
163
|
+
short?: string | undefined;
|
|
164
|
+
multiple?: boolean | undefined;
|
|
165
|
+
default?: string | boolean | string[] | boolean[] | undefined;
|
|
166
|
+
required?: boolean | undefined;
|
|
167
|
+
value?: {
|
|
168
|
+
kind: string;
|
|
169
|
+
name?: string | undefined;
|
|
170
|
+
choices?: readonly string[] | undefined;
|
|
171
|
+
caseInsensitive?: boolean | undefined;
|
|
172
|
+
pattern?: string | undefined;
|
|
173
|
+
description?: string | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
description?: string | undefined;
|
|
176
|
+
} | {
|
|
177
|
+
type: "string" | "boolean";
|
|
178
|
+
multiple?: undefined;
|
|
179
|
+
} | {
|
|
180
|
+
type: "string" | "boolean";
|
|
181
|
+
multiple: boolean;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
154
184
|
export declare const taskKeyPositional: {
|
|
155
185
|
readonly name: "task-key";
|
|
156
186
|
readonly min: 1;
|
package/src/input.js
CHANGED
|
@@ -9,6 +9,7 @@ export const inputValueSchema = z.strictObject({
|
|
|
9
9
|
});
|
|
10
10
|
export const inputOptionSchema = z.strictObject({
|
|
11
11
|
type: z.enum(["string", "boolean"]),
|
|
12
|
+
aliases: z.array(z.string()).readonly().optional(),
|
|
12
13
|
short: z.string().optional(),
|
|
13
14
|
multiple: z.boolean().optional(),
|
|
14
15
|
default: z.union([z.string(), z.boolean(), z.array(z.string()), z.array(z.boolean())]).optional(),
|
|
@@ -48,6 +49,23 @@ export const commandInputSchema = z.strictObject({
|
|
|
48
49
|
constraints: z.array(inputConstraintSchema).readonly(),
|
|
49
50
|
notes: z.array(z.string()).readonly().optional(),
|
|
50
51
|
});
|
|
52
|
+
export function optionAliasEntries(options) {
|
|
53
|
+
return Object.entries(options).flatMap(([name, option]) => (option.aliases ?? []).map((alias) => [alias, name]));
|
|
54
|
+
}
|
|
55
|
+
/** Lets `parseArgs` recognize and tokenize the spelling the caller used */
|
|
56
|
+
export function parseArgsOptions(options, aliases = optionAliasEntries(options)) {
|
|
57
|
+
if (aliases.length === 0) {
|
|
58
|
+
return options;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
...options,
|
|
62
|
+
...Object.fromEntries(aliases.map(([alias, name]) => {
|
|
63
|
+
const { type, multiple } = options[name];
|
|
64
|
+
// Node's parseArgs rejects a multiple key that is present but not a boolean.
|
|
65
|
+
return [alias, multiple === undefined ? { type } : { type, multiple }];
|
|
66
|
+
})),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
51
69
|
export const taskKeyPositional = {
|
|
52
70
|
name: "task-key",
|
|
53
71
|
min: 1,
|
package/src/lib.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { ParseArgsOptionsConfig } from "node:util";
|
|
2
|
-
import type { InputForm, InputOptions, InputOption } from "./input.js";
|
|
2
|
+
import type { CommandInput, InputForm, InputOptions, InputOption } from "./input.js";
|
|
3
3
|
import type { ErrorDetails } from "./errors.js";
|
|
4
|
+
import type { FlagCorrection } from "./types.js";
|
|
4
5
|
import { parseArgs } from "node:util";
|
|
5
6
|
import { CliError } from "./errors.js";
|
|
6
7
|
type ParsedTokens = NonNullable<ReturnType<typeof parseArgs>["tokens"]>;
|
|
8
|
+
/** What strict parseArgs with tokens returns for these options */
|
|
9
|
+
type ParsedCommandArgs<Options extends ParseArgsOptionsConfig> = ReturnType<typeof parseArgs<{
|
|
10
|
+
args: Array<string>;
|
|
11
|
+
options: Options;
|
|
12
|
+
allowPositionals: true;
|
|
13
|
+
strict: true;
|
|
14
|
+
tokens: true;
|
|
15
|
+
}>>;
|
|
7
16
|
type OutputMode = "text" | "json";
|
|
8
17
|
/** Keeps recovery guidance outside the shortened reason and never clips a repair command. */
|
|
9
18
|
export declare function boundParserMessage(message: string, options?: {
|
|
@@ -56,7 +65,68 @@ export declare class UsageError extends CliError {
|
|
|
56
65
|
* Optional words go last.
|
|
57
66
|
*/
|
|
58
67
|
export declare function validatePositionals(positionals: Array<string>, form: InputForm): void;
|
|
59
|
-
export declare function
|
|
68
|
+
export declare function validateTaskKey(taskKey: string): void;
|
|
69
|
+
/** `typedSpellings` maps an argument index to the flag the caller typed there, when it differs from the token name */
|
|
70
|
+
export declare function validateUniqueOptions(tokens: ParsedTokens, options: InputOptions, typedSpellings?: Map<number, string>): void;
|
|
71
|
+
/** Parses command options and collects positionals before checking their form. */
|
|
72
|
+
export declare function parseOptionArgs<Options extends InputOptions>(args: Array<string>, options: Options): ParsedCommandArgs<Options>;
|
|
73
|
+
/** Checks the positionals of a command with a single form. With several forms the caller selects one. */
|
|
74
|
+
export declare function parseCommandArgs<Input extends CommandInput>(args: Array<string>, input: Input): {
|
|
75
|
+
values: Input["options"] extends ParseArgsOptionsConfig ? (Input["options"] extends infer T extends ParseArgsOptionsConfig ? { -readonly [LongOption in keyof T]?: V[LongOption] | undefined; } : never) & (Input["options"] extends infer T_1 extends ParseArgsOptionsConfig ? { [LongOption_1 in keyof T_1 as Input["options"][LongOption_1]["default"] extends {} ? LongOption_1 : never]: V[LongOption_1]; } : never) extends infer P ? { [K in keyof P]: P[K]; } : never : {};
|
|
76
|
+
positionals: string[];
|
|
77
|
+
tokens: ({
|
|
78
|
+
kind: "positional";
|
|
79
|
+
index: number;
|
|
80
|
+
value: string;
|
|
81
|
+
} | {
|
|
82
|
+
kind: "option-terminator";
|
|
83
|
+
index: number;
|
|
84
|
+
} | (keyof Input["options"] extends infer T_2 ? T_2 extends keyof Input["options"] ? T_2 extends unknown ? Input["options"] extends ParseArgsOptionsConfig ? Input["options"][T_2]["type"] extends "string" ? {
|
|
85
|
+
kind: "option";
|
|
86
|
+
index: number;
|
|
87
|
+
name: T_2 & string;
|
|
88
|
+
rawName: string;
|
|
89
|
+
value: string;
|
|
90
|
+
inlineValue: boolean;
|
|
91
|
+
} : Input["options"][T_2]["type"] extends "boolean" ? {
|
|
92
|
+
kind: "option";
|
|
93
|
+
index: number;
|
|
94
|
+
name: T_2 & string;
|
|
95
|
+
rawName: string;
|
|
96
|
+
value: undefined;
|
|
97
|
+
inlineValue: undefined;
|
|
98
|
+
} : ({
|
|
99
|
+
kind: "option";
|
|
100
|
+
index: number;
|
|
101
|
+
name: string;
|
|
102
|
+
rawName: string;
|
|
103
|
+
value: string;
|
|
104
|
+
inlineValue: boolean;
|
|
105
|
+
} | {
|
|
106
|
+
kind: "option";
|
|
107
|
+
index: number;
|
|
108
|
+
name: string;
|
|
109
|
+
rawName: string;
|
|
110
|
+
value: undefined;
|
|
111
|
+
inlineValue: undefined;
|
|
112
|
+
}) & {
|
|
113
|
+
name: T_2 & string;
|
|
114
|
+
} : {
|
|
115
|
+
kind: "option";
|
|
116
|
+
index: number;
|
|
117
|
+
name: string;
|
|
118
|
+
rawName: string;
|
|
119
|
+
value: string;
|
|
120
|
+
inlineValue: boolean;
|
|
121
|
+
} | {
|
|
122
|
+
kind: "option";
|
|
123
|
+
index: number;
|
|
124
|
+
name: string;
|
|
125
|
+
rawName: string;
|
|
126
|
+
value: undefined;
|
|
127
|
+
inlineValue: undefined;
|
|
128
|
+
} : never : never : never))[];
|
|
129
|
+
};
|
|
60
130
|
/** The choices a positional accepts; positionals without choices contribute never. */
|
|
61
131
|
type PositionalChoices<Positional> = Positional extends {
|
|
62
132
|
value: {
|
|
@@ -92,10 +162,9 @@ export declare function shellQuote(word: string): string;
|
|
|
92
162
|
/** A command line to show, with each word quoted for the shell as needed. */
|
|
93
163
|
export declare function formatCommand(args: Array<string>): string;
|
|
94
164
|
/** The words of the command a user likely meant by a flag the command does not take, if known. */
|
|
95
|
-
type SuggestFor = (flag: string) => {
|
|
96
|
-
args: Array<string>;
|
|
165
|
+
type SuggestFor = (flag: string) => (FlagCorrection & {
|
|
97
166
|
route: Array<string>;
|
|
98
|
-
} | undefined;
|
|
167
|
+
}) | undefined;
|
|
99
168
|
/** Renames an option without changing values or words after `--` */
|
|
100
169
|
export declare function renameFlag(args: Array<string>, options: ParseArgsOptionsConfig, source: string, target: string): string[];
|
|
101
170
|
export declare function isParseArgsError(error: any): boolean;
|
|
@@ -104,5 +173,5 @@ export declare function isParseArgsError(error: any): boolean;
|
|
|
104
173
|
* parseArgs names the flag only in its message text, which Node and Bun word the same.
|
|
105
174
|
* `null` for any other error.
|
|
106
175
|
*/
|
|
107
|
-
export declare function parseArgsFailure(error: any, args: Array<string>, suggestFor: SuggestFor, route: Array<string
|
|
176
|
+
export declare function parseArgsFailure(error: any, args: Array<string>, suggestFor: SuggestFor, route: Array<string>, options: ParseArgsOptionsConfig): CliError | null;
|
|
108
177
|
export {};
|