@keepur/hive 0.1.10 → 0.2.1

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.
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # migrate-0.2.test.sh — shell test harness for migrate-0.2.sh
4
+ # =============================================================================
5
+ # Constructs a fake 0.1.x instance in a temp dir, runs migrate-0.2.sh in
6
+ # dry-run mode (real mode would require a real @keepur/hive install), and
7
+ # asserts the classification + skeleton logic work.
8
+ #
9
+ # Run: ./install/migrate-0.2.test.sh
10
+ # =============================================================================
11
+
12
+ set -euo pipefail
13
+
14
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
15
+ FIXTURES="$SCRIPT_DIR/migrate-0.2.fixtures/loose-files.txt"
16
+ TESTROOT=$(mktemp -d -t migrate-test.XXXXXX)
17
+ trap 'rm -rf "$TESTROOT"' EXIT
18
+
19
+ INSTANCE="$TESTROOT/fakeinstance"
20
+ mkdir -p "$INSTANCE"
21
+
22
+ # --- Build a 0.1.x-looking instance ---
23
+ # Engine files we expect Step 5 to delete
24
+ mkdir -p "$INSTANCE/dist" "$INSTANCE/node_modules" "$INSTANCE/src" "$INSTANCE/seeds"
25
+ echo "// dist" > "$INSTANCE/dist/index.js"
26
+ echo "{}" > "$INSTANCE/package.json"
27
+ echo "{}" > "$INSTANCE/package-lock.json"
28
+ echo "{}" > "$INSTANCE/tsconfig.json"
29
+ mkdir -p "$INSTANCE/plugins/claude-code"
30
+
31
+ # Preserved files
32
+ cat > "$INSTANCE/hive.yaml" <<YAML
33
+ instance:
34
+ id: fakeinstance
35
+ codeTask:
36
+ pluginDirs:
37
+ - ~/services/hive/plugins/claude-code
38
+ YAML
39
+ echo "SLACK_BOT_TOKEN=fake" > "$INSTANCE/.env"
40
+ mkdir -p "$INSTANCE/logs"
41
+ echo "{}" > "$INSTANCE/.hive-generated.json"
42
+
43
+ # Service dir (simulate a live primary plist symlink by just creating the file;
44
+ # Step 5's LIVE_PLISTS discovery uses ~/Library/LaunchAgents, which we don't
45
+ # want to touch in a test — so LIVE_PLISTS will be empty, and Step 5 will
46
+ # clear service/ entirely. That's correct for this test.)
47
+ mkdir -p "$INSTANCE/service"
48
+ echo "<xml/>" > "$INSTANCE/service/com.hive.agent.plist"
49
+
50
+ # Instance-git state (simulates 0.1.x internal state)
51
+ mkdir -p "$INSTANCE/.hive/git"
52
+ echo "state" > "$INSTANCE/.hive/git/HEAD"
53
+ echo '{"version":"0.1.10"}' > "$INSTANCE/.hive/installed-snapshot.json"
54
+
55
+ # Loose files from fixtures
56
+ while read -r f; do
57
+ [[ -z "$f" ]] && continue
58
+ [[ "$f" == .playwright-mcp/* ]] && continue # handled below
59
+ dir=$(dirname "$f")
60
+ [[ "$dir" == "." ]] || mkdir -p "$INSTANCE/$dir"
61
+ echo "content of $f" > "$INSTANCE/$f"
62
+ done < "$FIXTURES"
63
+
64
+ # .playwright-mcp with a couple of log files
65
+ mkdir -p "$INSTANCE/.playwright-mcp"
66
+ echo "console log 0" > "$INSTANCE/.playwright-mcp/console-0.log"
67
+ echo "console log 1" > "$INSTANCE/.playwright-mcp/console-1.log"
68
+
69
+ # --- Run the migrate script in dry-run ---
70
+ # Preflight needs: hive.yaml (present), dist/index.js OR .hive/git (both present),
71
+ # yq, jq, rsync, realpath, readlink, launchctl (all assumed present on macOS).
72
+ # No actual service running, so LaunchAgents preflight check is a no-op.
73
+ echo ""
74
+ echo "=== Dry-run ==="
75
+ bash "$SCRIPT_DIR/migrate-0.2.sh" --dry-run "$INSTANCE" | tee "$TESTROOT/dry-run.log"
76
+
77
+ # --- Assertions for dry-run ---
78
+ grep -q "preflight" "$TESTROOT/dry-run.log" || { echo "FAIL: no preflight line in dry-run output"; exit 1; }
79
+ grep -q "Dry-run complete" "$TESTROOT/dry-run.log" || { echo "FAIL: dry-run didn't exit via the dry-run branch"; exit 1; }
80
+
81
+ # Classification table lines we expect to see
82
+ expect_classification() {
83
+ local file="$1"
84
+ local dest="$2"
85
+ if ! grep -Eq "^\\s*$file\\s+→\\s+$dest" "$TESTROOT/dry-run.log"; then
86
+ echo "FAIL: expected '$file → $dest' in classification table"
87
+ grep -E "(milo|river|permit|standup|hubspot|stale|lead|query|README|fb-|linkedin|x-|analyze|check|extract)" "$TESTROOT/dry-run.log" || true
88
+ exit 1
89
+ fi
90
+ }
91
+
92
+ expect_classification "milo-standup-2026-03-15.md" "agents/milo/reports/archive-pre-0.2"
93
+ expect_classification "river-permits-weekly-2026-03-08.md" "agents/river/reports/archive-pre-0.2"
94
+ # Ordering-decisive: hits river-* (arm 2) not *-permits.csv (arm 9). Destinations agree;
95
+ # this guards against a reordering regression where a later arm stole the match.
96
+ expect_classification "river-high-tier-permits-extraction.csv" "agents/river/reports/archive-pre-0.2"
97
+ expect_classification "PERMIT-EXTRACTION-SUMMARY.md" "agents/river/reports/archive-pre-0.2"
98
+ expect_classification "fb-marketplace-scrape-2026-03-20.md" "data/archive-pre-0.2/social-scrapes"
99
+ expect_classification "linkedin-sales-prospects.md" "data/archive-pre-0.2/social-scrapes"
100
+ expect_classification "stale-deals.csv" "agents/milo/reports/archive-pre-0.2"
101
+ expect_classification "HUBSPOT-contacts-dump.csv" "agents/milo/reports/archive-pre-0.2"
102
+ # Ordering-decisive: HUBSPOT-river-pulls.csv must hit HUBSPOT-* (→ Milo), not any
103
+ # River pattern. Different destinations here, so a wrong match is silently wrong.
104
+ expect_classification "HUBSPOT-river-pulls.csv" "agents/milo/reports/archive-pre-0.2"
105
+ expect_classification "LEAD-SEGMENTATION-tier1.csv" "data/archive-pre-0.2/unsorted"
106
+ expect_classification "QUERY-RESULTS-high-value.csv" "data/archive-pre-0.2/unsorted"
107
+ expect_classification "analyze-pipeline.ts" "data/archive-pre-0.2/scripts"
108
+ expect_classification "README-stale-deals.md" "data/archive-pre-0.2"
109
+
110
+ # .playwright-mcp should be flagged for deletion
111
+ grep -q ".playwright-mcp" "$TESTROOT/dry-run.log" || { echo "FAIL: .playwright-mcp not mentioned"; exit 1; }
112
+
113
+ # --- Verify dry-run did NOT mutate ---
114
+ [[ -d "$INSTANCE/dist" ]] || { echo "FAIL: dry-run deleted dist/"; exit 1; }
115
+ [[ -d "$INSTANCE/node_modules" ]] || { echo "FAIL: dry-run deleted node_modules/"; exit 1; }
116
+ [[ -f "$INSTANCE/milo-standup-2026-03-15.md" ]] || { echo "FAIL: dry-run moved a loose file"; exit 1; }
117
+ [[ ! -d "$INSTANCE/agents" ]] || { echo "FAIL: dry-run created namespace dirs"; exit 1; }
118
+ [[ ! -e "$INSTANCE.pre-0.2-bak" ]] || { echo "FAIL: dry-run created snapshot"; exit 1; }
119
+
120
+ echo ""
121
+ echo "=== Classifier-only smoke (real mode skipped — would need @keepur/hive installed) ==="
122
+ echo "all dry-run assertions passed."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keepur/hive",
3
- "version": "0.1.10",
3
+ "version": "0.2.1",
4
4
  "hiveApi": "1.0.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -21,7 +21,9 @@
21
21
  "pkg/",
22
22
  "seeds/",
23
23
  "templates/",
24
- "scripts/honeypot"
24
+ "scripts/honeypot",
25
+ "install/",
26
+ "service/"
25
27
  ],
26
28
  "engines": {
27
29
  "node": ">=22.0.0"