@zinn-dev/cli 0.40.0 → 0.41.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 (60) hide show
  1. package/README.md +166 -38
  2. package/index.js +24 -13
  3. package/package.json +7 -2
  4. package/skills/zinn/SKILL.md +63 -0
  5. package/src/actor.d.ts +2 -1
  6. package/src/actor.js +78 -11
  7. package/src/capabilities-schema.d.ts +163 -0
  8. package/src/capabilities-schema.js +124 -0
  9. package/src/capabilities.d.ts +21 -0
  10. package/src/capabilities.js +22 -0
  11. package/src/database.d.ts +1 -1
  12. package/src/database.js +4 -4
  13. package/src/errors.d.ts +158 -0
  14. package/src/errors.js +224 -0
  15. package/src/input.d.ts +116 -0
  16. package/src/input.js +119 -0
  17. package/src/lib.d.ts +42 -7
  18. package/src/lib.js +213 -17
  19. package/src/presentation/activity-presentation.js +16 -2
  20. package/src/presentation/column-presentation.d.ts +3 -5
  21. package/src/presentation/info-presentation.d.ts +4 -0
  22. package/src/presentation/info-presentation.js +96 -0
  23. package/src/presentation/task-presentation.d.ts +2 -10
  24. package/src/project.d.ts +6 -0
  25. package/src/project.js +23 -10
  26. package/src/result-schemas.d.ts +987 -0
  27. package/src/result-schemas.js +220 -0
  28. package/src/results.d.ts +23 -0
  29. package/src/results.js +17 -0
  30. package/src/routes/activity-router.d.ts +71 -0
  31. package/src/routes/activity-router.js +59 -11
  32. package/src/routes/backup-router.d.ts +17 -0
  33. package/src/routes/backup-router.js +15 -3
  34. package/src/routes/capabilities-router.d.ts +21 -0
  35. package/src/routes/capabilities-router.js +28 -0
  36. package/src/routes/comment-router.d.ts +183 -4
  37. package/src/routes/comment-router.js +136 -29
  38. package/src/routes/info-router.d.ts +21 -0
  39. package/src/routes/info-router.js +29 -0
  40. package/src/routes/label-router.d.ts +165 -0
  41. package/src/routes/label-router.js +111 -29
  42. package/src/routes/migrate-router.d.ts +17 -0
  43. package/src/routes/migrate-router.js +17 -5
  44. package/src/routes/project-router.d.ts +349 -0
  45. package/src/routes/project-router.js +278 -92
  46. package/src/routes/reindex-router.d.ts +17 -0
  47. package/src/routes/reindex-router.js +15 -3
  48. package/src/routes/relation-router.d.ts +108 -12
  49. package/src/routes/relation-router.js +74 -14
  50. package/src/routes/restore-router.d.ts +29 -0
  51. package/src/routes/restore-router.js +30 -13
  52. package/src/routes/router.d.ts +1 -1
  53. package/src/routes/router.js +44 -25
  54. package/src/routes/routes.d.ts +1565 -0
  55. package/src/routes/routes.js +5 -1
  56. package/src/routes/task-router.d.ts +861 -0
  57. package/src/routes/task-router.js +419 -163
  58. package/src/text-edit.d.ts +20 -2
  59. package/src/text-edit.js +22 -10
  60. package/src/types.d.ts +14 -0
