@dypt/cli 0.1.1 → 0.1.3
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 +29 -0
- package/dist/index.js +534 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import { realpathSync } from "fs";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
6
6
|
import { createInterface } from "readline/promises";
|
|
7
|
-
import { Command, Option } from "commander";
|
|
7
|
+
import { Argument, Command, Option } from "commander";
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "@dypt/cli",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.3",
|
|
13
13
|
description: "Command-line interface for dypt task management",
|
|
14
14
|
license: "SEE LICENSE IN LICENSE",
|
|
15
15
|
homepage: "https://dypt.app",
|
|
@@ -251,8 +251,8 @@ async function createCliTrpcClient(options = {}) {
|
|
|
251
251
|
]
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
-
async function postJson(
|
|
255
|
-
const response = await fetch(new URL(
|
|
254
|
+
async function postJson(path4, body, options = {}) {
|
|
255
|
+
const response = await fetch(new URL(path4, resolveBaseUrl(options.baseUrl)), {
|
|
256
256
|
method: "POST",
|
|
257
257
|
headers: {
|
|
258
258
|
"content-type": "application/json"
|
|
@@ -381,6 +381,355 @@ async function runLogout(deps = createDefaultLogoutDeps()) {
|
|
|
381
381
|
deps.writeLine?.("Signed out of dypt CLI.");
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
// src/lib/agentToolkit.ts
|
|
385
|
+
import { createHash } from "crypto";
|
|
386
|
+
import {
|
|
387
|
+
cp,
|
|
388
|
+
mkdir as mkdir2,
|
|
389
|
+
mkdtemp,
|
|
390
|
+
readFile as readFile2,
|
|
391
|
+
readdir,
|
|
392
|
+
rm as rm2,
|
|
393
|
+
stat,
|
|
394
|
+
writeFile as writeFile2
|
|
395
|
+
} from "fs/promises";
|
|
396
|
+
import os2 from "os";
|
|
397
|
+
import path3 from "path";
|
|
398
|
+
var TOOLKIT_REPO = "poyzer-tech/dypt-toolkit";
|
|
399
|
+
var SKILL_RELATIVE_PATH = path3.join("skills", "dypt-cli");
|
|
400
|
+
var METADATA_FILE = ".dypt-install.json";
|
|
401
|
+
var REQUIRED_FILES = [
|
|
402
|
+
"SKILL.md",
|
|
403
|
+
path3.join("agents", "openai.yaml"),
|
|
404
|
+
path3.join("references", "cli-basics.md")
|
|
405
|
+
];
|
|
406
|
+
var AGENT_INSTRUCTIONS_SNIPPET = `## Work Tracking with dypt
|
|
407
|
+
|
|
408
|
+
This project uses dypt tasks as the canonical work tracker.
|
|
409
|
+
|
|
410
|
+
When working on repo tasks:
|
|
411
|
+
|
|
412
|
+
- Use the dypt CLI to inspect tasks, notes, children, dependencies, and nearby branch context before changing work.
|
|
413
|
+
- Search before creating new tasks to avoid duplicates.
|
|
414
|
+
- If the right parent or scope for a new or moved task is not clear, ask the user to confirm before changing task structure.
|
|
415
|
+
- Capture durable context in dypt notes.
|
|
416
|
+
- Format longer dypt notes with appropriate markdown so they are readable and well presented.
|
|
417
|
+
- When referencing tasks in dypt notes, use dypt task links such as [#123](#task-123) and do not repeat the task title after the link.
|
|
418
|
+
- When referring to tasks back to the user, include both id and title, for example #123 Add CLI docs.
|
|
419
|
+
- Track follow-up work as dypt tasks.
|
|
420
|
+
- Do not create a parallel markdown TODO tracker.
|
|
421
|
+
- Do not set leaf tasks to in progress; dypt derives in progress for parent tasks from child state.
|
|
422
|
+
- Preview cleanup or bulk changes before applying them when preview is available.
|
|
423
|
+
- If the dypt-cli skill is available, use it for dypt task workflows.
|
|
424
|
+
`;
|
|
425
|
+
function metadataPath(targetPath) {
|
|
426
|
+
return path3.join(targetPath, METADATA_FILE);
|
|
427
|
+
}
|
|
428
|
+
async function pathExists(filePath) {
|
|
429
|
+
try {
|
|
430
|
+
await stat(filePath);
|
|
431
|
+
return true;
|
|
432
|
+
} catch (error) {
|
|
433
|
+
if (error.code === "ENOENT") {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
throw error;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async function listFilesRecursive(root, prefix = "") {
|
|
440
|
+
const dir = path3.join(root, prefix);
|
|
441
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
442
|
+
const files = await Promise.all(
|
|
443
|
+
entries.map(async (entry) => {
|
|
444
|
+
const relativePath = path3.join(prefix, entry.name);
|
|
445
|
+
if (relativePath === METADATA_FILE) return [];
|
|
446
|
+
if (entry.isDirectory()) {
|
|
447
|
+
return listFilesRecursive(root, relativePath);
|
|
448
|
+
}
|
|
449
|
+
if (entry.isFile()) {
|
|
450
|
+
return [relativePath];
|
|
451
|
+
}
|
|
452
|
+
return [];
|
|
453
|
+
})
|
|
454
|
+
);
|
|
455
|
+
return files.flat().sort();
|
|
456
|
+
}
|
|
457
|
+
async function hashFile(filePath) {
|
|
458
|
+
const content = await readFile2(filePath);
|
|
459
|
+
return createHash("sha256").update(content).digest("hex");
|
|
460
|
+
}
|
|
461
|
+
async function hashManagedFiles(root) {
|
|
462
|
+
const files = await listFilesRecursive(root);
|
|
463
|
+
const entries = await Promise.all(
|
|
464
|
+
files.map(async (file) => [file, await hashFile(path3.join(root, file))])
|
|
465
|
+
);
|
|
466
|
+
return Object.fromEntries(entries);
|
|
467
|
+
}
|
|
468
|
+
async function readMetadata(targetPath) {
|
|
469
|
+
try {
|
|
470
|
+
return JSON.parse(await readFile2(metadataPath(targetPath), "utf8"));
|
|
471
|
+
} catch (error) {
|
|
472
|
+
if (error.code === "ENOENT") {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
throw error;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function hashesMatch(current, previous) {
|
|
479
|
+
const currentKeys = Object.keys(current).sort();
|
|
480
|
+
const previousKeys = Object.keys(previous).sort();
|
|
481
|
+
if (currentKeys.length !== previousKeys.length) return false;
|
|
482
|
+
return currentKeys.every(
|
|
483
|
+
(key, index) => key === previousKeys[index] && current[key] === previous[key]
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
async function validateSkillSource(skillPath) {
|
|
487
|
+
await Promise.all(
|
|
488
|
+
REQUIRED_FILES.map(async (file) => {
|
|
489
|
+
if (!await pathExists(path3.join(skillPath, file))) {
|
|
490
|
+
throw new Error(`Invalid dypt toolkit source. Missing ${file}.`);
|
|
491
|
+
}
|
|
492
|
+
})
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
function githubApiUrl(pathname) {
|
|
496
|
+
return `https://api.github.com/repos/${TOOLKIT_REPO}${pathname}`;
|
|
497
|
+
}
|
|
498
|
+
async function fetchJson(url, fetchFn) {
|
|
499
|
+
const response = await fetchFn(url, {
|
|
500
|
+
headers: { Accept: "application/vnd.github+json" }
|
|
501
|
+
});
|
|
502
|
+
if (!response.ok) {
|
|
503
|
+
throw new Error(`Failed to fetch ${url}: ${response.status}`);
|
|
504
|
+
}
|
|
505
|
+
return await response.json();
|
|
506
|
+
}
|
|
507
|
+
async function downloadGitHubSource(source, fetchFn) {
|
|
508
|
+
const ref = source.type === "github-main" ? "main" : source.version ?? (await fetchJson(
|
|
509
|
+
githubApiUrl("/releases/latest"),
|
|
510
|
+
fetchFn
|
|
511
|
+
)).tag_name;
|
|
512
|
+
const tempRoot = await mkdtemp(path3.join(os2.tmpdir(), "dypt-toolkit-"));
|
|
513
|
+
const tree = await fetchJson(githubApiUrl(`/git/trees/${encodeURIComponent(ref)}?recursive=1`), fetchFn);
|
|
514
|
+
const skillFiles = tree.tree.filter(
|
|
515
|
+
(item) => item.type === "blob" && item.path.startsWith("skills/dypt-cli/")
|
|
516
|
+
);
|
|
517
|
+
await Promise.all(
|
|
518
|
+
skillFiles.map(async (item) => {
|
|
519
|
+
const targetPath = path3.join(tempRoot, item.path);
|
|
520
|
+
await mkdir2(path3.dirname(targetPath), { recursive: true });
|
|
521
|
+
const rawUrl = `https://raw.githubusercontent.com/${TOOLKIT_REPO}/${encodeURIComponent(ref)}/${item.path}`;
|
|
522
|
+
const response = await fetchFn(rawUrl);
|
|
523
|
+
if (!response.ok) {
|
|
524
|
+
throw new Error(`Failed to fetch ${item.path}: ${response.status}`);
|
|
525
|
+
}
|
|
526
|
+
await writeFile2(targetPath, await response.text());
|
|
527
|
+
})
|
|
528
|
+
);
|
|
529
|
+
return {
|
|
530
|
+
cleanup: () => rm2(tempRoot, { recursive: true, force: true }),
|
|
531
|
+
ref,
|
|
532
|
+
root: tempRoot,
|
|
533
|
+
skillPath: path3.join(tempRoot, SKILL_RELATIVE_PATH)
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
async function resolveSource(source, fetchFn) {
|
|
537
|
+
if (source.type === "local") {
|
|
538
|
+
const skillPath = path3.join(source.path, SKILL_RELATIVE_PATH);
|
|
539
|
+
await validateSkillSource(skillPath);
|
|
540
|
+
return {
|
|
541
|
+
cleanup: async () => void 0,
|
|
542
|
+
ref: "local",
|
|
543
|
+
root: source.path,
|
|
544
|
+
skillPath
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
const downloaded = await downloadGitHubSource(source, fetchFn);
|
|
548
|
+
await validateSkillSource(downloaded.skillPath);
|
|
549
|
+
return downloaded;
|
|
550
|
+
}
|
|
551
|
+
function getSourceLabel(source) {
|
|
552
|
+
if (source.type === "local") return "local";
|
|
553
|
+
if (source.type === "github-main") return "github-main";
|
|
554
|
+
return "github-release";
|
|
555
|
+
}
|
|
556
|
+
function resolveAgentSkillPath(target, options = {}) {
|
|
557
|
+
const env = options.env ?? process.env;
|
|
558
|
+
const homeDir = options.homeDir ?? os2.homedir();
|
|
559
|
+
if (target === "codex") {
|
|
560
|
+
return path3.join(env.CODEX_HOME ?? path3.join(homeDir, ".codex"), "skills", "dypt-cli");
|
|
561
|
+
}
|
|
562
|
+
return path3.join(homeDir, ".claude", "skills", "dypt-cli");
|
|
563
|
+
}
|
|
564
|
+
async function installAgentSkill(input) {
|
|
565
|
+
const fetchFn = input.fetch ?? fetch;
|
|
566
|
+
const targetPath = resolveAgentSkillPath(input.target, {
|
|
567
|
+
env: input.env,
|
|
568
|
+
homeDir: input.homeDir
|
|
569
|
+
});
|
|
570
|
+
const source = await resolveSource(input.source, fetchFn);
|
|
571
|
+
try {
|
|
572
|
+
const exists = await pathExists(targetPath);
|
|
573
|
+
const action = exists ? "update" : "install";
|
|
574
|
+
const metadata = exists ? await readMetadata(targetPath) : null;
|
|
575
|
+
if (exists && !input.force && !input.backup) {
|
|
576
|
+
if (!metadata) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
"Installed dypt-cli skill is unmanaged. Use --backup or --force to replace it."
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
const currentHashes = await hashManagedFiles(targetPath);
|
|
582
|
+
if (!hashesMatch(currentHashes, metadata.files)) {
|
|
583
|
+
throw new Error(
|
|
584
|
+
"Installed dypt-cli skill has local modifications. Use --backup or --force to replace it."
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const incomingHashes = await hashManagedFiles(source.skillPath);
|
|
589
|
+
const backupPath = exists && input.backup ? `${targetPath}.backup-${(input.now ?? /* @__PURE__ */ new Date()).toISOString().replaceAll(/[-:]/g, "").replace(".000", "")}` : void 0;
|
|
590
|
+
if (!input.dryRun) {
|
|
591
|
+
if (backupPath) {
|
|
592
|
+
await cp(targetPath, backupPath, { recursive: true });
|
|
593
|
+
}
|
|
594
|
+
await rm2(targetPath, { recursive: true, force: true });
|
|
595
|
+
await mkdir2(path3.dirname(targetPath), { recursive: true });
|
|
596
|
+
await cp(source.skillPath, targetPath, { recursive: true });
|
|
597
|
+
const installMetadata = {
|
|
598
|
+
source: getSourceLabel(input.source),
|
|
599
|
+
repo: TOOLKIT_REPO,
|
|
600
|
+
version: source.ref,
|
|
601
|
+
installedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
602
|
+
files: incomingHashes
|
|
603
|
+
};
|
|
604
|
+
await writeFile2(metadataPath(targetPath), `${JSON.stringify(installMetadata, null, 2)}
|
|
605
|
+
`);
|
|
606
|
+
}
|
|
607
|
+
return {
|
|
608
|
+
action,
|
|
609
|
+
backupPath,
|
|
610
|
+
dryRun: Boolean(input.dryRun),
|
|
611
|
+
path: targetPath,
|
|
612
|
+
target: input.target,
|
|
613
|
+
version: source.ref
|
|
614
|
+
};
|
|
615
|
+
} finally {
|
|
616
|
+
await source.cleanup();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
async function appendAgentInstructions(input) {
|
|
620
|
+
const existing = await pathExists(input.filePath) ? await readFile2(input.filePath, "utf8") : "";
|
|
621
|
+
if (!input.force && existing.includes("## Work Tracking with dypt")) {
|
|
622
|
+
throw new Error(
|
|
623
|
+
`${input.filePath} already contains a dypt work-tracking section. Use --force to append anyway.`
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
if (!input.dryRun) {
|
|
627
|
+
await mkdir2(path3.dirname(input.filePath), { recursive: true });
|
|
628
|
+
const separator = existing.endsWith("\n") || existing.length === 0 ? "\n" : "\n\n";
|
|
629
|
+
await writeFile2(input.filePath, `${existing}${separator}${input.snippet}`);
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
action: "append",
|
|
633
|
+
dryRun: Boolean(input.dryRun),
|
|
634
|
+
filePath: input.filePath
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
async function latestGitHubRelease(fetchFn) {
|
|
638
|
+
return (await fetchJson(
|
|
639
|
+
githubApiUrl("/releases/latest"),
|
|
640
|
+
fetchFn
|
|
641
|
+
)).tag_name;
|
|
642
|
+
}
|
|
643
|
+
async function getAgentStatus(input) {
|
|
644
|
+
const fetchFn = input.fetch ?? fetch;
|
|
645
|
+
const targets = await Promise.all(
|
|
646
|
+
["codex", "claude"].map(async (target) => {
|
|
647
|
+
const targetPath = resolveAgentSkillPath(target, input);
|
|
648
|
+
const installed = await pathExists(targetPath);
|
|
649
|
+
const metadata = installed ? await readMetadata(targetPath) : null;
|
|
650
|
+
const modified = installed && metadata ? !hashesMatch(await hashManagedFiles(targetPath), metadata.files) : installed;
|
|
651
|
+
return {
|
|
652
|
+
target,
|
|
653
|
+
path: targetPath,
|
|
654
|
+
installed,
|
|
655
|
+
version: metadata?.version,
|
|
656
|
+
modified
|
|
657
|
+
};
|
|
658
|
+
})
|
|
659
|
+
);
|
|
660
|
+
let latestVersion;
|
|
661
|
+
try {
|
|
662
|
+
latestVersion = await latestGitHubRelease(fetchFn);
|
|
663
|
+
} catch {
|
|
664
|
+
latestVersion = void 0;
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
latestVersion,
|
|
668
|
+
targets: targets.map((target) => ({
|
|
669
|
+
...target,
|
|
670
|
+
updateAvailable: Boolean(latestVersion && target.version && latestVersion !== target.version)
|
|
671
|
+
}))
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/commands/agent/install.ts
|
|
676
|
+
function resolveSource2(input) {
|
|
677
|
+
if (input.source === "local") {
|
|
678
|
+
if (!input.path) {
|
|
679
|
+
throw new Error("Use --path <local-toolkit-path> with --source local.");
|
|
680
|
+
}
|
|
681
|
+
return { type: "local", path: input.path };
|
|
682
|
+
}
|
|
683
|
+
if (input.source === "github-main") {
|
|
684
|
+
return { type: "github-main" };
|
|
685
|
+
}
|
|
686
|
+
return {
|
|
687
|
+
type: "github-release",
|
|
688
|
+
version: input.version
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
async function runAgentInstall(input, deps) {
|
|
692
|
+
const result = await installAgentSkill({
|
|
693
|
+
target: input.target,
|
|
694
|
+
source: resolveSource2(input),
|
|
695
|
+
dryRun: input.dryRun,
|
|
696
|
+
yes: input.yes,
|
|
697
|
+
force: input.force,
|
|
698
|
+
backup: input.backup,
|
|
699
|
+
isTty: deps.isTty
|
|
700
|
+
});
|
|
701
|
+
if (input.json) {
|
|
702
|
+
deps.printJson(result);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
deps.printTable(result);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// src/commands/agent/installInstructions.ts
|
|
709
|
+
async function runAgentInstallInstructions(input, deps) {
|
|
710
|
+
const result = input.append ? await appendAgentInstructions({
|
|
711
|
+
filePath: input.append,
|
|
712
|
+
snippet: AGENT_INSTRUCTIONS_SNIPPET,
|
|
713
|
+
dryRun: input.dryRun,
|
|
714
|
+
force: input.force
|
|
715
|
+
}) : { snippet: AGENT_INSTRUCTIONS_SNIPPET };
|
|
716
|
+
if (input.json) {
|
|
717
|
+
deps.printJson(result);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
deps.printTable(result);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// src/commands/agent/status.ts
|
|
724
|
+
async function runAgentStatus(input, deps) {
|
|
725
|
+
const result = await deps.getStatus();
|
|
726
|
+
if (input.json) {
|
|
727
|
+
deps.printJson(result);
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
deps.printTable(result);
|
|
731
|
+
}
|
|
732
|
+
|
|
384
733
|
// src/commands/auth/status.ts
|
|
385
734
|
async function runStatus(input, deps) {
|
|
386
735
|
const result = await deps.getStatus();
|
|
@@ -475,7 +824,10 @@ async function runNoteSet(input, deps) {
|
|
|
475
824
|
async function runTaskCreate(input, deps) {
|
|
476
825
|
const result = await deps.createTask({
|
|
477
826
|
title: input.title,
|
|
478
|
-
parentId: input.parentId ? Number(input.parentId) : null
|
|
827
|
+
parentId: input.parentId ? Number(input.parentId) : null,
|
|
828
|
+
priority: input.priority,
|
|
829
|
+
deadline: input.deadline,
|
|
830
|
+
expectedTimeTaken: input.expectedTimeTaken
|
|
479
831
|
});
|
|
480
832
|
if (input.json) {
|
|
481
833
|
deps.printJson(result);
|
|
@@ -723,7 +1075,7 @@ async function runTaskUpdateMany(input, deps) {
|
|
|
723
1075
|
}
|
|
724
1076
|
|
|
725
1077
|
// src/commands/task/cleanupPlan.ts
|
|
726
|
-
import { readFile as
|
|
1078
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
727
1079
|
async function loadCleanupPlan(input) {
|
|
728
1080
|
if (input.plan && input.planFile) {
|
|
729
1081
|
throw new Error("Use either --plan or --plan-file, not both.");
|
|
@@ -731,7 +1083,7 @@ async function loadCleanupPlan(input) {
|
|
|
731
1083
|
if (!input.plan && !input.planFile) {
|
|
732
1084
|
throw new Error("Provide a cleanup plan with --plan or --plan-file.");
|
|
733
1085
|
}
|
|
734
|
-
const raw = input.plan ?? await
|
|
1086
|
+
const raw = input.plan ?? await readFile3(input.planFile, "utf8");
|
|
735
1087
|
try {
|
|
736
1088
|
return JSON.parse(raw);
|
|
737
1089
|
} catch {
|
|
@@ -1014,6 +1366,17 @@ function isTaskCollection(value) {
|
|
|
1014
1366
|
function isAuthStatusLike(value) {
|
|
1015
1367
|
return isRecord(value) && isRecord(value.user) && typeof value.user.userId === "string" && isRecord(value.token) && typeof value.token.id === "number" && typeof value.token.label === "string" && typeof value.token.scope === "string";
|
|
1016
1368
|
}
|
|
1369
|
+
function isAgentInstallResultLike(value) {
|
|
1370
|
+
return isRecord(value) && typeof value.target === "string" && (value.action === "install" || value.action === "update") && typeof value.path === "string";
|
|
1371
|
+
}
|
|
1372
|
+
function isAgentInstructionsLike(value) {
|
|
1373
|
+
return isRecord(value) && (typeof value.snippet === "string" || value.action === "append");
|
|
1374
|
+
}
|
|
1375
|
+
function isAgentStatusLike(value) {
|
|
1376
|
+
return isRecord(value) && Array.isArray(value.targets) && value.targets.every(
|
|
1377
|
+
(target) => isRecord(target) && typeof target.target === "string" && typeof target.path === "string" && typeof target.installed === "boolean"
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1017
1380
|
function isTaskDetailLike(value) {
|
|
1018
1381
|
return isRecord(value) && isTaskLike(value.task) && (value.taskChildren === void 0 || Array.isArray(value.taskChildren) && value.taskChildren.every(isTaskLike)) && (value.taskParents === void 0 || Array.isArray(value.taskParents) && value.taskParents.every(isTaskLike));
|
|
1019
1382
|
}
|
|
@@ -1463,12 +1826,18 @@ function renderTaskSummary(value, color) {
|
|
|
1463
1826
|
}
|
|
1464
1827
|
function renderPlanningMetadataGaps(value, color) {
|
|
1465
1828
|
const lines = [
|
|
1466
|
-
`${colorize(`#${value.task.id}`, "cyan", color)} ${
|
|
1829
|
+
`${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
|
|
1830
|
+
`${value.task.title} planning metadata gaps`,
|
|
1831
|
+
"bold",
|
|
1832
|
+
color
|
|
1833
|
+
)}`
|
|
1467
1834
|
];
|
|
1468
1835
|
if (value.items.length === 0) {
|
|
1836
|
+
lines.push("");
|
|
1469
1837
|
lines.push(dim("No planning metadata gaps found.", color));
|
|
1470
1838
|
return lines.join("\n");
|
|
1471
1839
|
}
|
|
1840
|
+
lines.push("");
|
|
1472
1841
|
lines.push(
|
|
1473
1842
|
...value.items.map(
|
|
1474
1843
|
(item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
|
|
@@ -1479,12 +1848,18 @@ function renderPlanningMetadataGaps(value, color) {
|
|
|
1479
1848
|
}
|
|
1480
1849
|
function renderNextActions(value, color) {
|
|
1481
1850
|
const lines = [
|
|
1482
|
-
`${colorize(`#${value.task.id}`, "cyan", color)} ${
|
|
1851
|
+
`${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
|
|
1852
|
+
`${value.task.title} likely next actions`,
|
|
1853
|
+
"bold",
|
|
1854
|
+
color
|
|
1855
|
+
)}`
|
|
1483
1856
|
];
|
|
1484
1857
|
if (value.items.length === 0) {
|
|
1858
|
+
lines.push("");
|
|
1485
1859
|
lines.push(dim("No next-action candidates found.", color));
|
|
1486
1860
|
return lines.join("\n");
|
|
1487
1861
|
}
|
|
1862
|
+
lines.push("");
|
|
1488
1863
|
lines.push(
|
|
1489
1864
|
...value.items.map(
|
|
1490
1865
|
(item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
|
|
@@ -1495,12 +1870,18 @@ function renderNextActions(value, color) {
|
|
|
1495
1870
|
}
|
|
1496
1871
|
function renderBranchFocusSignals(value, color) {
|
|
1497
1872
|
const lines = [
|
|
1498
|
-
`${colorize(`#${value.task.id}`, "cyan", color)} ${
|
|
1873
|
+
`${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
|
|
1874
|
+
`${value.task.title} branch focus signals`,
|
|
1875
|
+
"bold",
|
|
1876
|
+
color
|
|
1877
|
+
)}`
|
|
1499
1878
|
];
|
|
1500
1879
|
if (value.items.length === 0) {
|
|
1880
|
+
lines.push("");
|
|
1501
1881
|
lines.push(dim("No focus branches found.", color));
|
|
1502
1882
|
return lines.join("\n");
|
|
1503
1883
|
}
|
|
1884
|
+
lines.push("");
|
|
1504
1885
|
lines.push(
|
|
1505
1886
|
...value.items.map(
|
|
1506
1887
|
(item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
|
|
@@ -1682,6 +2063,48 @@ function renderAuthStatus(result, color) {
|
|
|
1682
2063
|
`Last used: ${formatDateTimeValue(result.token.lastUsedAt)}`
|
|
1683
2064
|
].join("\n");
|
|
1684
2065
|
}
|
|
2066
|
+
function renderAgentInstallResult(result, color) {
|
|
2067
|
+
const verb = result.action === "install" ? result.dryRun ? "Would install" : "Installed" : result.dryRun ? "Would update" : "Updated";
|
|
2068
|
+
const lines = [
|
|
2069
|
+
`${colorize(verb, result.dryRun ? "yellow" : "green", color)} dypt agent guidance for ${result.target}`,
|
|
2070
|
+
`Path: ${result.path}`
|
|
2071
|
+
];
|
|
2072
|
+
if (result.version) {
|
|
2073
|
+
lines.push(`Version: ${result.version}`);
|
|
2074
|
+
}
|
|
2075
|
+
if (result.backupPath) {
|
|
2076
|
+
lines.push(`Backup: ${result.backupPath}`);
|
|
2077
|
+
}
|
|
2078
|
+
return lines.join("\n");
|
|
2079
|
+
}
|
|
2080
|
+
function renderAgentInstructions(result, color) {
|
|
2081
|
+
if (typeof result.snippet === "string") {
|
|
2082
|
+
return result.snippet.trimEnd();
|
|
2083
|
+
}
|
|
2084
|
+
if (result.action === "append" && result.filePath) {
|
|
2085
|
+
const verb = result.dryRun ? "Would append" : "Appended";
|
|
2086
|
+
return `${colorize(verb, result.dryRun ? "yellow" : "green", color)} dypt instructions to ${result.filePath}`;
|
|
2087
|
+
}
|
|
2088
|
+
return JSON.stringify(result, null, 2);
|
|
2089
|
+
}
|
|
2090
|
+
function renderAgentStatus(result, color) {
|
|
2091
|
+
const lines = [
|
|
2092
|
+
"dypt agent guidance status",
|
|
2093
|
+
`Latest release: ${result.latestVersion ?? "-"}`,
|
|
2094
|
+
"",
|
|
2095
|
+
...result.targets.map((target) => {
|
|
2096
|
+
const status = target.installed ? target.modified ? colorize("modified", "yellow", color) : colorize("installed", "green", color) : dim("not installed", color);
|
|
2097
|
+
const update = target.updateAvailable === true ? colorize("update available", "yellow", color) : "up to date";
|
|
2098
|
+
return [
|
|
2099
|
+
`${target.target}: ${status}`,
|
|
2100
|
+
` Path: ${target.path}`,
|
|
2101
|
+
` Version: ${target.version ?? "-"}`,
|
|
2102
|
+
` Update: ${target.installed ? update : "-"}`
|
|
2103
|
+
].join("\n");
|
|
2104
|
+
})
|
|
2105
|
+
];
|
|
2106
|
+
return lines.join("\n");
|
|
2107
|
+
}
|
|
1685
2108
|
function formatHumanOutput(value, options = {}) {
|
|
1686
2109
|
const color = options.color ?? Boolean(process.stdout.isTTY);
|
|
1687
2110
|
if (Array.isArray(value) && value.length === 0) {
|
|
@@ -1711,6 +2134,15 @@ function formatHumanOutput(value, options = {}) {
|
|
|
1711
2134
|
if (isAuthStatusLike(value)) {
|
|
1712
2135
|
return renderAuthStatus(value, color);
|
|
1713
2136
|
}
|
|
2137
|
+
if (isAgentInstallResultLike(value)) {
|
|
2138
|
+
return renderAgentInstallResult(value, color);
|
|
2139
|
+
}
|
|
2140
|
+
if (isAgentInstructionsLike(value)) {
|
|
2141
|
+
return renderAgentInstructions(value, color);
|
|
2142
|
+
}
|
|
2143
|
+
if (isAgentStatusLike(value)) {
|
|
2144
|
+
return renderAgentStatus(value, color);
|
|
2145
|
+
}
|
|
1714
2146
|
if (isDependencyCollection(value)) {
|
|
1715
2147
|
return renderDependencies(value, color);
|
|
1716
2148
|
}
|
|
@@ -1775,6 +2207,8 @@ var taskStatusChoices = [
|
|
|
1775
2207
|
"completed"
|
|
1776
2208
|
];
|
|
1777
2209
|
var taskPriorityChoices = ["low", "mid", "medium", "high"];
|
|
2210
|
+
var agentTargetChoices = ["codex", "claude"];
|
|
2211
|
+
var agentSourceChoices = ["github-release", "github-main", "local"];
|
|
1778
2212
|
function normalizePriority(priority) {
|
|
1779
2213
|
if (!priority) return void 0;
|
|
1780
2214
|
if (priority === "medium") return "mid";
|
|
@@ -1849,8 +2283,8 @@ function resolveTaskRefFromSearchMatches(ref, matches) {
|
|
|
1849
2283
|
}
|
|
1850
2284
|
if (exactMatches.length > 1) {
|
|
1851
2285
|
const formattedMatches = exactMatches.map((task) => {
|
|
1852
|
-
const
|
|
1853
|
-
return `- #${task.id} ${
|
|
2286
|
+
const path4 = task.pathTitles?.join(" > ") ?? (task.parentTitle ? `${task.parentTitle} > ${task.title}` : task.title);
|
|
2287
|
+
return `- #${task.id} ${path4}`;
|
|
1854
2288
|
}).join("\n");
|
|
1855
2289
|
throw new Error(`Task reference is ambiguous: ${ref}
|
|
1856
2290
|
${formattedMatches}`);
|
|
@@ -1927,6 +2361,67 @@ function buildCli() {
|
|
|
1927
2361
|
auth.command("logout").description("Remove the local CLI token").action(async () => {
|
|
1928
2362
|
await runLogout(createDefaultLogoutDeps());
|
|
1929
2363
|
});
|
|
2364
|
+
const agent = addGroupHelpAction(
|
|
2365
|
+
program.command("agent").description("Agent guidance commands")
|
|
2366
|
+
);
|
|
2367
|
+
agent.command("install").description("Install or update dypt agent guidance").addArgument(
|
|
2368
|
+
new Argument(
|
|
2369
|
+
"<target>",
|
|
2370
|
+
`agent target (${agentTargetChoices.join("|")})`
|
|
2371
|
+
).choices([...agentTargetChoices])
|
|
2372
|
+
).addOption(
|
|
2373
|
+
new Option(
|
|
2374
|
+
"--source <source>",
|
|
2375
|
+
`toolkit source (${agentSourceChoices.join("|")})`
|
|
2376
|
+
).choices([...agentSourceChoices]).default("github-release")
|
|
2377
|
+
).option("--version <tag>", "GitHub release tag to install").option("--path <local-toolkit-path>", "local dypt-toolkit path").option("--dry-run", "show planned install without writing files").option("--yes", "approve safe prompts").option("--force", "replace modified or unmanaged installs").option("--backup", "back up an existing install before replacing it").option("--json", "print JSON output").action(
|
|
2378
|
+
async (target, options) => {
|
|
2379
|
+
await runAgentInstall(
|
|
2380
|
+
{
|
|
2381
|
+
target,
|
|
2382
|
+
source: options.source,
|
|
2383
|
+
version: options.version,
|
|
2384
|
+
path: options.path,
|
|
2385
|
+
dryRun: Boolean(options.dryRun),
|
|
2386
|
+
yes: Boolean(options.yes),
|
|
2387
|
+
force: Boolean(options.force),
|
|
2388
|
+
backup: Boolean(options.backup),
|
|
2389
|
+
json: Boolean(options.json)
|
|
2390
|
+
},
|
|
2391
|
+
{
|
|
2392
|
+
isTty: Boolean(process.stdout.isTTY),
|
|
2393
|
+
printJson,
|
|
2394
|
+
printTable
|
|
2395
|
+
}
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2398
|
+
);
|
|
2399
|
+
agent.command("status").description("Show dypt agent guidance install status").option("--json", "print JSON output").action(async (options) => {
|
|
2400
|
+
await runAgentStatus(
|
|
2401
|
+
{ json: Boolean(options.json) },
|
|
2402
|
+
{
|
|
2403
|
+
getStatus: () => getAgentStatus({}),
|
|
2404
|
+
printJson,
|
|
2405
|
+
printTable
|
|
2406
|
+
}
|
|
2407
|
+
);
|
|
2408
|
+
});
|
|
2409
|
+
agent.command("install-instructions").description("Print or append repo-level dypt agent instructions").option("--append <file>", "append instructions to the given file").option("--dry-run", "show planned change without writing files").option("--force", "append even if a dypt section already exists").option("--yes", "approve safe prompts").option("--json", "print JSON output").action(
|
|
2410
|
+
async (options) => {
|
|
2411
|
+
await runAgentInstallInstructions(
|
|
2412
|
+
{
|
|
2413
|
+
append: options.append,
|
|
2414
|
+
dryRun: Boolean(options.dryRun),
|
|
2415
|
+
force: Boolean(options.force),
|
|
2416
|
+
json: Boolean(options.json)
|
|
2417
|
+
},
|
|
2418
|
+
{
|
|
2419
|
+
printJson,
|
|
2420
|
+
printTable
|
|
2421
|
+
}
|
|
2422
|
+
);
|
|
2423
|
+
}
|
|
2424
|
+
);
|
|
1930
2425
|
const task = addGroupHelpAction(
|
|
1931
2426
|
program.command("task").description("Task commands")
|
|
1932
2427
|
);
|
|
@@ -2280,12 +2775,23 @@ function buildCli() {
|
|
|
2280
2775
|
if (taskNote) {
|
|
2281
2776
|
addTaskNoteCommands(taskNote);
|
|
2282
2777
|
}
|
|
2283
|
-
task.command("create").argument("<title>").option("--parent <taskId>", "parent task id").
|
|
2778
|
+
task.command("create").argument("<title>").option("--parent <taskId>", "parent task id").addOption(
|
|
2779
|
+
new Option(
|
|
2780
|
+
"--priority <priority>",
|
|
2781
|
+
`task priority (${taskPriorityChoices.join("|")})`
|
|
2782
|
+
).choices([...taskPriorityChoices])
|
|
2783
|
+
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--json", "print JSON output").action(
|
|
2284
2784
|
async (title, options) => {
|
|
2285
2785
|
await runTaskCreate(
|
|
2286
2786
|
{
|
|
2287
2787
|
title,
|
|
2288
2788
|
parentId: options.parent,
|
|
2789
|
+
priority: normalizePriority(options.priority),
|
|
2790
|
+
deadline: options.deadline ? parseDateOption(options.deadline, "start") : void 0,
|
|
2791
|
+
expectedTimeTaken: parseIntegerOption(
|
|
2792
|
+
options.expectedTime,
|
|
2793
|
+
"expected-time"
|
|
2794
|
+
),
|
|
2289
2795
|
json: Boolean(options.json)
|
|
2290
2796
|
},
|
|
2291
2797
|
{
|
|
@@ -2468,15 +2974,21 @@ function buildCli() {
|
|
|
2468
2974
|
}
|
|
2469
2975
|
);
|
|
2470
2976
|
const cleanup = addGroupHelpAction(
|
|
2471
|
-
task.command("cleanup").description(
|
|
2977
|
+
task.command("cleanup").description(
|
|
2978
|
+
[
|
|
2979
|
+
"Cleanup plan commands",
|
|
2980
|
+
"",
|
|
2981
|
+
"Use named cleanup workflows for task refs. Use preview/apply only with explicit cleanup plan JSON."
|
|
2982
|
+
].join("\n")
|
|
2983
|
+
)
|
|
2472
2984
|
);
|
|
2473
2985
|
cleanup.command("relocate-and-collapse").description("Move surviving direct children out of a wrapper and collapse it if emptied").requiredOption("--wrapper <ref>", "wrapper task to clean up").requiredOption("--tasks <refs...>", "surviving direct child tasks to move").requiredOption("--to <ref>", 'destination parent task or "root"').option("--preview", "preview the workflow without mutating (default)").option("--yes", "apply the workflow immediately").option("--json", "print JSON output").addHelpText(
|
|
2474
2986
|
"after",
|
|
2475
2987
|
[
|
|
2476
2988
|
"",
|
|
2477
2989
|
"Examples:",
|
|
2478
|
-
'
|
|
2479
|
-
"
|
|
2990
|
+
' dypt task cleanup relocate-and-collapse --wrapper "Old wrapper" --tasks 42 43 --to "Canonical branch"',
|
|
2991
|
+
" dypt task cleanup relocate-and-collapse --wrapper 100 --tasks 101 --to root --yes --json"
|
|
2480
2992
|
].join("\n")
|
|
2481
2993
|
).action(
|
|
2482
2994
|
async (options) => {
|
|
@@ -2507,13 +3019,13 @@ function buildCli() {
|
|
|
2507
3019
|
);
|
|
2508
3020
|
}
|
|
2509
3021
|
);
|
|
2510
|
-
cleanup.command("preview").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--json", "print JSON output").addHelpText(
|
|
3022
|
+
cleanup.command("preview").description("Preview an explicit cleanup plan JSON").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--json", "print JSON output").addHelpText(
|
|
2511
3023
|
"after",
|
|
2512
3024
|
[
|
|
2513
3025
|
"",
|
|
2514
3026
|
"Examples:",
|
|
2515
|
-
`
|
|
2516
|
-
"
|
|
3027
|
+
` dypt task cleanup preview --plan '{"operations":[{"type":"archive","taskIds":[42]}]}'`,
|
|
3028
|
+
" dypt task cleanup preview --plan-file /tmp/cleanup-plan.json --json"
|
|
2517
3029
|
].join("\n")
|
|
2518
3030
|
).action(
|
|
2519
3031
|
async (options) => {
|
|
@@ -2531,13 +3043,13 @@ function buildCli() {
|
|
|
2531
3043
|
);
|
|
2532
3044
|
}
|
|
2533
3045
|
);
|
|
2534
|
-
cleanup.command("apply").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--yes", "skip confirmation").option("--json", "print JSON output").addHelpText(
|
|
3046
|
+
cleanup.command("apply").description("Apply an explicit cleanup plan JSON").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--yes", "skip confirmation").option("--json", "print JSON output").addHelpText(
|
|
2535
3047
|
"after",
|
|
2536
3048
|
[
|
|
2537
3049
|
"",
|
|
2538
3050
|
"Examples:",
|
|
2539
|
-
`
|
|
2540
|
-
"
|
|
3051
|
+
` dypt task cleanup apply --plan '{"operations":[{"type":"archive","taskIds":[42]}]}' --yes`,
|
|
3052
|
+
" dypt task cleanup apply --plan-file /tmp/cleanup-plan.json --json --yes"
|
|
2541
3053
|
].join("\n")
|
|
2542
3054
|
).action(
|
|
2543
3055
|
async (options) => {
|