@bbcsoftwarefactory/skills 0.1.1 → 1.1.3
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/dist/index.json +2 -3
- package/dist/skills/code-quality-gate/SKILL.md +4 -5
- package/dist/skills/code-quality-gate/references/gate-bigo.md +1 -1
- package/dist/skills/delivery-coordinator/SKILL.md +7 -8
- package/dist/skills/delivery-coordinator/references/hud-output.md +1 -1
- package/dist/skills/delivery-coordinator/references/issue-claim.md +5 -5
- package/dist/skills/delivery-coordinator/references/issue-dedup.md +1 -1
- package/dist/skills/delivery-coordinator/references/worktree-isolation.md +2 -2
- package/dist/skills/greptile-review-loop/SKILL.md +3 -4
- package/dist/skills/greptile-review-loop/references/review-protocol.md +1 -1
- package/dist/skills/issue-reviewer/SKILL.md +10 -13
- package/dist/skills/issue-reviewer/references/review-format.md +1 -1
- package/dist/skills/issue-reviewer/references/triage.md +6 -6
- package/dist/skills/question-gate/SKILL.md +6 -8
- package/dist/skills/question-gate/references/client-hooks.md +10 -10
- package/dist/skills/question-gate/references/diagram-routing.md +3 -3
- package/dist/skills/skill-clean-architecture/SKILL.md +2 -3
- package/dist/skills/skill-clean-architecture/references/source-headers.md +2 -3
- package/dist/skills/tool-depot/references/readonly-access.md +1 -1
- package/dist/skills/tool-depot/references/tool-catalog.json +2 -2
- package/dist/skills/watcher-observability/SKILL.md +3 -4
- package/dist/skills/watcher-observability/references/batch-protocol.md +6 -6
- package/dist/skills/watcher-observability/references/configuration.md +1 -1
- package/dist/skills/watcher-observability/references/error-scan.md +1 -1
- package/dist/skills/watcher-observability/references/live-protocol.md +8 -8
- package/dist/skills/watcher-observability/references/server-account.md +8 -8
- package/dist/skills/watcher-observability/server/watcher-gate.sh +1 -1
- package/dist/skills/watcher-observability/tests/watcher-gate.test.sh +10 -7
- package/dist/skills/workflow-auditor/SKILL.md +3 -5
- package/dist/skills/workflow-auditor/references/audit-protocol.md +3 -3
- package/dist/skills/workflow-auditor/references/ledger.md +1 -1
- package/package.json +26 -27
- package/dist/skills/code-quality-gate/scripts/extract-diff-scope.py +0 -225
- package/dist/skills/code-quality-gate/tests/extract-diff-scope.test.sh +0 -200
- package/dist/skills/delivery-coordinator/scripts/check-issue-claim.py +0 -363
- package/dist/skills/delivery-coordinator/scripts/check-worktree-guard.py +0 -220
- package/dist/skills/delivery-coordinator/scripts/classify-change-lane.py +0 -263
- package/dist/skills/delivery-coordinator/tests/check-issue-claim.test.sh +0 -221
- package/dist/skills/delivery-coordinator/tests/check-worktree-guard.test.sh +0 -123
- package/dist/skills/delivery-coordinator/tests/classify-change-lane.test.sh +0 -124
- package/dist/skills/greptile-review-loop/scripts/review-loop.py +0 -435
- package/dist/skills/greptile-review-loop/tests/review-loop.test.sh +0 -331
- package/dist/skills/issue-reviewer/scripts/fetch-issue-attachments.py +0 -239
- package/dist/skills/issue-reviewer/scripts/plan-issue-triage.py +0 -311
- package/dist/skills/issue-reviewer/tests/fetch-issue-attachments.test.sh +0 -90
- package/dist/skills/issue-reviewer/tests/plan-issue-triage.test.sh +0 -168
- package/dist/skills/question-gate/scripts/triage-question.py +0 -713
- package/dist/skills/question-gate/tests/question-corpus.test.sh +0 -32
- package/dist/skills/question-gate/tests/triage-question.test.sh +0 -441
- package/dist/skills/skill-clean-architecture/scripts/measure-bigo.py +0 -427
- package/dist/skills/skill-clean-architecture/tests/measure-bigo.test.sh +0 -222
- package/dist/skills/watcher-observability/scripts/error-scan.py +0 -318
- package/dist/skills/watcher-observability/scripts/resolve-containers.py +0 -155
- package/dist/skills/watcher-observability/scripts/save-counts.py +0 -381
- package/dist/skills/watcher-observability/scripts/summarize-logs.py +0 -113
- package/dist/skills/watcher-observability/scripts/watch-live.py +0 -606
- package/dist/skills/watcher-observability/tests/error-scan.test.sh +0 -257
- package/dist/skills/watcher-observability/tests/live-windows.test.sh +0 -177
- package/dist/skills/watcher-observability/tests/resolve-containers.test.sh +0 -87
- package/dist/skills/watcher-observability/tests/save-counts.test.sh +0 -338
- package/dist/skills/watcher-observability/tests/sleuth.test.sh +0 -176
- package/dist/skills/watcher-observability/tests/summarize-logs.test.sh +0 -105
- package/dist/skills/watcher-observability/tests/watcher-config.test.sh +0 -70
- package/dist/skills/workflow-auditor/scripts/audit-ledger.py +0 -624
- package/dist/skills/workflow-auditor/scripts/list-zed-commands.py +0 -183
- package/dist/skills/workflow-auditor/scripts/render-workflow.py +0 -201
- package/dist/skills/workflow-auditor/scripts/validate-skills.py +0 -444
- package/dist/skills/workflow-auditor/tests/audit-ledger.test.sh +0 -660
- package/dist/skills/workflow-auditor/tests/list-zed-commands.test.sh +0 -93
- package/dist/skills/workflow-auditor/tests/render-workflow.test.sh +0 -135
- package/dist/skills/workflow-auditor/tests/validate-skills.test.sh +0 -190
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Suite for scripts/list-zed-commands.py (ADR 0001). A fake ACP agent lives in a
|
|
3
|
-
# fake Zed registry under a temporary HOME; no real Zed or Cursor is needed.
|
|
4
|
-
set -u
|
|
5
|
-
cd -- "${BASH_SOURCE[0]%/*}/.."
|
|
6
|
-
SCRIPT="$PWD/scripts/list-zed-commands.py"
|
|
7
|
-
PYTHON_BIN=$(command -v python3 || command -v python)
|
|
8
|
-
PYTHON_BIN=$("$PYTHON_BIN" -c 'import sys; print(sys.executable)')
|
|
9
|
-
# Physical path: the script reports the real directory (macOS: /var -> /private/var).
|
|
10
|
-
scratch=$(cd "$(mktemp -d)" && pwd -P)
|
|
11
|
-
trap 'rm -rf -- "$scratch"' EXIT
|
|
12
|
-
checks=0
|
|
13
|
-
failures=0
|
|
14
|
-
|
|
15
|
-
agent_dir="$scratch/home/.local/share/zed/external_agents/registry/cursor/v_1.0/dist-package"
|
|
16
|
-
mkdir -p "$agent_dir" "$scratch/project"
|
|
17
|
-
cat >"$agent_dir/cursor-agent" <<EOF
|
|
18
|
-
#!$PYTHON_BIN -I
|
|
19
|
-
import json, os, sys, time
|
|
20
|
-
mode = os.environ.get('FAKE_ACP', 'together')
|
|
21
|
-
if sys.argv[1:] != ['acp']:
|
|
22
|
-
sys.exit(90)
|
|
23
|
-
out = sys.stdout
|
|
24
|
-
sys.stderr.write('agent booting\n'); sys.stderr.flush()
|
|
25
|
-
for line in sys.stdin:
|
|
26
|
-
msg = json.loads(line)
|
|
27
|
-
if msg.get('method') == 'initialize':
|
|
28
|
-
if mode == 'die':
|
|
29
|
-
sys.exit(3)
|
|
30
|
-
out.write('not json at all\n')
|
|
31
|
-
out.write(json.dumps({'jsonrpc': '2.0', 'id': 1, 'result': {}}) + '\n'); out.flush()
|
|
32
|
-
elif msg.get('method') == 'session/new':
|
|
33
|
-
if msg['params'] != {'cwd': os.getcwd(), 'mcpServers': []}:
|
|
34
|
-
sys.exit(91)
|
|
35
|
-
if mode == 'error':
|
|
36
|
-
out.write(json.dumps({'jsonrpc': '2.0', 'id': 2, 'error': {'code': -32000, 'message': 'denegado'}}) + '\n')
|
|
37
|
-
out.flush()
|
|
38
|
-
continue
|
|
39
|
-
out.write(json.dumps({'jsonrpc': '2.0', 'id': 2, 'result': {'sessionId': 's1'}}) + '\n')
|
|
40
|
-
if mode == 'split':
|
|
41
|
-
out.flush(); time.sleep(0.3)
|
|
42
|
-
out.write(json.dumps({'jsonrpc': '2.0', 'method': 'session/update', 'params': {'update': {
|
|
43
|
-
'sessionUpdate': 'available_commands_update', 'availableCommands': [
|
|
44
|
-
{'name': 'daily', 'description': 'Daily refresh (project skill)'},
|
|
45
|
-
{'name': 'code-quality-gate', 'description': 'Gate (user skill)'},
|
|
46
|
-
{'name': 'plain', 'description': 'No scope'}]}}}) + '\n')
|
|
47
|
-
out.flush()
|
|
48
|
-
sys.exit(0)
|
|
49
|
-
EOF
|
|
50
|
-
chmod +x "$agent_dir/cursor-agent"
|
|
51
|
-
|
|
52
|
-
check() { # label, FAKE_ACP mode, want rc, want stdout, want stderr, extra args...
|
|
53
|
-
local label=$1 mode=$2 want_rc=$3 want_out=$4 want_err=$5 rc=0 out err
|
|
54
|
-
shift 5
|
|
55
|
-
out=$(env -i HOME="$scratch/home" PATH="/usr/bin:/bin" FAKE_ACP="$mode" \
|
|
56
|
-
"$PYTHON_BIN" -I -B "$SCRIPT" "${PROJECT:-$scratch/project}" "$@" 2>"$scratch/err") || rc=$?
|
|
57
|
-
err=$(cat "$scratch/err")
|
|
58
|
-
checks=$((checks + 1))
|
|
59
|
-
if [[ $rc != "$want_rc" || $out != "$want_out" || $err != "$want_err" ]]; then
|
|
60
|
-
printf 'FAIL %s: rc=%s\nstdout=%s\nstderr=%s\n' "$label" "$rc" "$out" "$err" >&2
|
|
61
|
-
failures=$((failures + 1))
|
|
62
|
-
fi
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
listed="3 commands advertised for $scratch/project (cursor)
|
|
66
|
-
/daily (project skill)
|
|
67
|
-
/code-quality-gate (user skill)
|
|
68
|
-
/plain"
|
|
69
|
-
# The session reply and the command list arrive in ONE chunk. The retired Node
|
|
70
|
-
# version returned from its chunk loop on the session reply and never printed the
|
|
71
|
-
# commands: exactly the "empty / menu" symptom this tool exists to diagnose.
|
|
72
|
-
check same-chunk together 0 "$listed" '[cursor] agent booting'
|
|
73
|
-
check separate-chunks split 0 "$listed" '[cursor] agent booting'
|
|
74
|
-
check session-error error 1 '' $'[cursor] agent booting\nSession error: {"code":-32000,"message":"denegado"}'
|
|
75
|
-
# The agent dies before opening a session: report it at once with its exit code.
|
|
76
|
-
# The old loop ignored the closed output and waited the full 60 s ("Timeout"),
|
|
77
|
-
# which is how macOS CI first showed the problem.
|
|
78
|
-
start=$SECONDS
|
|
79
|
-
check agent-exits die 1 '' $'[cursor] agent booting\nThe cursor agent exited (code 3) before opening a session.'
|
|
80
|
-
checks=$((checks + 1))
|
|
81
|
-
if (( SECONDS - start > 10 )); then
|
|
82
|
-
printf 'FAIL agent-exits: took %ss, the dead agent was not detected\n' "$((SECONDS - start))" >&2
|
|
83
|
-
failures=$((failures + 1))
|
|
84
|
-
fi
|
|
85
|
-
# A project reached through a symlink (macOS: /var -> /private/var). The agent sees
|
|
86
|
-
# the real directory, so the session must be opened, and reported, with that path.
|
|
87
|
-
ln -s "$scratch/project" "$scratch/link"
|
|
88
|
-
real=$(cd "$scratch/project" && pwd -P)
|
|
89
|
-
PROJECT="$scratch/link" check symlinked-project together 0 "${listed//$scratch\/project/$real}" '[cursor] agent booting'
|
|
90
|
-
check no-launcher together 2 '' $'No codex agent found in Zed\'s ACP registry.\nInstall it from the Agent Panel (zed: acp registry) or pass --agent <name>.' --agent codex
|
|
91
|
-
|
|
92
|
-
printf 'list-zed-commands.test.sh: %d checks, %d failed\n' "$checks" "$failures"
|
|
93
|
-
[[ $failures == 0 ]]
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Suite for scripts/render-workflow.py (ADR 0002, issue #47).
|
|
3
|
-
set -eu
|
|
4
|
-
cd -- "${BASH_SOURCE[0]%/*}/.."
|
|
5
|
-
PYTHON_BIN=$(command -v python3 || command -v python)
|
|
6
|
-
"$PYTHON_BIN" -I -B - <<'PY'
|
|
7
|
-
import contextlib, io, json, os, runpy, shutil, subprocess, sys, tempfile
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
script = Path('scripts/render-workflow.py').resolve()
|
|
11
|
-
mod = runpy.run_path(str(script))
|
|
12
|
-
repo = Path.cwd().parents[1]
|
|
13
|
-
checks, failures = 0, []
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def copy(tmp):
|
|
17
|
-
root = Path(tmp) / 'repo'
|
|
18
|
-
shutil.copytree(repo, root, ignore=shutil.ignore_patterns('.git', 'tmp_logs'))
|
|
19
|
-
return root
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def run(root, *flags):
|
|
23
|
-
out, err = io.StringIO(), io.StringIO()
|
|
24
|
-
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
|
25
|
-
code = mod['main']([*flags, str(root)])
|
|
26
|
-
return code, out.getvalue() + err.getvalue()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def expect(label, root, flags, code, needle):
|
|
30
|
-
global checks
|
|
31
|
-
checks += 1
|
|
32
|
-
got, text = run(root, *flags)
|
|
33
|
-
if got != code or needle not in text:
|
|
34
|
-
failures.append(f'{label}: rc={got} want {code}, output={text!r} (want {needle!r})')
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def edit_json(root, change):
|
|
38
|
-
path = root / 'docs/diagrams/workflow.json'
|
|
39
|
-
doc = json.loads(path.read_text(encoding='utf-8'))
|
|
40
|
-
change(doc)
|
|
41
|
-
path.write_text(json.dumps(doc, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def replace(path, old, new):
|
|
45
|
-
text = path.read_text(encoding='utf-8')
|
|
46
|
-
assert text.count(old) == 1, (path, old)
|
|
47
|
-
path.write_text(text.replace(old, new), encoding='utf-8')
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# 1. The committed README block is what the JSON generates.
|
|
51
|
-
expect('repository is up to date', repo, ['--check'], 0, 'up to date')
|
|
52
|
-
|
|
53
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
54
|
-
# 2. #47 criterion: a stage added only to the Mermaid block fails CI.
|
|
55
|
-
root = copy(tmp)
|
|
56
|
-
replace(root / 'README.md', ' observe2 -.-> observe\n',
|
|
57
|
-
' observe2 -.-> observe\n deploy --> canary["Canary Analyzer"]\n')
|
|
58
|
-
expect('stage only in Mermaid', root, ['--check'], 1, 'differs from docs/diagrams/workflow.json')
|
|
59
|
-
|
|
60
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
61
|
-
# 3. A stage added to the JSON needs --write; --write is then idempotent.
|
|
62
|
-
root = copy(tmp)
|
|
63
|
-
def add_stage(doc):
|
|
64
|
-
doc['nodes']['canary'] = {'label': 'Canary Analyzer', 'agents': 'Deploy & observe'}
|
|
65
|
-
doc['edges'].append({'from': 'deploy', 'to': 'canary', 'style': 'dotted'})
|
|
66
|
-
edit_json(root, add_stage)
|
|
67
|
-
expect('stage only in JSON', root, ['--check'], 1, 'run render-workflow.py --write')
|
|
68
|
-
expect('write renders it', root, ['--write'], 0, 'written')
|
|
69
|
-
expect('write is idempotent', root, ['--write'], 0, 'up to date')
|
|
70
|
-
checks += 1
|
|
71
|
-
if 'deploy -.-> canary["Canary Analyzer"]' not in (root / 'README.md').read_text(encoding='utf-8'):
|
|
72
|
-
failures.append('write did not render the new stage')
|
|
73
|
-
|
|
74
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
75
|
-
# 4. Every stage needs its agents phrase in the AGENTS.md handoff block.
|
|
76
|
-
root = copy(tmp)
|
|
77
|
-
edit_json(root, lambda d: d['nodes']['merge'].update(agents='Code Owner signs with a quill'))
|
|
78
|
-
expect('agents phrase missing', root, ['--check'], 1, 'lacks the agents phrase of merge')
|
|
79
|
-
|
|
80
|
-
# 5. Strict schema: injection and structural mistakes are rejected.
|
|
81
|
-
cases = {
|
|
82
|
-
'label injection': lambda d: d['nodes']['red'].update(label='RED"] --> pwn["x'),
|
|
83
|
-
'edge label pipe': lambda d: d['edges'][0].update(label='a|b'),
|
|
84
|
-
'newline in label': lambda d: d['nodes']['red'].update(label='a\nb'),
|
|
85
|
-
'unknown key': lambda d: d['nodes']['red'].update(color='red'),
|
|
86
|
-
'unknown node': lambda d: d['edges'].append({'from': 'red', 'to': 'ghost'}),
|
|
87
|
-
'unused node': lambda d: d['nodes'].update(lonely={'label': 'Lonely', 'agents': 'Human request'}),
|
|
88
|
-
'bad id': lambda d: d['nodes'].update({'bad id': {'label': 'x', 'agents': 'Human request'}}),
|
|
89
|
-
'bad style': lambda d: d['edges'][0].update(style='thick'),
|
|
90
|
-
'duplicate group': lambda d: d['groups'].append(dict(d['groups'][0])),
|
|
91
|
-
}
|
|
92
|
-
for label, change in cases.items():
|
|
93
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
94
|
-
root = copy(tmp)
|
|
95
|
-
edit_json(root, change)
|
|
96
|
-
before = (root / 'README.md').read_bytes()
|
|
97
|
-
expect(f'schema: {label}', root, ['--write'], 1, 'workflow:')
|
|
98
|
-
checks += 1
|
|
99
|
-
if (root / 'README.md').read_bytes() != before:
|
|
100
|
-
failures.append(f'schema: {label}: README was modified')
|
|
101
|
-
|
|
102
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
103
|
-
# 6. Markers: missing or duplicated -> refuse, README untouched.
|
|
104
|
-
root = copy(tmp)
|
|
105
|
-
readme = root / 'README.md'
|
|
106
|
-
replace(readme, mod['END'], '')
|
|
107
|
-
before = readme.read_bytes()
|
|
108
|
-
expect('missing end marker', root, ['--write'], 1, 'exactly one pair of workflow markers')
|
|
109
|
-
checks += 1
|
|
110
|
-
if readme.read_bytes() != before:
|
|
111
|
-
failures.append('missing marker: README was modified')
|
|
112
|
-
|
|
113
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
114
|
-
# 7. A symlinked README is refused (no writes through links).
|
|
115
|
-
if os.name == 'posix':
|
|
116
|
-
root = copy(tmp)
|
|
117
|
-
(root / 'README.md').rename(root / 'README.real.md')
|
|
118
|
-
(root / 'README.md').symlink_to(root / 'README.real.md')
|
|
119
|
-
expect('symlinked README', root, ['--write'], 1, 'not a symlink')
|
|
120
|
-
|
|
121
|
-
# 8. Only the Python standard library is needed: no PATH at all.
|
|
122
|
-
checks += 1
|
|
123
|
-
proc = subprocess.run([sys.executable, '-I', '-B', str(script), '--check', str(repo)],
|
|
124
|
-
env={'PATH': ''}, capture_output=True, text=True)
|
|
125
|
-
if proc.returncode != 0:
|
|
126
|
-
failures.append(f'empty PATH: rc={proc.returncode} {proc.stderr}')
|
|
127
|
-
|
|
128
|
-
# 9. Bad flags.
|
|
129
|
-
expect('check and write together', repo, ['--check', '--write'], 2, 'Usage')
|
|
130
|
-
|
|
131
|
-
for failure in failures:
|
|
132
|
-
print('FAIL ' + failure, file=sys.stderr)
|
|
133
|
-
print(f'render-workflow.test.sh: {checks} checks, {len(failures)} failed')
|
|
134
|
-
sys.exit(1 if failures else 0)
|
|
135
|
-
PY
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eu
|
|
3
|
-
cd -- "${BASH_SOURCE[0]%/*}/.."
|
|
4
|
-
PYTHON_BIN=$(command -v python3 || command -v python)
|
|
5
|
-
"$PYTHON_BIN" -I -B - <<'PY'
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
import runpy
|
|
8
|
-
import tempfile
|
|
9
|
-
|
|
10
|
-
mod = runpy.run_path('scripts/validate-skills.py')
|
|
11
|
-
repo_root = Path.cwd().parents[1]
|
|
12
|
-
|
|
13
|
-
# 1. Real repository must pass validation
|
|
14
|
-
report = mod['validate_repo'](repo_root)
|
|
15
|
-
assert report['verdict'] == 'pass', report
|
|
16
|
-
assert report['checked'] >= 14, report
|
|
17
|
-
assert report['frontmatter_bytes'] < mod['ZED_CATALOG_LIMIT_BYTES'], report
|
|
18
|
-
|
|
19
|
-
# 2. Missing declared script or missing compatibility must fail
|
|
20
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
21
|
-
root = Path(tmp)
|
|
22
|
-
sdir = root / 'skills' / 'demo-skill'
|
|
23
|
-
(sdir / 'scripts').mkdir(parents=True)
|
|
24
|
-
(sdir / 'scripts' / 'run.py').write_text('print(1)\n', encoding='utf-8')
|
|
25
|
-
(sdir / 'SKILL.md').write_text(
|
|
26
|
-
'---\nname: demo-skill\ndescription: "demo"\nmetadata:\n author: bbc\n version: "1.0"\n---\n',
|
|
27
|
-
encoding='utf-8',
|
|
28
|
-
)
|
|
29
|
-
bad = mod['validate_repo'](root)
|
|
30
|
-
assert bad['verdict'] == 'fail', bad
|
|
31
|
-
assert any('compatibility' in e for e in bad['errors']), bad['errors']
|
|
32
|
-
assert any('metadata.scripts' in e for e in bad['errors']), bad['errors']
|
|
33
|
-
|
|
34
|
-
# 3. An unknown metadata key must fail: a typo such as `hooks:` is not a hook.
|
|
35
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
36
|
-
root = Path(tmp)
|
|
37
|
-
kdir = root / 'skills' / 'demo-key'
|
|
38
|
-
kdir.mkdir(parents=True)
|
|
39
|
-
(kdir / 'SKILL.md').write_text(
|
|
40
|
-
'---\nname: demo-key\ndescription: "demo"\nmetadata:\n author: bbc\n'
|
|
41
|
-
' version: "1.0"\n hooks: "none"\n---\n',
|
|
42
|
-
encoding='utf-8',
|
|
43
|
-
)
|
|
44
|
-
keyed = mod['validate_repo'](root)
|
|
45
|
-
assert keyed['verdict'] == 'fail', keyed
|
|
46
|
-
assert any('unknown metadata key' in e and 'hooks' in e for e in keyed['errors']), keyed['errors']
|
|
47
|
-
|
|
48
|
-
# 4-6. Integrity checks (#46): broken relative links, purposes cited but not in
|
|
49
|
-
# the Tool Depot catalog, and catalog protocol paths that do not resolve.
|
|
50
|
-
import shutil
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def mutated_copy(tmp, edits):
|
|
54
|
-
root = Path(tmp) / 'repo'
|
|
55
|
-
shutil.copytree(repo_root, root, ignore=shutil.ignore_patterns('.git', 'tmp_logs'))
|
|
56
|
-
for rel, old, new in edits:
|
|
57
|
-
path = root / rel
|
|
58
|
-
text = path.read_text(encoding='utf-8')
|
|
59
|
-
assert old in text, (rel, old)
|
|
60
|
-
path.write_text(text.replace(old, new, 1), encoding='utf-8')
|
|
61
|
-
return mod['validate_repo'](root)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
65
|
-
rep = mutated_copy(tmp, [('skills/tool-depot/SKILL.md', 'references/checkout.md', 'references/NO-EXISTE.md')])
|
|
66
|
-
assert rep['verdict'] == 'fail', rep
|
|
67
|
-
assert any('broken link' in e and 'NO-EXISTE.md' in e for e in rep['errors']), rep['errors']
|
|
68
|
-
|
|
69
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
70
|
-
rep = mutated_copy(tmp, [('skills/tool-depot/references/tool-catalog.json',
|
|
71
|
-
'"read-approved-issue-or-pr"', '"purpose-inventado"')])
|
|
72
|
-
assert rep['verdict'] == 'fail', rep
|
|
73
|
-
assert any('read-approved-issue-or-pr' in e and 'not in the Tool Depot catalog' in e for e in rep['errors']), rep['errors']
|
|
74
|
-
|
|
75
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
76
|
-
rep = mutated_copy(tmp, [('skills/tool-depot/references/tool-catalog.json',
|
|
77
|
-
'../../risk-scout/references/risk-matrix.md', '../../risk-scout/references/gone.md')])
|
|
78
|
-
assert rep['verdict'] == 'fail', rep
|
|
79
|
-
assert any('protocol' in e and 'gone.md' in e for e in rep['errors']), rep['errors']
|
|
80
|
-
|
|
81
|
-
# 7. A hook that names a bundled script or reference must point to an existing file (#40).
|
|
82
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
83
|
-
rep = mutated_copy(tmp, [('skills/code-quality-gate/SKILL.md',
|
|
84
|
-
'pre_hook: "python3 -I -B scripts/extract-diff-scope.py', 'pre_hook: "python3 -I -B scripts/gone.py')])
|
|
85
|
-
assert rep['verdict'] == 'fail', rep
|
|
86
|
-
assert any('pre_hook' in e and 'scripts/gone.py' in e for e in rep['errors']), rep['errors']
|
|
87
|
-
|
|
88
|
-
# 8. Diagram drift (#47): every skill must appear in the README Mermaid block,
|
|
89
|
-
# the AGENTS.md handoff block, the SVG and the Excalidraw source.
|
|
90
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
91
|
-
rep = mutated_copy(tmp, [('README.md', '"🚦 Code Quality Gate · Software Engineer self-check"',
|
|
92
|
-
'"🚦 Gate · Software Engineer self-check"')])
|
|
93
|
-
assert rep['verdict'] == 'fail', rep
|
|
94
|
-
assert any('code-quality-gate' in e and 'mermaid' in e for e in rep['errors']), rep['errors']
|
|
95
|
-
|
|
96
|
-
# 9. A known gap that has been fixed must be removed from the exception list.
|
|
97
|
-
# The list is empty since #38, so the test registers a gap that is not missing.
|
|
98
|
-
from unittest.mock import patch
|
|
99
|
-
with patch.dict(mod['validate_repo'].__globals__['KNOWN_DIAGRAM_GAPS'], {('issue-reviewer', 'svg'): '#38'}):
|
|
100
|
-
rep = mod['validate_repo'](repo_root)
|
|
101
|
-
assert rep['verdict'] == 'fail', rep
|
|
102
|
-
assert any('stale' in e and 'issue-reviewer' in e and 'svg' in e for e in rep['errors']), rep['errors']
|
|
103
|
-
|
|
104
|
-
# 10. #59: the package is licensed. LICENSE exists, and every SKILL.md declares the
|
|
105
|
-
# same SPDX id, so a new skill cannot ship without one.
|
|
106
|
-
assert (repo_root / 'LICENSE').is_file(), 'LICENSE is missing'
|
|
107
|
-
real = mod['validate_repo'](repo_root)
|
|
108
|
-
assert real['verdict'] == 'pass', real
|
|
109
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
110
|
-
rep = mutated_copy(tmp, [('skills/risk-scout/SKILL.md', 'license: Apache-2.0\n', '')])
|
|
111
|
-
assert any('risk-scout' in e and 'license' in e for e in rep['errors']), rep['errors']
|
|
112
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
113
|
-
rep = mutated_copy(tmp, [('skills/risk-scout/SKILL.md', 'license: Apache-2.0', 'license: MIT')])
|
|
114
|
-
assert any('risk-scout' in e and 'MIT' in e for e in rep['errors']), rep['errors']
|
|
115
|
-
|
|
116
|
-
# 11. #63: a distributed (licensed) package ships its security, support and
|
|
117
|
-
# contribution policies, and they carry no personal contact data.
|
|
118
|
-
for doc in ('SECURITY.md', 'SUPPORT.md', 'CONTRIBUTING.md'):
|
|
119
|
-
assert (repo_root / doc).is_file(), f'{doc} is missing'
|
|
120
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
121
|
-
rep = mutated_copy(tmp, [])
|
|
122
|
-
(Path(tmp) / 'repo' / 'SUPPORT.md').unlink()
|
|
123
|
-
rep = mod['validate_repo'](Path(tmp) / 'repo')
|
|
124
|
-
assert any('SUPPORT.md' in e for e in rep['errors']), rep['errors']
|
|
125
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
126
|
-
rep = mutated_copy(tmp, [('SECURITY.md', '## Reporting', '## Reporting\n\nWrite to someone@example.org.\n')])
|
|
127
|
-
assert any('SECURITY.md' in e and 'contact' in e for e in rep['errors']), rep['errors']
|
|
128
|
-
|
|
129
|
-
# 12. #61: the core stays generic. Each profile under commands/<name>/ lists its own
|
|
130
|
-
# infrastructure identifiers in profile-identifiers.txt, and none may appear in a
|
|
131
|
-
# core file: skills/ (tests included, since the public edition ships them) and
|
|
132
|
-
# commands/daily. A synthetic profile keeps this test independent of real ones.
|
|
133
|
-
# Built at runtime: this file is itself a core file and must not contain the id.
|
|
134
|
-
ACME = 'acme-db' + '-7'
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def with_profile(tmp, rel, text):
|
|
138
|
-
mutated_copy(tmp, [])
|
|
139
|
-
root = Path(tmp) / 'repo'
|
|
140
|
-
shutil.copytree(root / 'commands' / 'daily', root / 'commands' / 'acme')
|
|
141
|
-
skill = root / 'commands' / 'acme' / 'SKILL.md'
|
|
142
|
-
skill.write_text(skill.read_text(encoding='utf-8').replace('name: daily', 'name: acme', 1), encoding='utf-8')
|
|
143
|
-
(root / 'commands' / 'acme' / 'profile-identifiers.txt').write_text(f'# acme\n{ACME}\n', encoding='utf-8')
|
|
144
|
-
with open(root / rel, 'a', encoding='utf-8') as handle:
|
|
145
|
-
handle.write(text.replace('ID', ACME).replace('UPPER', ACME.upper()))
|
|
146
|
-
return mod['validate_repo'](root)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
rep = with_profile(tempfile.mkdtemp(), 'skills/risk-scout/SKILL.md', '\nCheck UPPER first.\n')
|
|
150
|
-
assert any('risk-scout/SKILL.md' in e and ACME in e and 'acme profile' in e for e in rep['errors']), rep['errors']
|
|
151
|
-
rep = with_profile(tempfile.mkdtemp(), 'commands/daily/SKILL.md', '\nsee ID\n')
|
|
152
|
-
assert any('commands/daily/SKILL.md' in e for e in rep['errors']), rep['errors']
|
|
153
|
-
rep = with_profile(tempfile.mkdtemp(), 'skills/risk-scout/tests/x.test.sh' if (repo_root / 'skills/risk-scout/tests').is_dir()
|
|
154
|
-
else 'skills/question-gate/tests/triage-question.test.sh', '\n# ID\n')
|
|
155
|
-
assert any('tests/' in e and ACME in e for e in rep['errors']), rep['errors']
|
|
156
|
-
# A longer word that merely contains an identifier is not a leak.
|
|
157
|
-
rep = with_profile(tempfile.mkdtemp(), 'skills/risk-scout/SKILL.md', '\nxIDx\n')
|
|
158
|
-
assert rep['verdict'] == 'pass', rep['errors']
|
|
159
|
-
|
|
160
|
-
# 13. #62: a distributed package has a SemVer VERSION, and the newest CHANGELOG entry
|
|
161
|
-
# documents that same version. A release tag must name it exactly.
|
|
162
|
-
import contextlib, io
|
|
163
|
-
version = (repo_root / 'VERSION').read_text(encoding='utf-8').strip()
|
|
164
|
-
assert mod['SEMVER'].fullmatch(version), version
|
|
165
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
166
|
-
rep = mutated_copy(tmp, [('VERSION', version, '1.0')])
|
|
167
|
-
assert any('VERSION' in e and 'SemVer' in e for e in rep['errors']), rep['errors']
|
|
168
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
169
|
-
rep = mutated_copy(tmp, [('CHANGELOG.md', f'## [{version}]', '## [0.0.1]')])
|
|
170
|
-
assert any('CHANGELOG' in e and version in e for e in rep['errors']), rep['errors']
|
|
171
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
172
|
-
mutated_copy(tmp, [])
|
|
173
|
-
(Path(tmp) / 'repo' / 'CHANGELOG.md').unlink()
|
|
174
|
-
rep = mod['validate_repo'](Path(tmp) / 'repo')
|
|
175
|
-
assert any('CHANGELOG.md' in e for e in rep['errors']), rep['errors']
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def cli(*args):
|
|
179
|
-
out = io.StringIO()
|
|
180
|
-
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(out):
|
|
181
|
-
return mod['main'](list(args)), out.getvalue()
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
assert cli(str(repo_root), '--release-tag', f'v{version}')[0] == 0
|
|
185
|
-
for tag in ('v9.9.9', version, 'latest', f'v{version}-dirty'):
|
|
186
|
-
code, out = cli(str(repo_root), '--release-tag', tag)
|
|
187
|
-
assert code == 1 and 'release tag' in out, (tag, code, out)
|
|
188
|
-
|
|
189
|
-
print('PASS 13 checks')
|
|
190
|
-
PY
|