@vtstech/pi-react-fallback 1.0.3 → 1.0.4

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 +3 -2
  2. package/react-fallback.js +25 -45
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@vtstech/pi-react-fallback",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "ReAct fallback extension for Pi Coding Agent",
5
5
  "main": "react-fallback.js",
6
6
  "keywords": ["pi-package", "pi-extensions"],
7
7
  "license": "MIT",
8
8
  "access": "public",
9
+ "type": "module",
9
10
  "author": "VTSTech",
10
11
  "homepage": "https://www.vts-tech.org",
11
12
  "repository": {
@@ -13,7 +14,7 @@
13
14
  "url": "https://github.com/VTSTech/pi-coding-agent"
14
15
  },
15
16
  "dependencies": {
16
- "@vtstech/pi-shared": "1.0.3"
17
+ "@vtstech/pi-shared": "1.0.4"
17
18
  },
18
19
  "peerDependencies": {
19
20
  "@mariozechner/pi-coding-agent": ">=0.66"
package/react-fallback.js CHANGED
@@ -1,28 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
1
  // .build-npm/react-fallback/react-fallback.temp.ts
20
- var react_fallback_temp_exports = {};
21
- __export(react_fallback_temp_exports, {
22
- default: () => react_fallback_temp_default
23
- });
24
- module.exports = __toCommonJS(react_fallback_temp_exports);
25
- var import_format = require("@vtstech/pi-shared/format");
2
+ import { section, ok, fail, warn, info } from "@vtstech/pi-shared/format";
26
3
  function sanitizeModelJson(text) {
27
4
  text = text.replace(/:\s*True\b/g, ": true");
28
5
  text = text.replace(/:\s*False\b/g, ": false");
@@ -393,15 +370,15 @@ ${argsJson}`
393
370
  const status = reactModeEnabled ? "ENABLED" : "DISABLED";
394
371
  ctx.ui.notify(`ReAct mode ${status}`, "success");
395
372
  const lines = [branding];
396
- lines.push((0, import_format.section)("REACT FALLBACK MODE"));
397
- lines.push((0, import_format.info)(`Status: ${status}`));
398
- lines.push((0, import_format.info)(`Bridge calls: ${stats.bridgeCalls}`));
399
- lines.push((0, import_format.info)(`Fuzzy matches: ${stats.fuzzyMatches}`));
400
- lines.push((0, import_format.info)(`Argument normalizations: ${stats.argNormalizations}`));
401
- lines.push((0, import_format.info)(`Parse failures: ${stats.parseFailures}`));
373
+ lines.push(section("REACT FALLBACK MODE"));
374
+ lines.push(info(`Status: ${status}`));
375
+ lines.push(info(`Bridge calls: ${stats.bridgeCalls}`));
376
+ lines.push(info(`Fuzzy matches: ${stats.fuzzyMatches}`));
377
+ lines.push(info(`Argument normalizations: ${stats.argNormalizations}`));
378
+ lines.push(info(`Parse failures: ${stats.parseFailures}`));
402
379
  if (reactModeEnabled) {
403
- lines.push((0, import_format.ok)("The tool_call bridge tool is now available to the model"));
404
- lines.push((0, import_format.info)("ReAct system prompt instructions have been added"));
380
+ lines.push(ok("The tool_call bridge tool is now available to the model"));
381
+ lines.push(info("ReAct system prompt instructions have been added"));
405
382
  }
406
383
  const report = lines.join("\n");
407
384
  pi2.sendMessage({
@@ -420,17 +397,17 @@ ${argsJson}`
420
397
  return;
421
398
  }
422
399
  const lines = [branding];
423
- lines.push((0, import_format.section)("REACT PARSER TEST"));
424
- lines.push((0, import_format.info)(`Input: ${text.slice(0, 100)}${text.length > 100 ? "..." : ""}`));
400
+ lines.push(section("REACT PARSER TEST"));
401
+ lines.push(info(`Input: ${text.slice(0, 100)}${text.length > 100 ? "..." : ""}`));
425
402
  const reactResult = parseReact(text);
426
403
  if (reactResult) {
427
- lines.push((0, import_format.ok)("ReAct format detected!"));
428
- lines.push((0, import_format.info)(`Tool: ${reactResult.name}`));
429
- lines.push((0, import_format.info)(`Args: ${JSON.stringify(reactResult.args)}`));
430
- if (reactResult.thought) lines.push((0, import_format.info)(`Thought: ${reactResult.thought}`));
431
- if (reactResult.finalAnswer) lines.push((0, import_format.info)(`Final Answer: ${reactResult.finalAnswer}`));
404
+ lines.push(ok("ReAct format detected!"));
405
+ lines.push(info(`Tool: ${reactResult.name}`));
406
+ lines.push(info(`Args: ${JSON.stringify(reactResult.args)}`));
407
+ if (reactResult.thought) lines.push(info(`Thought: ${reactResult.thought}`));
408
+ if (reactResult.finalAnswer) lines.push(info(`Final Answer: ${reactResult.finalAnswer}`));
432
409
  } else {
433
- lines.push((0, import_format.fail)("No ReAct format detected"));
410
+ lines.push(fail("No ReAct format detected"));
434
411
  }
435
412
  try {
436
413
  const firstBrace = text.indexOf("{");
@@ -441,20 +418,20 @@ ${argsJson}`
441
418
  const parsed = JSON.parse(sanitizeModelJson(jsonStr));
442
419
  const toolResult = extractToolFromJson(parsed);
443
420
  if (toolResult) {
444
- lines.push((0, import_format.ok)("JSON tool call detected!"));
445
- lines.push((0, import_format.info)(`Tool: ${toolResult.name}`));
446
- lines.push((0, import_format.info)(`Args: ${JSON.stringify(toolResult.args)}`));
421
+ lines.push(ok("JSON tool call detected!"));
422
+ lines.push(info(`Tool: ${toolResult.name}`));
423
+ lines.push(info(`Args: ${JSON.stringify(toolResult.args)}`));
447
424
  }
448
425
  }
449
426
  }
450
427
  } catch {
451
428
  }
452
429
  if (looksLikeSchemaDump(text)) {
453
- lines.push((0, import_format.warn)("Text appears to be a tool schema dump (not a tool call)"));
430
+ lines.push(warn("Text appears to be a tool schema dump (not a tool call)"));
454
431
  }
455
432
  if (FINAL_ANSWER_RE.test(text)) {
456
433
  const fa = FINAL_ANSWER_RE.exec(text)[1].trim();
457
- lines.push((0, import_format.ok)(`Final Answer: ${fa}`));
434
+ lines.push(ok(`Final Answer: ${fa}`));
458
435
  }
459
436
  pi2.sendMessage({
460
437
  customType: "react-parse-report",
@@ -472,3 +449,6 @@ ${argsJson}`
472
449
  looksLikeSchemaDump
473
450
  };
474
451
  }
452
+ export {
453
+ react_fallback_temp_default as default
454
+ };