@justram/pie 0.2.5 → 0.2.6

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/CHANGELOG.md CHANGED
@@ -12,6 +12,21 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## 0.2.6
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ - Added SDK helper utilities for checking updates and formatting update notifications.
22
+ - Added CLI update notification that checks npm registry for newer versions.
23
+
24
+ ### Changed
25
+
26
+ ### Fixed
27
+
28
+ ### Removed
29
+
15
30
  ## 0.2.5
16
31
 
17
32
  ### Breaking Changes
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@ export { loadRecipeSetup, loadRecipes, resolveRecipe, } from "./recipes/index.js
12
12
  export type { ExtractionSetup, LoadExtractionSetupOptions } from "./setup.js";
13
13
  export { loadExtractionSetup } from "./setup.js";
14
14
  export type { ExtractOptions, ExtractResult, ExtractStream, ThinkingBudgets, ThinkingLevel, Usage } from "./types.js";
15
+ export { checkForUpdates, formatUpdateNotification, type UpdateInfo } from "./update.js";
package/dist/index.js CHANGED
@@ -7,3 +7,4 @@ export { extract, extractSync } from "./extract.js";
7
7
  export { getModel, getModels, getProviders } from "./models.js";
8
8
  export { loadRecipeSetup, loadRecipes, resolveRecipe, } from "./recipes/index.js";
9
9
  export { loadExtractionSetup } from "./setup.js";
10
+ export { checkForUpdates, formatUpdateNotification } from "./update.js";
package/dist/main.js CHANGED
@@ -11,6 +11,7 @@ import { loadExtractionSetupFromContent } from "./core/setup.js";
11
11
  import { extract } from "./extract.js";
12
12
  import { getModels, getProviders } from "./models.js";
13
13
  import { loadRecipeSetup, loadRecipes } from "./recipes/index.js";
14
+ import { checkForUpdates, formatUpdateNotification, getVersion } from "./update.js";
14
15
  const MODEL_PROVIDER_PREFERENCE = ["anthropic", "openai", "google"];
15
16
  class CliExitError extends Error {
16
17
  exitCode;
@@ -121,6 +122,7 @@ async function runCliInternal(argv, deps, stdout, stderr) {
121
122
  }
122
123
  return 0;
123
124
  }
125
+ startVersionCheck(stderr);
124
126
  const promptInput = args.promptFile ? readTextFile(args.promptFile, "prompt") : args.prompt;
125
127
  const promptPath = args.promptFile ? resolve(args.promptFile) : undefined;
126
128
  const promptIsSetup = !args.config && !useRecipe && typeof promptInput === "string" && promptInput.startsWith("---");
@@ -591,11 +593,14 @@ function mapExtractionExitCode(error) {
591
593
  function writeLine(stream, message) {
592
594
  stream.write(`${message}\n`);
593
595
  }
594
- function getVersion() {
595
- const pkgPath = new URL("../package.json", import.meta.url);
596
- const raw = readFileSync(pkgPath, "utf8");
597
- const pkg = JSON.parse(raw);
598
- return pkg.version ?? "0.0.0";
596
+ function startVersionCheck(stderr) {
597
+ void checkForUpdates().then((info) => {
598
+ if (!info)
599
+ return;
600
+ for (const line of formatUpdateNotification(info)) {
601
+ writeLine(stderr, line);
602
+ }
603
+ });
599
604
  }
600
605
  async function readStream(stream) {
601
606
  return await new Promise((resolveStream, reject) => {
@@ -0,0 +1,10 @@
1
+ export interface UpdateInfo {
2
+ packageName: string;
3
+ currentVersion: string;
4
+ latestVersion: string;
5
+ }
6
+ export declare function getVersion(): string;
7
+ export declare function checkForUpdates(options?: {
8
+ skipEnv?: boolean;
9
+ }): Promise<UpdateInfo | undefined>;
10
+ export declare function formatUpdateNotification(info: UpdateInfo): string[];
package/dist/update.js ADDED
@@ -0,0 +1,42 @@
1
+ import { readFileSync } from "node:fs";
2
+ function getPackageInfo() {
3
+ const pkgPath = new URL("../package.json", import.meta.url);
4
+ const raw = readFileSync(pkgPath, "utf8");
5
+ const pkg = JSON.parse(raw);
6
+ return {
7
+ name: pkg.name ?? "pie",
8
+ version: pkg.version ?? "0.0.0",
9
+ };
10
+ }
11
+ export function getVersion() {
12
+ return getPackageInfo().version;
13
+ }
14
+ export async function checkForUpdates(options = {}) {
15
+ if (!options.skipEnv && process.env.PI_SKIP_VERSION_CHECK)
16
+ return undefined;
17
+ const { name, version } = getPackageInfo();
18
+ try {
19
+ const response = await fetch(`https://registry.npmjs.org/${name}/latest`);
20
+ if (!response.ok)
21
+ return undefined;
22
+ const data = (await response.json());
23
+ const latestVersion = data.version;
24
+ if (latestVersion && latestVersion !== version) {
25
+ return {
26
+ packageName: name,
27
+ currentVersion: version,
28
+ latestVersion,
29
+ };
30
+ }
31
+ return undefined;
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ export function formatUpdateNotification(info) {
38
+ return [
39
+ `Update available for ${info.packageName}: v${info.latestVersion} (current v${info.currentVersion}). Run: npm install -g ${info.packageName}`,
40
+ "Changelog: https://github.com/justram/pie/blob/main/CHANGELOG.md",
41
+ ];
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justram/pie",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Structured extraction library and CLI built on @mariozechner/pi-ai.",
5
5
  "homepage": "https://github.com/justram/pie#readme",
6
6
  "repository": {