@askjo/pi-reflect 1.0.0 โ†’ 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askjo/pi-reflect",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Self-improving behavioral files for pi coding agents. Analyzes session transcripts for correction patterns and makes surgical edits to prevent recurrence.",
5
5
  "keywords": [
6
6
  "pi-package",
package/release.sh ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ BUMP="${1:-patch}"
5
+ if [[ "$BUMP" != "patch" && "$BUMP" != "minor" && "$BUMP" != "major" ]]; then
6
+ echo "Usage: ./release.sh [patch|minor|major]"
7
+ exit 1
8
+ fi
9
+
10
+ cd "$(dirname "$0")"
11
+
12
+ echo "๐Ÿ” Pre-flight checks..."
13
+ if [[ -n "$(git status --porcelain)" ]]; then
14
+ echo "โŒ Working tree is dirty. Commit changes first."
15
+ exit 1
16
+ fi
17
+ if [[ "$(git branch --show-current)" != "main" ]]; then
18
+ echo "โŒ Not on main."
19
+ exit 1
20
+ fi
21
+ git fetch origin main --quiet
22
+ if [[ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]]; then
23
+ echo "โŒ Local main differs from origin/main."
24
+ exit 1
25
+ fi
26
+
27
+ echo "๐Ÿงช Running tests..."
28
+ npm test
29
+
30
+ echo "๐Ÿ“ฆ Bumping version: $BUMP"
31
+ npm version "$BUMP" --message "v%s"
32
+ NEW_VERSION=$(node -p "require('./package.json').version")
33
+
34
+ echo "๐Ÿ“ค Pushing main and v${NEW_VERSION} tag..."
35
+ git push origin main --follow-tags
36
+
37
+ echo "โœ… Release v${NEW_VERSION} triggered"
38
+ echo " Actions: https://github.com/jo-inc/pi-reflect/actions"
39
+ echo " Package: https://www.npmjs.com/package/@askjo/pi-reflect"
@@ -345,4 +345,55 @@ describe("applyEdits", () => {
345
345
  assert.ok(result.includes("Line one, improved."));
346
346
  assert.ok(result.includes("Continuation line, also improved."));
347
347
  });
348
+
349
+ it("removes a rule with type=remove", () => {
350
+ const content = "- Rule A\n- Rule B (redundant)\n- Rule C\n";
351
+ const { result, applied } = applyEdits(content, [
352
+ { type: "remove", old_text: "- Rule B (redundant)", new_text: "" },
353
+ ]);
354
+ assert.equal(applied, 1);
355
+ assert.ok(!result.includes("Rule B"));
356
+ assert.ok(result.includes("Rule A"));
357
+ assert.ok(result.includes("Rule C"));
358
+ });
359
+
360
+ it("skips remove when text not found", () => {
361
+ const content = "- Rule A\n- Rule B\n";
362
+ const { applied, skipped } = applyEdits(content, [
363
+ { type: "remove", old_text: "- Rule X", new_text: "" },
364
+ ]);
365
+ assert.equal(applied, 0);
366
+ assert.equal(skipped.length, 1);
367
+ });
368
+
369
+ it("merges multiple rules into one", () => {
370
+ const content = "- Always check schema before SQL.\n- Verify column names before queries.\n- Other rule.\n";
371
+ const { result, applied } = applyEdits(content, [
372
+ {
373
+ type: "merge",
374
+ merge_sources: [
375
+ "- Always check schema before SQL.",
376
+ "- Verify column names before queries.",
377
+ ],
378
+ new_text: "- Always check DB schema before writing any SQL query.",
379
+ },
380
+ ]);
381
+ assert.equal(applied, 1);
382
+ assert.ok(result.includes("- Always check DB schema before writing any SQL query."));
383
+ assert.ok(!result.includes("Verify column names"));
384
+ assert.ok(result.includes("Other rule"));
385
+ });
386
+
387
+ it("skips merge when a source is not found", () => {
388
+ const content = "- Rule A\n- Rule B\n";
389
+ const { applied, skipped } = applyEdits(content, [
390
+ {
391
+ type: "merge",
392
+ merge_sources: ["- Rule A", "- Rule X"],
393
+ new_text: "- Merged rule.",
394
+ },
395
+ ]);
396
+ assert.equal(applied, 0);
397
+ assert.equal(skipped.length, 1);
398
+ });
348
399
  });