@zinn-dev/cli 0.40.0 → 0.42.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 (84) hide show
  1. package/README.md +11 -561
  2. package/index.js +24 -13
  3. package/package.json +8 -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 +162 -0
  8. package/src/capabilities-schema.js +59 -0
  9. package/src/capabilities.d.ts +29 -0
  10. package/src/capabilities.js +30 -0
  11. package/src/column-hint.d.ts +3 -0
  12. package/src/column-hint.js +225 -0
  13. package/src/database.d.ts +1 -1
  14. package/src/database.js +5 -8
  15. package/src/errors.d.ts +158 -0
  16. package/src/errors.js +226 -0
  17. package/src/input.d.ts +227 -0
  18. package/src/input.js +192 -0
  19. package/src/lib.d.ts +71 -8
  20. package/src/lib.js +275 -18
  21. package/src/presentation/activity-presentation.d.ts +9 -1
  22. package/src/presentation/activity-presentation.js +120 -23
  23. package/src/presentation/capabilities-presentation.d.ts +2 -0
  24. package/src/presentation/capabilities-presentation.js +3 -0
  25. package/src/presentation/column-presentation.d.ts +9 -5
  26. package/src/presentation/column-presentation.js +10 -0
  27. package/src/presentation/comment-presentation.d.ts +15 -0
  28. package/src/presentation/comment-presentation.js +29 -0
  29. package/src/presentation/description-presentation.d.ts +17 -0
  30. package/src/presentation/description-presentation.js +26 -4
  31. package/src/presentation/info-presentation.d.ts +4 -0
  32. package/src/presentation/info-presentation.js +96 -0
  33. package/src/presentation/label-presentation.d.ts +8 -0
  34. package/src/presentation/label-presentation.js +28 -0
  35. package/src/presentation/project-presentation.d.ts +7 -0
  36. package/src/presentation/project-presentation.js +19 -0
  37. package/src/presentation/relation-presentation.d.ts +7 -0
  38. package/src/presentation/relation-presentation.js +73 -0
  39. package/src/presentation/task-presentation.d.ts +4 -12
  40. package/src/presentation/task-presentation.js +22 -18
  41. package/src/project.d.ts +18 -3
  42. package/src/project.js +37 -12
  43. package/src/result-schemas.d.ts +1194 -0
  44. package/src/result-schemas.js +279 -0
  45. package/src/results.d.ts +40 -0
  46. package/src/results.js +36 -0
  47. package/src/routes/activity-router.d.ts +104 -0
  48. package/src/routes/activity-router.js +155 -34
  49. package/src/routes/aliases.d.ts +2 -0
  50. package/src/routes/aliases.js +11 -0
  51. package/src/routes/backup-router.d.ts +17 -0
  52. package/src/routes/backup-router.js +15 -3
  53. package/src/routes/capabilities-router.d.ts +21 -0
  54. package/src/routes/capabilities-router.js +34 -0
  55. package/src/routes/comment-router.d.ts +210 -8
  56. package/src/routes/comment-router.js +189 -65
  57. package/src/routes/info-router.d.ts +21 -0
  58. package/src/routes/info-router.js +29 -0
  59. package/src/routes/label-router.d.ts +217 -2
  60. package/src/routes/label-router.js +189 -62
  61. package/src/routes/migrate-router.d.ts +17 -0
  62. package/src/routes/migrate-router.js +17 -5
  63. package/src/routes/project-router.d.ts +373 -2
  64. package/src/routes/project-router.js +322 -132
  65. package/src/routes/reindex-router.d.ts +17 -0
  66. package/src/routes/reindex-router.js +15 -3
  67. package/src/routes/relation-router.d.ts +110 -14
  68. package/src/routes/relation-router.js +122 -79
  69. package/src/routes/restore-router.d.ts +29 -0
  70. package/src/routes/restore-router.js +31 -14
  71. package/src/routes/router.d.ts +1 -1
  72. package/src/routes/router.js +80 -32
  73. package/src/routes/routes.d.ts +1781 -8
  74. package/src/routes/routes.js +9 -1
  75. package/src/routes/task-router.d.ts +946 -4
  76. package/src/routes/task-router.js +524 -260
  77. package/src/routes/whoami-router.d.ts +21 -0
  78. package/src/routes/whoami-router.js +31 -0
  79. package/src/text-edit.d.ts +28 -6
  80. package/src/text-edit.js +40 -23
  81. package/src/text-input.d.ts +47 -0
  82. package/src/text-input.js +187 -0
  83. package/src/types.d.ts +37 -0
  84. package/src/types.js +9 -1
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: zinn
3
+ description: >-
4
+ Work a Zinn project board alongside coding work. Use before substantial work,
5
+ when resuming work, when recording follow-up tasks, and when finishing a
6
+ reviewable handoff, where the user or repository uses Zinn: the user requests
7
+ it, repository instructions mention it, zinn.local.json exists, or a Zinn task
8
+ key is referenced.
9
+ metadata:
10
+ zinn-cli-reviewed-version: "0.42.0"
11
+ ---
12
+
13
+ # Work with a Zinn board
14
+
15
+ Use the user's existing project and workflow. Repository and user instructions determine what work is authorized. Tracking a task does not authorize implementation, commits, publication, or unrelated changes.
16
+
17
+ ## Find the work
18
+
19
+ 1. Before substantial work, resolve the project. Use `zinn info --json` for the configured default project and selected database. If the project remains unidentified, use the user or repository's project setting and `zinn project list --json` to identify it. Ask when the project is ambiguous; do not create a project just to proceed. Result: one identified project in the intended store.
20
+ 2. Read an explicitly referenced task with `zinn task view <task-key> --json`. Otherwise inspect the project's tasks and find an existing task matching the requested work, then fetch it with `zinn task view <task-key> --json` before changing it. A list or search result does not include the task's comments and relations. Read the full task even when its title and description already match. On resuming, refresh that task instead of creating another. If substantial authorized work has no task, create one describing its scope and completion criteria. Result: a matching task with its description, comments, and relations read.
21
+ 3. Read the project's columns with `zinn project column list <project-key> --json`. Follow the project's workflow rather than assuming default column names. Check the task's current column before taking it: another agent may already be working on it. Move it to the working column before the first implementation edit. Ask when the workflow or ownership is unclear. Result: the task is visibly in progress before implementation begins.
22
+
23
+ ## Keep context useful
24
+
25
+ Record meaningful progress, decisions, verification results, and blockers in short task comments. On interrupted work, leave enough context for a later session to resume. Avoid a comment for every command or file read.
26
+
27
+ These field roles are recommendations the user may adopt:
28
+
29
+ - Description: the current specification, updated when requirements change.
30
+ - Comments: short dated updates containing outcomes, decisions and who made them, measurements, open items, and references. Put bulky evidence in a linked document or PR.
31
+ - Columns, relations, and labels: status and structure, rather than repeating that metadata in prose.
32
+
33
+ When follow-up work appears, search for an existing task before creating one. Record a new task's problem and scope, and link it to the current work. A dependency points from the task that needs something to the task it needs; use a related relation when neither must precede the other. Recording follow-up work does not authorize doing it now. Result: follow-up work has a task and a useful link.
34
+
35
+ ## Finish or hand off
36
+
37
+ When implementation and appropriate verification are complete, add a concise outcome comment with checks and any remaining limitations, move the task to the project's review column, and report its key with the reviewable result. Follow explicit user or repository completion rules when they differ. If work remains incomplete or blocked, record that state and the next step rather than moving it to review. Result: the board and final report agree about what is ready.
38
+
39
+ ## Use the installed CLI
40
+
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
+
43
+ If a command or option required by this skill is unavailable, or installed help or command results contradict these instructions, check both the CLI and this skill for drift. Do this once per session, and repeat only if either installation changes. Ordinary input, missing-item, permission, and database errors do not trigger this check.
44
+
45
+ Compare `zinn --version` with the latest published `@zinn-dev/cli` version in the npm registry, and compare the skill file loaded by this session with its installation source, respecting any pinned revision. The unpinned source is [Zinn's workflow skill](https://github.com/yethranayeh/zinn/blob/main/packages/cli/skills/zinn/SKILL.md). Use read-only metadata and file reads. A newer release or changed skill is evidence of a difference, not proof that it caused the problem. Report relevant differences or checks you could not complete. If the intended operation remains unclear, ask before proceeding. Update either installation only when authorized; after updating the skill, reload it or use a fresh session.
46
+
47
+ `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.
48
+
49
+ Checking and moving a task is not an atomic claim. Coordinate parallel work with the user or host; task coordination does not isolate a shared working tree.
50
+
51
+ For example, substitute the actual project, task, and observed column names:
52
+
53
+ ```sh
54
+ zinn --help
55
+ zinn info --json
56
+ zinn project list --json
57
+ zinn task list APP --json
58
+ zinn task view APP-1 --json
59
+ zinn project column list APP --json
60
+ zinn task move APP-1 'In Progress' --json
61
+ zinn task comment create APP-1 --text 'Implementation verified; ready for review.' --json
62
+ zinn task move APP-1 Review --json
63
+ ```
package/src/actor.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Actor } from "@zinn-dev/core";
2
2
  type Env = Record<string, string | undefined>;
3
- /** A marker without a fixed name records the variable's own value, e.g. `AI_AGENT=claude-code_2-1-280_agent`. */
3
+ /** Generic flags establish an unnamed agent only when no identifying marker follows. */
4
4
  export declare function detectAgent(env: Env): Actor | null;
5
+ export declare function resolveActor(env: Env): Actor;
5
6
  export declare function currentActor(): Actor;
6
7
  export {};
package/src/actor.js CHANGED
@@ -16,24 +16,78 @@ const AGENT_MARKERS = [
16
16
  { variables: ["COPILOT_AGENT_SESSION_ID"], name: "copilot" },
17
17
  { variables: ["CRUSH"], name: "crush" },
18
18
  ];
19
- /** A marker without a fixed name records the variable's own value, e.g. `AI_AGENT=claude-code_2-1-280_agent`. */
19
+ const SESSION_DECLARATIONS = [
20
+ { session: "ZINN_SESSION_ID", thread: "ZINN_THREAD_ID" },
21
+ { session: "CLAUDE_CODE_SESSION_ID", thread: null },
22
+ { session: "CODEX_SESSION_ID", thread: "CODEX_THREAD_ID" },
23
+ // OpenCode exports the executing session's ID, which is a subagent's own ID in its shell.
24
+ { session: null, thread: "OPENCODE_SESSION_ID" },
25
+ ];
26
+ function readDeclaration(env, variable) {
27
+ const value = variable === null ? undefined : env[variable]?.trim();
28
+ return value == null || value.length === 0 ? null : value;
29
+ }
30
+ function readExecutionIdentity(env) {
31
+ let sessionId = null;
32
+ let threadId = null;
33
+ for (const declaration of SESSION_DECLARATIONS) {
34
+ const declaredSession = readDeclaration(env, declaration.session);
35
+ const declaredThread = readDeclaration(env, declaration.thread);
36
+ const hasDeclaration = declaredSession !== null || declaredThread !== null;
37
+ if (hasDeclaration) {
38
+ sessionId = declaredSession;
39
+ threadId = declaredThread;
40
+ break;
41
+ }
42
+ }
43
+ return {
44
+ sessionId,
45
+ threadId,
46
+ agent: readDeclaration(env, "ZINN_AGENT"),
47
+ model: readDeclaration(env, "ZINN_MODEL"),
48
+ effort: readDeclaration(env, "ZINN_EFFORT"),
49
+ };
50
+ }
51
+ /** Generic flags establish an unnamed agent only when no identifying marker follows. */
20
52
  export function detectAgent(env) {
53
+ let flagSource = null;
21
54
  for (const marker of AGENT_MARKERS) {
22
55
  for (const variable of marker.variables) {
23
- const value = env[variable]?.trim();
24
- if (value == null || value.length === 0) {
56
+ const value = readDeclaration(env, variable);
57
+ if (value === null) {
58
+ continue;
59
+ }
60
+ const isGenericFlag = marker.name === null && /^(?:\d+|true|false|yes|no|on|off)$/i.test(value);
61
+ if (isGenericFlag) {
62
+ flagSource ??= `env:${variable}`;
25
63
  continue;
26
64
  }
27
- return { name: marker.name ?? value, email: null, kind: "agent" };
65
+ return {
66
+ name: marker.name ?? value,
67
+ email: null,
68
+ kind: "agent",
69
+ source: `env:${variable}`,
70
+ ...readExecutionIdentity(env),
71
+ };
28
72
  }
29
73
  }
74
+ if (flagSource !== null) {
75
+ return {
76
+ name: null,
77
+ email: null,
78
+ kind: "agent",
79
+ source: flagSource,
80
+ ...readExecutionIdentity(env),
81
+ };
82
+ }
30
83
  return null;
31
84
  }
32
- function readGitConfig(key) {
85
+ function readGitConfig(key, env) {
33
86
  try {
34
87
  const value = execFileSync("git", ["config", key], {
35
88
  encoding: "utf-8",
36
89
  stdio: ["ignore", "pipe", "ignore"],
90
+ env,
37
91
  }).trim();
38
92
  return value.length > 0 ? value : null;
39
93
  }
@@ -42,21 +96,34 @@ function readGitConfig(key) {
42
96
  return null;
43
97
  }
44
98
  }
45
- function resolveActor() {
46
- const agent = detectAgent(process.env);
99
+ export function resolveActor(env) {
100
+ const agent = detectAgent(env);
47
101
  if (agent != null) {
48
102
  return agent;
49
103
  }
50
- const gitName = readGitConfig("user.name");
104
+ const identity = readExecutionIdentity(env);
105
+ const gitName = readGitConfig("user.name", env);
51
106
  if (gitName != null) {
52
- return { name: gitName, email: readGitConfig("user.email"), kind: "human" };
107
+ return {
108
+ name: gitName,
109
+ email: readGitConfig("user.email", env),
110
+ kind: "human",
111
+ source: "git-config",
112
+ ...identity,
113
+ };
53
114
  }
54
- return { name: userInfo().username, email: null, kind: "human" };
115
+ return {
116
+ name: userInfo().username,
117
+ email: null,
118
+ kind: "human",
119
+ source: "os-user",
120
+ ...identity,
121
+ };
55
122
  }
56
123
  let actor = null;
57
124
  export function currentActor() {
58
125
  if (actor == null) {
59
- actor = resolveActor();
126
+ actor = resolveActor(process.env);
60
127
  }
61
128
  return actor;
62
129
  }
@@ -0,0 +1,162 @@
1
+ import { z } from "zod";
2
+ export declare const jsonValueSchema: z.ZodJSONSchema;
3
+ export declare const capabilitiesSchema: z.ZodObject<{
4
+ manifestVersion: z.ZodLiteral<1>;
5
+ cli: z.ZodObject<{
6
+ name: z.ZodString;
7
+ version: z.ZodString;
8
+ }, z.core.$strict>;
9
+ invocation: z.ZodObject<{
10
+ routerOptions: z.ZodRecord<z.ZodString, z.ZodObject<{
11
+ type: z.ZodEnum<{
12
+ string: "string";
13
+ boolean: "boolean";
14
+ }>;
15
+ short: z.ZodOptional<z.ZodString>;
16
+ multiple: z.ZodOptional<z.ZodBoolean>;
17
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
18
+ required: z.ZodOptional<z.ZodBoolean>;
19
+ value: z.ZodOptional<z.ZodObject<{
20
+ kind: z.ZodString;
21
+ name: z.ZodOptional<z.ZodString>;
22
+ choices: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
23
+ caseInsensitive: z.ZodOptional<z.ZodBoolean>;
24
+ pattern: z.ZodOptional<z.ZodString>;
25
+ description: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strict>>;
27
+ description: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strict>>;
29
+ routerOptionPlacement: z.ZodLiteral<"exact-tokens-anywhere-before-separator">;
30
+ optionSeparator: z.ZodLiteral<"--">;
31
+ literalOptionValue: z.ZodLiteral<"equals">;
32
+ singularOptions: z.ZodLiteral<"reject-repetition">;
33
+ jsonFailure: z.ZodLiteral<"one-stderr-document-with-buffered-diagnostics">;
34
+ jsonSuccessDiagnostics: z.ZodLiteral<"text-on-stderr-at-completion">;
35
+ canonicalArgv: z.ZodTuple<[z.ZodLiteral<"command-path">, z.ZodLiteral<"options-with-equals-values">, z.ZodLiteral<"--json">, z.ZodLiteral<"separator-if-positionals">, z.ZodLiteral<"positionals">], null>;
36
+ version: z.ZodObject<{
37
+ spellings: z.ZodArray<z.ZodString>;
38
+ placement: z.ZodLiteral<"sole-argument">;
39
+ stdout: z.ZodLiteral<"text">;
40
+ exitCode: z.ZodLiteral<0>;
41
+ }, z.core.$strict>;
42
+ help: z.ZodObject<{
43
+ spellings: z.ZodArray<z.ZodString>;
44
+ stdout: z.ZodLiteral<"text">;
45
+ exitCode: z.ZodLiteral<0>;
46
+ precedence: z.ZodLiteral<"root-first-token-otherwise-router-prefix-before-help">;
47
+ scansRouterOptionsFirst: z.ZodLiteral<true>;
48
+ }, z.core.$strict>;
49
+ }, z.core.$strict>;
50
+ commands: z.ZodArray<z.ZodObject<{
51
+ path: z.ZodArray<z.ZodString>;
52
+ aliases: z.ZodArray<z.ZodArray<z.ZodString>>;
53
+ summary: z.ZodString;
54
+ input: z.ZodObject<{
55
+ options: z.ZodRecord<z.ZodString, z.ZodObject<{
56
+ type: z.ZodEnum<{
57
+ string: "string";
58
+ boolean: "boolean";
59
+ }>;
60
+ short: z.ZodOptional<z.ZodString>;
61
+ multiple: z.ZodOptional<z.ZodBoolean>;
62
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>>;
63
+ required: z.ZodOptional<z.ZodBoolean>;
64
+ value: z.ZodOptional<z.ZodObject<{
65
+ kind: z.ZodString;
66
+ name: z.ZodOptional<z.ZodString>;
67
+ choices: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
68
+ caseInsensitive: z.ZodOptional<z.ZodBoolean>;
69
+ pattern: z.ZodOptional<z.ZodString>;
70
+ description: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strict>>;
72
+ description: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strict>>;
74
+ forms: z.ZodReadonly<z.ZodArray<z.ZodObject<{
75
+ id: z.ZodString;
76
+ positionals: z.ZodReadonly<z.ZodArray<z.ZodObject<{
77
+ name: z.ZodString;
78
+ min: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
79
+ max: z.ZodNullable<z.ZodLiteral<1>>;
80
+ value: z.ZodObject<{
81
+ kind: z.ZodString;
82
+ name: z.ZodOptional<z.ZodString>;
83
+ choices: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
84
+ caseInsensitive: z.ZodOptional<z.ZodBoolean>;
85
+ pattern: z.ZodOptional<z.ZodString>;
86
+ description: z.ZodOptional<z.ZodString>;
87
+ }, z.core.$strict>;
88
+ }, z.core.$strict>>>;
89
+ }, z.core.$strict>>>;
90
+ constraints: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
91
+ kind: z.ZodLiteral<"exclusive">;
92
+ members: z.ZodReadonly<z.ZodArray<z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>>>;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ kind: z.ZodLiteral<"requires">;
95
+ input: z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>;
96
+ requires: z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>;
97
+ }, z.core.$strict>, z.ZodObject<{
98
+ kind: z.ZodLiteral<"requiresAny">;
99
+ input: z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>;
100
+ members: z.ZodReadonly<z.ZodArray<z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>>>;
101
+ }, z.core.$strict>, z.ZodObject<{
102
+ kind: z.ZodLiteral<"atLeastOne">;
103
+ members: z.ZodReadonly<z.ZodArray<z.ZodTemplateLiteral<`option:${string}` | `positional:${string}`>>>;
104
+ }, z.core.$strict>], "kind">>>;
105
+ notes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
106
+ }, z.core.$strict>;
107
+ effects: z.ZodObject<{
108
+ domain: z.ZodEnum<{
109
+ read: "read";
110
+ create: "create";
111
+ update: "update";
112
+ delete: "delete";
113
+ replace: "replace";
114
+ none: "none";
115
+ }>;
116
+ storage: z.ZodEnum<{
117
+ backup: "backup";
118
+ none: "none";
119
+ "normal-open": "normal-open";
120
+ restore: "restore";
121
+ migrate: "migrate";
122
+ reindex: "reindex";
123
+ inspect: "inspect";
124
+ }>;
125
+ }, z.core.$strict>;
126
+ confirmation: z.ZodObject<{
127
+ kind: z.ZodEnum<{
128
+ prompt: "prompt";
129
+ none: "none";
130
+ "project-delete": "project-delete";
131
+ }>;
132
+ description: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strict>;
134
+ results: z.ZodReadonly<z.ZodArray<z.ZodObject<{
135
+ selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
136
+ kind: z.ZodLiteral<"always">;
137
+ }, z.core.$strict>, z.ZodObject<{
138
+ kind: z.ZodLiteral<"booleanOption">;
139
+ name: z.ZodString;
140
+ value: z.ZodBoolean;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ kind: z.ZodLiteral<"positionalCount">;
143
+ name: z.ZodString;
144
+ min: z.ZodNumber;
145
+ max: z.ZodNullable<z.ZodNumber>;
146
+ }, z.core.$strict>], "kind">;
147
+ schemaRef: z.ZodString;
148
+ mode: z.ZodLiteral<"json">;
149
+ stream: z.ZodLiteral<"stdout">;
150
+ exitCode: z.ZodLiteral<0>;
151
+ }, z.core.$strict>>>;
152
+ }, z.core.$strict>>;
153
+ error: z.ZodObject<{
154
+ schemaRef: z.ZodString;
155
+ exitCode: z.ZodLiteral<1>;
156
+ stream: z.ZodLiteral<"stderr">;
157
+ }, z.core.$strict>;
158
+ schemas: z.ZodObject<{
159
+ $schema: z.ZodLiteral<"http://json-schema.org/draft-07/schema#">;
160
+ definitions: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
161
+ }, z.core.$strict>;
162
+ }, z.core.$strict>;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { commandInputSchema, inputOptionsSchema, invocation } from "./input.js";
3
+ import { commandResultSchema, resultReferenceSchema } from "./results.js";
4
+ import { commandEffectsSchema, commandConfirmationSchema } from "./types.js";
5
+ export const jsonValueSchema = z.json();
6
+ export const capabilitiesSchema = z.strictObject({
7
+ manifestVersion: z.literal(1),
8
+ cli: z.strictObject({ name: z.string(), version: z.string() }),
9
+ invocation: z.strictObject({
10
+ routerOptions: inputOptionsSchema,
11
+ routerOptionPlacement: z.literal(invocation.routerOptionPlacement),
12
+ optionSeparator: z.literal(invocation.optionSeparator),
13
+ literalOptionValue: z.literal(invocation.literalOptionValue),
14
+ singularOptions: z.literal(invocation.singularOptions),
15
+ jsonFailure: z.literal(invocation.jsonFailure),
16
+ jsonSuccessDiagnostics: z.literal(invocation.jsonSuccessDiagnostics),
17
+ canonicalArgv: z.tuple([
18
+ z.literal(invocation.canonicalArgv[0]),
19
+ z.literal(invocation.canonicalArgv[1]),
20
+ z.literal(invocation.canonicalArgv[2]),
21
+ z.literal(invocation.canonicalArgv[3]),
22
+ z.literal(invocation.canonicalArgv[4]),
23
+ ]),
24
+ version: z.strictObject({
25
+ spellings: z.array(z.string()),
26
+ placement: z.literal(invocation.version.placement),
27
+ stdout: z.literal("text"),
28
+ exitCode: z.literal(0),
29
+ }),
30
+ help: z.strictObject({
31
+ spellings: z.array(z.string()),
32
+ stdout: z.literal("text"),
33
+ exitCode: z.literal(0),
34
+ precedence: z.literal(invocation.help.precedence),
35
+ scansRouterOptionsFirst: z.literal(true),
36
+ }),
37
+ }),
38
+ commands: z
39
+ .array(z.strictObject({
40
+ path: z.array(z.string()).min(1),
41
+ aliases: z.array(z.array(z.string()).min(1)),
42
+ summary: z.string(),
43
+ input: commandInputSchema,
44
+ effects: commandEffectsSchema,
45
+ confirmation: commandConfirmationSchema,
46
+ results: z.array(commandResultSchema).min(1).readonly(),
47
+ }))
48
+ .min(1),
49
+ error: z.strictObject({
50
+ schemaRef: resultReferenceSchema,
51
+ exitCode: z.literal(1),
52
+ stream: z.literal("stderr"),
53
+ }),
54
+ schemas: z.strictObject({
55
+ $schema: z.literal("http://json-schema.org/draft-07/schema#"),
56
+ // Schema documents contain JSON values rather than another manifest instance.
57
+ definitions: z.record(z.string(), z.record(z.string(), jsonValueSchema)),
58
+ }),
59
+ });
@@ -0,0 +1,29 @@
1
+ import type { ParsedRoute } from "./types.js";
2
+ import { invocation } from "./input.js";
3
+ import { generateResultSchemas } from "./result-schemas.js";
4
+ export type Capabilities = {
5
+ manifestVersion: 1;
6
+ cli: {
7
+ name: string;
8
+ version: string;
9
+ };
10
+ invocation: typeof invocation;
11
+ commands: Array<Pick<ParsedRoute, "aliases" | "summary" | "input" | "effects" | "confirmation" | "results"> & {
12
+ path: Array<string>;
13
+ }>;
14
+ error: {
15
+ schemaRef: "#/schemas/definitions/ErrorEnvelope";
16
+ exitCode: 1;
17
+ stream: "stderr";
18
+ };
19
+ schemas: ReturnType<typeof generateResultSchemas>;
20
+ };
21
+ export declare function getCapabilitySummary(): {
22
+ cli: {
23
+ name: string;
24
+ version: string;
25
+ };
26
+ commandCount: number;
27
+ manifestVersion: number;
28
+ };
29
+ export declare function generateCapabilities(): Capabilities;
@@ -0,0 +1,30 @@
1
+ import { invocation } from "./input.js";
2
+ import { generateResultSchemas } from "./result-schemas.js";
3
+ import { parsedRoutes } from "./routes/routes.js";
4
+ import packageJson from "../package.json" with { type: "json" };
5
+ export function getCapabilitySummary() {
6
+ return {
7
+ cli: { name: packageJson.name, version: packageJson.version },
8
+ commandCount: parsedRoutes.length,
9
+ manifestVersion: 1,
10
+ };
11
+ }
12
+ export function generateCapabilities() {
13
+ const { cli } = getCapabilitySummary();
14
+ return {
15
+ manifestVersion: 1,
16
+ cli,
17
+ invocation,
18
+ commands: parsedRoutes.map(({ command, aliases, summary, input, effects, confirmation, results }) => ({
19
+ path: command.split(" "),
20
+ aliases,
21
+ summary,
22
+ input,
23
+ effects,
24
+ confirmation,
25
+ results,
26
+ })),
27
+ error: { schemaRef: "#/schemas/definitions/ErrorEnvelope", exitCode: 1, stream: "stderr" },
28
+ schemas: generateResultSchemas(),
29
+ };
30
+ }
@@ -0,0 +1,3 @@
1
+ import type { ParsedRoute } from "./types.js";
2
+ /** Recognizes only checked split-column mistakes after an invocation has failed. */
3
+ export declare function quotedColumnHint(error: unknown, route: ParsedRoute, rawArgs: string[], routeWordCount: number): string | undefined;