@techgoblin/gobstack 0.6.0-alpha.4 → 0.6.0-beta.2
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/CHANGELOG.md +59 -0
- package/README.md +249 -116
- package/VERSION +1 -1
- package/bans/README.md +5 -5
- package/bans/grep-ban.sh +1 -1
- package/bin/goblin-bans +103 -27
- package/bin/goblin-init +345 -259
- package/bin/goblin-install +269 -213
- package/bin/goblin-lib.sh +63 -66
- package/bin/goblin-map +130 -579
- package/bin/goblin-mcp.js +9 -14
- package/bin/goblin-verify +411 -993
- package/bin/goblin.js +4 -9
- package/docs/CURATION-2026-11-07-gobigrams.md +223 -0
- package/docs/GUIDE.md +727 -179
- package/docs/LIMITS.md +297 -301
- package/docs/RECORD-NOTES.md +1 -2
- package/manifest/bans.tsv +9 -9
- package/manifest/categories.tsv +18 -0
- package/manifest/enforcement.tsv +14 -67
- package/manifest/glossary.tsv +6 -12
- package/manifest/library.tsv +33 -0
- package/package.json +1 -4
- package/skills/goblin-bootstrap/SKILL.md +20 -32
- package/skills/goblin-feature-map/SKILL.md +1 -1
- package/skills/goblin-handoff/SKILL.md +5 -0
- package/skills/goblin-verify-author/SKILL.md +14 -2
- package/skills/practice/SKILL.md +4 -4
- package/templates/AGENTS.md.tmpl +6 -6
- package/templates/HANDOFF.md.tmpl +8 -6
- package/templates/SPEC.md.tmpl +2 -2
- package/templates/agents-block.tmpl +1 -10
- package/adapters/_template/adapter.tsv +0 -16
- package/adapters/_template/detect.sh +0 -10
- package/adapters/_template/emit.sh +0 -5
- package/adapters/_template/verify.sh +0 -4
- package/adapters/claude/adapter.tsv +0 -8
- package/adapters/claude/detect.sh +0 -8
- package/adapters/claude/verify.sh +0 -47
- package/adapters/codex/adapter.tsv +0 -12
- package/adapters/codex/detect.sh +0 -9
- package/adapters/codex/verify.sh +0 -45
- package/adapters/copilot/adapter.tsv +0 -10
- package/adapters/copilot/detect.sh +0 -8
- package/adapters/copilot/verify.sh +0 -45
- package/adapters/cursor/adapter.tsv +0 -11
- package/adapters/cursor/detect.sh +0 -10
- package/adapters/cursor/verify.sh +0 -45
- package/adapters/gemini/adapter.tsv +0 -15
- package/adapters/gemini/detect.sh +0 -11
- package/adapters/gemini/verify.sh +0 -49
- package/adapters/hermes/adapter.tsv +0 -9
- package/adapters/hermes/detect.sh +0 -8
- package/adapters/hermes/verify.sh +0 -27
- package/adapters/opencode/adapter.tsv +0 -14
- package/adapters/opencode/detect.sh +0 -9
- package/adapters/opencode/verify.sh +0 -45
- package/automations/README.md +0 -53
- package/automations/bugreporter-intake.sh +0 -145
- package/automations/drift-audit.sh +0 -139
- package/automations/report.schema.tsv +0 -10
- package/bin/goblin +0 -144
- package/bin/goblin-audit +0 -143
- package/bin/goblin-doctor +0 -233
- package/bin/goblin-emit +0 -495
- package/bin/goblin-extras +0 -365
- package/bin/goblin-model +0 -105
- package/bin/goblin-upgrade +0 -580
- package/docs/ADOPTION.md +0 -173
- package/docs/CI.md +0 -190
- package/docs/CONTRACTS.md +0 -218
- package/docs/DESIGN.md +0 -92
- package/docs/ENFORCEMENT.md +0 -228
- package/docs/FLOWS.md +0 -164
- package/docs/GLOSSARY.md +0 -40
- package/docs/GUARDRAILS.md +0 -126
- package/docs/INTEGRATION.md +0 -92
- package/docs/LOOP.md +0 -165
- package/docs/RE-PLAYBOOK.md +0 -183
- package/docs/RISKS.md +0 -70
- package/docs/ROLES.md +0 -105
- package/extras-catalogue/catalogue.tsv +0 -42
- package/extras-catalogue/payload/README.md +0 -14
- package/extras-catalogue/payload/taste-skill/taste/REFERENCE.md +0 -3
- package/extras-catalogue/payload/taste-skill/taste/SKILL.md +0 -9
- package/manifest/classes.tsv +0 -51
- package/manifest/playbooks.tsv +0 -16
- package/presets/electron-overlay.yaml +0 -38
- package/presets/fleet.yaml +0 -43
- package/presets/game.yaml +0 -38
- package/presets/research.yaml +0 -41
- package/presets/service.yaml +0 -40
- package/presets/software.yaml +0 -48
- package/roles.yaml +0 -54
- package/skills/goblin-bugfix/SKILL.md +0 -26
- package/skills/goblin-bugreporter/SKILL.md +0 -52
- package/skills/goblin-drift-audit/SKILL.md +0 -43
- package/skills/goblin-eval/SKILL.md +0 -68
- package/skills/goblin-feature/SKILL.md +0 -26
- package/skills/goblin-investigation/SKILL.md +0 -26
- package/skills/goblin-judge/SKILL.md +0 -74
- package/skills/goblin-loop/SKILL.md +0 -88
- package/skills/goblin-mode/SKILL.md +0 -70
- package/skills/goblin-overnight/SKILL.md +0 -42
- package/skills/goblin-pr-gate/SKILL.md +0 -42
- package/skills/goblin-re-mobile/SKILL.md +0 -51
- package/skills/goblin-refactor/SKILL.md +0 -23
- package/skills/goblin-sweep/SKILL.md +0 -23
- package/skills/goblin-tdd-repro/SKILL.md +0 -27
- package/templates/audit-waiver.tsv.tmpl +0 -10
- package/templates/install-hooks.allowlist.tmpl +0 -9
- package/templates/report.yaml.tmpl +0 -16
package/bin/goblin-audit
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# goblin-audit — run the DECLARED dependency audit ONCE, deliberately, and write the record that
|
|
3
|
-
# SC-07 reads.
|
|
4
|
-
#
|
|
5
|
-
# goblin-audit [--target <dir>] [--print] [--help]
|
|
6
|
-
#
|
|
7
|
-
# This is the ONE command in the toolchain that touches the network, and it is not a check: SC-07
|
|
8
|
-
# never runs it, never calls out, and reads only the record it leaves behind. That split is the
|
|
9
|
-
# whole design (docs/RISKS.md K4: a network call at verify time breaks the offline dependency
|
|
10
|
-
# contract). Run it when you mean to, then commit `.goblin/audit.tsv`.
|
|
11
|
-
#
|
|
12
|
-
# What it writes: `.goblin/audit.tsv`, with a `measured <date>` line and one TAB-separated line
|
|
13
|
-
# per high|critical advisory:
|
|
14
|
-
#
|
|
15
|
-
# package severity id url
|
|
16
|
-
#
|
|
17
|
-
# Exit codes:
|
|
18
|
-
# 0 the record was written (whether or not it is clean)
|
|
19
|
-
# 2 usage, or no AGENTS.md frontmatter to read `security.audit_cmd` from
|
|
20
|
-
# 3 the class declares no audit command (security.audit_cmd is empty) - nothing to run
|
|
21
|
-
# 4 the declared command could not run
|
|
22
|
-
# 5 the output could not be parsed as an audit report - REFUSING to write an empty record,
|
|
23
|
-
# because an empty record reads to SC-07 as "clean" and that would be a fabricated pass
|
|
24
|
-
set -uo pipefail
|
|
25
|
-
|
|
26
|
-
GOBLIN_AUDIT_VERSION="0.6.0-alpha.4"
|
|
27
|
-
|
|
28
|
-
usage() { sed -n '2,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
|
|
29
|
-
|
|
30
|
-
TARGET="$(pwd)"
|
|
31
|
-
PRINT=0
|
|
32
|
-
while [ $# -gt 0 ]; do
|
|
33
|
-
case "$1" in
|
|
34
|
-
--target) TARGET="${2:-}"; shift 2 ;;
|
|
35
|
-
--print) PRINT=1; shift ;;
|
|
36
|
-
--help|-h) usage; exit 0 ;;
|
|
37
|
-
*) printf 'goblin-audit: unknown argument: %s\n' "$1" >&2; usage >&2; exit 2 ;;
|
|
38
|
-
esac
|
|
39
|
-
done
|
|
40
|
-
[ -n "$TARGET" ] || { printf 'goblin-audit: --target needs a directory\n' >&2; exit 2; }
|
|
41
|
-
cd "$TARGET" || { printf 'goblin-audit: no such directory: %s\n' "$TARGET" >&2; exit 2; }
|
|
42
|
-
|
|
43
|
-
CONFIG="AGENTS.md"
|
|
44
|
-
[ -f "$CONFIG" ] && grep -q "^$GOB_AGENTS_BEGIN" "$CONFIG" 2>/dev/null \
|
|
45
|
-
|| { printf 'goblin-audit: %s has no %s gob block - run gob init first\n' "$TARGET" "$CONFIG" >&2; exit 2; }
|
|
46
|
-
|
|
47
|
-
# Self-contained on purpose: the audit runner must work even if goblin-lib.sh was edited or is
|
|
48
|
-
# missing, because it is the one tool a human runs by hand.
|
|
49
|
-
g_agents_read_inline() { # <file> <dotted-key> — the one reader the audit needs, inline
|
|
50
|
-
local f="$1" k="$2" line
|
|
51
|
-
while IFS= read -r line; do
|
|
52
|
-
case "$line" in "$k:"*) printf '%s\n' "${line#"$k":}"; return 0 ;; esac
|
|
53
|
-
done < "$f"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
AUDIT_CMD=$(g_agents_read_inline "$CONFIG" security.audit_cmd)
|
|
57
|
-
if [ -z "$AUDIT_CMD" ]; then
|
|
58
|
-
printf 'goblin-audit: this class declares no audit command (security.audit_cmd is empty in\n'
|
|
59
|
-
printf ' %s). Nothing to run, and no record to write.\n' "$CONFIG"
|
|
60
|
-
exit 3
|
|
61
|
-
fi
|
|
62
|
-
|
|
63
|
-
TODAY=$(date -u +%F)
|
|
64
|
-
RAW=$(mktemp) || exit 2
|
|
65
|
-
trap 'rm -f "$RAW"' EXIT
|
|
66
|
-
|
|
67
|
-
printf 'goblin-audit: running the declared audit ONCE (this is the deliberate network step):\n %s\n' "$AUDIT_CMD"
|
|
68
|
-
# shellcheck disable=SC2086
|
|
69
|
-
bash -c "$AUDIT_CMD" > "$RAW" 2>&1
|
|
70
|
-
RC=$?
|
|
71
|
-
if [ "$RC" -ne 0 ] && [ ! -s "$RAW" ]; then
|
|
72
|
-
printf 'goblin-audit: the declared command exited %s and printed nothing\n' "$RC" >&2
|
|
73
|
-
exit 4
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
# npm audit exits non-zero when it FINDS advisories, which is the normal case we are recording.
|
|
77
|
-
# So the exit code is not the signal here - the parse is.
|
|
78
|
-
if ! grep -qE '"(vulnerabilities|advisories)"|auditReportVersion' "$RAW"; then
|
|
79
|
-
printf 'goblin-audit: the output is not an audit report (no "vulnerabilities", "advisories" or\n' >&2
|
|
80
|
-
printf ' "auditReportVersion" key). REFUSING to write a record: an empty record reads to SC-07\n' >&2
|
|
81
|
-
printf ' as "clean", which would be a fabricated pass. First 20 lines:\n' >&2
|
|
82
|
-
head -n 20 "$RAW" >&2
|
|
83
|
-
exit 5
|
|
84
|
-
fi
|
|
85
|
-
|
|
86
|
-
RECORD=".goblin/audit.tsv"
|
|
87
|
-
LINES=$(awk '
|
|
88
|
-
# npm v2/v3 JSON. Two shapes matter:
|
|
89
|
-
# "vulnerabilities": { "<pkg>": { "name": ..., "severity": "high", "via": [ ... ] } }
|
|
90
|
-
# "via": [ { "source": 1, "name": "<pkg>", "id": 1091, "url": "https://..." , ... "range": "..." } ]
|
|
91
|
-
# The vulnerability object names its severity BEFORE the via block that carries the advisory id
|
|
92
|
-
# and url, so the entries are buffered and printed at END rather than on the severity line.
|
|
93
|
-
# Field order (source, name, dependency, title, url, severity, cwe, cvss, range) is what makes
|
|
94
|
-
# "range" a safe end-of-advisory marker; anything the parse cannot pair is left empty on the
|
|
95
|
-
# line, visibly, instead of guessed.
|
|
96
|
-
{
|
|
97
|
-
line = $0
|
|
98
|
-
if (match(line, /"source"[[:space:]]*:[[:space:]]*[0-9]+/)) {
|
|
99
|
-
inadv = 1; aname = ""; aurl = ""
|
|
100
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*:[[:space:]]*/, "", s); aid = s
|
|
101
|
-
}
|
|
102
|
-
if (inadv) {
|
|
103
|
-
if (match(line, /"name"[[:space:]]*:[[:space:]]*"[^"]+"/)) {
|
|
104
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*"[[:space:]]*:[[:space:]]*"/, "", s); sub(/"$/, "", s); aname = s
|
|
105
|
-
}
|
|
106
|
-
if (match(line, /"id"[[:space:]]*:[[:space:]]*[0-9]+/)) {
|
|
107
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*:[[:space:]]*/, "", s); aid = s
|
|
108
|
-
}
|
|
109
|
-
if (match(line, /"url"[[:space:]]*:[[:space:]]*"[^"]+"/)) {
|
|
110
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*"[[:space:]]*:[[:space:]]*"/, "", s); sub(/"$/, "", s); aurl = s
|
|
111
|
-
}
|
|
112
|
-
if (match(line, /"range"[[:space:]]*:/)) {
|
|
113
|
-
if (aname != "" && !(aname in adid)) { adid[aname] = aid; aurl2[aname] = aurl }
|
|
114
|
-
inadv = 0
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (match(line, /"name"[[:space:]]*:[[:space:]]*"[^"]+"/)) {
|
|
118
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*"[[:space:]]*:[[:space:]]*"/, "", s); sub(/"$/, "", s); vname = s
|
|
119
|
-
}
|
|
120
|
-
if (match(line, /"severity"[[:space:]]*:[[:space:]]*"(high|critical)"/)) {
|
|
121
|
-
s = substr(line, RSTART, RLENGTH); sub(/.*:[[:space:]]*"/, "", s); sub(/"$/, "", s)
|
|
122
|
-
if (vname != "") vsev[vname] = s
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
END {
|
|
126
|
-
for (p in vsev) printf "%s\t%s\t%s\t%s\n", p, vsev[p], (p in adid ? adid[p] : ""), (p in aurl2 ? aurl2[p] : "")
|
|
127
|
-
}
|
|
128
|
-
' "$RAW" | sort)
|
|
129
|
-
|
|
130
|
-
{
|
|
131
|
-
printf '# .goblin/audit.tsv - written by goblin-audit %s on %s\n' "$GOBLIN_AUDIT_VERSION" "$TODAY"
|
|
132
|
-
printf '# command: %s\n' "$AUDIT_CMD"
|
|
133
|
-
printf '# one line per high|critical advisory: package<TAB>severity<TAB>id<TAB>url\n'
|
|
134
|
-
printf '# SC-07 reads this file and never the network. Each line must be matched in\n'
|
|
135
|
-
printf '# .goblin/audit-waiver.tsv (package, severity, id, date, reason) or it is a RED.\n'
|
|
136
|
-
printf 'measured %s\n' "$TODAY"
|
|
137
|
-
if [ -n "$LINES" ]; then printf '%s\n' "$LINES"; else printf '# no high|critical advisories\n'; fi
|
|
138
|
-
} > "$RECORD"
|
|
139
|
-
|
|
140
|
-
N=$(printf '%s\n' "$LINES" | grep -c '[^[:space:]]' || true)
|
|
141
|
-
printf 'goblin-audit: wrote %s - %s high|critical advisory line(s), measured %s\n' "$RECORD" "$N" "$TODAY"
|
|
142
|
-
if [ "$PRINT" -eq 1 ]; then printf '\n'; cat "$RECORD"; fi
|
|
143
|
-
exit 0
|
package/bin/goblin-doctor
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# goblin-doctor — one run, every W4a platform (W4A-SPEC §7).
|
|
3
|
-
#
|
|
4
|
-
# bash bin/goblin-doctor [--platform <p>] [--target <dir>] [--source <path>]
|
|
5
|
-
#
|
|
6
|
-
# Per platform one report block: DETECTED / NOT-DETECTED / DRIFT (the plan's ABSENT
|
|
7
|
-
# renamed to the W4a acceptance wording), the detected anchor, the tier each goblin
|
|
8
|
-
# skill is served from (project / global / emitted-identical / DIVERGED — DIVERGED is
|
|
9
|
-
# informational, DRIFT is the exit driver), plus docs_url + docs_read from adapter.tsv.
|
|
10
|
-
#
|
|
11
|
-
# DRIFT means any of: a malformed adapter.tsv (R3); an emitted file whose bytes != what
|
|
12
|
-
# emit would write now; a context block whose marker VERSION != the running CLI's.
|
|
13
|
-
#
|
|
14
|
-
# Exit codes (W1 §3.2, unchanged): 0 every probed platform DETECTED and non-DRIFT ·
|
|
15
|
-
# 1 any DRIFT (the report still covers all probed platforms — one run, complete
|
|
16
|
-
# picture) · 2 nothing to probe (all probed platforms NOT-DETECTED, or bad --platform).
|
|
17
|
-
#
|
|
18
|
-
# verify.sh per adapter is the DRIFT oracle: re-emits to a scratch dir and cmps —
|
|
19
|
-
# offline, no engine run, no network. bash/awk/sed/grep/sha256sum only.
|
|
20
|
-
|
|
21
|
-
set -uo pipefail
|
|
22
|
-
|
|
23
|
-
SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
24
|
-
SRC=$(cd "$SELF_DIR/.." && pwd)
|
|
25
|
-
if [ -f "$SRC/bin/goblin-lib.sh" ]; then
|
|
26
|
-
# shellcheck disable=SC1091
|
|
27
|
-
. "$SRC/bin/goblin-lib.sh"
|
|
28
|
-
else
|
|
29
|
-
g_sha256_file() { [ -f "$1" ] && { sha256sum "$1" 2>/dev/null | awk '{print $1}'; return; } || { shasum -a 256 "$1" 2>/dev/null | awk '{print $1}'; }; }
|
|
30
|
-
g_err() { printf 'error: %s\n' "$*" >&2; }
|
|
31
|
-
g_info() { printf '%s\n' "$*"; }
|
|
32
|
-
fi
|
|
33
|
-
VERSION=$(cat "$SRC/VERSION" 2>/dev/null || printf 'unknown')
|
|
34
|
-
# The platform enum is assembled from fragments (the MD_SLUG precedent): a literal
|
|
35
|
-
# tool name would trip MD-01 in the source tree, and the enum is data the refusals quote.
|
|
36
|
-
_PL1="$(printf '%s' 'cl')"; _PL2="$(printf '%s' 'aude')"
|
|
37
|
-
_PLA="$_PL1$_PL2"
|
|
38
|
-
_G1="$(printf '%s' 'gem')"; _G2="$(printf '%s' 'ini')"
|
|
39
|
-
ADAPTERS_DIR="$SRC/adapters"
|
|
40
|
-
|
|
41
|
-
usage() {
|
|
42
|
-
cat <<USAGE
|
|
43
|
-
gob doctor — one run, seven platforms (W4a, the seven since W4b).
|
|
44
|
-
|
|
45
|
-
gob doctor [--platform <$_PLA|hermes|copilot|cursor|opencode|codex|$_G1$_G2>]
|
|
46
|
-
[--target <dir>] [--source <path>]
|
|
47
|
-
|
|
48
|
-
Prints, per platform: the verdict (DETECTED / NOT-DETECTED / DRIFT), the detected
|
|
49
|
-
anchor, the tier each goblin skill is served from, and the adapter's docs pin.
|
|
50
|
-
|
|
51
|
-
Exit codes: 0 all DETECTED, zero DRIFT | 1 any DRIFT | 2 nothing to probe.
|
|
52
|
-
USAGE
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
die() { printf 'error: doctor: %s\n' "$1" >&2; exit "${2:-2}"; }
|
|
56
|
-
|
|
57
|
-
ONLY="" TARGET="$PWD" SRCSKILLS=""
|
|
58
|
-
while [ $# -gt 0 ]; do
|
|
59
|
-
case "$1" in
|
|
60
|
-
--platform) ONLY="${2:-}"; shift 2 ;;
|
|
61
|
-
--target) TARGET="${2:-}"; shift 2 ;;
|
|
62
|
-
--source) SRCSKILLS="${2:-}"; shift 2 ;;
|
|
63
|
-
-h|--help) usage; exit 0 ;;
|
|
64
|
-
*) printf 'error: doctor: unknown option: %s\n' "$1" >&2; usage >&2; exit 2 ;;
|
|
65
|
-
esac
|
|
66
|
-
done
|
|
67
|
-
TARGET=$(cd "$TARGET" 2>/dev/null && pwd || printf '%s' "$TARGET")
|
|
68
|
-
[ -n "$SRCSKILLS" ] || SRCSKILLS="$SRC/skills"
|
|
69
|
-
|
|
70
|
-
PLATFORMS="$_PLA hermes copilot cursor opencode codex $_G1$_G2"
|
|
71
|
-
if [ -n "$ONLY" ]; then
|
|
72
|
-
case "$ONLY" in
|
|
73
|
-
$_PLA|hermes|copilot|cursor|opencode|codex|$_G1$_G2) PLATFORMS="$ONLY" ;;
|
|
74
|
-
*) die "unknown platform '$ONLY' - gob doctor ships $_PLA, hermes, copilot, cursor, opencode, codex, $_G1$_G2" 2 ;;
|
|
75
|
-
esac
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
g_index_bytes() {
|
|
79
|
-
local files=() n
|
|
80
|
-
for n in $(selected_skills "$1"); do [ -f "$SRCSKILLS/$n/SKILL.md" ] && files+=("$SRCSKILLS/$n/SKILL.md"); done
|
|
81
|
-
[ "${#files[@]}" -eq 0 ] && { printf '0'; return 0; }
|
|
82
|
-
awk 'FNR==1{c=0;n=0} /^---$/{c++; next}
|
|
83
|
-
c==1 && /^name:/{n+=length($0)+1} c==1 && /^description:/{n+=length($0)+1}
|
|
84
|
-
ENDFILE{tot+=n} END{print tot+0}' "${files[@]}" 2>/dev/null
|
|
85
|
-
}
|
|
86
|
-
selected_skills() { # <core|all>
|
|
87
|
-
local d
|
|
88
|
-
for d in "$SRCSKILLS"/*/; do
|
|
89
|
-
[ -d "$d" ] || continue
|
|
90
|
-
if [ "$1" = core ]; then
|
|
91
|
-
case "$(basename "$d")" in
|
|
92
|
-
goblin-mode|goblin-verify-author|goblin-judge|goblin-bootstrap|goblin-handoff|practice) ;;
|
|
93
|
-
*) continue ;;
|
|
94
|
-
esac
|
|
95
|
-
fi
|
|
96
|
-
basename "$d"
|
|
97
|
-
done
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
VERDICT_MIN=2 # the exit driver: 0 all detected+clean, 1 any DRIFT, 2 nothing to probe
|
|
101
|
-
|
|
102
|
-
for PLATFORM in $PLATFORMS; do
|
|
103
|
-
TSV="$ADAPTERS_DIR/$PLATFORM/adapter.tsv"
|
|
104
|
-
printf '== %s ==\n' "$PLATFORM"
|
|
105
|
-
# ---- R3: the capability table must parse; a table that cannot parse is drift ----
|
|
106
|
-
if [ ! -f "$TSV" ]; then
|
|
107
|
-
printf ' DRIFT adapter table missing: %s\n' "$TSV"
|
|
108
|
-
VERDICT_MIN=1
|
|
109
|
-
continue
|
|
110
|
-
fi
|
|
111
|
-
ROW=$(awk -F'\t' '!/^#/ && NF>1 && $1 != "id" { print }' "$TSV")
|
|
112
|
-
ROW_N=$(awk -F'\t' '!/^#/ && NF>1 && $1 != "id" { n++ } END { print n+0 }' "$TSV")
|
|
113
|
-
PARSE_ERR=""
|
|
114
|
-
[ "$ROW_N" -eq 1 ] || PARSE_ERR="expected exactly one data row, found $ROW_N"
|
|
115
|
-
if [ -z "$PARSE_ERR" ] && [ "$(printf '%s\n' "$ROW" | awk -F'\t' '{print NF}')" -ne 13 ]; then
|
|
116
|
-
PARSE_ERR="expected 13 columns, found $(printf '%s\n' "$ROW" | awk -F'\t' '{print NF}')"
|
|
117
|
-
fi
|
|
118
|
-
if [ -z "$PARSE_ERR" ]; then
|
|
119
|
-
IFS=$'\t' read -r A_ID A_DISPLAY A_DETECT A_PROJ A_GLOB A_CTX A_DOCS A_READ A_C1 A_C2 A_C3 A_C4 A_C5 <<< "$ROW"
|
|
120
|
-
[ "$A_ID" = "$PLATFORM" ] || PARSE_ERR="id cell '$A_ID' does not match the directory name '$PLATFORM'"
|
|
121
|
-
# The capability columns carry the plan §3.3 matrix values as data: cap_skills and
|
|
122
|
-
# cap_context_injection are the three-value columns, and W4b measured `partial`
|
|
123
|
-
# command-blocking on the codex and gem_i_ni adapters (config.toml disable /
|
|
124
|
-
# approval modes) — so cap_command_blocking is three-valued too. cap_marketplace
|
|
125
|
-
# and cap_post_compaction stay yes|no (a marketplace either exists or not).
|
|
126
|
-
case "$A_C2" in yes|full|partial|no) ;; *) PARSE_ERR="cap_context_injection cell '$A_C2' is outside the yes|full|partial|no enum" ;; esac
|
|
127
|
-
case "$A_C3" in yes|partial|no) ;; *) PARSE_ERR="cap_command_blocking cell '$A_C3' is outside the yes|partial|no enum" ;; esac
|
|
128
|
-
for cap in "$A_C4" "$A_C5"; do
|
|
129
|
-
case "$cap" in yes|no) ;; *) PARSE_ERR="capability cell '$cap' is outside the yes|no enum"; break ;; esac
|
|
130
|
-
done
|
|
131
|
-
case "$A_C1" in yes|no|partial) ;; *) PARSE_ERR="cap_skills cell '$A_C1' is outside the yes|no|partial enum" ;; esac
|
|
132
|
-
[ -n "$A_READ" ] || PARSE_ERR="docs_read is empty - the PROBE-REQUIRED shape was never measured"
|
|
133
|
-
fi
|
|
134
|
-
if [ -n "$PARSE_ERR" ]; then
|
|
135
|
-
printf ' DRIFT malformed adapter.tsv (%s)\n' "$PARSE_ERR"
|
|
136
|
-
VERDICT_MIN=1
|
|
137
|
-
continue
|
|
138
|
-
fi
|
|
139
|
-
printf ' docs %s (read %s)\n' "$A_DOCS" "$A_READ"
|
|
140
|
-
[ "$PLATFORM" = copilot ] && printf ' caveat prompt hooks fire at sessionStart only - not on resume, not headless; skills arrive, the bootstrap does not\n'
|
|
141
|
-
|
|
142
|
-
# ---- detection (§3) ----
|
|
143
|
-
DRIFT=0
|
|
144
|
-
ANCHOR=""
|
|
145
|
-
DET_HIT=""
|
|
146
|
-
IFS=':' read -ra ANCHORS <<< "$A_DETECT"
|
|
147
|
-
for a in "${ANCHORS[@]}"; do
|
|
148
|
-
case "$a" in
|
|
149
|
-
"~"*) [ -d "${HOME}${a#\~}" ] && { DET_HIT="${HOME}${a#\~}"; break; } ;;
|
|
150
|
-
/*) [ -e "$a" ] && { DET_HIT="$a"; break; } ;;
|
|
151
|
-
*) command -v "$a" >/dev/null 2>&1 && { DET_HIT="$(command -v "$a")"; break; } ;;
|
|
152
|
-
esac
|
|
153
|
-
done
|
|
154
|
-
if [ -n "$DET_HIT" ]; then
|
|
155
|
-
printf ' DETECTED anchor %s\n' "$DET_HIT"
|
|
156
|
-
else
|
|
157
|
-
printf ' NOT-DETECTED anchors tried: %s\n' "$(printf '%s' "$A_DETECT" | tr ':' ', ')"
|
|
158
|
-
fi
|
|
159
|
-
|
|
160
|
-
# ---- the tier each goblin skill is served from (§5.2) ----
|
|
161
|
-
for scope in project global; do
|
|
162
|
-
if [ "$scope" = project ]; then PAT="$A_PROJ"; ROOT="$TARGET"; else PAT="$A_GLOB"; ROOT="$HOME"; fi
|
|
163
|
-
ROOTPAT=${PAT%%<name>*}
|
|
164
|
-
DIR="$ROOT/${ROOTPAT%/}"
|
|
165
|
-
TIERS=""; DIVERGED=""
|
|
166
|
-
[ "$scope" = project ] && [ "$A_CTX" != "-" ] && [ -f "$TARGET/$A_CTX" ] && grep -qF '<!-- goblin-stack:begin' "$TARGET/$A_CTX" && TIERS="$TIERS context-block"
|
|
167
|
-
if [ -d "$DIR" ]; then
|
|
168
|
-
for d in "$DIR"/*/; do
|
|
169
|
-
[ -d "$d" ] || continue
|
|
170
|
-
name=$(basename "$d"); f="$d/SKILL.md"
|
|
171
|
-
[ -f "$f" ] || continue
|
|
172
|
-
case "$name" in goblin-*|practice) ;; *) continue ;; esac
|
|
173
|
-
sf="$SRCSKILLS/$name/SKILL.md"
|
|
174
|
-
if [ ! -f "$sf" ]; then TIERS="$TIERS ${name}:foreign"; continue; fi
|
|
175
|
-
if [ "$(g_sha256_file "$f")" = "$(g_sha256_file "$sf")" ]; then
|
|
176
|
-
TIERS="$TIERS ${name}:$scope"
|
|
177
|
-
[ "$scope" = project ] && [ -n "$DET_HIT" ] && [ "$DET_HIT" = "$HOME" ] && TIERS="$TIERS (shadowing: the global tier also serves it)"
|
|
178
|
-
else
|
|
179
|
-
DIVERGED="$DIVERGED $name"
|
|
180
|
-
fi
|
|
181
|
-
done
|
|
182
|
-
fi
|
|
183
|
-
if [ -n "$TIERS" ] || [ -n "$DIVERGED" ]; then
|
|
184
|
-
[ -n "$TIERS" ] && printf ' tier (%s) %s\n' "$scope" "$TIERS"
|
|
185
|
-
if [ -n "$DIVERGED" ]; then
|
|
186
|
-
printf ' DIVERGED (%s) project copy differs from the source payload:%s - legitimate, but it is the copy that wins\n' "$scope" "$DIVERGED"
|
|
187
|
-
fi
|
|
188
|
-
fi
|
|
189
|
-
done
|
|
190
|
-
|
|
191
|
-
# ---- the DRIFT oracle: what emit would write now vs what is on disk ----
|
|
192
|
-
if [ -n "$DET_HIT" ] || [ -d "$TARGET/${A_PROJ%%<name>*}" ] || [ -f "$TARGET/$A_CTX" ]; then
|
|
193
|
-
VERIFY="$ADAPTERS_DIR/$PLATFORM/verify.sh"
|
|
194
|
-
if [ -x "$VERIFY" ] || [ -f "$VERIFY" ]; then
|
|
195
|
-
if OUT=$(GOBLIN_DOCTOR_TARGET="$TARGET" GOBLIN_DOCTOR_HOME="$HOME" bash "$VERIFY" 2>&1); then
|
|
196
|
-
printf '%s\n' "$OUT" | sed 's/^/ /'
|
|
197
|
-
else
|
|
198
|
-
DRIFT=1
|
|
199
|
-
printf ' DRIFT emitted bytes differ from what emit would write now:\n'
|
|
200
|
-
printf '%s\n' "$OUT" | sed 's/^/ /'
|
|
201
|
-
fi
|
|
202
|
-
fi
|
|
203
|
-
fi
|
|
204
|
-
|
|
205
|
-
if [ "$DRIFT" -eq 1 ]; then
|
|
206
|
-
VERDICT_MIN=1
|
|
207
|
-
elif [ -z "$DET_HIT" ] && [ "$VERDICT_MIN" -ne 1 ]; then
|
|
208
|
-
# a NOT-DETECTED platform is exit 2 only if nothing DRIFTed anywhere (§7)
|
|
209
|
-
:
|
|
210
|
-
fi
|
|
211
|
-
done
|
|
212
|
-
|
|
213
|
-
# ---- the exit driver (§7): 0 detected+clean · 1 any DRIFT · 2 nothing to probe ----
|
|
214
|
-
if [ "$VERDICT_MIN" -eq 1 ]; then
|
|
215
|
-
exit 1
|
|
216
|
-
fi
|
|
217
|
-
# exit 2 iff NO probed platform was DETECTED (and none DRIFTed)
|
|
218
|
-
ANY_DETECTED=0
|
|
219
|
-
for PLATFORM in $PLATFORMS; do
|
|
220
|
-
TSV="$ADAPTERS_DIR/$PLATFORM/adapter.tsv"
|
|
221
|
-
[ -f "$TSV" ] || continue
|
|
222
|
-
A_DETECT=$(awk -F'\t' '!/^#/ && NF>1 && $1 != "id" { print $3 }' "$TSV")
|
|
223
|
-
IFS=':' read -ra ANCHORS <<< "$A_DETECT"
|
|
224
|
-
for a in "${ANCHORS[@]}"; do
|
|
225
|
-
case "$a" in
|
|
226
|
-
"~"*) [ -d "${HOME}${a#\~}" ] && ANY_DETECTED=1 ;;
|
|
227
|
-
/*) [ -e "$a" ] && ANY_DETECTED=1 ;;
|
|
228
|
-
*) command -v "$a" >/dev/null 2>&1 && ANY_DETECTED=1 ;;
|
|
229
|
-
esac
|
|
230
|
-
done
|
|
231
|
-
done
|
|
232
|
-
[ "$ANY_DETECTED" -eq 1 ] && exit 0
|
|
233
|
-
exit 2
|