superpowers-manager 0.1.4 → 0.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/README.md +180 -82
- package/bin/superpowers-manager.js +85 -30
- package/package.json +2 -1
- package/scripts/adapters/codex/adapter +603 -0
- package/scripts/adapters/codex/lib.sh +449 -0
- package/scripts/{validate-generated-plugin.py → adapters/codex/validate-generated-plugin.py} +3 -3
- package/scripts/core/adapter.sh +103 -0
- package/scripts/core/common.sh +59 -0
- package/scripts/core/lifecycle.sh +141 -0
- package/scripts/core/provenance.sh +135 -0
- package/scripts/core/selection-state.py +414 -0
- package/scripts/core/selection.sh +168 -0
- package/scripts/core/status.sh +27 -0
- package/scripts/core/upstream.sh +280 -0
- package/scripts/core/validate-adapter-response.py +284 -0
- package/scripts/install +30 -29
- package/scripts/pin +51 -0
- package/scripts/prepare +60 -79
- package/scripts/probe +62 -30
- package/scripts/track-latest +30 -0
- package/scripts/uninstall +21 -47
- package/scripts/unpin +41 -0
- package/scripts/update +8 -10
- package/scripts/lib.sh +0 -651
package/scripts/probe
CHANGED
|
@@ -2,49 +2,81 @@
|
|
|
2
2
|
set -eu
|
|
3
3
|
|
|
4
4
|
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
5
|
-
. "$root/scripts/
|
|
5
|
+
. "$root/scripts/core/common.sh"
|
|
6
|
+
. "$root/scripts/core/upstream.sh"
|
|
7
|
+
. "$root/scripts/core/selection.sh"
|
|
8
|
+
. "$root/scripts/core/provenance.sh"
|
|
9
|
+
. "$root/scripts/core/status.sh"
|
|
10
|
+
. "$root/scripts/core/lifecycle.sh"
|
|
11
|
+
. "$root/scripts/core/adapter.sh"
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
identity_snapshot=$(spw_codex_identity_snapshot "$codex_bin")
|
|
11
|
-
identity_state=$(spw_snapshot_get "$identity_snapshot" identity_state)
|
|
12
|
-
|
|
13
|
-
upstream_url="${SUPERPOWERS_UPSTREAM_URL:-$SPW_UPSTREAM_URL_DEFAULT}"
|
|
14
|
-
requested_ref=$(spw_config_ref "$root")
|
|
15
|
-
resolved_record=$(spw_resolve_ref "$upstream_url" "$requested_ref")
|
|
16
|
-
resolved_ref=$(printf '%s\n' "$resolved_record" | awk '{ print $2 }')
|
|
17
|
-
desired_commit=$(printf '%s\n' "$resolved_record" | awk '{ print $3 }')
|
|
18
|
-
|
|
19
|
-
generated_metadata="$root/plugins/superpowers/.superpowers-upstream.json"
|
|
20
|
-
generated_commit=$(spw_metadata_commit_or_empty "$generated_metadata" || true)
|
|
21
|
-
|
|
22
|
-
installed_metadata=$(spw_find_installed_metadata || true)
|
|
23
|
-
installed_manifest=$(spw_find_installed_manifest || true)
|
|
24
|
-
installed_commit=""
|
|
25
|
-
if [ -n "$installed_metadata" ]; then
|
|
26
|
-
installed_commit=$(spw_metadata_commit_or_empty "$installed_metadata" || true)
|
|
13
|
+
tmp_parent="${TMPDIR:-/tmp}"
|
|
14
|
+
if ! probe_workspace=$(spw_make_workspace "$tmp_parent" "superpowers-manager.probe"); then
|
|
15
|
+
spw_die "cannot create probe workspace under $tmp_parent"
|
|
27
16
|
fi
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
spw_install_workspace_trap "$probe_workspace"
|
|
18
|
+
fingerprint_result="$probe_workspace/fingerprint.json"
|
|
19
|
+
ownership_result="$probe_workspace/ownership.json"
|
|
20
|
+
update_control_result="$probe_workspace/update-control.json"
|
|
21
|
+
|
|
22
|
+
TMPDIR="$probe_workspace"
|
|
23
|
+
export TMPDIR
|
|
24
|
+
spw_compute_effective_selection "$root" "$probe_workspace"
|
|
25
|
+
effective_source=$(spw_display_source "$SPW_EFFECTIVE_SOURCE")
|
|
26
|
+
if [ -n "$SPW_SAVED_SOURCE" ]; then
|
|
27
|
+
saved_source=$(spw_display_source "$SPW_SAVED_SOURCE")
|
|
28
|
+
else
|
|
29
|
+
saved_source=""
|
|
30
30
|
fi
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
generated_commit=$(spw_generated_commit_or_empty "$root")
|
|
33
|
+
spw_inspect_fingerprint "$fingerprint_result"
|
|
34
|
+
installed_commit=$(spw_adapter_result_get "$fingerprint_result" "fingerprint")
|
|
35
|
+
spw_inspect_ownership "$ownership_result"
|
|
36
|
+
identity_state=$(spw_adapter_result_get "$ownership_result" "identity_state")
|
|
37
|
+
spw_inspect_update_control "$update_control_result"
|
|
38
|
+
update_control=$(spw_adapter_result_get "$update_control_result" "update_control")
|
|
39
|
+
|
|
40
|
+
status=$(spw_status_for_commits "$SPW_DESIRED_COMMIT" "$generated_commit" "$installed_commit")
|
|
33
41
|
|
|
34
42
|
if [ "${1:-}" = "--porcelain" ]; then
|
|
35
|
-
printf 'requested_ref=%s\n' "$
|
|
36
|
-
printf 'resolved_ref=%s\n' "$
|
|
37
|
-
printf 'desired_commit=%s\n' "$
|
|
43
|
+
printf 'requested_ref=%s\n' "$SPW_REQUESTED_REF"
|
|
44
|
+
printf 'resolved_ref=%s\n' "$SPW_RESOLVED_REF"
|
|
45
|
+
printf 'desired_commit=%s\n' "$SPW_DESIRED_COMMIT"
|
|
38
46
|
printf 'generated_commit=%s\n' "$generated_commit"
|
|
39
47
|
printf 'installed_commit=%s\n' "$installed_commit"
|
|
40
48
|
printf 'identity_state=%s\n' "$identity_state"
|
|
41
49
|
printf 'status=%s\n' "$status"
|
|
50
|
+
printf 'selection_origin=%s\n' "$SPW_SELECTION_ORIGIN"
|
|
51
|
+
printf 'selection_mode=%s\n' "$SPW_SELECTION_MODE"
|
|
52
|
+
printf 'upstream_source_origin=%s\n' "$SPW_UPSTREAM_SOURCE_ORIGIN"
|
|
53
|
+
printf 'effective_source=%s\n' "$effective_source"
|
|
54
|
+
printf 'saved_mode=%s\n' "$SPW_SAVED_MODE"
|
|
55
|
+
printf 'saved_source=%s\n' "$saved_source"
|
|
56
|
+
printf 'saved_requested_ref=%s\n' "$SPW_SAVED_REQUESTED_REF"
|
|
57
|
+
printf 'saved_resolved_ref=%s\n' "$SPW_SAVED_RESOLVED_REF"
|
|
58
|
+
printf 'saved_commit=%s\n' "$SPW_SAVED_COMMIT"
|
|
59
|
+
printf 'update_control=%s\n' "$update_control"
|
|
42
60
|
else
|
|
43
|
-
printf 'requested ref: %s\n' "$
|
|
44
|
-
printf 'resolved ref: %s\n' "$
|
|
45
|
-
printf 'desired commit: %s\n' "$
|
|
61
|
+
printf 'requested ref: %s\n' "$SPW_REQUESTED_REF"
|
|
62
|
+
printf 'resolved ref: %s\n' "$SPW_RESOLVED_REF"
|
|
63
|
+
printf 'desired commit: %s\n' "$SPW_DESIRED_COMMIT"
|
|
46
64
|
printf 'generated plugin commit: %s\n' "${generated_commit:-not present}"
|
|
47
65
|
printf 'installed manager commit or fingerprint: %s\n' "${installed_commit:-not detected}"
|
|
48
66
|
printf 'Codex identity state: %s\n' "$identity_state"
|
|
49
67
|
printf 'status: %s\n' "$status"
|
|
68
|
+
printf 'selection origin: %s\n' "$SPW_SELECTION_ORIGIN"
|
|
69
|
+
printf 'selection mode: %s\n' "$SPW_SELECTION_MODE"
|
|
70
|
+
printf 'upstream source origin: %s\n' "$SPW_UPSTREAM_SOURCE_ORIGIN"
|
|
71
|
+
printf 'effective source: %s\n' "$effective_source"
|
|
72
|
+
printf 'saved mode: %s\n' "$SPW_SAVED_MODE"
|
|
73
|
+
printf 'saved source: %s\n' "$saved_source"
|
|
74
|
+
printf 'saved requested ref: %s\n' "$SPW_SAVED_REQUESTED_REF"
|
|
75
|
+
printf 'saved resolved ref: %s\n' "$SPW_SAVED_RESOLVED_REF"
|
|
76
|
+
printf 'saved commit: %s\n' "$SPW_SAVED_COMMIT"
|
|
77
|
+
printf 'update control: %s\n' "$update_control"
|
|
78
|
+
if [ "$SPW_SELECTION_ORIGIN" != "$SPW_UPSTREAM_SOURCE_ORIGIN" ]; then
|
|
79
|
+
printf 'warning: effective ref and source have mixed origins (ref: %s, source: %s)\n' \
|
|
80
|
+
"$SPW_SELECTION_ORIGIN" "$SPW_UPSTREAM_SOURCE_ORIGIN"
|
|
81
|
+
fi
|
|
50
82
|
fi
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
5
|
+
. "$root/scripts/core/common.sh"
|
|
6
|
+
. "$root/scripts/core/upstream.sh"
|
|
7
|
+
. "$root/scripts/core/selection.sh"
|
|
8
|
+
|
|
9
|
+
[ "$#" -eq 0 ] || spw_usage_error 'usage: superpowers-manager track-latest'
|
|
10
|
+
|
|
11
|
+
spw_require_command python3
|
|
12
|
+
state_path=$(spw_selection_state_path)
|
|
13
|
+
tmp_parent="${TMPDIR:-/tmp}"
|
|
14
|
+
if ! track_workspace=$(spw_make_workspace "$tmp_parent" "superpowers-manager.track-latest"); then
|
|
15
|
+
spw_die "cannot create track-latest workspace under $tmp_parent"
|
|
16
|
+
fi
|
|
17
|
+
spw_install_workspace_trap "$track_workspace"
|
|
18
|
+
|
|
19
|
+
normalized="$track_workspace/selection.json"
|
|
20
|
+
spw_selection_state "$root" read \
|
|
21
|
+
--path="$state_path" --output="$normalized"
|
|
22
|
+
|
|
23
|
+
source="${SUPERPOWERS_UPSTREAM_URL:-$SPW_UPSTREAM_URL_DEFAULT}"
|
|
24
|
+
spw_selection_state "$root" \
|
|
25
|
+
validate-source --source="$source"
|
|
26
|
+
|
|
27
|
+
spw_selection_state "$root" write-track-latest \
|
|
28
|
+
--path="$state_path" --source="$source"
|
|
29
|
+
|
|
30
|
+
printf '%s\n' 'saved upstream selection: latest stable release'
|
package/scripts/uninstall
CHANGED
|
@@ -2,60 +2,34 @@
|
|
|
2
2
|
set -eu
|
|
3
3
|
|
|
4
4
|
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
5
|
-
. "$root/scripts/
|
|
5
|
+
. "$root/scripts/core/common.sh"
|
|
6
|
+
. "$root/scripts/core/provenance.sh"
|
|
7
|
+
. "$root/scripts/core/lifecycle.sh"
|
|
8
|
+
. "$root/scripts/core/adapter.sh"
|
|
6
9
|
|
|
7
|
-
codex_bin="${SUPERPOWERS_CODEX:-codex}"
|
|
8
|
-
|
|
9
|
-
spw_require_command "$codex_bin"
|
|
10
10
|
spw_require_command python3
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
plugin_present=$(spw_snapshot_get "$ownership" manager_plugin)
|
|
16
|
-
marketplace_present=$(spw_snapshot_get "$ownership" manager_marketplace)
|
|
17
|
-
|
|
18
|
-
# Remove the plugin first, then the marketplace, so an installed plugin is
|
|
19
|
-
# never orphaned from a just-removed marketplace source.
|
|
20
|
-
if [ "$plugin_present" = true ]; then
|
|
21
|
-
if ! "$codex_bin" plugin remove "$SPW_PLUGIN_ID"; then
|
|
22
|
-
spw_die "codex plugin remove failed for $SPW_PLUGIN_ID"
|
|
23
|
-
fi
|
|
24
|
-
echo "removed plugin $SPW_PLUGIN_ID"
|
|
25
|
-
else
|
|
26
|
-
echo "plugin not installed; skipping"
|
|
12
|
+
tmp_parent="${TMPDIR:-/tmp}"
|
|
13
|
+
if ! uninstall_workspace=$(spw_make_workspace "$tmp_parent" "superpowers-manager.uninstall"); then
|
|
14
|
+
spw_die "cannot create uninstall workspace under $tmp_parent"
|
|
27
15
|
fi
|
|
16
|
+
spw_install_workspace_trap "$uninstall_workspace"
|
|
17
|
+
inspect_result="$uninstall_workspace/inspect.json"
|
|
18
|
+
uninstall_result="$uninstall_workspace/uninstall.json"
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
spw_die "codex plugin marketplace remove failed for $SPW_MARKETPLACE_NAME"
|
|
32
|
-
fi
|
|
33
|
-
echo "removed marketplace $SPW_MARKETPLACE_NAME"
|
|
34
|
-
else
|
|
35
|
-
echo "marketplace not registered; skipping"
|
|
36
|
-
fi
|
|
20
|
+
TMPDIR="$uninstall_workspace"
|
|
21
|
+
export TMPDIR
|
|
37
22
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
plugin_present
|
|
43
|
-
marketplace_present=$(spw_snapshot_get "$ownership" manager_marketplace)
|
|
44
|
-
identity_state=$(spw_snapshot_get "$ownership" identity_state)
|
|
45
|
-
if [ "$plugin_present" = true ]; then
|
|
46
|
-
spw_die "plugin $SPW_PLUGIN_ID is still installed after removal"
|
|
47
|
-
fi
|
|
48
|
-
if [ "$marketplace_present" = true ]; then
|
|
49
|
-
spw_die "marketplace $SPW_MARKETPLACE_NAME is still registered after removal"
|
|
50
|
-
fi
|
|
23
|
+
spw_inspect_ownership "$inspect_result"
|
|
24
|
+
plugin_present=$(spw_adapter_result_boolean "$inspect_result" "resources.plugin")
|
|
25
|
+
marketplace_present=$(spw_adapter_result_boolean "$inspect_result" "resources.marketplace")
|
|
26
|
+
|
|
27
|
+
spw_adapter_uninstall "$uninstall_result" "$plugin_present" "$marketplace_present"
|
|
51
28
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'Run: npx superpowers-wrapper@0.1.1 uninstall'
|
|
57
|
-
;;
|
|
58
|
-
esac
|
|
29
|
+
spw_inspect_ownership "$inspect_result"
|
|
30
|
+
spw_verify_uninstalled_resources "$inspect_result"
|
|
31
|
+
identity_state=$(spw_adapter_result_get "$inspect_result" "identity_state")
|
|
32
|
+
spw_report_legacy_state "$identity_state"
|
|
59
33
|
|
|
60
34
|
echo "uninstall complete"
|
|
61
35
|
echo "note: local generated artifacts under plugins/superpowers/ and .cache/upstream/ were left in place; remove them manually or regenerate with scripts/prepare."
|
package/scripts/unpin
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
5
|
+
. "$root/scripts/core/common.sh"
|
|
6
|
+
. "$root/scripts/core/upstream.sh"
|
|
7
|
+
. "$root/scripts/core/selection.sh"
|
|
8
|
+
|
|
9
|
+
[ "$#" -eq 0 ] || spw_usage_error 'usage: superpowers-manager unpin'
|
|
10
|
+
|
|
11
|
+
state_path=$(spw_selection_state_path)
|
|
12
|
+
fallback=$(SUPERPOWERS_REF= spw_config_ref "$root")
|
|
13
|
+
removed=false
|
|
14
|
+
|
|
15
|
+
if [ -L "$state_path" ]; then
|
|
16
|
+
spw_die "selection state path is not a regular file; remove it manually after inspecting: $state_path"
|
|
17
|
+
elif [ -e "$state_path" ]; then
|
|
18
|
+
if [ ! -f "$state_path" ]; then
|
|
19
|
+
spw_die "selection state path is not a regular file; remove it manually after inspecting: $state_path"
|
|
20
|
+
fi
|
|
21
|
+
if ! rm -f "$state_path"; then
|
|
22
|
+
spw_die "cannot remove selection state: $state_path"
|
|
23
|
+
fi
|
|
24
|
+
removed=true
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
if [ -e "$state_path" ] || [ -L "$state_path" ]; then
|
|
28
|
+
spw_die "selection state remains after removal attempt: $state_path"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [ "$removed" = true ]; then
|
|
32
|
+
printf 'removed saved upstream selection; packaged fallback is %s\n' "$fallback"
|
|
33
|
+
else
|
|
34
|
+
printf 'no saved upstream selection; packaged fallback is %s\n' "$fallback"
|
|
35
|
+
fi
|
|
36
|
+
if [ -n "${SUPERPOWERS_REF:-}" ]; then
|
|
37
|
+
printf '%s\n' 'note: active SUPERPOWERS_REF override remains effective'
|
|
38
|
+
fi
|
|
39
|
+
if [ -n "${SUPERPOWERS_UPSTREAM_URL:-}" ]; then
|
|
40
|
+
printf '%s\n' 'note: active SUPERPOWERS_UPSTREAM_URL override remains effective'
|
|
41
|
+
fi
|
package/scripts/update
CHANGED
|
@@ -2,31 +2,29 @@
|
|
|
2
2
|
set -eu
|
|
3
3
|
|
|
4
4
|
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
5
|
-
. "$root/scripts/
|
|
5
|
+
. "$root/scripts/core/common.sh"
|
|
6
|
+
. "$root/scripts/core/lifecycle.sh"
|
|
6
7
|
|
|
7
8
|
probe_output=$(sh "$root/scripts/probe" --porcelain)
|
|
8
|
-
identity_state=$(
|
|
9
|
-
[ -n "$identity_state" ] || spw_die "probe did not report
|
|
9
|
+
identity_state=$(spw_probe_field "$probe_output" identity_state)
|
|
10
|
+
[ -n "$identity_state" ] || spw_die "probe did not report adapter identity state"
|
|
10
11
|
spw_require_no_legacy_state "$identity_state"
|
|
11
|
-
status=$(
|
|
12
|
+
status=$(spw_probe_field "$probe_output" status)
|
|
13
|
+
update_control=$(spw_probe_field "$probe_output" update_control)
|
|
14
|
+
[ -n "$update_control" ] || spw_die "probe did not report adapter update-control capability"
|
|
12
15
|
|
|
13
16
|
case "$status" in
|
|
14
17
|
current)
|
|
18
|
+
spw_require_managed_update_control "$update_control"
|
|
15
19
|
printf '%s\n' "$probe_output"
|
|
16
20
|
echo "manager is current"
|
|
17
21
|
;;
|
|
18
22
|
needs\ prepare)
|
|
19
23
|
sh "$root/scripts/prepare"
|
|
20
24
|
sh "$root/scripts/install"
|
|
21
|
-
desired_commit=$(spw_metadata_commit_or_empty "$root/plugins/superpowers/.superpowers-upstream.json" || true)
|
|
22
|
-
[ -n "$desired_commit" ] || spw_die "generated metadata missing desired commit after install"
|
|
23
|
-
spw_verify_refresh "$desired_commit"
|
|
24
25
|
;;
|
|
25
26
|
needs\ install)
|
|
26
27
|
sh "$root/scripts/install"
|
|
27
|
-
desired_commit=$(spw_metadata_commit_or_empty "$root/plugins/superpowers/.superpowers-upstream.json" || true)
|
|
28
|
-
[ -n "$desired_commit" ] || spw_die "generated metadata missing desired commit after install"
|
|
29
|
-
spw_verify_refresh "$desired_commit"
|
|
30
28
|
;;
|
|
31
29
|
*)
|
|
32
30
|
echo "$probe_output"
|