@@ -0,0 +1,220 @@
1
+ import { z } from "zod";
2
+ import { activityActionSchema, activityEntityTypeSchema, actorKindSchema, infoDatabaseStateSchema, labelColorSchema, relationTypeSchema, settingsFileSourceSchema, settingsFileStateSchema, settingsSchema, storageSourceSchema, taskPrioritySchema, } from "@zinn-dev/core";
3
+ import { errorDocumentSchema } from "./errors.js";
4
+ import { capabilitiesSchema, jsonValueSchema } from "./capabilities-schema.js";
5
+ const nullableText = z.string().nullable();
6
+ const count = z.number().int().nonnegative();
7
+ const timestamp = z.number().int().describe("Milliseconds since the Unix epoch.");
8
+ const taskStatus = z.enum(["Active", "Archived"]);
9
+ export const taskSchema = z.strictObject({
10
+ key: z.string().describe("Readable project key and task number."),
11
+ status: taskStatus,
12
+ column: z.string().describe("Current column name."),
13
+ title: z.string(),
14
+ description: nullableText,
15
+ priority: z
16
+ .string()
17
+ .nullable()
18
+ .describe(`Known priorities: ${taskPrioritySchema.options.join(", ")}. Other stored values may occur.`),
19
+ labels: z.array(z.string()).describe("Attached label names."),
20
+ });
21
+ export const relationSchema = z.strictObject({
22
+ type: z
23
+ .string()
24
+ .describe(`Known relation types: ${relationTypeSchema.options.join(", ")}. Other stored values may occur.`),
25
+ direction: z
26
+ .enum(["outgoing", "incoming"])
27
+ .nullable()
28
+ .describe("Direction relative to the viewed task; null for a symmetric relation."),
29
+ task: taskSchema.pick({ key: true, column: true, title: true, status: true }),
30
+ });
31
+ export const relationChangeSchema = z.strictObject({
32
+ type: relationSchema.shape.type,
33
+ source: z.string().describe("Source task key, in the supplied direction."),
34
+ target: z.string().describe("Target task key, in the supplied direction."),
35
+ });
36
+ export const commentSchema = z.strictObject({
37
+ key: z.string().describe("Readable task key and comment number."),
38
+ text: z.string(),
39
+ created_at: timestamp,
40
+ updated_at: timestamp,
41
+ });
42
+ export const activitySchema = z.strictObject({
43
+ id: z.string().describe("Full activity event ID."),
44
+ created_at: timestamp,
45
+ actor_name: nullableText,
46
+ actor_email: nullableText,
47
+ actor_kind: z
48
+ .string()
49
+ .describe(`Known actor kinds: ${actorKindSchema.options.join(", ")}. Other stored values may occur.`),
50
+ actor_source: nullableText,
51
+ actor_session_id: nullableText,
52
+ actor_thread_id: nullableText,
53
+ actor_agent: nullableText,
54
+ actor_model: nullableText,
55
+ actor_effort: nullableText,
56
+ entity_type: z
57
+ .string()
58
+ .describe(`Known entity types: ${activityEntityTypeSchema.options.join(", ")}. Other stored values may occur.`),
59
+ entity_id: z.string().describe("Stored ID of the affected entity."),
60
+ action: z
61
+ .string()
62
+ .describe(`Known actions: ${activityActionSchema.options.join(", ")}. Other stored values may occur.`),
63
+ changes: z
64
+ .looseObject({})
65
+ .nullable()
66
+ .describe("Raw recorded JSON object, including unknown fields; null when no payload was recorded."),
67
+ });
68
+ export const taskDetailSchema = taskSchema.extend({
69
+ relations: z.array(relationSchema),
70
+ comments: z.array(commentSchema),
71
+ });
72
+ export const taskDetailHistorySchema = taskDetailSchema.extend({
73
+ activity: z
74
+ .array(activitySchema)
75
+ .describe("Recorded activity, newest first; present even when empty."),
76
+ });
77
+ export const taskChangeSchema = taskSchema.extend({
78
+ changed: z.boolean().describe("Whether this key occurrence changed the task's state."),
79
+ });
80
+ export const projectSchema = z.strictObject({
81
+ key: z.string(),
82
+ name: z.string(),
83
+ description: nullableText,
84
+ });
85
+ export const columnSchema = z.strictObject({ project: z.string(), name: z.string() });
86
+ export const columnTaskCountSchema = z.strictObject({ name: z.string(), taskCount: count });
87
+ export const projectViewSchema = projectSchema.extend({
88
+ columns: z.array(columnTaskCountSchema),
89
+ archivedTaskCount: count,
90
+ });
91
+ export const labelSchema = z.strictObject({
92
+ name: z.string(),
93
+ color: z
94
+ .string()
95
+ .describe(`Known label colors: ${labelColorSchema.options.join(", ")}. Other stored values may occur.`),
96
+ description: nullableText,
97
+ });
98
+ const settingsFileBase = z.strictObject({
99
+ path: z.string(),
100
+ source: settingsFileSourceSchema,
101
+ });
102
+ export const settingsFileSchema = z.discriminatedUnion("state", [
103
+ settingsFileBase.extend({
104
+ state: settingsFileStateSchema.extract(["found"]),
105
+ settings: settingsSchema,
106
+ }),
107
+ settingsFileBase.extend({ state: settingsFileStateSchema.extract(["missing"]) }),
108
+ settingsFileBase.extend({ state: settingsFileStateSchema.extract(["error"]), error: z.string() }),
109
+ settingsFileBase.extend({
110
+ state: settingsFileStateSchema.extract(["not-read"]),
111
+ reason: z.literal("ZINN_DIR"),
112
+ }),
113
+ ]);
114
+ export const infoSchema = z.strictObject({
115
+ settingsFiles: z.array(settingsFileSchema),
116
+ storage: z.strictObject({
117
+ directory: nullableText,
118
+ source: storageSourceSchema.nullable(),
119
+ settingsPath: nullableText,
120
+ exists: z.boolean().nullable(),
121
+ error: nullableText,
122
+ }),
123
+ defaultProject: z.strictObject({
124
+ key: nullableText,
125
+ settingsPath: nullableText,
126
+ error: nullableText,
127
+ }),
128
+ database: z.strictObject({
129
+ path: nullableText,
130
+ state: infoDatabaseStateSchema,
131
+ version: count.nullable(),
132
+ latestVersion: count,
133
+ error: nullableText,
134
+ }),
135
+ versions: z.strictObject({
136
+ cli: z.string(),
137
+ core: z.string(),
138
+ runtime: z.strictObject({ name: z.enum(["Node", "Bun"]), version: z.string() }),
139
+ }),
140
+ });
141
+ export const backupSchema = z.strictObject({ path: z.string() });
142
+ export const restoreSchema = z.strictObject({
143
+ databasePath: z.string(),
144
+ previousVersion: count.describe("Destination schema version before restore; zero when the destination had no schema version. backupPath says whether it was replaced."),
145
+ restoredVersion: count,
146
+ backupPath: nullableText.describe("Snapshot of the replaced database, or null when none was needed."),
147
+ });
148
+ export const migrateSchema = z.strictObject({
149
+ databasePath: z.string(),
150
+ previousVersion: count,
151
+ finalVersion: count,
152
+ changed: z.boolean(),
153
+ backupPath: nullableText.describe("Snapshot taken before migration; null on a no-op."),
154
+ });
155
+ export const reindexSchema = z.strictObject({ databasePath: z.string(), taskCount: count });
156
+ export const resultSchemas = {
157
+ Task: taskSchema,
158
+ TaskList: z.array(taskSchema),
159
+ TaskDetail: taskDetailSchema,
160
+ TaskDetailHistory: taskDetailHistorySchema,
161
+ TaskChange: taskChangeSchema,
162
+ TaskChanges: z.array(taskChangeSchema).min(2),
163
+ Relation: relationSchema,
164
+ RelationList: z.array(relationSchema),
165
+ RelationChange: relationChangeSchema,
166
+ Comment: commentSchema,
167
+ CommentList: z.array(commentSchema),
168
+ Project: projectSchema,
169
+ ProjectList: z.array(projectSchema),
170
+ ProjectView: projectViewSchema,
171
+ Column: columnSchema,
172
+ ColumnTaskCount: columnTaskCountSchema,
173
+ ColumnList: z.array(columnTaskCountSchema),
174
+ Label: labelSchema,
175
+ LabelList: z.array(labelSchema),
176
+ Activity: activitySchema,
177
+ ActivityList: z.array(activitySchema),
178
+ Info: infoSchema,
179
+ Backup: backupSchema,
180
+ Restore: restoreSchema,
181
+ Migrate: migrateSchema,
182
+ Reindex: reindexSchema,
183
+ ErrorEnvelope: errorDocumentSchema,
184
+ Capabilities: capabilitiesSchema,
185
+ JsonValue: jsonValueSchema,
186
+ };
187
+ /** Generates local references against the extracted schemas document in draft-07 spec */
188
+ export function generateResultSchemas(schemas = resultSchemas) {
189
+ const schemaVersion = "draft-07";
190
+ const registry = z.registry();
191
+ for (const [id, schema] of Object.entries(schemas)) {
192
+ registry.add(schema, { id });
193
+ }
194
+ const generated = z.toJSONSchema(registry, {
195
+ target: schemaVersion,
196
+ unrepresentable: "throw",
197
+ uri: (id) => `#/definitions/${id.replaceAll("~", "~0").replaceAll("/", "~1")}`,
198
+ });
199
+ function rebaseReferences(value) {
200
+ if (value === null || typeof value !== "object") {
201
+ return;
202
+ }
203
+ for (const [key, child] of Object.entries(value)) {
204
+ if (key === "$ref" && typeof child === "string") {
205
+ // Zod's shared document fragment becomes a path inside the embedded definition.
206
+ value[key] = child.replace(/^(#\/definitions\/[^#]+)#\//, "$1/");
207
+ }
208
+ else {
209
+ rebaseReferences(child);
210
+ }
211
+ }
212
+ }
213
+ rebaseReferences(generated.schemas);
214
+ const definitions = Object.fromEntries(Object.entries(generated.schemas).map(([name, schema]) => {
215
+ // Embedded definitions share their document's base URI.
216
+ const { $id, $schema, ...definition } = schema;
217
+ return [name, definition];
218
+ }));
219
+ return { $schema: `http://json-schema.org/${schemaVersion}/schema#`, definitions };
220
+ }
@@ -0,0 +1,23 @@
1
+ import type { ResultSchemaName } from "./result-schemas.js";
2
+ export type ResultSelector = {
3
+ kind: "always";
4
+ } | {
5
+ kind: "booleanOption";
6
+ name: string;
7
+ value: boolean;
8
+ } | {
9
+ kind: "positionalCount";
10
+ name: string;
11
+ min: number;
12
+ max: number | null;
13
+ };
14
+ export type CommandResult = {
15
+ selector: ResultSelector;
16
+ schemaRef: `#/schemas/definitions/${ResultSchemaName}`;
17
+ mode: "json";
18
+ stream: "stdout";
19
+ exitCode: 0;
20
+ };
21
+ export declare function jsonResult(schema: ResultSchemaName, selector?: ResultSelector): CommandResult;
22
+ export declare const taskDetailResults: CommandResult[];
23
+ export declare const taskChangeResults: CommandResult[];
package/src/results.js ADDED
@@ -0,0 +1,17 @@
1
+ export function jsonResult(schema, selector = { kind: "always" }) {
2
+ return {
3
+ selector,
4
+ schemaRef: `#/schemas/definitions/${schema}`,
5
+ mode: "json",
6
+ stream: "stdout",
7
+ exitCode: 0,
8
+ };
9
+ }
10
+ export const taskDetailResults = [
11
+ jsonResult("TaskDetail", { kind: "booleanOption", name: "history", value: false }),
12
+ jsonResult("TaskDetailHistory", { kind: "booleanOption", name: "history", value: true }),
13
+ ];
14
+ export const taskChangeResults = [
15
+ jsonResult("TaskChange", { kind: "positionalCount", name: "task-key", min: 1, max: 1 }),
16
+ jsonResult("TaskChanges", { kind: "positionalCount", name: "task-key", min: 2, max: null }),
17
+ ];
@@ -1,9 +1,80 @@
1
1
  export declare const activityRouter: {
2
2
  list: {
3
+ summary: string;
4
+ effects: {
5
+ domain: "read";
6
+ storage: "normal-open";
7
+ };
8
+ confirmation: {
9
+ kind: "none";
10
+ };
11
+ input: {
12
+ readonly options: {
13
+ readonly task: {
14
+ readonly type: "string";
15
+ readonly value: {
16
+ readonly kind: "task-key";
17
+ readonly name: "task-key";
18
+ };
19
+ };
20
+ readonly session: {
21
+ readonly type: "string";
22
+ readonly value: {
23
+ readonly kind: "text";
24
+ readonly name: "id";
25
+ };
26
+ };
27
+ readonly thread: {
28
+ readonly type: "string";
29
+ readonly value: {
30
+ readonly kind: "text";
31
+ readonly name: "id";
32
+ };
33
+ };
34
+ readonly limit: {
35
+ readonly type: "string";
36
+ readonly value: {
37
+ readonly kind: "positive-integer";
38
+ readonly name: "n";
39
+ readonly pattern: "^[1-9]\\d{0,14}\\d?$";
40
+ };
41
+ };
42
+ };
43
+ readonly forms: readonly [{
44
+ readonly id: "default";
45
+ readonly positionals: readonly [];
46
+ }];
47
+ readonly constraints: readonly [];
48
+ };
49
+ results: import("../results.js").CommandResult[];
3
50
  run: (args: string[]) => void;
4
51
  help: string;
5
52
  };
6
53
  view: {
54
+ summary: string;
55
+ effects: {
56
+ domain: "read";
57
+ storage: "normal-open";
58
+ };
59
+ confirmation: {
60
+ kind: "none";
61
+ };
62
+ input: {
63
+ readonly options: {};
64
+ readonly forms: readonly [{
65
+ readonly id: "default";
66
+ readonly positionals: readonly [{
67
+ readonly name: "activity-id";
68
+ readonly min: 1;
69
+ readonly max: 1;
70
+ readonly value: {
71
+ readonly kind: "activity-id";
72
+ };
73
+ }];
74
+ }];
75
+ readonly constraints: readonly [];
76
+ };
77
+ results: import("../results.js").CommandResult[];
7
78
  run: (args: string[]) => void;
8
79
  help: string;
9
80
  };
@@ -1,31 +1,65 @@
1
+ import { jsonResult } from "../results.js";
1
2
  import { parseArgs } from "node:util";
2
3
  import { activity, activityLimitMessage, positiveIntegerPattern } from "@zinn-dev/core";
4
+ import { generateCommandUsage } from "../input.js";
3
5
  import { output, quit, validatePositionals, validateUniqueOptions } from "../lib.js";
4
6
  import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
7
+ const activityInputs = {
8
+ list: {
9
+ options: {
10
+ task: { type: "string", value: { kind: "task-key", name: "task-key" } },
11
+ session: { type: "string", value: { kind: "text", name: "id" } },
12
+ thread: { type: "string", value: { kind: "text", name: "id" } },
13
+ limit: {
14
+ type: "string",
15
+ value: { kind: "positive-integer", name: "n", pattern: `^${positiveIntegerPattern}\\d?$` },
16
+ },
17
+ },
18
+ forms: [{ id: "default", positionals: [] }],
19
+ constraints: [],
20
+ },
21
+ view: {
22
+ options: {},
23
+ forms: [
24
+ {
25
+ id: "default",
26
+ positionals: [{ name: "activity-id", min: 1, max: 1, value: { kind: "activity-id" } }],
27
+ },
28
+ ],
29
+ constraints: [],
30
+ },
31
+ };
5
32
  export const activityRouter = {
6
33
  list: {
34
+ summary: "List recorded activity across the database, newest first.",
35
+ effects: { domain: "read", storage: "normal-open" },
36
+ confirmation: { kind: "none" },
37
+ input: activityInputs.list,
38
+ results: [jsonResult("ActivityList")],
7
39
  run: (args) => {
8
40
  const { values, positionals, tokens } = parseArgs({
9
41
  args,
10
- options: { task: { type: "string" }, limit: { type: "string" } },
42
+ options: activityInputs.list.options,
11
43
  allowPositionals: true,
12
44
  strict: true,
13
45
  tokens: true,
14
46
  });
15
- validateUniqueOptions(tokens);
16
- validatePositionals(positionals, []);
47
+ validateUniqueOptions(tokens, activityInputs.list.options);
48
+ validatePositionals(positionals, activityInputs.list.forms[0]);
17
49
  // Safe integers can have one more digit than readable task numbers.
18
- const limitPattern = new RegExp(`^${positiveIntegerPattern}\\d?$`);
50
+ const limitPattern = new RegExp(activityInputs.list.options.limit.value.pattern);
19
51
  if (values.limit !== undefined && !limitPattern.test(values.limit)) {
20
- quit(activityLimitMessage);
52
+ quit(activityLimitMessage, undefined, { argument: "--limit" });
21
53
  }
22
54
  const events = activity.getAll({
23
55
  taskKey: values.task,
56
+ sessionId: values.session,
57
+ threadId: values.thread,
24
58
  limit: values.limit === undefined ? undefined : Number(values.limit),
25
59
  });
26
60
  output(events, (items) => formatActivityList(presentActivities(items, { taskKey: values.task })));
27
61
  },
28
- help: `Usage: zinn activity list [--task <task-key>] [--limit <n>] [--json]
62
+ help: `${generateCommandUsage("activity list", activityInputs.list)}
29
63
 
30
64
  List recorded activity across the database, newest first.
31
65
  By default, all matching events are returned. --limit takes a positive safe integer.
@@ -33,6 +67,8 @@ By default, all matching events are returned. --limit takes a positive safe inte
33
67
  including the recorded project deletion that removed a task.
34
68
  A key reused after project deletion includes every known lifetime.
35
69
  A valid key without recoverable history returns an empty list.
70
+ --session and --thread match the complete stored IDs exactly, including case.
71
+ All supplied filters must match; --limit applies afterwards.
36
72
 
37
73
  Text times are local dates/times with a UTC offset.
38
74
  Event IDs are the shortest globally unique left prefixes of at least eight hex digits.
@@ -44,17 +80,29 @@ A project deletion event's entity_id is the project ID and removed task IDs are
44
80
 
45
81
  Examples:
46
82
  zinn activity list --limit 10
47
- zinn activity list --task APP-2 --json`,
83
+ zinn activity list --task APP-2 --json
84
+ zinn activity list --session conversation-id --thread child-thread-id`,
48
85
  },
49
86
  view: {
87
+ summary: "Show one recorded event with full activity/entity IDs, actor and complete changes.",
88
+ effects: { domain: "read", storage: "normal-open" },
89
+ confirmation: { kind: "none" },
90
+ input: activityInputs.view,
91
+ results: [jsonResult("Activity")],
50
92
  run: (args) => {
51
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
52
- validatePositionals(positionals, ["<activity-id>"]);
53
- output(activity.getById(positionals[0]), (event) => formatActivityList(presentActivities([event], { showsFullIds: true }), {
93
+ const { positionals } = parseArgs({
94
+ options: activityInputs.view.options,
95
+ args,
96
+ allowPositionals: true,
97
+ strict: true,
98
+ });
99
+ validatePositionals(positionals, activityInputs.view.forms[0]);
100
+ const viewed = activity.getById(positionals[0]);
101
+ output(viewed, (event) => formatActivityList(presentActivities([event], { showsFullIds: true }), {
54
102
  showsDetails: true,
55
103
  }));
56
104
  },
57
- help: `Usage: zinn activity view <activity-id> [--json]
105
+ help: `${generateCommandUsage("activity view", activityInputs.view)}
58
106
 
59
107
  Show one recorded event with full activity/entity IDs, actor and complete changes.
60
108
  Text and line breaks are preserved; unknown change fields remain available as raw JSON.
@@ -1,4 +1,21 @@
1
1
  export declare const backupCommand: {
2
+ summary: string;
3
+ effects: {
4
+ domain: "none";
5
+ storage: "backup";
6
+ };
7
+ confirmation: {
8
+ kind: "none";
9
+ };
10
+ input: {
11
+ readonly options: {};
12
+ readonly forms: readonly [{
13
+ readonly id: "default";
14
+ readonly positionals: readonly [];
15
+ }];
16
+ readonly constraints: readonly [];
17
+ };
18
+ results: import("../results.js").CommandResult[];
2
19
  run: (args: string[]) => void;
3
20
  help: string;
4
21
  };
@@ -1,15 +1,27 @@
1
+ import { jsonResult } from "../results.js";
1
2
  import { parseArgs } from "node:util";
2
3
  import { backup } from "@zinn-dev/core";
4
+ import { generateCommandUsage, noInput } from "../input.js";
3
5
  import { output, validatePositionals } from "../lib.js";
4
6
  import packageJson from "../../package.json" with { type: "json" };
5
7
  export const backupCommand = {
8
+ summary: "Save a copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.",
9
+ effects: { domain: "none", storage: "backup" },
10
+ confirmation: { kind: "none" },
11
+ input: noInput,
12
+ results: [jsonResult("Backup")],
6
13
  run: (args) => {
7
- const { positionals } = parseArgs({ args, strict: true, allowPositionals: true });
8
- validatePositionals(positionals, []);
14
+ const { positionals } = parseArgs({
15
+ options: noInput.options,
16
+ args,
17
+ strict: true,
18
+ allowPositionals: true,
19
+ });
20
+ validatePositionals(positionals, noInput.forms[0]);
9
21
  const created = backup.create({ client: "cli", version: packageJson.version });
10
22
  output(created, (b) => `Saved a backup to ${b.path}`);
11
23
  },
12
- help: `Usage: zinn backup
24
+ help: `${generateCommandUsage("backup", noInput)}
13
25
 
14
26
  Save a copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.
15
27
 
@@ -0,0 +1,21 @@
1
+ export declare const capabilitiesCommand: {
2
+ summary: string;
3
+ effects: {
4
+ domain: "none";
5
+ storage: "none";
6
+ };
7
+ confirmation: {
8
+ kind: "none";
9
+ };
10
+ input: {
11
+ readonly options: {};
12
+ readonly forms: readonly [{
13
+ readonly id: "default";
14
+ readonly positionals: readonly [];
15
+ }];
16
+ readonly constraints: readonly [];
17
+ };
18
+ results: import("../results.js").CommandResult[];
19
+ run: (args: string[]) => Promise<void>;
20
+ help: string;
21
+ };
@@ -0,0 +1,28 @@
1
+ import { parseArgs } from "node:util";
2
+ import { generateCommandUsage, noInput } from "../input.js";
3
+ import { output, validatePositionals } from "../lib.js";
4
+ import { jsonResult } from "../results.js";
5
+ export const capabilitiesCommand = {
6
+ summary: "Describe the installed CLI commands, inputs, results and errors.",
7
+ effects: { domain: "none", storage: "none" },
8
+ confirmation: { kind: "none" },
9
+ input: noInput,
10
+ results: [jsonResult("Capabilities")],
11
+ run: async (args) => {
12
+ const { positionals } = parseArgs({
13
+ options: noInput.options,
14
+ args,
15
+ strict: true,
16
+ allowPositionals: true,
17
+ });
18
+ validatePositionals(positionals, noInput.forms[0]);
19
+ const { generateCapabilities } = await import("../capabilities.js");
20
+ output(generateCapabilities(), (manifest) => `${manifest.cli.name} ${manifest.cli.version} (Experimental): ${manifest.commands.length} commands, manifest format ${manifest.manifestVersion}.\nRun zinn capabilities --json for the full contract.`);
21
+ },
22
+ help: `${generateCommandUsage("capabilities", noInput)}
23
+
24
+ Describe the installed CLI commands, inputs, results and errors.
25
+
26
+ Experimental. Use --json for the full contract, including reusable JSON Schemas.
27
+ Discovery works without reading settings or opening storage.`,
28
+ };