@justram/pie 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -12,6 +12,34 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## 0.2.2
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ ### Changed
22
+
23
+ ### Fixed
24
+
25
+ - Added release automation scripts and documented the release flow.
26
+
27
+ ### Removed
28
+
29
+ ## 0.2.1
30
+
31
+ ### Breaking Changes
32
+
33
+ ### Added
34
+
35
+ ### Changed
36
+
37
+ ### Fixed
38
+
39
+ - Restored minimal `AGENTS.md` pointing to `docs/` onboarding.
40
+
41
+ ### Removed
42
+
15
43
  ## 0.2.0
16
44
 
17
45
  ### Breaking Changes
package/dist/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justram/pie",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Structured extraction library and CLI built on @mariozechner/pi-ai.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -49,6 +49,17 @@
49
49
  "test": "vitest run",
50
50
  "test:watch": "vitest",
51
51
  "test:e2e": "vitest run --config vitest.config.e2e.ts",
52
+ "clean": "rm -rf dist",
53
+ "version:patch": "npm version patch --no-git-tag-version && node scripts/sync-versions.js",
54
+ "version:minor": "npm version minor --no-git-tag-version && node scripts/sync-versions.js",
55
+ "version:major": "npm version major --no-git-tag-version && node scripts/sync-versions.js",
56
+ "version:set": "npm version --no-git-tag-version",
57
+ "prepublishOnly": "npm run clean && npm run build && npm run check",
58
+ "publish": "npm run prepublishOnly && npm publish --access public",
59
+ "publish:dry": "npm run prepublishOnly && npm publish --access public --dry-run",
60
+ "release:patch": "node scripts/release.mjs patch",
61
+ "release:minor": "node scripts/release.mjs minor",
62
+ "release:major": "node scripts/release.mjs major",
52
63
  "prepare": "husky"
53
64
  },
