pluginfinity 0.1.1 → 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.
- package/bats/pluginfinity.bash +88 -0
- package/package.json +9 -9
- package/version.js +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# shellcheck shell=bash
|
|
2
|
+
# pluginfinity's bats helper: run a plugin's built hook scripts the way each
|
|
3
|
+
# host runs them, and assert on the response.
|
|
4
|
+
#
|
|
5
|
+
# Load it from plugins/<name>/__test__/*.bats:
|
|
6
|
+
# load "$BATS_TEST_DIRNAME/../node_modules/pluginfinity/bats/pluginfinity.bash"
|
|
7
|
+
#
|
|
8
|
+
# Tests run against builds/<target>/, so run `pluginfinity build` first.
|
|
9
|
+
|
|
10
|
+
bats_require_minimum_version 1.5.0
|
|
11
|
+
|
|
12
|
+
: "${PLUGIN_DIR:=$(cd "$BATS_TEST_DIRNAME/.." && pwd)}"
|
|
13
|
+
|
|
14
|
+
# run_hook <target> <script> <fixture> [VAR=value...]
|
|
15
|
+
# Runs builds/<target>/<script> under env -i with the host's environment and
|
|
16
|
+
# the fixture on stdin. Sets $status, $output and $stderr.
|
|
17
|
+
run_hook() {
|
|
18
|
+
local target=$1 script=$2 fixture=$3
|
|
19
|
+
shift 3
|
|
20
|
+
local root="$PLUGIN_DIR/builds/$target"
|
|
21
|
+
if [ ! -f "$root/$script" ]; then
|
|
22
|
+
echo "run_hook: $root/$script not found; run pluginfinity build" >&2
|
|
23
|
+
return 1
|
|
24
|
+
fi
|
|
25
|
+
case "$fixture" in
|
|
26
|
+
/*) ;;
|
|
27
|
+
*) fixture="$PLUGIN_DIR/__test__/fixtures/$fixture" ;;
|
|
28
|
+
esac
|
|
29
|
+
local event
|
|
30
|
+
event=$(jq -r '.hook_event_name // empty' "$fixture")
|
|
31
|
+
case "$target" in
|
|
32
|
+
claude)
|
|
33
|
+
run --separate-stderr env -i PATH="$PATH" HOME="$BATS_TEST_TMPDIR/home" \
|
|
34
|
+
XDG_STATE_HOME="$BATS_TEST_TMPDIR/state" CLAUDE_PLUGIN_ROOT="$root" \
|
|
35
|
+
CLAUDE_PROJECT_DIR="${HOOK_PROJECT_DIR:-$BATS_TEST_TMPDIR}" "$@" bash "$root/$script" <"$fixture"
|
|
36
|
+
;;
|
|
37
|
+
copilot)
|
|
38
|
+
# Copilot runs hooks from the plugin root, and the build sets
|
|
39
|
+
# PLUGINFINITY_EVENT on every entry.
|
|
40
|
+
run --separate-stderr env -i PATH="$PATH" HOME="$BATS_TEST_TMPDIR/home" \
|
|
41
|
+
XDG_STATE_HOME="$BATS_TEST_TMPDIR/state" PLUGIN_ROOT="$root" \
|
|
42
|
+
PLUGINFINITY_EVENT="$event" "$@" bash -c 'cd "$1" && shift && exec bash "$@"' _ "$root" "$root/$script" <"$fixture"
|
|
43
|
+
;;
|
|
44
|
+
*)
|
|
45
|
+
echo "run_hook: unknown target $target" >&2
|
|
46
|
+
return 1
|
|
47
|
+
;;
|
|
48
|
+
esac
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# assert_hook_exit <n>
|
|
52
|
+
assert_hook_exit() {
|
|
53
|
+
[ "$status" -eq "$1" ] || {
|
|
54
|
+
echo "exit $status, expected $1; stderr: $stderr" >&2
|
|
55
|
+
return 1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# assert_hook_json <jq-filter> <expected>: compare the filter's raw value.
|
|
60
|
+
assert_hook_json() {
|
|
61
|
+
local got
|
|
62
|
+
got=$(printf '%s' "$output" | jq -r "$1" 2>/dev/null) || {
|
|
63
|
+
echo "stdout is not JSON: $output" >&2
|
|
64
|
+
return 1
|
|
65
|
+
}
|
|
66
|
+
[ "$got" = "$2" ] || {
|
|
67
|
+
echo "$1 is '$got', expected '$2'; stdout: $output" >&2
|
|
68
|
+
return 1
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# assert_hook_noop: exit 0 with no response or an empty object.
|
|
73
|
+
assert_hook_noop() {
|
|
74
|
+
if [ "$status" -eq 0 ] && { [ -z "$output" ] || [ "$output" = "{}" ]; }; then return 0; fi
|
|
75
|
+
echo "expected a no-op, got exit $status: $output" >&2
|
|
76
|
+
return 1
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# hook_fixture <event> [overrides-json]: write a Claude-shaped input for
|
|
80
|
+
# <event> to a temp file and print its path.
|
|
81
|
+
hook_fixture() {
|
|
82
|
+
local overrides=${2:-}
|
|
83
|
+
[ -n "$overrides" ] || overrides='{}'
|
|
84
|
+
local file="$BATS_TEST_TMPDIR/fixture-$1-$RANDOM.json"
|
|
85
|
+
jq -n --arg e "$1" --arg cwd "$BATS_TEST_TMPDIR" --argjson o "$overrides" \
|
|
86
|
+
'{session_id: "test-session", transcript_path: "/dev/null", cwd: $cwd, hook_event_name: $e} + $o' >"$file"
|
|
87
|
+
printf '%s\n' "$file"
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pluginfinity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build one agent-plugin source into every host's format: Claude Code, GitHub Copilot and more, from a single config.",
|
|
6
6
|
"keywords": [
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"pluginfinity": "bin/pluginfinity.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@effect/platform-node": "^4.0.
|
|
44
|
-
"@effected/cli": "^0.
|
|
43
|
+
"@effect/platform-node": "^4.0.1",
|
|
44
|
+
"@effected/cli": "^0.13.0",
|
|
45
45
|
"@effected/commands": "^0.11.0",
|
|
46
|
-
"@effected/engine": "^0.
|
|
46
|
+
"@effected/engine": "^0.4.0",
|
|
47
47
|
"@effected/env": "^0.1.0",
|
|
48
48
|
"@effected/glob": "^0.10.0",
|
|
49
49
|
"@effected/semver": "^0.11.0",
|
|
50
50
|
"@effected/walker": "^0.15.0",
|
|
51
|
-
"@pluginfinity/cli": "0.
|
|
52
|
-
"@pluginfinity/core": "0.
|
|
53
|
-
"@pluginfinity/engine": "0.
|
|
54
|
-
"@pluginfinity/targets": "0.
|
|
55
|
-
"effect": "^4.0.
|
|
51
|
+
"@pluginfinity/cli": "0.2.1",
|
|
52
|
+
"@pluginfinity/core": "0.2.1",
|
|
53
|
+
"@pluginfinity/engine": "0.2.1",
|
|
54
|
+
"@pluginfinity/targets": "0.2.1",
|
|
55
|
+
"effect": "^4.0.1",
|
|
56
56
|
"jiti": "^2.6.1"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
package/version.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* with this package's own version, so this is not a runtime environment read.
|
|
9
9
|
* `"0.0.0"` is the unbuilt-source fallback.
|
|
10
10
|
*/
|
|
11
|
-
const PLUGINFINITY_VERSION = "0.
|
|
11
|
+
const PLUGINFINITY_VERSION = "0.2.1";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { PLUGINFINITY_VERSION };
|