@dayofweek/dcli 1.1.1 → 1.2.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/dist/bin/dcli.js +77 -30
- package/dist/client.d.ts +1 -0
- package/dist/client.js +2 -0
- package/package.json +1 -1
package/dist/bin/dcli.js
CHANGED
|
@@ -6,10 +6,13 @@ import { readFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
6
6
|
import { join, dirname } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { createInterface } from "node:readline/promises";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf-8"));
|
|
9
12
|
const program = new Command()
|
|
10
13
|
.name("dcli")
|
|
11
14
|
.description("CLI for the Day of Week AgTech platform")
|
|
12
|
-
.version(
|
|
15
|
+
.version(pkg.version)
|
|
13
16
|
.option("--token <token>", "Auth token (overrides DCLI_AUTH_TOKEN)")
|
|
14
17
|
.option("--api-url <url>", "API base URL (overrides DCLI_API_URL)")
|
|
15
18
|
.option("--json", "Output JSON (default for non-interactive use)");
|
|
@@ -138,10 +141,11 @@ read
|
|
|
138
141
|
});
|
|
139
142
|
read
|
|
140
143
|
.command("catalog")
|
|
141
|
-
.description("Search or browse the produce catalog")
|
|
144
|
+
.description("Search or browse the produce catalog (selectable items only by default)")
|
|
142
145
|
.option("--search <query>", "Search by name")
|
|
143
146
|
.option("--parent <conceptId>", "List children of a category")
|
|
144
147
|
.option("--type <nodeType>", "Filter by type (category, produce, variety)")
|
|
148
|
+
.option("--include-categories", "Include non-selectable categories in results")
|
|
145
149
|
.option("--limit <count>", "Max results", parseInt)
|
|
146
150
|
.action(async (opts) => {
|
|
147
151
|
const client = getClient();
|
|
@@ -229,14 +233,22 @@ agent
|
|
|
229
233
|
});
|
|
230
234
|
// ── Skill Commands ───────────────────────────────────────────────────────────
|
|
231
235
|
const skill = program.command("skill").description("Manage the Day of Week agent skill");
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
function resolveTargetDirs(target, bundleName, customDir) {
|
|
237
|
+
if (customDir)
|
|
238
|
+
return [customDir];
|
|
239
|
+
const agentsDir = join(homedir(), ".agents", "skills", bundleName);
|
|
240
|
+
const claudeDir = join(homedir(), ".claude", "skills", bundleName);
|
|
241
|
+
const claudeRootExists = existsSync(join(homedir(), ".claude"));
|
|
242
|
+
switch (target) {
|
|
243
|
+
case "agents":
|
|
244
|
+
return [agentsDir];
|
|
245
|
+
case "claude":
|
|
246
|
+
return [claudeDir];
|
|
247
|
+
case "all":
|
|
248
|
+
return claudeRootExists ? [agentsDir, claudeDir] : [agentsDir];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function writeBundle(bundle, targetDir) {
|
|
240
252
|
let filesWritten = 0;
|
|
241
253
|
for (const file of bundle.files) {
|
|
242
254
|
const filePath = join(targetDir, file.path);
|
|
@@ -244,42 +256,77 @@ skill
|
|
|
244
256
|
writeFileSync(filePath, file.content, "utf-8");
|
|
245
257
|
filesWritten++;
|
|
246
258
|
}
|
|
247
|
-
|
|
259
|
+
return filesWritten;
|
|
260
|
+
}
|
|
261
|
+
function parseTarget(value) {
|
|
262
|
+
const v = (value ?? "all").toLowerCase();
|
|
263
|
+
if (v !== "agents" && v !== "claude" && v !== "all") {
|
|
264
|
+
console.error(`Invalid --target: ${value}. Use agents, claude, or all.`);
|
|
265
|
+
process.exit(1);
|
|
266
|
+
}
|
|
267
|
+
return v;
|
|
268
|
+
}
|
|
269
|
+
skill
|
|
270
|
+
.command("install")
|
|
271
|
+
.description("Install the agent skill (requires valid auth)")
|
|
272
|
+
.option("--dir <path>", "Custom install directory (overrides --target)")
|
|
273
|
+
.option("--target <target>", "Install target: agents, claude, or all (default: all)")
|
|
274
|
+
.action(async (opts) => {
|
|
275
|
+
const client = getClient();
|
|
276
|
+
const bundle = await client.getSkillBundle();
|
|
277
|
+
const target = parseTarget(opts.target);
|
|
278
|
+
const dirs = resolveTargetDirs(target, bundle.name, opts.dir);
|
|
279
|
+
for (const dir of dirs) {
|
|
280
|
+
const count = writeBundle(bundle, dir);
|
|
281
|
+
console.log(`Installed ${count} files to ${dir}`);
|
|
282
|
+
}
|
|
248
283
|
console.log("Any compatible agent will discover the skill automatically.");
|
|
249
284
|
});
|
|
250
285
|
skill
|
|
251
286
|
.command("update")
|
|
252
287
|
.description("Update the skill to the latest version")
|
|
253
|
-
.option("--dir <path>", "Custom install directory")
|
|
288
|
+
.option("--dir <path>", "Custom install directory (overrides --target)")
|
|
289
|
+
.option("--target <target>", "Install target: agents, claude, or all (default: all)")
|
|
254
290
|
.action(async (opts) => {
|
|
255
|
-
// Same as install — overwrites
|
|
256
291
|
const client = getClient();
|
|
257
292
|
const bundle = await client.getSkillBundle();
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
for (const
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
writeFileSync(filePath, file.content, "utf-8");
|
|
264
|
-
filesWritten++;
|
|
293
|
+
const target = parseTarget(opts.target);
|
|
294
|
+
const dirs = resolveTargetDirs(target, bundle.name, opts.dir);
|
|
295
|
+
for (const dir of dirs) {
|
|
296
|
+
const count = writeBundle(bundle, dir);
|
|
297
|
+
console.log(`Updated ${count} files in ${dir}`);
|
|
265
298
|
}
|
|
266
|
-
console.log(`Updated ${filesWritten} files in ${targetDir}`);
|
|
267
299
|
});
|
|
268
300
|
skill
|
|
269
301
|
.command("status")
|
|
270
302
|
.description("Check if the skill is installed")
|
|
271
|
-
.option("--dir <path>", "Custom install directory")
|
|
303
|
+
.option("--dir <path>", "Custom install directory (overrides --target)")
|
|
304
|
+
.option("--target <target>", "Check target: agents, claude, or all (default: all)")
|
|
272
305
|
.action(async (opts) => {
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
306
|
+
const bundleName = "dayofweek-platform";
|
|
307
|
+
const target = parseTarget(opts.target);
|
|
308
|
+
const dirs = opts.dir
|
|
309
|
+
? [opts.dir]
|
|
310
|
+
: target === "all"
|
|
311
|
+
? [join(homedir(), ".agents", "skills", bundleName), join(homedir(), ".claude", "skills", bundleName)]
|
|
312
|
+
: resolveTargetDirs(target, bundleName);
|
|
313
|
+
let anyInstalled = false;
|
|
314
|
+
for (const dir of dirs) {
|
|
315
|
+
const skillPath = join(dir, "SKILL.md");
|
|
316
|
+
if (!existsSync(skillPath)) {
|
|
317
|
+
console.log(`Not installed at: ${dir}`);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
anyInstalled = true;
|
|
321
|
+
const content = readFileSync(skillPath, "utf-8");
|
|
322
|
+
const versionMatch = content.match(/version:\s*"([^"]+)"/);
|
|
323
|
+
console.log(`Installed at: ${dir}`);
|
|
324
|
+
console.log(` Version: ${versionMatch?.[1] ?? "unknown"}`);
|
|
325
|
+
}
|
|
326
|
+
if (!anyInstalled) {
|
|
327
|
+
console.log("\nRun: dcli skill install");
|
|
277
328
|
process.exit(1);
|
|
278
329
|
}
|
|
279
|
-
const content = readFileSync(skillPath, "utf-8");
|
|
280
|
-
const versionMatch = content.match(/version:\s*"([^"]+)"/);
|
|
281
|
-
console.log(`Installed at: ${dir}`);
|
|
282
|
-
console.log(`Version: ${versionMatch?.[1] ?? "unknown"}`);
|
|
283
330
|
console.log("\nTo update: dcli skill update");
|
|
284
331
|
});
|
|
285
332
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -75,6 +75,8 @@ export class DayOfWeekClient {
|
|
|
75
75
|
params.set("parent", opts.parent);
|
|
76
76
|
if (opts?.type)
|
|
77
77
|
params.set("type", opts.type);
|
|
78
|
+
if (opts?.includeCategories)
|
|
79
|
+
params.set("includeCategories", "true");
|
|
78
80
|
if (opts?.limit)
|
|
79
81
|
params.set("limit", String(opts.limit));
|
|
80
82
|
const qs = params.toString();
|