@bbcsoftwarefactory/skills 0.0.0-stage → 0.1.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.
Files changed (100) hide show
  1. package/dist/index.json +42 -0
  2. package/dist/skills/code-quality-gate/SKILL.md +59 -0
  3. package/dist/skills/code-quality-gate/references/gate-bigo.md +31 -0
  4. package/dist/skills/code-quality-gate/references/gate-earlyreturn.md +73 -0
  5. package/dist/skills/code-quality-gate/references/gate-typesafe.md +32 -0
  6. package/dist/skills/code-quality-gate/references/output-schema.yml +40 -0
  7. package/dist/skills/code-quality-gate/scripts/extract-diff-scope.py +225 -0
  8. package/dist/skills/code-quality-gate/tests/extract-diff-scope.test.sh +200 -0
  9. package/dist/skills/delivery-coordinator/SKILL.md +81 -0
  10. package/dist/skills/delivery-coordinator/references/hud-output.md +55 -0
  11. package/dist/skills/delivery-coordinator/references/intake.md +86 -0
  12. package/dist/skills/delivery-coordinator/references/issue-claim.md +143 -0
  13. package/dist/skills/delivery-coordinator/references/issue-dedup.md +38 -0
  14. package/dist/skills/delivery-coordinator/references/sleuth-regression-exercise.md +60 -0
  15. package/dist/skills/delivery-coordinator/references/visual-reference.md +45 -0
  16. package/dist/skills/delivery-coordinator/references/worktree-isolation.md +19 -0
  17. package/dist/skills/delivery-coordinator/scripts/check-issue-claim.py +363 -0
  18. package/dist/skills/delivery-coordinator/scripts/check-worktree-guard.py +220 -0
  19. package/dist/skills/delivery-coordinator/scripts/classify-change-lane.py +263 -0
  20. package/dist/skills/delivery-coordinator/tests/check-issue-claim.test.sh +221 -0
  21. package/dist/skills/delivery-coordinator/tests/check-worktree-guard.test.sh +123 -0
  22. package/dist/skills/delivery-coordinator/tests/classify-change-lane.test.sh +124 -0
  23. package/dist/skills/documentation-steward/SKILL.md +43 -0
  24. package/dist/skills/documentation-steward/references/discovery.md +17 -0
  25. package/dist/skills/documentation-steward/references/handoff.md +15 -0
  26. package/dist/skills/greptile-review-loop/SKILL.md +57 -0
  27. package/dist/skills/greptile-review-loop/references/review-protocol.md +37 -0
  28. package/dist/skills/greptile-review-loop/scripts/review-loop.py +435 -0
  29. package/dist/skills/greptile-review-loop/tests/review-loop.test.sh +331 -0
  30. package/dist/skills/issue-reviewer/SKILL.md +87 -0
  31. package/dist/skills/issue-reviewer/references/review-format.md +100 -0
  32. package/dist/skills/issue-reviewer/references/triage.md +105 -0
  33. package/dist/skills/issue-reviewer/scripts/fetch-issue-attachments.py +239 -0
  34. package/dist/skills/issue-reviewer/scripts/plan-issue-triage.py +311 -0
  35. package/dist/skills/issue-reviewer/tests/fetch-issue-attachments.test.sh +90 -0
  36. package/dist/skills/issue-reviewer/tests/plan-issue-triage.test.sh +168 -0
  37. package/dist/skills/question-gate/SKILL.md +66 -0
  38. package/dist/skills/question-gate/references/client-hooks.md +111 -0
  39. package/dist/skills/question-gate/references/diagram-routing.md +58 -0
  40. package/dist/skills/question-gate/scripts/triage-question.py +713 -0
  41. package/dist/skills/question-gate/tests/fixtures/question-corpus.json +481 -0
  42. package/dist/skills/question-gate/tests/question-corpus.test.sh +32 -0
  43. package/dist/skills/question-gate/tests/triage-question.test.sh +441 -0
  44. package/dist/skills/regression-testing/SKILL.md +49 -0
  45. package/dist/skills/regression-testing/references/evidence-record.md +35 -0
  46. package/dist/skills/requirements-spec/SKILL.md +59 -0
  47. package/dist/skills/risk-scout/SKILL.md +53 -0
  48. package/dist/skills/risk-scout/references/risk-matrix.md +49 -0
  49. package/dist/skills/skill-clean-architecture/SKILL.md +54 -0
  50. package/dist/skills/skill-clean-architecture/references/layer-rules.md +22 -0
  51. package/dist/skills/skill-clean-architecture/references/source-headers.md +31 -0
  52. package/dist/skills/skill-clean-architecture/scripts/measure-bigo.py +427 -0
  53. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/bad-utf8.js +1 -0
  54. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/edge-crlf.ts +6 -0
  55. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/edge-mixed.ts +15 -0
  56. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/empty.js +0 -0
  57. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/no-newline.js +1 -0
  58. package/dist/skills/skill-clean-architecture/tests/fixtures/bigo.expected.yml +95 -0
  59. package/dist/skills/skill-clean-architecture/tests/measure-bigo.test.sh +222 -0
  60. package/dist/skills/tool-depot/SKILL.md +47 -0
  61. package/dist/skills/tool-depot/references/checkout.md +29 -0
  62. package/dist/skills/tool-depot/references/loki-read.md +41 -0
  63. package/dist/skills/tool-depot/references/readonly-access.md +84 -0
  64. package/dist/skills/tool-depot/references/tool-catalog.json +47 -0
  65. package/dist/skills/tool-depot/scripts/loki-runtime-logs.py +305 -0
  66. package/dist/skills/tool-depot/tests/loki-runtime-logs.test.sh +101 -0
  67. package/dist/skills/watcher-observability/SKILL.md +73 -0
  68. package/dist/skills/watcher-observability/references/batch-protocol.md +44 -0
  69. package/dist/skills/watcher-observability/references/configuration.md +31 -0
  70. package/dist/skills/watcher-observability/references/error-scan.md +102 -0
  71. package/dist/skills/watcher-observability/references/live-protocol.md +49 -0
  72. package/dist/skills/watcher-observability/references/server-account.md +72 -0
  73. package/dist/skills/watcher-observability/scripts/error-scan.py +318 -0
  74. package/dist/skills/watcher-observability/scripts/resolve-containers.py +155 -0
  75. package/dist/skills/watcher-observability/scripts/save-counts.py +381 -0
  76. package/dist/skills/watcher-observability/scripts/summarize-logs.py +113 -0
  77. package/dist/skills/watcher-observability/scripts/watch-live.py +606 -0
  78. package/dist/skills/watcher-observability/server/watcher-gate.sh +51 -0
  79. package/dist/skills/watcher-observability/tests/error-scan.test.sh +257 -0
  80. package/dist/skills/watcher-observability/tests/live-windows.test.sh +177 -0
  81. package/dist/skills/watcher-observability/tests/resolve-containers.test.sh +87 -0
  82. package/dist/skills/watcher-observability/tests/save-counts.test.sh +338 -0
  83. package/dist/skills/watcher-observability/tests/sleuth.test.sh +176 -0
  84. package/dist/skills/watcher-observability/tests/summarize-logs.test.sh +105 -0
  85. package/dist/skills/watcher-observability/tests/watcher-config.test.sh +70 -0
  86. package/dist/skills/watcher-observability/tests/watcher-gate.test.sh +110 -0
  87. package/dist/skills/watcher-observability/watcher.json +1 -0
  88. package/dist/skills/workflow-auditor/SKILL.md +55 -0
  89. package/dist/skills/workflow-auditor/references/audit-protocol.md +49 -0
  90. package/dist/skills/workflow-auditor/references/ledger.md +122 -0
  91. package/dist/skills/workflow-auditor/scripts/audit-ledger.py +624 -0
  92. package/dist/skills/workflow-auditor/scripts/list-zed-commands.py +183 -0
  93. package/dist/skills/workflow-auditor/scripts/render-workflow.py +201 -0
  94. package/dist/skills/workflow-auditor/scripts/validate-skills.py +444 -0
  95. package/dist/skills/workflow-auditor/tests/audit-ledger.test.sh +660 -0
  96. package/dist/skills/workflow-auditor/tests/list-zed-commands.test.sh +93 -0
  97. package/dist/skills/workflow-auditor/tests/render-workflow.test.sh +135 -0
  98. package/dist/skills/workflow-auditor/tests/validate-skills.test.sh +190 -0
  99. package/package.json +27 -6
  100. package/README.md +0 -3
@@ -0,0 +1,93 @@
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 ]]
@@ -0,0 +1,135 @@
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
@@ -0,0 +1,190 @@
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
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
- {
2
- "name": "@bbcsoftwarefactory/skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@bbcsoftwarefactory/skills",
3
+ "version": "0.1.1",
4
+ "description": "Public BuilderBot agent skills and slash commands, packaged for installation by the CLI.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22.18.0"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "node build.ts",
15
+ "prepack": "node build.ts",
16
+ "test": "node --test \"*.test.ts\""
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/builberbot/bbc-skill-internals.git",
21
+ "directory": "packages/skills"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "provenance": true
26
+ }
27
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.