@newlandnpt/pep-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.
Files changed (2) hide show
  1. package/dist/pep.cjs +21 -12
  2. package/package.json +1 -1
package/dist/pep.cjs CHANGED
@@ -196,12 +196,12 @@ async function waitForAuthorizationCallback(args) {
196
196
  throw new Error("CLI redirect URI must be an http://localhost URL with an explicit port.");
197
197
  }
198
198
  let server;
199
- return new Promise((resolve, reject) => {
199
+ return new Promise((resolve2, reject) => {
200
200
  const finish = (error, code) => {
201
201
  clearTimeout(timeout);
202
202
  server?.close();
203
203
  if (error) reject(error);
204
- else resolve(code);
204
+ else resolve2(code);
205
205
  };
206
206
  const timeout = setTimeout(
207
207
  () => finish(new Error("Login timed out while waiting for the browser callback.")),
@@ -244,7 +244,7 @@ async function waitForAuthorizationCallback(args) {
244
244
  function openBrowser(url) {
245
245
  const command = process.platform === "win32" ? "rundll32.exe" : process.platform === "darwin" ? "open" : "xdg-open";
246
246
  const commandArgs = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
247
- return new Promise((resolve, reject) => {
247
+ return new Promise((resolve2, reject) => {
248
248
  const child = (0, import_node_child_process.spawn)(command, commandArgs, {
249
249
  detached: true,
250
250
  stdio: "ignore",
@@ -253,7 +253,7 @@ function openBrowser(url) {
253
253
  child.once("error", reject);
254
254
  child.once("spawn", () => {
255
255
  child.unref();
256
- resolve();
256
+ resolve2();
257
257
  });
258
258
  });
259
259
  }
@@ -364,7 +364,7 @@ var REFRESH_EARLY_MS = 60 * 1e3;
364
364
  var LOCK_STALE_MS = 30 * 1e3;
365
365
  var LOCK_WAIT_MS = 10 * 1e3;
366
366
  async function delay(milliseconds) {
367
- await new Promise((resolve) => setTimeout(resolve, milliseconds));
367
+ await new Promise((resolve2) => setTimeout(resolve2, milliseconds));
368
368
  }
369
369
  async function withAuthorizationLock(path, action) {
370
370
  await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(path), { recursive: true });
@@ -558,7 +558,7 @@ function encodedPowerShell(script) {
558
558
  return Buffer.from(script, "utf16le").toString("base64");
559
559
  }
560
560
  async function runPowerShell(script, input) {
561
- return new Promise((resolve, reject) => {
561
+ return new Promise((resolve2, reject) => {
562
562
  const child = (0, import_node_child_process2.spawn)(
563
563
  "powershell.exe",
564
564
  [
@@ -581,7 +581,7 @@ async function runPowerShell(script, input) {
581
581
  );
582
582
  child.once("close", (code) => {
583
583
  clearTimeout(timeout);
584
- if (code === 0) resolve(stdout.trim());
584
+ if (code === 0) resolve2(stdout.trim());
585
585
  else
586
586
  reject(
587
587
  new Error(
@@ -631,7 +631,7 @@ $raw = [Console]::In.ReadToEnd()
631
631
  }
632
632
  var SECURITY_NOT_FOUND = 44;
633
633
  async function runSecurity(args) {
634
- return new Promise((resolve, reject) => {
634
+ return new Promise((resolve2, reject) => {
635
635
  const child = (0, import_node_child_process2.spawn)("/usr/bin/security", [...args], {
636
636
  stdio: ["ignore", "pipe", "pipe"]
637
637
  });
@@ -646,7 +646,7 @@ async function runSecurity(args) {
646
646
  );
647
647
  child.once("close", (code) => {
648
648
  clearTimeout(timeout);
649
- resolve({ code: code ?? -1, stdout, stderr });
649
+ resolve2({ code: code ?? -1, stdout, stderr });
650
650
  });
651
651
  });
652
652
  }
@@ -881,13 +881,22 @@ function describeFailure2(status) {
881
881
  }
882
882
  return `PEP answered ${status}.`;
883
883
  }
884
+ async function physicalDir(path) {
885
+ const absolute = (0, import_node_path3.resolve)(path);
886
+ try {
887
+ return (0, import_node_path3.join)(await (0, import_promises3.realpath)((0, import_node_path3.dirname)(absolute)), (0, import_node_path3.basename)(absolute));
888
+ } catch {
889
+ return absolute;
890
+ }
891
+ }
884
892
  async function linkSkill(canonicalSkillDir, linkPath) {
885
893
  await (0, import_promises3.rm)(linkPath, { recursive: true, force: true });
886
- await (0, import_promises3.mkdir)((0, import_node_path3.dirname)(linkPath), { recursive: true });
894
+ const linkDir = (0, import_node_path3.dirname)(linkPath);
895
+ await (0, import_promises3.mkdir)(linkDir, { recursive: true });
887
896
  try {
888
897
  const junction = (0, import_node_os2.platform)() === "win32";
889
898
  await (0, import_promises3.symlink)(
890
- junction ? canonicalSkillDir : (0, import_node_path3.relative)((0, import_node_path3.dirname)(linkPath), canonicalSkillDir),
899
+ junction ? canonicalSkillDir : (0, import_node_path3.relative)(await physicalDir(linkDir), canonicalSkillDir),
891
900
  linkPath,
892
901
  junction ? "junction" : void 0
893
902
  );
@@ -973,7 +982,7 @@ async function syncSkills(dependencies) {
973
982
  }
974
983
 
975
984
  // src/cli.ts
976
- var VERSION = "0.1.2";
985
+ var VERSION = "0.1.3";
977
986
  function usage() {
978
987
  return `PEP CLI ${VERSION}
979
988
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlandnpt/pep-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "PEP CLI —— 凭 PEP 身份读取 Newland 开发者文档与 agent skills",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",