@onlooker-community/ecosystem 0.32.2 → 0.33.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/.claude-plugin/plugin.json +1 -1
- package/.release-please-manifest.json +9 -9
- package/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/plugins/archivist/scripts/lib/archivist-config.sh +10 -34
- package/plugins/assayer/.claude-plugin/plugin.json +1 -1
- package/plugins/assayer/CHANGELOG.md +7 -0
- package/plugins/assayer/scripts/lib/assayer-config.sh +39 -62
- package/plugins/bursar/.claude-plugin/plugin.json +1 -1
- package/plugins/bursar/CHANGELOG.md +12 -0
- package/plugins/bursar/scripts/hooks/bursar-session-end.sh +6 -5
- package/plugins/bursar/scripts/lib/bursar-config.sh +10 -43
- package/plugins/cartographer/scripts/lib/cartographer-config.sh +11 -29
- package/plugins/compass/scripts/lib/compass-config.sh +16 -46
- package/plugins/counsel/scripts/lib/counsel-config.sh +15 -46
- package/plugins/curator/.claude-plugin/plugin.json +1 -1
- package/plugins/curator/CHANGELOG.md +7 -0
- package/plugins/curator/scripts/lib/curator-config.sh +19 -44
- package/plugins/echo/scripts/lib/echo-config.sh +30 -59
- package/plugins/governor/scripts/lib/governor-config.sh +11 -41
- package/plugins/historian/scripts/lib/historian-config.sh +9 -33
- package/plugins/inspector/.claude-plugin/plugin.json +1 -1
- package/plugins/inspector/CHANGELOG.md +7 -0
- package/plugins/inspector/scripts/lib/inspector-config.sh +39 -63
- package/plugins/librarian/.claude-plugin/plugin.json +1 -1
- package/plugins/librarian/CHANGELOG.md +7 -0
- package/plugins/librarian/scripts/hooks/librarian-session-end.sh +38 -3
- package/plugins/librarian/scripts/lib/librarian-config.sh +10 -34
- package/plugins/lineage/.claude-plugin/plugin.json +1 -1
- package/plugins/lineage/CHANGELOG.md +7 -0
- package/plugins/lineage/scripts/lib/lineage-config.sh +17 -53
- package/plugins/scribe/.claude-plugin/plugin.json +1 -1
- package/plugins/scribe/CHANGELOG.md +7 -0
- package/plugins/scribe/scripts/lib/scribe-config.sh +17 -47
- package/plugins/tribunal/.claude-plugin/plugin.json +1 -1
- package/plugins/tribunal/CHANGELOG.md +7 -0
- package/plugins/tribunal/scripts/lib/tribunal-config.sh +25 -63
- package/plugins/warden/scripts/lib/warden-config.sh +17 -54
- package/scripts/lib/config-loader.sh +138 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Shared config loader for Onlooker plugins.
|
|
3
|
+
#
|
|
4
|
+
# Plugins use this to avoid duplicating config merging logic. Handles all five
|
|
5
|
+
# layers of settings precedence in a single jq pass, with consistent behavior
|
|
6
|
+
# across the ecosystem.
|
|
7
|
+
#
|
|
8
|
+
# Usage:
|
|
9
|
+
# # In your plugin's config loader (e.g., plugins/bursar/scripts/lib/bursar-config.sh):
|
|
10
|
+
# source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
|
|
11
|
+
# config_load_plugin "bursar" "$repo_root" "_BURSAR_CONFIG"
|
|
12
|
+
# config_get "_BURSAR_CONFIG" '.bursar.window' # returns value or empty string
|
|
13
|
+
#
|
|
14
|
+
# Precedence (latest wins):
|
|
15
|
+
# 1. plugin config.json (shipped defaults)
|
|
16
|
+
# 2. ~/.claude/settings.json
|
|
17
|
+
# 3. ~/.claude/settings.local.json (local overrides user)
|
|
18
|
+
# 4. <repo>/.claude/settings.json
|
|
19
|
+
# 5. <repo>/.claude/settings.local.json (local overrides project)
|
|
20
|
+
|
|
21
|
+
# Load config for a plugin, merging all five layers into a variable.
|
|
22
|
+
#
|
|
23
|
+
# Arguments:
|
|
24
|
+
# $1 = plugin name (e.g., "bursar", "compass")
|
|
25
|
+
# $2 = repo root (or empty for no-repo defaults)
|
|
26
|
+
# $3 = output variable name (e.g., "_BURSAR_CONFIG")
|
|
27
|
+
#
|
|
28
|
+
# Sets the output variable to the merged JSON config.
|
|
29
|
+
config_load_plugin() {
|
|
30
|
+
local plugin_name="${1:-}"
|
|
31
|
+
local repo_root="${2:-}"
|
|
32
|
+
local output_var="${3:-}"
|
|
33
|
+
|
|
34
|
+
[[ -z "$plugin_name" || -z "$output_var" ]] && return 1
|
|
35
|
+
|
|
36
|
+
local plugin_root="${CLAUDE_PLUGIN_ROOT:-}"
|
|
37
|
+
local home_dir="${HOME:-}"
|
|
38
|
+
|
|
39
|
+
# Read all five layers as raw text using $(<file) to avoid process forks.
|
|
40
|
+
# Missing files degrade to empty strings (handled by jq with //).
|
|
41
|
+
local default_txt="" home_txt="" home_local_txt="" repo_txt="" repo_local_txt=""
|
|
42
|
+
local default_file="${plugin_root}/config.json"
|
|
43
|
+
local home_file="${home_dir}/.claude/settings.json"
|
|
44
|
+
local home_local_file="${home_dir}/.claude/settings.local.json"
|
|
45
|
+
local repo_file=""
|
|
46
|
+
local repo_local_file=""
|
|
47
|
+
|
|
48
|
+
[[ -n "$repo_root" ]] && repo_file="${repo_root}/.claude/settings.json"
|
|
49
|
+
[[ -n "$repo_root" ]] && repo_local_file="${repo_root}/.claude/settings.local.json"
|
|
50
|
+
|
|
51
|
+
# Read each layer defensively—missing or malformed files degrade to empty.
|
|
52
|
+
[[ -f "$default_file" ]] && default_txt="$(<"$default_file")"
|
|
53
|
+
[[ -f "$home_file" ]] && home_txt="$(<"$home_file")"
|
|
54
|
+
[[ -f "$home_local_file" ]] && home_local_txt="$(<"$home_local_file")"
|
|
55
|
+
[[ -f "$repo_file" ]] && repo_txt="$(<"$repo_file")"
|
|
56
|
+
[[ -f "$repo_local_file" ]] && repo_local_txt="$(<"$repo_local_file")"
|
|
57
|
+
|
|
58
|
+
# Merge all five layers in a single jq invocation. Precedence:
|
|
59
|
+
# defaults < home < home-local < repo < repo-local
|
|
60
|
+
# Settings files (.json, .local.json) contribute only their plugin-scoped key.
|
|
61
|
+
local merged_json
|
|
62
|
+
merged_json=$(jq -n \
|
|
63
|
+
--arg plugin "$plugin_name" \
|
|
64
|
+
--arg d "$default_txt" \
|
|
65
|
+
--arg h "$home_txt" \
|
|
66
|
+
--arg hl "$home_local_txt" \
|
|
67
|
+
--arg r "$repo_txt" \
|
|
68
|
+
--arg rl "$repo_local_txt" \
|
|
69
|
+
'
|
|
70
|
+
def deepmerge($a; $b):
|
|
71
|
+
if ($a|type) == "object" and ($b|type) == "object" then
|
|
72
|
+
reduce (($a|keys) + ($b|keys) | unique)[] as $k
|
|
73
|
+
({}; .[$k] = deepmerge($a[$k]; $b[$k]))
|
|
74
|
+
elif $b == null then $a
|
|
75
|
+
else $b end;
|
|
76
|
+
|
|
77
|
+
($d | fromjson? // {}) as $defaults
|
|
78
|
+
| (($h | fromjson? // {}) | {($plugin): (.[$plugin] // {})}) as $home
|
|
79
|
+
| (($hl | fromjson? // {}) | {($plugin): (.[$plugin] // {})}) as $home_local
|
|
80
|
+
| (($r | fromjson? // {}) | {($plugin): (.[$plugin] // {})}) as $repo
|
|
81
|
+
| (($rl | fromjson? // {}) | {($plugin): (.[$plugin] // {})}) as $repo_local
|
|
82
|
+
| deepmerge(
|
|
83
|
+
deepmerge(
|
|
84
|
+
deepmerge(
|
|
85
|
+
deepmerge($defaults; $home);
|
|
86
|
+
$home_local);
|
|
87
|
+
$repo);
|
|
88
|
+
$repo_local)
|
|
89
|
+
' 2>/dev/null) || merged_json="{}"
|
|
90
|
+
|
|
91
|
+
[[ -z "$merged_json" ]] && merged_json="{}"
|
|
92
|
+
|
|
93
|
+
# Set the output variable in the caller's scope via printf (works in bash).
|
|
94
|
+
printf -v "$output_var" '%s' "$merged_json"
|
|
95
|
+
return 0
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# Get a string value from loaded config.
|
|
99
|
+
#
|
|
100
|
+
# Arguments:
|
|
101
|
+
# $1 = variable name containing the config JSON (e.g., "_BURSAR_CONFIG")
|
|
102
|
+
# $2 = jq path to the value (e.g., '.bursar.window')
|
|
103
|
+
#
|
|
104
|
+
# Outputs: the string value, or empty string if not found.
|
|
105
|
+
config_get() {
|
|
106
|
+
local config_var="${1:-}"
|
|
107
|
+
local path="${2:-}"
|
|
108
|
+
|
|
109
|
+
[[ -z "$config_var" ]] && return 1
|
|
110
|
+
|
|
111
|
+
# Use indirect expansion to read the variable's value.
|
|
112
|
+
local config_json="${!config_var}"
|
|
113
|
+
# NB: do NOT use `${path} // empty` — jq's `//` treats `false` and `0` as
|
|
114
|
+
# empty, so a false boolean would read back as "" and a true default would
|
|
115
|
+
# silently flip it. Emit the raw value and map only a literal JSON null to
|
|
116
|
+
# the empty string.
|
|
117
|
+
local v
|
|
118
|
+
v=$(printf '%s' "$config_json" | jq -r "${path}" 2>/dev/null) || return 1
|
|
119
|
+
[[ "$v" == "null" ]] && v=""
|
|
120
|
+
printf '%s' "$v"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# Get a JSON value from loaded config.
|
|
124
|
+
#
|
|
125
|
+
# Arguments:
|
|
126
|
+
# $1 = variable name containing the config JSON (e.g., "_BURSAR_CONFIG")
|
|
127
|
+
# $2 = jq path to the value (e.g., '.bursar.markers')
|
|
128
|
+
#
|
|
129
|
+
# Outputs: the JSON value, or null if not found.
|
|
130
|
+
config_get_json() {
|
|
131
|
+
local config_var="${1:-}"
|
|
132
|
+
local path="${2:-}"
|
|
133
|
+
|
|
134
|
+
[[ -z "$config_var" ]] && return 1
|
|
135
|
+
|
|
136
|
+
local config_json="${!config_var}"
|
|
137
|
+
printf '%s' "$config_json" | jq -c "${path}" 2>/dev/null
|
|
138
|
+
}
|