54
65
  "dependencies": {
@@ -1,5 +0,0 @@
1
- import type { AssistantMessage, ImageContent, Message, ToolCall } from "@mariozechner/pi-ai";
2
- export declare function buildMessages(input: string | Message[], attachments?: ImageContent[]): Message[];
3
- export declare function findToolCall(message: AssistantMessage, toolName: string): ToolCall | undefined;
4
- export declare function getTextContent(message: AssistantMessage): string;
5
- export declare function parseJsonFromText(message: AssistantMessage): unknown | null;
@@ -1,80 +0,0 @@
1
- export function buildMessages(input, attachments) {
2
- if (typeof input !== "string") {
3
- return input;
4
- }
5
- const content = attachments?.length
6
- ? [{ type: "text", text: input }, ...attachments]
7
- : input;
8
- const message = {
9
- role: "user",
10
- content,
11
- timestamp: Date.now(),
12
- };
13
- return [message];
14
- }
15
- export function findToolCall(message, toolName) {
16
- for (const content of message.content) {
17
- if (content.type === "toolCall" && content.name === toolName) {
18
- return content;
19
- }
20
- }
21
- return undefined;
22
- }
23
- export function getTextContent(message) {
24
- return message.content
25
- .filter((content) => content.type === "text")
26
- .map((content) => content.text)
27
- .join("\n")
28
- .trim();
29
- }
30
- export function parseJsonFromText(message) {
31
- const text = getTextContent(message);
32
- if (!text) {
33
- return null;
34
- }
35
- const candidates = collectJsonCandidates(text);
36
- for (const candidate of candidates) {
37
- const parsed = tryParseJson(candidate);
38
- if (parsed !== null) {
39
- return parsed;
40
- }
41
- }
42
- return null;
43
- }
44
- function collectJsonCandidates(text) {
45
- const candidates = [];
46
- const fenced = extractFencedJson(text);
47
- if (fenced) {
48
- candidates.push(fenced);
49
- }
50
- candidates.push(text);
51
- const objectCandidate = sliceBetween(text, "{", "}");
52
- if (objectCandidate) {
53
- candidates.push(objectCandidate);
54
- }
55
- const arrayCandidate = sliceBetween(text, "[", "]");
56
- if (arrayCandidate) {
57
- candidates.push(arrayCandidate);
58
- }
59
- return candidates;
60
- }
61
- function extractFencedJson(text) {
62
- const match = text.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
63
- return match ? match[1].trim() : null;
64
- }
65
- function sliceBetween(text, open, close) {
66
- const start = text.indexOf(open);
67
- const end = text.lastIndexOf(close);
68
- if (start === -1 || end === -1 || end <= start) {
69
- return null;
70
- }
71
- return text.slice(start, end + 1).trim();
72
- }
73
- function tryParseJson(text) {
74
- try {
75
- return JSON.parse(text);
76
- }
77
- catch {
78
- return null;
79
- }
80
- }
@@ -1 +0,0 @@
1
- export declare function runAsserts(data: unknown, asserts: string[], signal?: AbortSignal): Promise<void>;
@@ -1,18 +0,0 @@
1
- import { AssertionError } from "../errors.js";
2
- import { runShell } from "./shell.js";
3
- function shSingleQuote(text) {
4
- // Wrap in single quotes, escaping any embedded single quotes:
5
- // abc'def -> 'abc'\''def'
6
- return `'${text.replaceAll("'", "'\\''")}'`;
7
- }
8
- export async function runAsserts(data, asserts, signal) {
9
- const json = JSON.stringify(data);
10
- for (const expr of asserts) {
11
- const result = await runShell(`jq -e ${shSingleQuote(expr)}`, { stdin: json, signal });
12
- if (result.code === 0) {
13
- continue;
14
- }
15
- const message = result.stderr.trim() || `Assertion failed: ${expr}`;
16
- throw new AssertionError(message, expr);
17
- }
18
- }
@@ -1,2 +0,0 @@
1
- import type { Runtime } from "./types.js";
2
- export declare function createNodeRuntime(): Runtime;
@@ -1,71 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { readFile, rm, stat, writeFile, mkdir } from "node:fs/promises";
3
- import { spawn } from "node:child_process";
4
- export function createNodeRuntime() {
5
- return {
6
- now: () => Date.now(),
7
- env: {
8
- get: (name) => process.env[name],
9
- },
10
- fs: {
11
- exists: async (path) => {
12
- try {
13
- await stat(path);
14
- return true;
15
- }
16
- catch {
17
- return false;
18
- }
19
- },
20
- readFile: async (path) => {
21
- const buf = await readFile(path);
22
- return new Uint8Array(buf);
23
- },
24
- readTextFile: async (path) => {
25
- return await readFile(path, { encoding: "utf8" });
26
- },
27
- writeFile: async (path, data) => {
28
- await writeFile(path, data);
29
- },
30
- writeTextFile: async (path, text) => {
31
- await writeFile(path, text, { encoding: "utf8" });
32
- },
33
- mkdir: async (path, options) => {
34
- await mkdir(path, { recursive: options?.recursive ?? false });
35
- },
36
- remove: async (path, options) => {
37
- await rm(path, { recursive: options?.recursive ?? false, force: true });
38
- },
39
- },
40
- crypto: {
41
- sha256Hex: async (text) => {
42
- return createHash("sha256").update(text).digest("hex");
43
- },
44
- },
45
- process: {
46
- runShell: async (command, options) => {
47
- const child = spawn("sh", ["-c", command], {
48
- stdio: ["pipe", "pipe", "pipe"],
49
- signal: options?.signal,
50
- });
51
- const stdoutChunks = [];
52
- const stderrChunks = [];
53
- child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
54
- child.stderr.on("data", (chunk) => stderrChunks.push(chunk));
55
- if (options?.stdin !== undefined) {
56
- child.stdin.write(options.stdin);
57
- }
58
- child.stdin.end();
59
- const code = await new Promise((resolve, reject) => {
60
- child.on("error", reject);
61
- child.on("close", (c) => resolve(c ?? 0));
62
- });
63
- return {
64
- code,
65
- stdout: Buffer.concat(stdoutChunks).toString("utf8"),
66
- stderr: Buffer.concat(stderrChunks).toString("utf8"),
67
- };
68
- },
69
- },
70
- };
71
- }
@@ -1,32 +0,0 @@
1
- export interface Runtime {
2
- now(): number;
3
- env: {
4
- get(name: string): string | undefined;
5
- };
6
- fs: {
7
- exists(path: string): Promise<boolean>;
8
- readFile(path: string): Promise<Uint8Array>;
9
- readTextFile(path: string): Promise<string>;
10
- writeFile(path: string, data: Uint8Array): Promise<void>;
11
- writeTextFile(path: string, text: string): Promise<void>;
12
- mkdir(path: string, options?: {
13
- recursive?: boolean;
14
- }): Promise<void>;
15
- remove(path: string, options?: {
16
- recursive?: boolean;
17
- }): Promise<void>;
18
- };
19
- crypto: {
20
- sha256Hex(text: string): Promise<string>;
21
- };
22
- process: {
23
- runShell(command: string, options?: {
24
- stdin?: string;
25
- signal?: AbortSignal;
26
- }): Promise<{
27
- code: number;
28
- stdout: string;
29
- stderr: string;
30
- }>;
31
- };
32
- }
@@ -1 +0,0 @@
1
- export {};