@dypt/cli 0.1.19 → 0.1.21
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 +16 -0
- package/dist/index.js +90 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,22 @@ dypt auth login
|
|
|
25
25
|
dypt auth status
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
By default on macOS, dypt stores CLI credentials in Keychain and falls back to
|
|
29
|
+
the URL-scoped file under `~/.config/dypt/tokens` only when Keychain is
|
|
30
|
+
unavailable. To deliberately use one file and skip Keychain entirely, set an
|
|
31
|
+
absolute path:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
DYPT_TOKEN_FILE=/absolute/path/to/dypt-token.json dypt auth login
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Keep `DYPT_TOKEN_FILE` set to the same path for subsequent commands and
|
|
38
|
+
`dypt auth logout`. When explicitly configured, a missing or invalid file does
|
|
39
|
+
not fall back to Keychain or another identity. The CLI creates the token file
|
|
40
|
+
with owner-only permissions and tightens an existing regular file before
|
|
41
|
+
writing. It refuses symlink and non-file destinations. The containing directory
|
|
42
|
+
and any sandbox access to the file remain the user's responsibility.
|
|
43
|
+
|
|
28
44
|
### List tasks
|
|
29
45
|
|
|
30
46
|
See tasks from your account:
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Argument, Command, Option } from "commander";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "@dypt/cli",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.21",
|
|
13
13
|
description: "Command-line interface for dypt task management",
|
|
14
14
|
license: "SEE LICENSE IN LICENSE",
|
|
15
15
|
homepage: "https://dypt.app",
|
|
@@ -67,6 +67,17 @@ function getScopedTokenFilePath(baseUrl) {
|
|
|
67
67
|
const scope = `${url.protocol.slice(0, -1)}-${url.hostname}${url.port ? `-${url.port}` : ""}`.replace(/[^a-zA-Z0-9.-]/g, "-").toLowerCase();
|
|
68
68
|
return path.join(getConfigDir(), "tokens", `${scope}.json`);
|
|
69
69
|
}
|
|
70
|
+
function getConfiguredTokenFilePath() {
|
|
71
|
+
const configuredPath = process.env.DYPT_TOKEN_FILE;
|
|
72
|
+
if (configuredPath === void 0) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const normalizedPath = configuredPath.trim();
|
|
76
|
+
if (!normalizedPath || !path.isAbsolute(normalizedPath)) {
|
|
77
|
+
throw new Error("DYPT_TOKEN_FILE must be a non-empty absolute path");
|
|
78
|
+
}
|
|
79
|
+
return path.normalize(normalizedPath);
|
|
80
|
+
}
|
|
70
81
|
function getBaseUrl() {
|
|
71
82
|
return (process.env.DYPT_BASE_URL ?? process.env.NEXT_PUBLIC_URL ?? "https://dypt.app").replace(/\/+$/, "");
|
|
72
83
|
}
|
|
@@ -77,7 +88,8 @@ function getDefaultDeviceLabel() {
|
|
|
77
88
|
|
|
78
89
|
// src/lib/keychain.ts
|
|
79
90
|
import { execFile } from "child_process";
|
|
80
|
-
import {
|
|
91
|
+
import { constants } from "fs";
|
|
92
|
+
import { mkdir, open, readFile, rm } from "fs/promises";
|
|
81
93
|
import path2 from "path";
|
|
82
94
|
import { promisify } from "util";
|
|
83
95
|
var execFileAsync = promisify(execFile);
|
|
@@ -101,6 +113,19 @@ async function removeFallbackTokenFile(filePath) {
|
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
115
|
}
|
|
116
|
+
function resolveTokenStorage(baseUrl, filePath) {
|
|
117
|
+
if (filePath !== void 0) {
|
|
118
|
+
return { filePath, useKeychain: true };
|
|
119
|
+
}
|
|
120
|
+
const configuredFilePath = getConfiguredTokenFilePath();
|
|
121
|
+
if (configuredFilePath) {
|
|
122
|
+
return { filePath: configuredFilePath, useKeychain: false };
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
filePath: getScopedTokenFilePath(baseUrl),
|
|
126
|
+
useKeychain: true
|
|
127
|
+
};
|
|
128
|
+
}
|
|
104
129
|
function getCredentialScope(baseUrl = getBaseUrl()) {
|
|
105
130
|
const url = new URL(baseUrl);
|
|
106
131
|
return `${url.protocol}//${url.host}`;
|
|
@@ -174,13 +199,16 @@ async function clearMacOsKeychainToken(baseUrl) {
|
|
|
174
199
|
}
|
|
175
200
|
}
|
|
176
201
|
}
|
|
177
|
-
async function readCliToken(baseUrl = getBaseUrl(), filePath
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
|
|
202
|
+
async function readCliToken(baseUrl = getBaseUrl(), filePath) {
|
|
203
|
+
const storage = resolveTokenStorage(baseUrl, filePath);
|
|
204
|
+
if (storage.useKeychain) {
|
|
205
|
+
const keychainRecord = await readMacOsKeychainToken(baseUrl);
|
|
206
|
+
if (keychainRecord) {
|
|
207
|
+
return keychainRecord;
|
|
208
|
+
}
|
|
181
209
|
}
|
|
182
210
|
try {
|
|
183
|
-
const raw = await readFile(filePath, "utf8");
|
|
211
|
+
const raw = await readFile(storage.filePath, "utf8");
|
|
184
212
|
const parsed = JSON.parse(raw);
|
|
185
213
|
if (!parsed.accessToken || !parsed.expiresAt) {
|
|
186
214
|
return null;
|
|
@@ -196,35 +224,50 @@ async function readCliToken(baseUrl = getBaseUrl(), filePath = getScopedTokenFil
|
|
|
196
224
|
throw error;
|
|
197
225
|
}
|
|
198
226
|
}
|
|
199
|
-
async function saveCliToken(accessToken, expiresAt, baseUrl = getBaseUrl(), filePath
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
await writeFile(
|
|
211
|
-
filePath,
|
|
212
|
-
`${JSON.stringify({ accessToken, expiresAt }, null, 2)}
|
|
213
|
-
`,
|
|
214
|
-
{
|
|
215
|
-
mode: 384
|
|
227
|
+
async function saveCliToken(accessToken, expiresAt, baseUrl = getBaseUrl(), filePath) {
|
|
228
|
+
const storage = resolveTokenStorage(baseUrl, filePath);
|
|
229
|
+
if (storage.useKeychain) {
|
|
230
|
+
const wroteToKeychain = await saveMacOsKeychainToken(
|
|
231
|
+
accessToken,
|
|
232
|
+
expiresAt,
|
|
233
|
+
baseUrl
|
|
234
|
+
);
|
|
235
|
+
if (wroteToKeychain) {
|
|
236
|
+
await removeFallbackTokenFile(storage.filePath);
|
|
237
|
+
return;
|
|
216
238
|
}
|
|
239
|
+
}
|
|
240
|
+
await ensureParentDirectory(storage.filePath);
|
|
241
|
+
const file = await open(
|
|
242
|
+
storage.filePath,
|
|
243
|
+
constants.O_WRONLY | constants.O_CREAT | constants.O_NOFOLLOW,
|
|
244
|
+
384
|
|
217
245
|
);
|
|
246
|
+
try {
|
|
247
|
+
if (!(await file.stat()).isFile())
|
|
248
|
+
throw new Error("Token destination must be a regular file");
|
|
249
|
+
await file.chmod(384);
|
|
250
|
+
await file.truncate(0);
|
|
251
|
+
await file.writeFile(
|
|
252
|
+
`${JSON.stringify({ accessToken, expiresAt }, null, 2)}
|
|
253
|
+
`
|
|
254
|
+
);
|
|
255
|
+
} finally {
|
|
256
|
+
await file.close();
|
|
257
|
+
}
|
|
218
258
|
}
|
|
219
|
-
async function clearCliToken(baseUrl = getBaseUrl(), filePath
|
|
259
|
+
async function clearCliToken(baseUrl = getBaseUrl(), filePath) {
|
|
260
|
+
const storage = resolveTokenStorage(baseUrl, filePath);
|
|
220
261
|
const cleanupErrors = [];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
262
|
+
if (storage.useKeychain) {
|
|
263
|
+
try {
|
|
264
|
+
await clearMacOsKeychainToken(baseUrl);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
cleanupErrors.push(error);
|
|
267
|
+
}
|
|
225
268
|
}
|
|
226
269
|
try {
|
|
227
|
-
await removeFallbackTokenFile(filePath);
|
|
270
|
+
await removeFallbackTokenFile(storage.filePath);
|
|
228
271
|
} catch (error) {
|
|
229
272
|
cleanupErrors.push(error);
|
|
230
273
|
}
|
|
@@ -590,7 +633,7 @@ import {
|
|
|
590
633
|
realpath,
|
|
591
634
|
rm as rm2,
|
|
592
635
|
stat,
|
|
593
|
-
writeFile
|
|
636
|
+
writeFile
|
|
594
637
|
} from "fs/promises";
|
|
595
638
|
import os2 from "os";
|
|
596
639
|
import path3 from "path";
|
|
@@ -786,7 +829,7 @@ async function downloadGitHubSource(source, fetchFn) {
|
|
|
786
829
|
if (!response.ok) {
|
|
787
830
|
throw new Error(`Failed to fetch ${item.path}: ${response.status}`);
|
|
788
831
|
}
|
|
789
|
-
await
|
|
832
|
+
await writeFile(targetPath, await response.text());
|
|
790
833
|
})
|
|
791
834
|
);
|
|
792
835
|
return {
|
|
@@ -869,7 +912,7 @@ async function installAgentSkill(input) {
|
|
|
869
912
|
installedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
870
913
|
files: incomingHashes
|
|
871
914
|
};
|
|
872
|
-
await
|
|
915
|
+
await writeFile(metadataPath(targetPath), `${JSON.stringify(installMetadata, null, 2)}
|
|
873
916
|
`);
|
|
874
917
|
}
|
|
875
918
|
return {
|
|
@@ -894,7 +937,7 @@ async function appendAgentInstructions(input) {
|
|
|
894
937
|
if (!input.dryRun) {
|
|
895
938
|
await mkdir2(path3.dirname(input.filePath), { recursive: true });
|
|
896
939
|
const separator = existing.endsWith("\n") || existing.length === 0 ? "\n" : "\n\n";
|
|
897
|
-
await
|
|
940
|
+
await writeFile(input.filePath, `${existing}${separator}${input.snippet}`);
|
|
898
941
|
}
|
|
899
942
|
return {
|
|
900
943
|
action: "append",
|
|
@@ -1246,7 +1289,10 @@ async function runTaskArchive(input, deps) {
|
|
|
1246
1289
|
|
|
1247
1290
|
// src/commands/task/delete.ts
|
|
1248
1291
|
async function runTaskDelete(input, deps) {
|
|
1249
|
-
if (
|
|
1292
|
+
if (!input.yes && !deps.isTty) {
|
|
1293
|
+
throw new Error("Non-interactive task deletion requires --yes.");
|
|
1294
|
+
}
|
|
1295
|
+
if (!input.yes) {
|
|
1250
1296
|
const accepted = await deps.confirm(`Delete task ${input.ref}?`);
|
|
1251
1297
|
if (!accepted) {
|
|
1252
1298
|
return;
|
|
@@ -1257,10 +1303,11 @@ async function runTaskDelete(input, deps) {
|
|
|
1257
1303
|
|
|
1258
1304
|
// src/commands/task/deleteMany.ts
|
|
1259
1305
|
async function runTaskDeleteMany(input, deps) {
|
|
1260
|
-
if (
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1306
|
+
if (!input.yes && !deps.isTty) {
|
|
1307
|
+
throw new Error("Non-interactive bulk deletion requires --yes.");
|
|
1308
|
+
}
|
|
1309
|
+
if (!input.yes) {
|
|
1310
|
+
const accepted = await deps.confirm(`Delete ${input.refs.length} tasks?`);
|
|
1264
1311
|
if (!accepted) {
|
|
1265
1312
|
return;
|
|
1266
1313
|
}
|
|
@@ -1559,7 +1606,10 @@ async function runTaskCleanupApply(input, deps) {
|
|
|
1559
1606
|
plan: input.plan,
|
|
1560
1607
|
planFile: input.planFile
|
|
1561
1608
|
});
|
|
1562
|
-
if (!input.yes && deps.isTty) {
|
|
1609
|
+
if (!input.yes && !deps.isTty) {
|
|
1610
|
+
throw new Error("Non-interactive cleanup apply requires --yes.");
|
|
1611
|
+
}
|
|
1612
|
+
if (!input.yes) {
|
|
1563
1613
|
const confirmed = await deps.confirm(
|
|
1564
1614
|
`Apply cleanup plan with ${summarizeCleanupPlan(plan)}?`
|
|
1565
1615
|
);
|