@caplets/pi 0.5.8 → 0.6.0

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 (3) hide show
  1. package/README.md +8 -9
  2. package/dist/index.js +18 -16
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -35,19 +35,18 @@ running without `getActiveTools()` / `setActiveTools()`, stale tools may remain
35
35
  Pi reloads extensions or restarts, but calls to removed Caplets return Caplets' normal structured
36
36
  "server not found" error.
37
37
 
38
- ## Remote Caplets service
38
+ ## Remote Selection
39
39
 
40
- By default the extension uses the local Caplets native service. To connect Pi to a remote
41
- `caplets serve --transport http` service, prefer environment variables for connection details,
42
- especially the password:
40
+ By default the extension uses the local Caplets native service. Use `CAPLETS_MODE` and `CAPLETS_REMOTE_*` to select local, self-hosted remote, or Caplets Cloud behavior:
43
41
 
44
42
  ```sh
45
- export CAPLETS_MODE="remote"
46
- export CAPLETS_SERVER_URL="https://caplets.example.com/caplets"
47
- export CAPLETS_SERVER_USER="caplets"
48
- export CAPLETS_SERVER_PASSWORD="..." # or load from your shell/secret manager
43
+ CAPLETS_MODE=local pi
44
+ CAPLETS_MODE=remote CAPLETS_REMOTE_URL=https://caplets.example.com/caplets pi
45
+ CAPLETS_MODE=cloud CAPLETS_REMOTE_URL=https://cloud.caplets.dev pi
49
46
  ```
50
47
 
48
+ Run `caplets cloud auth login` before Cloud mode. For authenticated self-hosted remotes, prefer `CAPLETS_REMOTE_TOKEN`, or `CAPLETS_REMOTE_USER` plus `CAPLETS_REMOTE_PASSWORD`, from your shell or secret manager.
49
+
51
50
  Pi currently calls extension factories with the Pi API only, so this extension reads its remote
52
51
  settings from the top-level `caplets` key in `~/.pi/agent/settings.json` when no programmatic
53
52
  options are supplied:
