@dypt/cli 0.1.20 → 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 CHANGED
@@ -36,9 +36,10 @@ DYPT_TOKEN_FILE=/absolute/path/to/dypt-token.json dypt auth login
36
36
 
37
37
  Keep `DYPT_TOKEN_FILE` set to the same path for subsequent commands and
38
38
  `dypt auth logout`. When explicitly configured, a missing or invalid file does
39
- not fall back to Keychain or another identity. The token file is created with
40
- owner-only permissions; its containing directory and any sandbox access to the
41
- file remain the user's responsibility.
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.
42
43
 
43
44
  ### List tasks
44
45
 
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.20",
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",
@@ -88,7 +88,8 @@ function getDefaultDeviceLabel() {
88
88
 
89
89
  // src/lib/keychain.ts
90
90
  import { execFile } from "child_process";
91
- import { mkdir, readFile, rm, writeFile } from "fs/promises";
91
+ import { constants } from "fs";
92
+ import { mkdir, open, readFile, rm } from "fs/promises";
92
93
  import path2 from "path";
93
94
  import { promisify } from "util";
94
95
  var execFileAsync = promisify(execFile);
@@ -237,14 +238,23 @@ async function saveCliToken(accessToken, expiresAt, baseUrl = getBaseUrl(), file
237
238
  }
238
239
  }
239
240
  await ensureParentDirectory(storage.filePath);
240
- await writeFile(
241
+ const file = await open(
241
242
  storage.filePath,
242
- `${JSON.stringify({ accessToken, expiresAt }, null, 2)}
243
- `,
244
- {
245
- mode: 384
246
- }
243
+ constants.O_WRONLY | constants.O_CREAT | constants.O_NOFOLLOW,
244
+ 384
247
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
+ }
248
258
  }
249
259
  async function clearCliToken(baseUrl = getBaseUrl(), filePath) {
250
260
  const storage = resolveTokenStorage(baseUrl, filePath);
@@ -623,7 +633,7 @@ import {
623
633
  realpath,
624
634
  rm as rm2,
625
635
  stat,
626
- writeFile as writeFile2
636
+ writeFile
627
637
  } from "fs/promises";
628
638
  import os2 from "os";
629
639
  import path3 from "path";
@@ -819,7 +829,7 @@ async function downloadGitHubSource(source, fetchFn) {
819
829
  if (!response.ok) {
820
830
  throw new Error(`Failed to fetch ${item.path}: ${response.status}`);
821
831
  }
822
- await writeFile2(targetPath, await response.text());
832
+ await writeFile(targetPath, await response.text());
823
833
  })
824
834
  );
825
835
  return {
@@ -902,7 +912,7 @@ async function installAgentSkill(input) {
902
912
  installedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
903
913
  files: incomingHashes
904
914
  };
905
- await writeFile2(metadataPath(targetPath), `${JSON.stringify(installMetadata, null, 2)}
915
+ await writeFile(metadataPath(targetPath), `${JSON.stringify(installMetadata, null, 2)}
906
916
  `);
907
917
  }
908
918
  return {
@@ -927,7 +937,7 @@ async function appendAgentInstructions(input) {
927
937
  if (!input.dryRun) {
928
938
  await mkdir2(path3.dirname(input.filePath), { recursive: true });
929
939
  const separator = existing.endsWith("\n") || existing.length === 0 ? "\n" : "\n\n";
930
- await writeFile2(input.filePath, `${existing}${separator}${input.snippet}`);
940
+ await writeFile(input.filePath, `${existing}${separator}${input.snippet}`);
931
941
  }
932
942
  return {
933
943
  action: "append",