@techgoblin/gobstack 0.6.0-alpha.4 → 0.6.0-beta.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/CHANGELOG.md +45 -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 +249 -993
- package/bin/goblin.js +4 -9
- package/docs/GUIDE.md +724 -179
- package/docs/LIMITS.md +273 -301
- package/docs/RECORD-NOTES.md +1 -2
- package/manifest/bans.tsv +9 -9
- package/manifest/categories.tsv +18 -0
- package/manifest/enforcement.tsv +11 -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-verify-author/SKILL.md +2 -2
- package/skills/practice/SKILL.md +4 -4
- package/templates/AGENTS.md.tmpl +6 -6
- package/templates/HANDOFF.md.tmpl +1 -1
- 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
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# bugreporter-intake.sh — A-01's intake validator (the gate in front of `goblin-bugreporter`, P13).
|
|
3
|
-
#
|
|
4
|
-
# bash bugreporter-intake.sh <slug> [--reports <dir>] [--cards]
|
|
5
|
-
#
|
|
6
|
-
# A report is a FILE WITH A SCHEMA, not prose in a card body: prose invites the agent to fill
|
|
7
|
-
# the gaps by guessing, and a guess at intake poisons everything downstream. This script does
|
|
8
|
-
# the schema check with line-oriented shell, computes the content-only dedup key, and prints
|
|
9
|
-
# the exact card command.
|
|
10
|
-
#
|
|
11
|
-
# Exit codes: 0 the report passed intake | 1 REFUSED (the gap is named) | 2 could not run.
|
|
12
|
-
#
|
|
13
|
-
# The report is UNTRUSTED INPUT, so nothing reads it into a shell: the card is created by
|
|
14
|
-
# exec'ing an argv array (`run_card`), and the form printed for an operator (`card_cmd`) quotes
|
|
15
|
-
# every value that came out of the report. There is no `eval` on any path. A `symptom:` carrying
|
|
16
|
-
# a backtick, `$(...)` or a quote is text, in the card title and on the printed line alike.
|
|
17
|
-
#
|
|
18
|
-
# An under-specified report is filed, not dropped and not guessed: the refusal command carries
|
|
19
|
-
# NO --assignee, so the dispatcher buckets the card `skipped_unassigned` and it is structurally
|
|
20
|
-
# un-spawnable, while remaining visible on the board to a human.
|
|
21
|
-
set -uo pipefail
|
|
22
|
-
|
|
23
|
-
SLUG=""
|
|
24
|
-
REPORTS="reports"
|
|
25
|
-
CARDS=0
|
|
26
|
-
|
|
27
|
-
while [ $# -gt 0 ]; do
|
|
28
|
-
case "$1" in
|
|
29
|
-
--reports) REPORTS="${2:-}"; shift 2 ;;
|
|
30
|
-
--cards) CARDS=1; shift ;;
|
|
31
|
-
-h|--help) sed -n '2,/^set -/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
32
|
-
-*)
|
|
33
|
-
printf 'bugreporter-intake: unknown option: %s\n' "$1" >&2; exit 2 ;;
|
|
34
|
-
*) SLUG="$1"; shift ;;
|
|
35
|
-
esac
|
|
36
|
-
done
|
|
37
|
-
|
|
38
|
-
[ -n "$SLUG" ] || { printf 'bugreporter-intake: usage: bugreporter-intake.sh <slug> [--reports <dir>]\n' >&2; exit 2; }
|
|
39
|
-
REPORT="$REPORTS/$SLUG/report.yaml"
|
|
40
|
-
[ -f "$REPORT" ] || { printf 'bugreporter-intake: no report at %s\n' "$REPORT" >&2; exit 2; }
|
|
41
|
-
|
|
42
|
-
field() { sed -n "s/^$1:[[:space:]]*//p" "$REPORT" | head -n 1; }
|
|
43
|
-
# present <key> — the key exists AND carries something: an inline value, or at least one
|
|
44
|
-
# indented item under it (repro_steps is a block list, so a bare `field` read is empty for a
|
|
45
|
-
# perfectly good report - that false refusal was measured and is why this helper exists).
|
|
46
|
-
present() {
|
|
47
|
-
grep -q "^$1:" "$REPORT" || return 1
|
|
48
|
-
[ -n "$(field "$1")" ] && return 0
|
|
49
|
-
awk -v k="$1" '
|
|
50
|
-
$0 ~ ("^" k ":[[:space:]]*$") { inb = 1; next }
|
|
51
|
-
inb && /^[^[:space:]]/ { inb = 0 }
|
|
52
|
-
inb && /^[[:space:]]+[^[:space:]]/ { f = 1 }
|
|
53
|
-
END { exit !f }
|
|
54
|
-
' "$REPORT"
|
|
55
|
-
}
|
|
56
|
-
sha12() {
|
|
57
|
-
if command -v sha256sum >/dev/null 2>&1; then printf '%s' "$1" | sha256sum | cut -c1-12
|
|
58
|
-
else printf '%s' "$1" | shasum -a 256 | cut -c1-12; fi
|
|
59
|
-
}
|
|
60
|
-
# normalised = lowercased, whitespace collapsed, trimmed. The dedup key is a function of THIS
|
|
61
|
-
# and nothing else: no date, no run id, no counter - or it dedups nothing.
|
|
62
|
-
normalise() { printf '%s' "$1" | tr 'A-Z' 'a-z' | tr -s '[:space:]' ' ' | sed 's/^ //; s/ $//'; }
|
|
63
|
-
|
|
64
|
-
REPO=$(field repo)
|
|
65
|
-
SYMPTOM=$(field symptom)
|
|
66
|
-
REVISION=$(field revision)
|
|
67
|
-
KEY=$(field dedup_key)
|
|
68
|
-
|
|
69
|
-
MISSING=""
|
|
70
|
-
for k in repo symptom expected observed repro_steps revision; do
|
|
71
|
-
present "$k" || MISSING="$MISSING $k"
|
|
72
|
-
done
|
|
73
|
-
|
|
74
|
-
WANT_KEY="bug:${REPO}:$(sha12 "$(normalise "$SYMPTOM")")"
|
|
75
|
-
|
|
76
|
-
TITLE="bug: ${SYMPTOM}"
|
|
77
|
-
|
|
78
|
-
# shq <word> — the word quoted for a shell, so the printed form can be pasted without executing
|
|
79
|
-
# anything the report says. Single quotes make backticks and `$( )` text; an embedded single
|
|
80
|
-
# quote is written as the four-character `'\''` (close, escaped quote, reopen).
|
|
81
|
-
shq() { local s="$1"; s=${s//\'/\'\\\'\'}; printf "'%s'" "$s"; }
|
|
82
|
-
|
|
83
|
-
# card_cmd <title-suffix> <idempotency-key> <max-runtime> <max-retries> [assignee-args...]
|
|
84
|
-
# The card command as it is PRINTED for an operator. Every value that came out of the report is
|
|
85
|
-
# shell-quoted; flags and numbers are printed literally, so the line stays greppable. The printed
|
|
86
|
-
# form is what skills/goblin-bugreporter/SKILL.md step 1 tells the operator to run, so it must be
|
|
87
|
-
# paste-safe: the report is the untrusted input this gate exists to validate (G8-1).
|
|
88
|
-
card_cmd() {
|
|
89
|
-
local title="$TITLE$1" key="$2" rt="$3" rr="$4"; shift 4
|
|
90
|
-
local a
|
|
91
|
-
printf 'hermes kanban create %s' "$(shq "$title")"
|
|
92
|
-
for a in "$@"; do printf ' %s' "$a"; done
|
|
93
|
-
printf ' --idempotency-key %s --body-file %s --max-runtime %s --max-retries %s\n' \
|
|
94
|
-
"$(shq "$key")" "$(shq "$REPORT")" "$rt" "$rr"
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# run_card <title-suffix> <idempotency-key> <max-runtime> <max-retries> [assignee-args...]
|
|
98
|
-
# The same card as an ARGV ARRAY: no `eval`, no command string, so the title reaches the board as
|
|
99
|
-
# ONE argument whatever it contains. Never build a shell command out of file content (G8-1).
|
|
100
|
-
run_card() {
|
|
101
|
-
local title="$TITLE$1" key="$2" rt="$3" rr="$4"; shift 4
|
|
102
|
-
hermes kanban create "$title" "$@" --idempotency-key "$key" --body-file "$REPORT" \
|
|
103
|
-
--max-runtime "$rt" --max-retries "$rr"
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if [ -n "$MISSING" ]; then
|
|
107
|
-
printf 'bugreporter-intake: REFUSED - %s carries no value for:%s\n' "$REPORT" "$MISSING"
|
|
108
|
-
printf '# the card is created WITHOUT --assignee, so no agent can be spawned on it\n'
|
|
109
|
-
card_cmd " (incomplete intake)" "${KEY:-incomplete:$SLUG}" 600 0
|
|
110
|
-
exit 1
|
|
111
|
-
fi
|
|
112
|
-
|
|
113
|
-
if [ -n "$KEY" ] && [ "$KEY" != "$WANT_KEY" ]; then
|
|
114
|
-
printf 'bugreporter-intake: REFUSED - the recorded dedup_key is not the content key\n'
|
|
115
|
-
printf ' recorded %s\n recomputed %s\n' "$KEY" "$WANT_KEY"
|
|
116
|
-
printf ' a key derived from a date, a run id or a counter dedups nothing\n'
|
|
117
|
-
card_cmd " (bad key)" "$WANT_KEY" 600 0
|
|
118
|
-
exit 1
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
# The false-positive guard: a reproduction must name a revision that exists. A report with an
|
|
122
|
-
# unverifiable `revision:` is a refusal, not a card.
|
|
123
|
-
if [ -d "$REPO" ]; then
|
|
124
|
-
if ! ( cd "$REPO" && git rev-parse --verify --quiet "$REVISION^{commit}" >/dev/null 2>&1 ); then
|
|
125
|
-
printf 'bugreporter-intake: REFUSED - revision "%s" does not resolve in %s\n' "$REVISION" "$REPO"
|
|
126
|
-
card_cmd " (unresolvable revision)" "$WANT_KEY" 600 0
|
|
127
|
-
exit 1
|
|
128
|
-
fi
|
|
129
|
-
else
|
|
130
|
-
printf '# note: %s is not a local directory - the revision gate is unexercised here\n' "$REPO" >&2
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
if [ "$CARDS" -eq 0 ]; then
|
|
134
|
-
card_cmd "" "$WANT_KEY" 1800 1 --assignee researcher --skill goblin-bugreporter
|
|
135
|
-
exit 0
|
|
136
|
-
fi
|
|
137
|
-
if ! command -v hermes >/dev/null 2>&1; then
|
|
138
|
-
printf 'bugreporter-intake: hermes is not on PATH - the command is printed, no card was created\n' >&2
|
|
139
|
-
card_cmd "" "$WANT_KEY" 1800 1 --assignee researcher --skill goblin-bugreporter
|
|
140
|
-
exit 0
|
|
141
|
-
fi
|
|
142
|
-
run_card "" "$WANT_KEY" 1800 1 --assignee researcher --skill goblin-bugreporter >/dev/null 2>&1 \
|
|
143
|
-
|| { printf 'bugreporter-intake: the card was NOT created\n' >&2; exit 1; }
|
|
144
|
-
printf 'bugreporter-intake: card created with key %s\n' "$WANT_KEY"
|
|
145
|
-
exit 0
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# drift-audit.sh — A-02's producer, the no-agent half of `goblin-drift-audit` (P14).
|
|
3
|
-
#
|
|
4
|
-
# bash drift-audit.sh [--root <glob>] [--state <file>] [--dry-run] [--cards] [--limit <n>]
|
|
5
|
-
#
|
|
6
|
-
# It compares a RECORDED CLAIM with an ARTIFACT, never a memory and never a judgement, so its
|
|
7
|
-
# false-positive rate is structurally zero: the comparison is made by this script, which cannot
|
|
8
|
-
# invent a finding.
|
|
9
|
-
#
|
|
10
|
-
# claim 1: the HANDOFF names a commit that exists here and is an ancestor of HEAD (HP-05)
|
|
11
|
-
# claim 2: every installed file still matches its recorded hash (IN-02)
|
|
12
|
-
# artifact: the repo's git state and the files on disk
|
|
13
|
-
#
|
|
14
|
-
# It is deliberately the FIRST automation to turn on: no agent sits inside the producer, so it
|
|
15
|
-
# costs zero tokens when there is nothing to report.
|
|
16
|
-
#
|
|
17
|
-
# Exit codes: 0 clean, or nothing to do | 1 drift found | 2 could not run.
|
|
18
|
-
#
|
|
19
|
-
# Kill switch <state> carrying `enabled: false` stops it dead, and prints nothing on stdout.
|
|
20
|
-
# Ceiling `run:` lines in <state> from the last 24 h, capped by --limit (default 5). A
|
|
21
|
-
# capped run prints one `# capped` line, so "silent because clean" and "silent
|
|
22
|
-
# because the ceiling was hit" are never confused for each other.
|
|
23
|
-
set -uo pipefail
|
|
24
|
-
|
|
25
|
-
ROOT_GLOB="${HOME}/projects/*"
|
|
26
|
-
STATE="${GOBLIN_DRIFT_STATE:-${HOME}/.goblin/automations/drift-audit.state}"
|
|
27
|
-
DRY_RUN=0
|
|
28
|
-
CARDS=0
|
|
29
|
-
LIMIT=5
|
|
30
|
-
|
|
31
|
-
while [ $# -gt 0 ]; do
|
|
32
|
-
case "$1" in
|
|
33
|
-
--root) ROOT_GLOB="${2:-}"; shift 2 ;;
|
|
34
|
-
--state) STATE="${2:-}"; shift 2 ;;
|
|
35
|
-
--limit) LIMIT="${2:-}"; shift 2 ;;
|
|
36
|
-
--dry-run) DRY_RUN=1; shift ;;
|
|
37
|
-
--cards) CARDS=1; shift ;;
|
|
38
|
-
-h|--help) sed -n '2,/^set -/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
39
|
-
*) printf 'drift-audit: unknown option: %s\n' "$1" >&2; exit 2 ;;
|
|
40
|
-
esac
|
|
41
|
-
done
|
|
42
|
-
|
|
43
|
-
sha12() {
|
|
44
|
-
if command -v sha256sum >/dev/null 2>&1; then printf '%s' "$1" | sha256sum | cut -c1-12
|
|
45
|
-
else printf '%s' "$1" | shasum -a 256 | cut -c1-12; fi
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# ---- kill switch -------------------------------------------------------------
|
|
49
|
-
if [ -f "$STATE" ] && grep -q '^enabled:[[:space:]]*false' "$STATE"; then
|
|
50
|
-
printf 'drift-audit: disabled (enabled: false in %s)\n' "$STATE" >&2
|
|
51
|
-
exit 0
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# ---- the producer's own ceiling ----------------------------------------------
|
|
55
|
-
TODAY=$(date -u +%F)
|
|
56
|
-
RUNS=0
|
|
57
|
-
if [ -f "$STATE" ]; then
|
|
58
|
-
RUNS=$(grep -c "^run: $TODAY" "$STATE" 2>/dev/null || true)
|
|
59
|
-
case "$RUNS" in ''|*[!0-9]*) RUNS=0 ;; esac
|
|
60
|
-
fi
|
|
61
|
-
if [ "$RUNS" -ge "$LIMIT" ]; then
|
|
62
|
-
printf '# capped: %s of %s runs used today - nothing filed\n' "$RUNS" "$LIMIT"
|
|
63
|
-
exit 0
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
# ---- enumerate targets by glob, never by memory ------------------------------
|
|
67
|
-
TARGETS=0
|
|
68
|
-
SKIPPED=""
|
|
69
|
-
DRIFT=""
|
|
70
|
-
DETAIL=""
|
|
71
|
-
|
|
72
|
-
for d in $ROOT_GLOB; do
|
|
73
|
-
[ -d "$d" ] || continue
|
|
74
|
-
TARGETS=$((TARGETS + 1))
|
|
75
|
-
if [ ! -f "$d/.gob/goblin.yaml" ] && [ ! -f "$d/AGENTS.md" ]; then
|
|
76
|
-
SKIPPED="$SKIPPED $(basename "$d")"
|
|
77
|
-
continue
|
|
78
|
-
fi
|
|
79
|
-
if [ ! -f "$d/.gob/bin/goblin-verify" ]; then
|
|
80
|
-
SKIPPED="$SKIPPED $(basename "$d")(no-verifier)"
|
|
81
|
-
continue
|
|
82
|
-
fi
|
|
83
|
-
# --only IN-02,HP-05 rather than a full run: both are builtins that write no runtime state,
|
|
84
|
-
# so the audit never edits the tree it is auditing (design rule 2 of the honesty section).
|
|
85
|
-
OUT=$( cd "$d" && bash .gob/bin/goblin-verify --json --only IN-02,HP-05 2>/dev/null )
|
|
86
|
-
RC=$?
|
|
87
|
-
case "$RC" in
|
|
88
|
-
0|1) ;;
|
|
89
|
-
*) SKIPPED="$SKIPPED $(basename "$d")(verify-exit-$RC)"; continue ;;
|
|
90
|
-
esac
|
|
91
|
-
FAILED=$(printf '%s' "$OUT" | grep -o '"id":"[A-Z][A-Z0-9-]*","status":"FAIL"' | sed 's/"id":"//; s/","status":"FAIL"//')
|
|
92
|
-
for id in $FAILED; do
|
|
93
|
-
DRIFT="$DRIFT $d/$id"
|
|
94
|
-
DETAIL="$DETAIL$d $id cd $d && bash .gob/bin/goblin-verify --only $id
|
|
95
|
-
"
|
|
96
|
-
done
|
|
97
|
-
done
|
|
98
|
-
|
|
99
|
-
# ---- print nothing when there is nothing to file -----------------------------
|
|
100
|
-
# A clean run writes nothing either: the ceiling counts the runs that FILED something (the
|
|
101
|
-
# cards it created), never the runs that found nothing - otherwise a quiet week would exhaust
|
|
102
|
-
# the ceiling and silence a real finding.
|
|
103
|
-
if [ -z "$DRIFT" ]; then
|
|
104
|
-
exit 0
|
|
105
|
-
fi
|
|
106
|
-
|
|
107
|
-
printf '%s' "$DETAIL"
|
|
108
|
-
printf '# coverage: %s target(s) audited by glob, %s drifting, skipped:%s\n' \
|
|
109
|
-
"$TARGETS" "$(printf '%s' "$DRIFT" | wc -w | tr -d ' ')" "${SKIPPED:- none}"
|
|
110
|
-
printf '# run: %s of %s today\n' "$((RUNS + 1))" "$LIMIT"
|
|
111
|
-
|
|
112
|
-
if [ "$DRY_RUN" -eq 0 ]; then
|
|
113
|
-
[ -d "$(dirname "$STATE")" ] || mkdir -p "$(dirname "$STATE")"
|
|
114
|
-
printf 'run: %s\n' "$TODAY" >> "$STATE"
|
|
115
|
-
fi
|
|
116
|
-
if [ "$CARDS" -eq 1 ]; then
|
|
117
|
-
if command -v hermes >/dev/null 2>&1; then
|
|
118
|
-
printf '%s' "$DETAIL" | while IFS=$'\t' read -r repo id cmd; do
|
|
119
|
-
[ -n "$id" ] || continue
|
|
120
|
-
KEY="drift:$(basename "$repo"):$id"
|
|
121
|
-
BODY=$(mktemp)
|
|
122
|
-
{
|
|
123
|
-
printf '# Drift: %s %s\n\n' "$(basename "$repo")" "$id"
|
|
124
|
-
printf 'The producer compared a recorded claim with an artifact and they disagree.\n\n'
|
|
125
|
-
printf ' %s\n\n' "$cmd"
|
|
126
|
-
printf 'Reproduces at %s. Dedup key: %s\n' "$(date -u +%F)" "$KEY"
|
|
127
|
-
printf 'sha256 of the record: %s\n' "$(sha12 "$repo$id$cmd")"
|
|
128
|
-
} > "$BODY"
|
|
129
|
-
hermes kanban create "drift: $(basename "$repo") $id" --assignee architect \
|
|
130
|
-
--skill goblin-drift-audit --idempotency-key "$KEY" --body-file "$BODY" \
|
|
131
|
-
--max-runtime 1800 --max-retries 1 >/dev/null 2>&1 \
|
|
132
|
-
|| printf 'drift-audit: could not create the card for %s %s\n' "$(basename "$repo")" "$id" >&2
|
|
133
|
-
rm -f "$BODY"
|
|
134
|
-
done
|
|
135
|
-
else
|
|
136
|
-
printf 'drift-audit: hermes is not on PATH - the record is printed, no card was created\n' >&2
|
|
137
|
-
fi
|
|
138
|
-
fi
|
|
139
|
-
exit 1
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
key required shape
|
|
2
|
-
repo yes path or remote of the repository the defect is in
|
|
3
|
-
symptom yes one line, observable
|
|
4
|
-
expected yes one line
|
|
5
|
-
observed yes one line
|
|
6
|
-
repro_steps yes ordered list, one item per line, 4-space indented
|
|
7
|
-
revision yes a commit that exists in that repository
|
|
8
|
-
dedup_key yes bug:<repo>:<sha256(normalised symptom)[:12]> - content only, never a date
|
|
9
|
-
environment no platform/version; absent is recorded as unknown, never guessed
|
|
10
|
-
evidence no paths to captures; evidence for a human, never harness proof
|
package/bin/goblin
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# goblin — the CLI dispatcher.
|
|
3
|
-
#
|
|
4
|
-
# gob init [--heuristic | --write <proposal>] [--target <dir>] [...]
|
|
5
|
-
# gob map [target] [--agent | --heuristic] [--write <dir>] [--force]
|
|
6
|
-
# gob verify [--only <id[,id...]>] [--json] [--list] [--source <path>]
|
|
7
|
-
# gob bans [--only <id[,id...]>] [--list]
|
|
8
|
-
# gob extras list [category] | show <id> | install <id...> [--target <dir>]
|
|
9
|
-
# [--platform <id>] [--with-mcp-config] [--dry-run]
|
|
10
|
-
# gob mcp serve the harness over MCP stdio
|
|
11
|
-
# gob uninstall --target <dir>
|
|
12
|
-
# gob --version
|
|
13
|
-
#
|
|
14
|
-
# v2 SURFACE (AI-driven development): the CLI calls no AI API. `gob init` and `gob map`
|
|
15
|
-
# EMIT a prompt + schema that the agent already running in this repo fulfils with its own
|
|
16
|
-
# tools; heuristic detection demotes to the --heuristic fallback.
|
|
17
|
-
#
|
|
18
|
-
# UNWIRED this session (code kept under bin/, deletion is session 3): doctor, audit,
|
|
19
|
-
# upgrade, emit/sync. `sync` becomes an init-internal step (hidden --resync flag).
|
|
20
|
-
#
|
|
21
|
-
# Identity: the package is gobstack (npm @techgoblin/gobstack), the command is `gob`
|
|
22
|
-
# (`goblin` remains as a legacy alias).
|
|
23
|
-
#
|
|
24
|
-
# The four-value verify contract is unchanged and non-negotiable (bin/goblin-verify:5-9):
|
|
25
|
-
# 0 every executed check passed
|
|
26
|
-
# 1 at least one check failed
|
|
27
|
-
# 2 could not run
|
|
28
|
-
# 3 the manifest itself is broken
|
|
29
|
-
# Every subcommand propagates the engine's exit code verbatim; no wrapper translates a
|
|
30
|
-
# 1 into a 0.
|
|
31
|
-
#
|
|
32
|
-
# Root resolution: find_installed_root() walks up from $PWD to an AGENTS.md carrying the
|
|
33
|
-
# gob marker block; fall back to git toplevel, then $PWD — the D20 nested-repo fix.
|
|
34
|
-
#
|
|
35
|
-
# No npm, no jq, no yq, no network. bash/awk/sed/grep only.
|
|
36
|
-
|
|
37
|
-
set -uo pipefail
|
|
38
|
-
|
|
39
|
-
SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
40
|
-
SRC=$(cd "$SELF_DIR/.." && pwd)
|
|
41
|
-
VERSION=$(cat "$SRC/VERSION" 2>/dev/null || printf 'unknown')
|
|
42
|
-
|
|
43
|
-
g_err() { printf 'error: %s\n' "$*" >&2; }
|
|
44
|
-
|
|
45
|
-
usage() {
|
|
46
|
-
cat <<'USAGE'
|
|
47
|
-
gob — the gobstack command line.
|
|
48
|
-
|
|
49
|
-
gob init [--heuristic | --write <proposal>] [--target <dir>] [--class app|A-F] [--dry-run]
|
|
50
|
-
gob map [target] [--agent | --heuristic] [--write <dir>] [--force]
|
|
51
|
-
gob verify [--only <id[,id...]>] [--json] [--list] [--source <path>]
|
|
52
|
-
gob bans [--only <id[,id...]>] [--list]
|
|
53
|
-
gob extras list [category] | show <id> | install <id...> # the curated extras catalogue
|
|
54
|
-
gob mcp serve the harness to your agent over MCP stdio (verify/map/init tools)
|
|
55
|
-
gob uninstall --target <dir>
|
|
56
|
-
gob --version
|
|
57
|
-
|
|
58
|
-
gob init and gob map are AI-DRIVEN: they print a prompt + schema for the agent already
|
|
59
|
-
running in this repo, which writes the proposal file; `--write` validates and installs
|
|
60
|
-
it. The heuristic detectors are the --heuristic fallback.
|
|
61
|
-
|
|
62
|
-
Exit codes (verify): 0 pass | 1 a check failed | 2 could not run | 3 the manifest is
|
|
63
|
-
broken. Every subcommand propagates the engine's exit code verbatim.
|
|
64
|
-
USAGE
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# ---- the repo-root locator (an AGENTS.md gob block is the install marker) ----
|
|
68
|
-
find_installed_root() {
|
|
69
|
-
local d="$PWD"
|
|
70
|
-
while :; do
|
|
71
|
-
if [ -f "$d/AGENTS.md" ] && grep -q '^<!-- gob:begin' "$d/AGENTS.md" 2>/dev/null; then
|
|
72
|
-
printf '%s\n' "$d"; return 0
|
|
73
|
-
fi
|
|
74
|
-
[ "$d" = "/" ] && return 1
|
|
75
|
-
d=$(dirname "$d")
|
|
76
|
-
done
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
# ---- subcommand dispatch ------------------------------------------------------
|
|
80
|
-
CMD="${1:-}"
|
|
81
|
-
[ -n "$CMD" ] || { usage; exit 2; }
|
|
82
|
-
shift
|
|
83
|
-
|
|
84
|
-
case "$CMD" in
|
|
85
|
-
init)
|
|
86
|
-
# The prompt+schema engine: prints the agent brief, or installs a proposal.
|
|
87
|
-
exec bash "$SRC/bin/goblin-init" "$@"
|
|
88
|
-
;;
|
|
89
|
-
map)
|
|
90
|
-
# The standalone feature-map generator: `--agent` (default) prints prompt+schema;
|
|
91
|
-
# --heuristic runs the scanner. Routes and propagates its 0/1/2 contract verbatim.
|
|
92
|
-
exec bash "$SRC/bin/goblin-map" "$@"
|
|
93
|
-
;;
|
|
94
|
-
verify)
|
|
95
|
-
# The engine is whatever the per-repo chain resolves (W1 §2.3): --source, vendored,
|
|
96
|
-
# engine_dir:, GOBLIN_ENGINE_DIR, ~/.goblin/engine — all inside goblin-verify. The
|
|
97
|
-
# CLI is a pass-through, not a second root-resolution opinion (§3.4).
|
|
98
|
-
exec bash "$SRC/bin/goblin-verify" "$@"
|
|
99
|
-
;;
|
|
100
|
-
bans)
|
|
101
|
-
exec bash "$SRC/bin/goblin-bans" "$@"
|
|
102
|
-
;;
|
|
103
|
-
extras)
|
|
104
|
-
# The curated catalogue browser + installer (bin/goblin-extras): list/show/install
|
|
105
|
-
# over extras-catalogue/catalogue.tsv. The catalogue is the ALLOWLIST: nothing is
|
|
106
|
-
# ever installed that a catalogue row does not name, and `gob init` only suggests.
|
|
107
|
-
exec bash "$SRC/bin/goblin-extras" "$@"
|
|
108
|
-
;;
|
|
109
|
-
mcp)
|
|
110
|
-
# The MCP stdio server (bin/goblin-mcp.js): JSON-RPC 2.0 over stdin/stdout, a LOCAL
|
|
111
|
-
# tool server over the vendored harness — no API call, no socket. node is the same
|
|
112
|
-
# runtime bin/goblin.js already needs; it is exec'd directly, args pass through.
|
|
113
|
-
exec node "$SRC/bin/goblin-mcp.js" "$@"
|
|
114
|
-
;;
|
|
115
|
-
uninstall)
|
|
116
|
-
# Routes into the installer's uninstall job. `--uninstall` is appended FIRST so the
|
|
117
|
-
# user's own `--target <dir>` and options still parse.
|
|
118
|
-
exec bash "$SRC/bin/goblin-install" --uninstall "$@"
|
|
119
|
-
;;
|
|
120
|
-
--version|-V|-v)
|
|
121
|
-
printf '%s\n' "$VERSION"
|
|
122
|
-
exit 0
|
|
123
|
-
;;
|
|
124
|
-
-h|--help|help)
|
|
125
|
-
usage
|
|
126
|
-
exit 0
|
|
127
|
-
;;
|
|
128
|
-
doctor|audit|upgrade|emit|sync|install)
|
|
129
|
-
# Unwired from usage in v2 (code kept; deletion is session 3). The refusal names
|
|
130
|
-
# what replaced each verb rather than silently executing the old path.
|
|
131
|
-
g_err "gob $CMD is unwired in v2."
|
|
132
|
-
case "$CMD" in
|
|
133
|
-
install|init-legacy) g_err "fix: gob init --write <proposal> installs a repo now." ;;
|
|
134
|
-
sync|emit) g_err "fix: gob init --write <proposal> runs the sync step internally." ;;
|
|
135
|
-
doctor|audit|upgrade) g_err "fix: gob verify (audit stays a deliberate manual step; see docs/)." ;;
|
|
136
|
-
esac
|
|
137
|
-
exit 2
|
|
138
|
-
;;
|
|
139
|
-
*)
|
|
140
|
-
g_err "unknown subcommand: $CMD"
|
|
141
|
-
usage >&2
|
|
142
|
-
exit 2
|
|
143
|
-
;;
|
|
144
|
-
esac
|
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
|