@narumitw/pi-sync 0.4.1 → 0.4.2

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/package.json +2 -2
  2. package/src/sync.ts +13 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-sync",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Pi extension that syncs Pi configuration through Cloudflare R2 or S3-compatible storage.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@biomejs/biome": "2.4.14",
33
- "@mariozechner/pi-coding-agent": "0.73.0",
33
+ "@earendil-works/pi-coding-agent": "0.74.0",
34
34
  "typescript": "6.0.3"
35
35
  },
36
36
  "repository": {
package/src/sync.ts CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  ExtensionAPI,
10
10
  ExtensionCommandContext,
11
11
  ExtensionContext,
12
- } from "@mariozechner/pi-coding-agent";
12
+ } from "@earendil-works/pi-coding-agent";
13
13
 
14
14
  const gzipAsync = promisify(gzip);
15
15
  const gunzipAsync = promisify(gunzip);
@@ -631,7 +631,7 @@ async function addFile(results: SnapshotFile[], root: string, relativePath: stri
631
631
  results.push({ path: relativePath, contentBase64: content.toString("base64"), sha256: sha256(content) });
632
632
  }
633
633
 
634
- function isDeniedPath(relativePath: string) {
634
+ export function isDeniedPath(relativePath: string) {
635
635
  const normalized = toPosix(relativePath);
636
636
  const base = path.posix.basename(normalized).toLowerCase();
637
637
  return (
@@ -647,7 +647,7 @@ function isDeniedPath(relativePath: string) {
647
647
  );
648
648
  }
649
649
 
650
- function scanSnapshot(snapshot: Snapshot) {
650
+ export function scanSnapshot(snapshot: Snapshot) {
651
651
  const findings: string[] = [];
652
652
  for (const file of snapshot.files) {
653
653
  const content = Buffer.from(file.contentBase64, "base64");
@@ -718,7 +718,7 @@ async function applySnapshot(snapshot: Snapshot) {
718
718
  }
719
719
  }
720
720
 
721
- function preflightSnapshotApply(root: string, snapshot: Snapshot, current: Snapshot) {
721
+ export function preflightSnapshotApply(root: string, snapshot: Snapshot, current: Snapshot) {
722
722
  const seenPaths = new Set<string>();
723
723
  const remotePaths = new Set<string>();
724
724
  const writes: Array<{ target: string; content: Buffer }> = [];
@@ -1124,7 +1124,7 @@ async function assertNoSymlinkParents(root: string, target: string) {
1124
1124
  }
1125
1125
  }
1126
1126
 
1127
- function safeJoin(root: string, relativePath: string) {
1127
+ export function safeJoin(root: string, relativePath: string) {
1128
1128
  const target = path.resolve(root, relativePath);
1129
1129
  assertWithinRoot(root, target, relativePath);
1130
1130
  return target;
@@ -1138,11 +1138,11 @@ function assertWithinRoot(root: string, target: string, label = target) {
1138
1138
  }
1139
1139
  }
1140
1140
 
1141
- function splitArgs(input: string) {
1141
+ export function splitArgs(input: string) {
1142
1142
  return input.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g)?.map((arg) => arg.replace(/^['"]|['"]$/g, "")) ?? [];
1143
1143
  }
1144
1144
 
1145
- function parseOptions(args: string[]): CommandOptions {
1145
+ export function parseOptions(args: string[]): CommandOptions {
1146
1146
  return {
1147
1147
  yes: args.includes("--yes") || args.includes("-y"),
1148
1148
  force: args.includes("--force"),
@@ -1170,11 +1170,11 @@ function iso8601Basic(date: Date) {
1170
1170
  return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
1171
1171
  }
1172
1172
 
1173
- function encodeKey(key: string) {
1173
+ export function encodeKey(key: string) {
1174
1174
  return key.split("/").map(encodeURIComponent).join("/");
1175
1175
  }
1176
1176
 
1177
- function posixJoin(...parts: string[]) {
1177
+ export function posixJoin(...parts: string[]) {
1178
1178
  return parts.map((part) => trimSlashes(part)).filter(Boolean).join("/");
1179
1179
  }
1180
1180
 
@@ -1186,7 +1186,7 @@ function trimSlashes(value: string) {
1186
1186
  return value.replace(/^\/+|\/+$/g, "");
1187
1187
  }
1188
1188
 
1189
- function safeName(value: string) {
1189
+ export function safeName(value: string) {
1190
1190
  return value.replace(/[^A-Za-z0-9._-]/g, "_");
1191
1191
  }
1192
1192
 
@@ -1207,7 +1207,7 @@ function selectSessionToken(fileSessionToken: string | undefined) {
1207
1207
  return normalizeOptionalString(process.env.AWS_SESSION_TOKEN) ?? normalizeOptionalString(fileSessionToken);
1208
1208
  }
1209
1209
 
1210
- function sessionTokenWarnings(config: { endpoint?: string; sessionToken?: string }) {
1210
+ export function sessionTokenWarnings(config: { endpoint?: string; sessionToken?: string }) {
1211
1211
  if (!isCloudflareR2Endpoint(config.endpoint) || !config.sessionToken) return [];
1212
1212
  return [
1213
1213
  "session token: configured for Cloudflare R2; if R2 rejects X-Amz-Security-Token, pi-sync retries once without it. R2 static access keys usually do not need a session token.",
@@ -1221,7 +1221,7 @@ function isSecurityTokenInvalidArgument(text: string) {
1221
1221
  );
1222
1222
  }
1223
1223
 
1224
- function isCloudflareR2Endpoint(endpoint: string | undefined) {
1224
+ export function isCloudflareR2Endpoint(endpoint: string | undefined) {
1225
1225
  const value = endpoint?.trim();
1226
1226
  if (!value) return false;
1227
1227
  try {
@@ -1241,7 +1241,7 @@ function hasEnv(name: string) {
1241
1241
  return Object.prototype.hasOwnProperty.call(process.env, name);
1242
1242
  }
1243
1243
 
1244
- function isEnabled(value: boolean | string | undefined, defaultValue: boolean) {
1244
+ export function isEnabled(value: boolean | string | undefined, defaultValue: boolean) {
1245
1245
  if (value === undefined) return defaultValue;
1246
1246
  if (typeof value === "boolean") return value;
1247
1247
  return !["0", "false", "no", "off"].includes(value.trim().toLowerCase());