@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.
- package/README.md +1 -1
- package/package.json +3 -3
- package/skills/zinn/SKILL.md +7 -9
- package/src/actor.d.ts +1 -1
- package/src/actor.js +4 -1
- package/src/capabilities-schema.d.ts +9 -1
- package/src/column-hint.js +1 -3
- package/src/database.d.ts +1 -2
- package/src/database.js +1 -6
- package/src/duration-input.d.ts +7 -0
- package/src/duration-input.js +31 -0
- package/src/errors.d.ts +26 -0
- package/src/errors.js +46 -8
- package/src/expected-values.d.ts +48 -0
- package/src/expected-values.js +60 -0
- package/src/follow.d.ts +9 -0
- package/src/follow.js +58 -0
- package/src/input.d.ts +0 -8
- package/src/input.js +36 -16
- package/src/lib.d.ts +7 -3
- package/src/lib.js +70 -28
- package/src/list-continuation.js +1 -4
- package/src/presentation/activity-presentation.d.ts +2 -0
- package/src/presentation/activity-presentation.js +60 -3
- package/src/presentation/column-presentation.d.ts +9 -4
- package/src/presentation/column-presentation.js +29 -12
- package/src/presentation/doctor-presentation.d.ts +10 -0
- package/src/presentation/doctor-presentation.js +28 -0
- package/src/presentation/relation-presentation.js +2 -1
- 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 +2 -4
- package/src/presentation/task-blame-presentation.js +4 -2
- package/src/presentation/task-presentation.d.ts +18 -4
- package/src/presentation/task-presentation.js +94 -30
- package/src/result-schemas.d.ts +490 -58
- package/src/result-schemas.js +97 -2
- package/src/results.d.ts +6 -2
- package/src/results.js +9 -3
- package/src/routes/activity-router.d.ts +16 -5
- package/src/routes/activity-router.js +131 -70
- package/src/routes/aliases.js +1 -0
- package/src/routes/backup-router.d.ts +1 -0
- package/src/routes/backup-router.js +4 -3
- package/src/routes/capabilities-router.d.ts +1 -0
- package/src/routes/capabilities-router.js +1 -1
- package/src/routes/comment-router.d.ts +29 -6
- package/src/routes/comment-router.js +20 -10
- package/src/routes/doctor-router.d.ts +40 -0
- package/src/routes/doctor-router.js +83 -0
- package/src/routes/info-router.d.ts +1 -0
- package/src/routes/info-router.js +1 -1
- package/src/routes/label-router.d.ts +44 -6
- package/src/routes/label-router.js +27 -10
- package/src/routes/migrate-router.d.ts +1 -0
- package/src/routes/migrate-router.js +5 -7
- package/src/routes/project-router.d.ts +70 -11
- package/src/routes/project-router.js +130 -56
- package/src/routes/reindex-router.d.ts +1 -0
- package/src/routes/reindex-router.js +1 -1
- package/src/routes/relation-router.d.ts +3 -0
- package/src/routes/relation-router.js +9 -6
- package/src/routes/restore-router.d.ts +1 -0
- package/src/routes/restore-router.js +5 -6
- package/src/routes/router.js +5 -9
- package/src/routes/routes.d.ts +517 -35
- package/src/routes/routes.js +4 -0
- package/src/routes/skill-router.d.ts +76 -0
- package/src/routes/skill-router.js +179 -0
- package/src/routes/task-router.d.ts +264 -13
- package/src/routes/task-router.js +415 -93
- package/src/routes/whoami-router.d.ts +1 -0
- package/src/routes/whoami-router.js +1 -1
- 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 +8 -3
- package/src/text-edit.d.ts +2 -2
- package/src/text-input.d.ts +19 -1
- package/src/text-input.js +26 -5
- package/src/types.d.ts +4 -0
- package/src/types.js +6 -0
package/src/routes/routes.js
CHANGED
|
@@ -7,8 +7,10 @@ import { restoreCommand } from "./restore-router.js";
|
|
|
7
7
|
import { migrateCommand } from "./migrate-router.js";
|
|
8
8
|
import { reindexCommand } from "./reindex-router.js";
|
|
9
9
|
import { infoCommand } from "./info-router.js";
|
|
10
|
+
import { doctorCommand } from "./doctor-router.js";
|
|
10
11
|
import { whoamiCommand } from "./whoami-router.js";
|
|
11
12
|
import { capabilitiesCommand } from "./capabilities-router.js";
|
|
13
|
+
import { skillRouter } from "./skill-router.js";
|
|
12
14
|
import { parseRoutes } from "./router.js";
|
|
13
15
|
// TODO: lazy load?
|
|
14
16
|
export const routes = {
|
|
@@ -21,7 +23,9 @@ export const routes = {
|
|
|
21
23
|
migrate: migrateCommand,
|
|
22
24
|
reindex: reindexCommand,
|
|
23
25
|
info: infoCommand,
|
|
26
|
+
doctor: doctorCommand,
|
|
24
27
|
whoami: whoamiCommand,
|
|
28
|
+
skill: skillRouter,
|
|
25
29
|
capabilities: capabilitiesCommand,
|
|
26
30
|
};
|
|
27
31
|
export const parsedRoutes = parseRoutes(routes);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare const skillRouter: {
|
|
2
|
+
install: {
|
|
3
|
+
summary: string;
|
|
4
|
+
effects: {
|
|
5
|
+
domain: "none";
|
|
6
|
+
storage: "none";
|
|
7
|
+
external: ("files" | "network")[];
|
|
8
|
+
};
|
|
9
|
+
confirmation: {
|
|
10
|
+
kind: "none";
|
|
11
|
+
};
|
|
12
|
+
input: {
|
|
13
|
+
readonly options: {
|
|
14
|
+
readonly project: {
|
|
15
|
+
readonly type: "boolean";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly forms: readonly [{
|
|
19
|
+
readonly id: "default";
|
|
20
|
+
readonly positionals: readonly [];
|
|
21
|
+
}];
|
|
22
|
+
readonly constraints: readonly [];
|
|
23
|
+
};
|
|
24
|
+
results: import("../results.js").CommandResult[];
|
|
25
|
+
run: (args: string[]) => Promise<void>;
|
|
26
|
+
help: string;
|
|
27
|
+
};
|
|
28
|
+
status: {
|
|
29
|
+
summary: string;
|
|
30
|
+
effects: {
|
|
31
|
+
domain: "none";
|
|
32
|
+
storage: "none";
|
|
33
|
+
external: never[];
|
|
34
|
+
};
|
|
35
|
+
confirmation: {
|
|
36
|
+
kind: "none";
|
|
37
|
+
};
|
|
38
|
+
input: {
|
|
39
|
+
readonly options: {};
|
|
40
|
+
readonly forms: readonly [{
|
|
41
|
+
readonly id: "default";
|
|
42
|
+
readonly positionals: readonly [];
|
|
43
|
+
}];
|
|
44
|
+
readonly constraints: readonly [];
|
|
45
|
+
};
|
|
46
|
+
results: import("../results.js").CommandResult[];
|
|
47
|
+
run: (args: string[]) => void;
|
|
48
|
+
help: string;
|
|
49
|
+
};
|
|
50
|
+
uninstall: {
|
|
51
|
+
summary: string;
|
|
52
|
+
effects: {
|
|
53
|
+
domain: "none";
|
|
54
|
+
storage: "none";
|
|
55
|
+
external: ("files" | "network")[];
|
|
56
|
+
};
|
|
57
|
+
confirmation: {
|
|
58
|
+
kind: "none";
|
|
59
|
+
};
|
|
60
|
+
input: {
|
|
61
|
+
readonly options: {
|
|
62
|
+
readonly project: {
|
|
63
|
+
readonly type: "boolean";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly forms: readonly [{
|
|
67
|
+
readonly id: "default";
|
|
68
|
+
readonly positionals: readonly [];
|
|
69
|
+
}];
|
|
70
|
+
readonly constraints: readonly [];
|
|
71
|
+
};
|
|
72
|
+
results: import("../results.js").CommandResult[];
|
|
73
|
+
run: (args: string[]) => Promise<void>;
|
|
74
|
+
help: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { CliError } from "../errors.js";
|
|
5
|
+
import { generateCommandUsage, noInput } from "../input.js";
|
|
6
|
+
import { diagnostic, getOutputMode, output, validatePositionals, validateUniqueOptions, } from "../lib.js";
|
|
7
|
+
import { jsonResult } from "../results.js";
|
|
8
|
+
import { formatSkillStatus, presentSkillStatus, } from "../presentation/skill-status-presentation.js";
|
|
9
|
+
import { bundledSkillDirectory, findSkillCopies, SKILL_NAME } from "../skill-copies.js";
|
|
10
|
+
/** On Windows npx is `npx.cmd`, which Node only starts through a shell */
|
|
11
|
+
const needsShell = process.platform === "win32";
|
|
12
|
+
/** Starts npx with one argument per array item, or on Windows as one command line for the shell */
|
|
13
|
+
function startNpx(args, stdio) {
|
|
14
|
+
if (needsShell) {
|
|
15
|
+
// Node warns when an argument array is combined with a shell (DEP0190), so the line is built here.
|
|
16
|
+
// Windows paths cannot contain double quotes, so quoting each argument keeps spaces inside it.
|
|
17
|
+
const commandLine = ["npx", ...args.map((arg) => `"${arg}"`)].join(" ");
|
|
18
|
+
return spawn(commandLine, { stdio, shell: true });
|
|
19
|
+
}
|
|
20
|
+
return spawn("npx", args, { stdio });
|
|
21
|
+
}
|
|
22
|
+
const skillScopeInput = {
|
|
23
|
+
options: { project: { type: "boolean" } },
|
|
24
|
+
forms: [{ id: "default", positionals: [] }],
|
|
25
|
+
constraints: [],
|
|
26
|
+
};
|
|
27
|
+
const skillInputs = {
|
|
28
|
+
install: skillScopeInput,
|
|
29
|
+
uninstall: skillScopeInput,
|
|
30
|
+
};
|
|
31
|
+
/** Parses the shared skill command arguments and says whether the command targets the current folder */
|
|
32
|
+
function parseSkillScope(args) {
|
|
33
|
+
const { positionals, values, tokens } = parseArgs({
|
|
34
|
+
options: skillScopeInput.options,
|
|
35
|
+
args,
|
|
36
|
+
strict: true,
|
|
37
|
+
allowPositionals: true,
|
|
38
|
+
tokens: true,
|
|
39
|
+
});
|
|
40
|
+
validateUniqueOptions(tokens, skillScopeInput.options);
|
|
41
|
+
validatePositionals(positionals, skillScopeInput.forms[0]);
|
|
42
|
+
return values.project === true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Runs the skills CLI with the given subcommand and arguments in the current working directory
|
|
46
|
+
* Resolves with its exit code, or `null` if a signal ends it
|
|
47
|
+
*/
|
|
48
|
+
function runSkillsCli(skillsArgs, isProject, zinnCommand) {
|
|
49
|
+
const isJson = getOutputMode() === "json";
|
|
50
|
+
/**
|
|
51
|
+
* JSON output keeps stdout for the result and stderr for one error document,
|
|
52
|
+
* so the skills CLI's output is captured and reported as notices.
|
|
53
|
+
* Without `-g` the skills CLI works in the current folder.
|
|
54
|
+
*/
|
|
55
|
+
const scopeArgs = isProject ? [] : ["-g"];
|
|
56
|
+
const child = startNpx(["--yes", "skills", ...skillsArgs, ...scopeArgs, "-y"], ["inherit", isJson ? "pipe" : "inherit", isJson ? "pipe" : "inherit"]);
|
|
57
|
+
const captured = [];
|
|
58
|
+
// Decoding per stream keeps a character intact when its bytes arrive across two chunks
|
|
59
|
+
for (const stream of [child.stdout, child.stderr]) {
|
|
60
|
+
stream?.setEncoding("utf8");
|
|
61
|
+
stream?.on("data", (text) => captured.push(text));
|
|
62
|
+
}
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
child.once("error", (error) => {
|
|
65
|
+
if (error.code === "ENOENT") {
|
|
66
|
+
const message = `npx was not found. ${zinnCommand} needs npx, which comes with npm.`;
|
|
67
|
+
reject(new CliError(message, "not_found", undefined, undefined, undefined, error));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
reject(error);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
child.once("close", (code) => {
|
|
74
|
+
const lines = captured
|
|
75
|
+
.join("")
|
|
76
|
+
.split(/\r?\n/)
|
|
77
|
+
.filter((line) => line.trim().length > 0);
|
|
78
|
+
for (const line of lines) {
|
|
79
|
+
diagnostic(line);
|
|
80
|
+
}
|
|
81
|
+
resolve(code);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Throws when the skills CLI failed, so Zinn exits with its exit code
|
|
87
|
+
* `details` adds what the error document names besides the exit code
|
|
88
|
+
*/
|
|
89
|
+
function throwOnSkillsCliFailure(exitCode, details) {
|
|
90
|
+
if (exitCode === 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const endedBySignal = exitCode === null;
|
|
94
|
+
const failure = new CliError(endedBySignal ? "The skills CLI was stopped." : `The skills CLI exited with code ${exitCode}.`, "internal", { ...details, ...(endedBySignal ? {} : { exitCode }) });
|
|
95
|
+
if (!endedBySignal) {
|
|
96
|
+
failure.exitCode = exitCode;
|
|
97
|
+
}
|
|
98
|
+
throw failure;
|
|
99
|
+
}
|
|
100
|
+
export const skillRouter = {
|
|
101
|
+
install: {
|
|
102
|
+
summary: "Install the agent skill bundled with this CLI using the skills CLI.",
|
|
103
|
+
effects: { domain: "none", storage: "none", external: ["files", "network"] },
|
|
104
|
+
confirmation: { kind: "none" },
|
|
105
|
+
input: skillInputs.install,
|
|
106
|
+
results: [jsonResult("SkillInstall")],
|
|
107
|
+
run: async (args) => {
|
|
108
|
+
const isProject = parseSkillScope(args);
|
|
109
|
+
const exitCode = await runSkillsCli(["add", bundledSkillDirectory], isProject, "zinn skill install");
|
|
110
|
+
throwOnSkillsCliFailure(exitCode, { path: bundledSkillDirectory });
|
|
111
|
+
const installed = { source: bundledSkillDirectory };
|
|
112
|
+
output(installed, () => "");
|
|
113
|
+
},
|
|
114
|
+
help: `${generateCommandUsage("skill install", skillInputs.install)}
|
|
115
|
+
|
|
116
|
+
Install the agent skill bundled with this CLI using the skills CLI (https://github.com/vercel-labs/skills).
|
|
117
|
+
|
|
118
|
+
Runs npx --yes skills add <skill folder> -g -y, where the skill folder is the one inside this CLI's package, and passes the skills CLI's output and exit code through.
|
|
119
|
+
Use --project to install into the current folder instead. It runs the same command without -g there, and the skills CLI records the copy in that folder's skills-lock.json.
|
|
120
|
+
Rerun it after upgrading Zinn, or run npx skills update -g, which reads the same folder. Each project with its own copy needs zinn skill install --project rerun there after an upgrade.
|
|
121
|
+
With --json, the skills CLI's output is reported as notices: on stderr after the result, or in error.diagnostics when it fails.`,
|
|
122
|
+
},
|
|
123
|
+
status: {
|
|
124
|
+
summary: "List the Zinn agent skill copies and whether each matches the skill this CLI installs.",
|
|
125
|
+
effects: { domain: "none", storage: "none", external: [] },
|
|
126
|
+
confirmation: { kind: "none" },
|
|
127
|
+
input: noInput,
|
|
128
|
+
results: [jsonResult("SkillStatus")],
|
|
129
|
+
run: (args) => {
|
|
130
|
+
const { positionals } = parseArgs({
|
|
131
|
+
options: noInput.options,
|
|
132
|
+
args,
|
|
133
|
+
strict: true,
|
|
134
|
+
allowPositionals: true,
|
|
135
|
+
});
|
|
136
|
+
validatePositionals(positionals, noInput.forms[0]);
|
|
137
|
+
const workingFolder = process.cwd();
|
|
138
|
+
const status = presentSkillStatus(findSkillCopies(homedir(), workingFolder), bundledSkillDirectory, workingFolder);
|
|
139
|
+
output(status, formatSkillStatus);
|
|
140
|
+
},
|
|
141
|
+
help: `${generateCommandUsage("skill status", noInput)}
|
|
142
|
+
|
|
143
|
+
List the Zinn skill copies agents may load and whether each matches the skill this CLI installs.
|
|
144
|
+
|
|
145
|
+
Checks ~/.agents/skills/zinn, ~/.claude/skills/zinn and the same two folders in the current folder, as zinn doctor does. Paths that reach one file through links count as one copy. Each copy that differs names the command that updates it.
|
|
146
|
+
Reads local files only and changes nothing.
|
|
147
|
+
Exits 0 when a copy differs. zinn doctor exits 1 then. With --json, matches says whether each copy matches.`,
|
|
148
|
+
},
|
|
149
|
+
uninstall: {
|
|
150
|
+
summary: "Remove the Zinn agent skill using the skills CLI.",
|
|
151
|
+
effects: { domain: "none", storage: "none", external: ["files", "network"] },
|
|
152
|
+
confirmation: { kind: "none" },
|
|
153
|
+
input: skillInputs.uninstall,
|
|
154
|
+
results: [jsonResult("SkillUninstall")],
|
|
155
|
+
run: async (args) => {
|
|
156
|
+
const isProject = parseSkillScope(args);
|
|
157
|
+
const copiesBefore = findSkillCopies(homedir(), process.cwd()).copies;
|
|
158
|
+
const exitCode = await runSkillsCli(["remove", SKILL_NAME], isProject, "zinn skill uninstall");
|
|
159
|
+
throwOnSkillsCliFailure(exitCode, {});
|
|
160
|
+
const realPathsAfter = new Set(findSkillCopies(homedir(), process.cwd()).copies.map((copy) => copy.realPath));
|
|
161
|
+
const result = {
|
|
162
|
+
removed: copiesBefore
|
|
163
|
+
.filter((copy) => !realPathsAfter.has(copy.realPath))
|
|
164
|
+
.map(({ path, scope }) => ({ path, scope })),
|
|
165
|
+
};
|
|
166
|
+
output(result, () => "");
|
|
167
|
+
},
|
|
168
|
+
help: `${generateCommandUsage("skill uninstall", skillInputs.uninstall)}
|
|
169
|
+
|
|
170
|
+
Remove the Zinn agent skill using the skills CLI (https://github.com/vercel-labs/skills).
|
|
171
|
+
|
|
172
|
+
Runs npx --yes skills remove zinn -g -y and passes the skills CLI's output and exit code through. It removes the global copy and its agent links.
|
|
173
|
+
Use --project to remove the copy in the current folder instead. It runs the same command without -g there.
|
|
174
|
+
The skill is removed by its name, zinn, so a copy installed from another source, such as the GitHub repository, is removed too.
|
|
175
|
+
zinn skill install puts the skill back.
|
|
176
|
+
With --json, the result lists the removed copies among ~/.agents/skills/zinn, ~/.claude/skills/zinn and the same two folders in the current folder, though the skills CLI may also remove copies in other agent folders.
|
|
177
|
+
With --json, the skills CLI's output is reported as notices: on stderr after the result, or in error.diagnostics when it fails.`,
|
|
178
|
+
},
|
|
179
|
+
};
|