@@ -97,5 +96,5 @@ export default createCapletsPiExtension({
97
96
  ```
98
97
 
99
98
  The explicit config shape is `{ mode, server: { url, user }, remote: { pollIntervalMs } }`.
100
- Prefer environment variables for `CAPLETS_SERVER_PASSWORD` rather than storing passwords in
99
+ Prefer environment variables for `CAPLETS_REMOTE_TOKEN` or `CAPLETS_REMOTE_PASSWORD` rather than storing passwords in
101
100
  settings files or source code.
package/dist/index.js CHANGED
@@ -682,8 +682,9 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
682
682
  return 1;
683
683
  }
684
684
  //#endregion
685
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.75.5/node_modules/@earendil-works/pi-tui/dist/utils.js
686
- const segmenter$1 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
685
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/utils.js
686
+ const graphemeSegmenter$1 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
687
+ new Intl.Segmenter(void 0, { granularity: "word" });
687
688
  /**
688
689
  * Check if a grapheme cluster (after segmentation) could possibly be an RGI emoji.
689
690
  * This is a fast heuristic to avoid the expensive rgiEmojiRegex test.
@@ -723,7 +724,7 @@ function truncateFragmentToWidth(text, maxWidth) {
723
724
  if (!hasAnsi && !hasTabs) {
724
725
  let result = "";
725
726
  let width = 0;
726
- for (const { segment } of segmenter$1.segment(text)) {
727
+ for (const { segment } of graphemeSegmenter$1.segment(text)) {
727
728
  const w = graphemeWidth(segment);
728
729
  if (width + w > maxWidth) break;
729
730
  result += segment;
@@ -761,7 +762,7 @@ function truncateFragmentToWidth(text, maxWidth) {
761
762
  if (extractAnsiCode(text, end)) break;
762
763
  end++;
763
764
  }
764
- for (const { segment } of segmenter$1.segment(text.slice(i, end))) {
765
+ for (const { segment } of graphemeSegmenter$1.segment(text.slice(i, end))) {
765
766
  const w = graphemeWidth(segment);
766
767
  if (width + w > maxWidth) return {
767
768
  text: result,
@@ -833,7 +834,7 @@ function visibleWidth(str) {
833
834
  clean = stripped;
834
835
  }
835
836
  let width = 0;
836
- for (const { segment } of segmenter$1.segment(clean)) width += graphemeWidth(segment);
837
+ for (const { segment } of graphemeSegmenter$1.segment(clean)) width += graphemeWidth(segment);
837
838
  if (widthCache.size >= WIDTH_CACHE_SIZE) {
838
839
  const firstKey = widthCache.keys().next().value;
839
840
  if (firstKey !== void 0) widthCache.delete(firstKey);
@@ -1134,8 +1135,8 @@ function wrapTextWithAnsi(text, width) {
1134
1135
  const result = [];
1135
1136
  const tracker = new AnsiCodeTracker();
1136
1137
  for (const inputLine of inputLines) {
1137
- const prefix = result.length > 0 ? tracker.getActiveCodes() : "";
1138
- result.push(...wrapSingleLine(prefix + inputLine, width));
1138
+ const wrappedLines = wrapSingleLine((result.length > 0 ? tracker.getActiveCodes() : "") + inputLine, width);
1139
+ for (const wrappedLine of wrappedLines) result.push(wrappedLine);
1139
1140
  updateTrackerFromText(inputLine, tracker);
1140
1141
  }
1141
1142
  return result.length > 0 ? result : [""];
@@ -1160,7 +1161,7 @@ function wrapSingleLine(line, width) {
1160
1161
  currentVisibleLength = 0;
1161
1162
  }
1162
1163
  const broken = breakLongWord(token, width, tracker);
1163
- wrapped.push(...broken.slice(0, -1));
1164
+ for (let i = 0; i < broken.length - 1; i++) wrapped.push(broken[i]);
1164
1165
  currentLine = broken[broken.length - 1];
1165
1166
  currentVisibleLength = visibleWidth(currentLine);
1166
1167
  continue;
@@ -1207,7 +1208,7 @@ function breakLongWord(word, width, tracker) {
1207
1208
  end++;
1208
1209
  }
1209
1210
  const textPortion = word.slice(i, end);
1210
- for (const seg of segmenter$1.segment(textPortion)) segments.push({
1211
+ for (const seg of graphemeSegmenter$1.segment(textPortion)) segments.push({
1211
1212
  type: "grapheme",
1212
1213
  value: seg.segment
1213
1214
  });
@@ -1287,7 +1288,7 @@ function truncateToWidth(text, maxWidth, ellipsis = "...", pad = false) {
1287
1288
  const hasAnsi = text.includes("\x1B");
1288
1289
  const hasTabs = text.includes(" ");
1289
1290
  if (!hasAnsi && !hasTabs) {
1290
- for (const { segment } of segmenter$1.segment(text)) {
1291
+ for (const { segment } of graphemeSegmenter$1.segment(text)) {
1291
1292
  const width = graphemeWidth(segment);
1292
1293
  if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
1293
1294
  result += segment;
@@ -1334,7 +1335,7 @@ function truncateToWidth(text, maxWidth, ellipsis = "...", pad = false) {
1334
1335
  if (extractAnsiCode(text, end)) break;
1335
1336
  end++;
1336
1337
  }
1337
- for (const { segment } of segmenter$1.segment(text.slice(i, end))) {
1338
+ for (const { segment } of graphemeSegmenter$1.segment(text.slice(i, end))) {
1338
1339
  const width = graphemeWidth(segment);
1339
1340
  if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
1340
1341
  if (pendingAnsi) {
@@ -1363,7 +1364,7 @@ function truncateToWidth(text, maxWidth, ellipsis = "...", pad = false) {
1363
1364
  }
1364
1365
  new AnsiCodeTracker();
1365
1366
  //#endregion
1366
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.75.5/node_modules/@earendil-works/pi-tui/dist/keys.js
1367
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/keys.js
1367
1368
  const MODIFIERS = {
1368
1369
  shift: 1,
1369
1370
  alt: 2,
@@ -1416,7 +1417,7 @@ new Map([
1416
1417
  ]);
1417
1418
  MODIFIERS.shift | LOCK_MASK;
1418
1419
  //#endregion
1419
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.75.5/node_modules/@earendil-works/pi-tui/dist/components/text.js
1420
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/components/text.js
1420
1421
  /**
1421
1422
  * Text component - displays multi-line text with word wrapping
1422
1423
  */
@@ -3324,7 +3325,7 @@ marked.parseInline;
3324
3325
  _Parser.parse;
3325
3326
  _Lexer.lex;
3326
3327
  //#endregion
3327
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.75.5/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
3328
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
3328
3329
  const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
3329
3330
  var StrictStrikethroughTokenizer = class extends _Tokenizer {
3330
3331
  del(src) {
@@ -3341,6 +3342,7 @@ var StrictStrikethroughTokenizer = class extends _Tokenizer {
3341
3342
  };
3342
3343
  new Marked().setOptions({ tokenizer: new StrictStrikethroughTokenizer() });
3343
3344
  createRequire(import.meta.url);
3345
+ createRequire(import.meta.url);
3344
3346
  //#endregion
3345
3347
  //#region src/index.ts
3346
3348
  function createCapletsPiExtension(options) {
@@ -3466,7 +3468,7 @@ function parsePiNativeOptions(value, writeWarning, path = "settings.caplets") {
3466
3468
  const result = {};
3467
3469
  const mode = value.mode;
3468
3470
  if (mode !== void 0) {
3469
- if (mode !== "auto" && mode !== "local" && mode !== "remote") return void 0;
3471
+ if (mode !== "auto" && mode !== "local" && mode !== "remote" && mode !== "cloud") return;
3470
3472
  result.mode = mode;
3471
3473
  }
3472
3474
  const statusWidget = value.statusWidget;
@@ -3534,7 +3536,7 @@ function nativeServiceOptions(options) {
3534
3536
  function shouldShowStatusWidget(options, statusWidget) {
3535
3537
  if (statusWidget === false) return false;
3536
3538
  if (options.mode === "local") return false;
3537
- return options.mode === "remote" || !!options.server?.url || process.env.CAPLETS_SERVER_URL !== void 0;
3539
+ return options.mode === "remote" || options.mode === "cloud" || !!options.server?.url || process.env.CAPLETS_SERVER_URL !== void 0;
3538
3540
  }
3539
3541
  async function readFileUtf8(path) {
3540
3542
  return readFile(path, "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caplets/pi",
3
- "version": "0.5.8",
3
+ "version": "0.6.0",
4
4
  "description": "Native Pi extension for Caplets.",
5
5
  "homepage": "https://github.com/spiritledsoftware/caplets#readme",
6
6
  "bugs": {
@@ -26,14 +26,14 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@caplets/core": "0.18.8"
29
+ "@caplets/core": "0.19.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^25.9.1",
33
- "@typescript/native-preview": "7.0.0-dev.20260527.1",
33
+ "@typescript/native-preview": "7.0.0-dev.20260603.1",
34
34
  "rolldown": "^1.0.3",
35
35
  "typescript": "^6.0.3",
36
- "vitest": "^4.1.7"
36
+ "vitest": "^4.1.8"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "*",