@dypt/cli 0.1.2 → 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 +482 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,35 @@ dypt task list --limit 10 --json
|
|
|
71
71
|
dypt task get 123 --json
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
## Agent guidance
|
|
75
|
+
|
|
76
|
+
Install or inspect dypt agent guidance for supported AI coding tools:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
dypt agent status
|
|
80
|
+
dypt agent install codex
|
|
81
|
+
dypt agent install claude
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
By default, `dypt agent install` installs the latest released `dypt-cli` skill
|
|
85
|
+
from the public [`poyzer-tech/dypt-toolkit`](https://github.com/poyzer-tech/dypt-toolkit)
|
|
86
|
+
repository. It is safe to rerun: missing installs are created, managed
|
|
87
|
+
unmodified installs are updated, and locally modified installs require an
|
|
88
|
+
explicit `--backup` or `--force`.
|
|
89
|
+
|
|
90
|
+
For development or testing, install from a local toolkit checkout:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
dypt agent install codex --source local --path /path/to/dypt-toolkit --dry-run
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Print repo-level `AGENTS.md` / `CLAUDE.md` guidance, or append it explicitly:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
dypt agent install-instructions
|
|
100
|
+
dypt agent install-instructions --append AGENTS.md
|
|
101
|
+
```
|
|
102
|
+
|
|
74
103
|
## Support policy
|
|
75
104
|
|
|
76
105
|
- the CLI is currently versioned as an early `0.x` release, so command shape and
|
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();
|
|
@@ -726,7 +1075,7 @@ async function runTaskUpdateMany(input, deps) {
|
|
|
726
1075
|
}
|
|
727
1076
|
|
|
728
1077
|
// src/commands/task/cleanupPlan.ts
|
|
729
|
-
import { readFile as
|
|
1078
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
730
1079
|
async function loadCleanupPlan(input) {
|
|
731
1080
|
if (input.plan && input.planFile) {
|
|
732
1081
|
throw new Error("Use either --plan or --plan-file, not both.");
|
|
@@ -734,7 +1083,7 @@ async function loadCleanupPlan(input) {
|
|
|
734
1083
|
if (!input.plan && !input.planFile) {
|
|
735
1084
|
throw new Error("Provide a cleanup plan with --plan or --plan-file.");
|
|
736
1085
|
}
|
|
737
|
-
const raw = input.plan ?? await
|
|
1086
|
+
const raw = input.plan ?? await readFile3(input.planFile, "utf8");
|
|
738
1087
|
try {
|
|
739
1088
|
return JSON.parse(raw);
|
|
740
1089
|
} catch {
|
|
@@ -1017,6 +1366,17 @@ function isTaskCollection(value) {
|
|
|
1017
1366
|
function isAuthStatusLike(value) {
|
|
1018
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";
|
|
1019
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
|
+
}
|
|
1020
1380
|
function isTaskDetailLike(value) {
|
|
1021
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));
|
|
1022
1382
|
}
|
|
@@ -1703,6 +2063,48 @@ function renderAuthStatus(result, color) {
|
|
|
1703
2063
|
`Last used: ${formatDateTimeValue(result.token.lastUsedAt)}`
|
|
1704
2064
|
].join("\n");
|
|
1705
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
|
+
}
|
|
1706
2108
|
function formatHumanOutput(value, options = {}) {
|
|
1707
2109
|
const color = options.color ?? Boolean(process.stdout.isTTY);
|
|
1708
2110
|
if (Array.isArray(value) && value.length === 0) {
|
|
@@ -1732,6 +2134,15 @@ function formatHumanOutput(value, options = {}) {
|
|
|
1732
2134
|
if (isAuthStatusLike(value)) {
|
|
1733
2135
|
return renderAuthStatus(value, color);
|
|
1734
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
|
+
}
|
|
1735
2146
|
if (isDependencyCollection(value)) {
|
|
1736
2147
|
return renderDependencies(value, color);
|
|
1737
2148
|
}
|
|
@@ -1796,6 +2207,8 @@ var taskStatusChoices = [
|
|
|
1796
2207
|
"completed"
|
|
1797
2208
|
];
|
|
1798
2209
|
var taskPriorityChoices = ["low", "mid", "medium", "high"];
|
|
2210
|
+
var agentTargetChoices = ["codex", "claude"];
|
|
2211
|
+
var agentSourceChoices = ["github-release", "github-main", "local"];
|
|
1799
2212
|
function normalizePriority(priority) {
|
|
1800
2213
|
if (!priority) return void 0;
|
|
1801
2214
|
if (priority === "medium") return "mid";
|
|
@@ -1870,8 +2283,8 @@ function resolveTaskRefFromSearchMatches(ref, matches) {
|
|
|
1870
2283
|
}
|
|
1871
2284
|
if (exactMatches.length > 1) {
|
|
1872
2285
|
const formattedMatches = exactMatches.map((task) => {
|
|
1873
|
-
const
|
|
1874
|
-
return `- #${task.id} ${
|
|
2286
|
+
const path4 = task.pathTitles?.join(" > ") ?? (task.parentTitle ? `${task.parentTitle} > ${task.title}` : task.title);
|
|
2287
|
+
return `- #${task.id} ${path4}`;
|
|
1875
2288
|
}).join("\n");
|
|
1876
2289
|
throw new Error(`Task reference is ambiguous: ${ref}
|
|
1877
2290
|
${formattedMatches}`);
|
|
@@ -1948,6 +2361,67 @@ function buildCli() {
|
|
|
1948
2361
|
auth.command("logout").description("Remove the local CLI token").action(async () => {
|
|
1949
2362
|
await runLogout(createDefaultLogoutDeps());
|
|
1950
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
|
+
);
|
|
1951
2425
|
const task = addGroupHelpAction(
|
|
1952
2426
|
program.command("task").description("Task commands")
|
|
1953
2427
|
);
|