@rayul/kordis 0.6.6 → 0.6.7
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/dist/index.js +141 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1919,14 +1919,47 @@ var SORT_MODES = [
|
|
|
1919
1919
|
"rising"
|
|
1920
1920
|
];
|
|
1921
1921
|
var TIME_WINDOWS = ["24h", "7d", "30d"];
|
|
1922
|
+
var TOOL_SLUGS = [
|
|
1923
|
+
"claude-code",
|
|
1924
|
+
"codex",
|
|
1925
|
+
"cursor",
|
|
1926
|
+
"antigravity",
|
|
1927
|
+
"windsurf",
|
|
1928
|
+
"continue",
|
|
1929
|
+
"copilot",
|
|
1930
|
+
"opencode",
|
|
1931
|
+
"gemini-cli"
|
|
1932
|
+
];
|
|
1933
|
+
var TOOL_ALIASES = {
|
|
1934
|
+
claude: "claude-code",
|
|
1935
|
+
gemini: "gemini-cli"
|
|
1936
|
+
};
|
|
1922
1937
|
function searchCommand() {
|
|
1923
|
-
return new Command3("search").description("search the Kordis registry").argument("[query...]", "keywords to match against title/description").option("--type <type>", "filter by harness type (skill|mcp-server|project-rules|custom-agent|hook)").option(
|
|
1938
|
+
return new Command3("search").description("search the Kordis registry").argument("[query...]", "keywords to match against title/description").option("--type <type>", "filter by harness type (skill|mcp-server|project-rules|custom-agent|hook)").option(
|
|
1939
|
+
"--tool <tool>",
|
|
1940
|
+
`filter by compatible tool \u2014 one of: ${TOOL_SLUGS.join("|")} (aliases: ${Object.entries(
|
|
1941
|
+
TOOL_ALIASES
|
|
1942
|
+
).map(([alias, canonical]) => `${alias}\u2192${canonical}`).join(", ")})`
|
|
1943
|
+
).option("--tier <tier>", "filter by portability tier (A|B|C|D)").option("--author <username>", "filter to a single author (server returns exact total when set)").option(
|
|
1944
|
+
"--cursor <token>",
|
|
1945
|
+
"pagination cursor \u2014 pass the next_cursor field from a prior search response to fetch the next page"
|
|
1946
|
+
).option("--sort <mode>", `sort: ${SORT_MODES.join("|")}`).option("--trending", "list trending packages (overrides --sort)", false).option("--rising", "list rising packages by 7d acceleration (overrides --sort)", false).option("--window <w>", `time window for --trending: ${TIME_WINDOWS.join("|")}`, "24h").option("--limit <n>", "max results", (v) => parseInt(v, 10), 20).action(async (query, opts) => {
|
|
1924
1947
|
if (opts.sort && !SORT_MODES.includes(opts.sort)) {
|
|
1925
1948
|
throw new Error(`--sort must be one of ${SORT_MODES.join(", ")}`);
|
|
1926
1949
|
}
|
|
1927
1950
|
if (opts.window && !TIME_WINDOWS.includes(opts.window)) {
|
|
1928
1951
|
throw new Error(`--window must be one of ${TIME_WINDOWS.join(", ")}`);
|
|
1929
1952
|
}
|
|
1953
|
+
let resolvedTool;
|
|
1954
|
+
if (opts.tool) {
|
|
1955
|
+
const candidate = TOOL_ALIASES[opts.tool] ?? opts.tool;
|
|
1956
|
+
if (!TOOL_SLUGS.includes(candidate)) {
|
|
1957
|
+
throw new Error(
|
|
1958
|
+
`--tool must be one of ${TOOL_SLUGS.join(", ")} (you passed "${opts.tool}")`
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
resolvedTool = candidate;
|
|
1962
|
+
}
|
|
1930
1963
|
const bundle = await useClient();
|
|
1931
1964
|
let res;
|
|
1932
1965
|
if (opts.rising) {
|
|
@@ -1944,9 +1977,10 @@ function searchCommand() {
|
|
|
1944
1977
|
res = await bundle.api.search({
|
|
1945
1978
|
q: query.join(" ") || void 0,
|
|
1946
1979
|
type: opts.type ? [opts.type] : void 0,
|
|
1947
|
-
tool:
|
|
1980
|
+
tool: resolvedTool ? [resolvedTool] : void 0,
|
|
1948
1981
|
tier: opts.tier,
|
|
1949
1982
|
...opts.author ? { author: opts.author } : {},
|
|
1983
|
+
...opts.cursor ? { cursor: opts.cursor } : {},
|
|
1950
1984
|
sort: opts.sort ?? "relevance",
|
|
1951
1985
|
limit: opts.limit
|
|
1952
1986
|
});
|
|
@@ -3302,18 +3336,23 @@ function getTranslator(type, format) {
|
|
|
3302
3336
|
import { homedir as homedir6 } from "os";
|
|
3303
3337
|
import { join as join8 } from "path";
|
|
3304
3338
|
import { readFile as readFile7, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
3305
|
-
|
|
3339
|
+
function kordisHome2() {
|
|
3340
|
+
return process.env["KORDIS_HOME"] ?? join8(homedir6(), ".kordis");
|
|
3341
|
+
}
|
|
3342
|
+
function lockfilePath() {
|
|
3343
|
+
return join8(kordisHome2(), "installed.json");
|
|
3344
|
+
}
|
|
3306
3345
|
async function readLockfile() {
|
|
3307
3346
|
try {
|
|
3308
|
-
const raw = await readFile7(
|
|
3347
|
+
const raw = await readFile7(lockfilePath(), "utf8");
|
|
3309
3348
|
return JSON.parse(raw);
|
|
3310
3349
|
} catch {
|
|
3311
3350
|
return { packages: {} };
|
|
3312
3351
|
}
|
|
3313
3352
|
}
|
|
3314
3353
|
async function writeLockfile(lf) {
|
|
3315
|
-
await mkdir5(
|
|
3316
|
-
await writeFile5(
|
|
3354
|
+
await mkdir5(kordisHome2(), { recursive: true });
|
|
3355
|
+
await writeFile5(lockfilePath(), JSON.stringify(lf, null, 2) + "\n", "utf8");
|
|
3317
3356
|
}
|
|
3318
3357
|
async function recordInstalled(fullSlug, entry) {
|
|
3319
3358
|
const lf = await readLockfile();
|
|
@@ -3833,6 +3872,8 @@ var KINDS = [
|
|
|
3833
3872
|
"praise",
|
|
3834
3873
|
"question"
|
|
3835
3874
|
];
|
|
3875
|
+
var LIST_SORTS = ["recent", "old"];
|
|
3876
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3836
3877
|
function commentCommand() {
|
|
3837
3878
|
return new Command10("comment").description("post a comment on a package").argument("<full_slug>", "package identifier {username}/{slug}").requiredOption("--body <text>", "comment body (1\u201310000 chars)").option("--kind <kind>", `top-level kind: ${KINDS.join("|")}`, "comment").option("--title <text>", "top-level post title (1\u2013140 chars)").action(
|
|
3838
3879
|
async (rawSlug, opts) => {
|
|
@@ -3863,11 +3904,103 @@ function commentCommand() {
|
|
|
3863
3904
|
if (res.permalink) {
|
|
3864
3905
|
printHuman(c.gray(` view: ${res.permalink}`));
|
|
3865
3906
|
}
|
|
3907
|
+
printHuman(c.gray(` delete: kordis uncomment ${res.id}`));
|
|
3866
3908
|
}
|
|
3867
3909
|
});
|
|
3868
3910
|
}
|
|
3869
3911
|
);
|
|
3870
3912
|
}
|
|
3913
|
+
function commentsCommand() {
|
|
3914
|
+
return new Command10("comments").description("list comments on a package").argument("<full_slug>", "package identifier {username}/{slug}").option("--limit <n>", "max top-level comments (1\u201350)", (v) => parseInt(v, 10), 20).option("--cursor <token>", "pagination cursor returned by a prior call as next_cursor").option(
|
|
3915
|
+
"--kind <kind>",
|
|
3916
|
+
`filter top-level posts by kind: ${KINDS.join("|")}`
|
|
3917
|
+
).option("--sort <mode>", `sort: ${LIST_SORTS.join("|")} (default: recent)`).action(
|
|
3918
|
+
async (rawSlug, opts) => {
|
|
3919
|
+
const [username, slug] = rawSlug.split("/");
|
|
3920
|
+
if (!username || !slug) {
|
|
3921
|
+
throw new Error('full_slug must be "{username}/{slug}"');
|
|
3922
|
+
}
|
|
3923
|
+
if (opts.kind && !KINDS.includes(opts.kind)) {
|
|
3924
|
+
throw new Error(`--kind must be one of ${KINDS.join(", ")}`);
|
|
3925
|
+
}
|
|
3926
|
+
if (opts.sort && !LIST_SORTS.includes(opts.sort)) {
|
|
3927
|
+
throw new Error(`--sort must be one of ${LIST_SORTS.join(", ")}`);
|
|
3928
|
+
}
|
|
3929
|
+
const bundle = await useClient();
|
|
3930
|
+
const res = await bundle.api.listComments(username, slug, {
|
|
3931
|
+
limit: opts.limit,
|
|
3932
|
+
...opts.cursor ? { cursor: opts.cursor } : {},
|
|
3933
|
+
...opts.kind ? { kind: opts.kind } : {},
|
|
3934
|
+
...opts.sort ? { sort: opts.sort } : {}
|
|
3935
|
+
});
|
|
3936
|
+
printDual({
|
|
3937
|
+
json: res,
|
|
3938
|
+
human: () => {
|
|
3939
|
+
if (res.results.length === 0) {
|
|
3940
|
+
printHuman(c.yellow("(no comments)"));
|
|
3941
|
+
printHuman(
|
|
3942
|
+
c.gray(" \u2192 be the first: kordis comment " + rawSlug + ' --body "..."')
|
|
3943
|
+
);
|
|
3944
|
+
return;
|
|
3945
|
+
}
|
|
3946
|
+
printHuman(
|
|
3947
|
+
c.gray(
|
|
3948
|
+
`Showing ${res.results.length} of ${res.total} top-level comment${res.total === 1 ? "" : "s"}`
|
|
3949
|
+
)
|
|
3950
|
+
);
|
|
3951
|
+
printHuman("");
|
|
3952
|
+
for (const node of res.results) {
|
|
3953
|
+
renderCommentNode(node, 0);
|
|
3954
|
+
}
|
|
3955
|
+
if (res.next_cursor) {
|
|
3956
|
+
printHuman(
|
|
3957
|
+
c.gray(
|
|
3958
|
+
`(more available \u2014 kordis comments ${rawSlug} --cursor ${res.next_cursor})`
|
|
3959
|
+
)
|
|
3960
|
+
);
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
);
|
|
3966
|
+
}
|
|
3967
|
+
function renderCommentNode(node, depth) {
|
|
3968
|
+
const indent = " ".repeat(depth);
|
|
3969
|
+
const tag = node.kind === "comment" ? "" : c.cyan(`[${node.kind}]`) + " ";
|
|
3970
|
+
const title = node.title ? c.bold(node.title) + " " : "";
|
|
3971
|
+
const author = `${node.author.username}${node.author.display_name ? ` (${node.author.display_name})` : ""}`;
|
|
3972
|
+
printHuman(`${indent}${tag}${title}${c.gray(`\u2014 ${author}`)}`);
|
|
3973
|
+
for (const line of node.body.split("\n")) {
|
|
3974
|
+
printHuman(`${indent} ${line}`);
|
|
3975
|
+
}
|
|
3976
|
+
const trail = [`id: ${node.id}`];
|
|
3977
|
+
if (node.reply_count > 0) trail.push(`${node.reply_count} repl${node.reply_count === 1 ? "y" : "ies"}`);
|
|
3978
|
+
if (node.is_edited) trail.push("edited");
|
|
3979
|
+
if (node.permalink) trail.push(`view: ${node.permalink}`);
|
|
3980
|
+
printHuman(c.gray(`${indent} ${trail.join(" \xB7 ")}`));
|
|
3981
|
+
printHuman("");
|
|
3982
|
+
for (const child of node.replies) {
|
|
3983
|
+
renderCommentNode(child, depth + 1);
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
function uncommentCommand() {
|
|
3987
|
+
return new Command10("uncomment").description("delete one of your comments by id").argument("<id>", "comment id (uuid v4)").action(async (id) => {
|
|
3988
|
+
if (!UUID_RE.test(id)) {
|
|
3989
|
+
throw new Error(
|
|
3990
|
+
"comment id must be a uuid v4 \u2014 get it from `kordis comments <slug>` or the `id` field on `kordis comment`'s response"
|
|
3991
|
+
);
|
|
3992
|
+
}
|
|
3993
|
+
const bundle = await useClient();
|
|
3994
|
+
requireAuth(bundle);
|
|
3995
|
+
await bundle.authedRequest((api) => api.deleteComment(id));
|
|
3996
|
+
printDual({
|
|
3997
|
+
json: { status: "deleted", id },
|
|
3998
|
+
human: () => {
|
|
3999
|
+
printHuman(c.gray(`\u2717 deleted comment ${id}`));
|
|
4000
|
+
}
|
|
4001
|
+
});
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
3871
4004
|
|
|
3872
4005
|
// src/commands/star.ts
|
|
3873
4006
|
import { Command as Command11 } from "commander";
|
|
@@ -4465,6 +4598,8 @@ function buildProgram() {
|
|
|
4465
4598
|
program.addCommand(readCommand());
|
|
4466
4599
|
program.addCommand(infoCommand());
|
|
4467
4600
|
program.addCommand(commentCommand());
|
|
4601
|
+
program.addCommand(commentsCommand());
|
|
4602
|
+
program.addCommand(uncommentCommand());
|
|
4468
4603
|
program.addCommand(starCommand());
|
|
4469
4604
|
program.addCommand(unstarCommand());
|
|
4470
4605
|
program.addCommand(deleteCommand());
|