android-skills 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +130 -2
  3. package/android-ui-minimal/SKILL.md +98 -0
  4. package/android-ui-minimal/references/anti-slop-checklist.md +61 -0
  5. package/android-ui-minimal/references/clarifying-questions.md +55 -0
  6. package/android-ui-minimal/references/color-and-contrast.md +104 -0
  7. package/android-ui-minimal/references/compose-patterns.md +120 -0
  8. package/android-ui-minimal/references/reconstruction-workflow.md +74 -0
  9. package/android-ui-minimal/references/typography-spacing.md +93 -0
  10. package/android-ui-minimal/scripts/contrast.py +68 -0
  11. package/android-ui-minimal/scripts/gen_tokens.py +165 -0
  12. package/android-ui-minimal/scripts/lint_ui.py +189 -0
  13. package/android-ui-security-review/SKILL.md +93 -0
  14. package/android-ui-security-review/references/checklist.md +95 -0
  15. package/android-ui-security-review/references/components-intents.md +74 -0
  16. package/android-ui-security-review/references/compose-risks.md +86 -0
  17. package/android-ui-security-review/references/input-and-state.md +77 -0
  18. package/android-ui-security-review/references/network-storage.md +87 -0
  19. package/android-ui-security-review/references/report-template.md +71 -0
  20. package/android-ui-security-review/references/sensitive-data-ui.md +73 -0
  21. package/android-ui-security-review/references/webview.md +105 -0
  22. package/android-ui-security-review/scripts/scan.py +411 -0
  23. package/bin/android-skills.js +47 -0
  24. package/install.py +337 -0
  25. package/opencode/commands/ui-minimal.md +9 -0
  26. package/opencode/commands/ui-security.md +9 -0
  27. package/package.json +43 -4
package/install.py ADDED
@@ -0,0 +1,337 @@
1
+ #!/usr/bin/env python3
2
+ """Pemasang skill Android untuk berbagai agent AI.
3
+
4
+ Didukung: opencode (default), claude, codex, gemini, copilot, cursor, windsurf.
5
+
6
+ Pemakaian:
7
+ python3 install.py # OpenCode global
8
+ python3 install.py --project . # OpenCode proyek
9
+ python3 install.py --target claude --project . # Claude Code proyek
10
+ python3 install.py --target cursor # Cursor global
11
+ python3 install.py --target codex --project . # Codex: .android-skills/ + blok di AGENTS.md
12
+ python3 install.py --target gemini --project . # Gemini CLI: GEMINI.md
13
+ python3 install.py --target copilot --project . # GitHub Copilot: .github/copilot-instructions.md
14
+ python3 install.py --link # symlink, bukan salinan
15
+ python3 install.py --agents-md # tulis blok instruksi ke file aturan (skills mode)
16
+ python3 install.py --uninstall
17
+ python3 install.py --validate
18
+
19
+ OpenCode & Claude Code memakai layout skill <root>/skills/<nama>/SKILL.md .
20
+ Cursor & Windsurf memakai file rules di <root>/rules/ .
21
+ Codex, Gemini CLI, dan Copilot memakai file instruksi (AGENTS.md, GEMINI.md,
22
+ copilot-instructions.md) plus folder skill di <root>/.android-skills/ (proyek)
23
+ atau <root>/android-skills/ (global).
24
+ """
25
+ import argparse
26
+ import os
27
+ import re
28
+ import shutil
29
+ import sys
30
+
31
+ HERE = os.path.dirname(os.path.abspath(__file__))
32
+ SKILLS = ["android-ui-minimal", "android-ui-security-review"]
33
+ SKILL_SUMMARY = {
34
+ "android-ui-minimal": "membuat, merekonstruksi, dan merapikan UI Android",
35
+ "android-ui-security-review": "meninjau keamanan pada lapisan UI/frontend Android",
36
+ }
37
+ NAME_RE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$")
38
+ BEGIN, END = "<!-- android-skills:begin -->", "<!-- android-skills:end -->"
39
+ COMMANDS = ("ui-minimal.md", "ui-security.md")
40
+
41
+ TARGETS = {
42
+ "opencode": dict(
43
+ desc="OpenCode", mode="skills", commands=True,
44
+ global_base=lambda: os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "opencode"),
45
+ project_base=".opencode", rules="AGENTS.md",
46
+ ),
47
+ "claude": dict(
48
+ desc="Claude Code", mode="skills", commands=False,
49
+ global_base=lambda: os.path.expanduser("~/.claude"),
50
+ project_base=".claude", rules="CLAUDE.md",
51
+ ),
52
+ "codex": dict(
53
+ desc="Codex CLI", mode="instructions", commands=False,
54
+ global_base=lambda: os.path.expanduser("~/.codex"),
55
+ project_base=None, rules="AGENTS.md",
56
+ ),
57
+ "gemini": dict(
58
+ desc="Gemini CLI", mode="instructions", commands=False,
59
+ global_base=lambda: os.path.expanduser("~/.gemini"),
60
+ project_base=None, rules="GEMINI.md",
61
+ ),
62
+ "copilot": dict(
63
+ desc="GitHub Copilot", mode="instructions", commands=False,
64
+ global_base=None,
65
+ project_base=".github", rules=".github/copilot-instructions.md",
66
+ ),
67
+ "cursor": dict(
68
+ desc="Cursor", mode="rules", commands=False,
69
+ global_base=lambda: os.path.expanduser("~/.cursor"),
70
+ project_base=".cursor", rules_dir="rules", rules_ext=".mdc",
71
+ ),
72
+ "windsurf": dict(
73
+ desc="Windsurf", mode="rules", commands=False,
74
+ global_base=lambda: os.path.expanduser("~/.windsurf"),
75
+ project_base=".windsurf", rules_dir="rules", rules_ext=".md",
76
+ ),
77
+ }
78
+
79
+
80
+ def frontmatter(path):
81
+ with open(path, encoding="utf-8") as fh:
82
+ text = fh.read()
83
+ text = text.replace("\r\n", "\n")
84
+ m = re.match(r"^---\n(.*?)\n---(?:\n|$)", text, re.S)
85
+ if not m:
86
+ return None
87
+ data = {}
88
+ for line in m.group(1).splitlines():
89
+ if re.match(r"^[A-Za-z_-]+:", line):
90
+ k, _, v = line.partition(":")
91
+ data[k.strip()] = v.strip()
92
+ return data
93
+
94
+
95
+ def validate():
96
+ ok = True
97
+ for s in SKILLS:
98
+ md = os.path.join(HERE, s, "SKILL.md")
99
+ if not os.path.isfile(md):
100
+ print(f"GAGAL {s}: SKILL.md tidak ada")
101
+ ok = False
102
+ continue
103
+ fm = frontmatter(md)
104
+ if not fm:
105
+ print(f"GAGAL {s}: frontmatter tidak ditemukan")
106
+ ok = False
107
+ continue
108
+ name, desc = fm.get("name", ""), fm.get("description", "")
109
+ problems = []
110
+ if name != s:
111
+ problems.append(f"name '{name}' harus sama dengan nama folder '{s}'")
112
+ if not (1 <= len(name) <= 64 and NAME_RE.match(name)):
113
+ problems.append("name harus huruf kecil, angka, dan tanda hubung tunggal (1-64)")
114
+ if not (1 <= len(desc) <= 1024):
115
+ problems.append(f"description harus 1-1024 karakter (sekarang {len(desc)})")
116
+ for p in problems:
117
+ print(f"GAGAL {s}: {p}")
118
+ ok &= not problems
119
+ if not problems:
120
+ print(f"OK {s} (description {len(desc)} karakter)")
121
+ return ok
122
+
123
+
124
+ def put(src, dst, link):
125
+ if os.path.lexists(dst):
126
+ if os.path.islink(dst) or os.path.isfile(dst):
127
+ os.remove(dst)
128
+ else:
129
+ shutil.rmtree(dst)
130
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
131
+ if link:
132
+ os.symlink(src, dst)
133
+ elif os.path.isdir(src):
134
+ shutil.copytree(src, dst, ignore=shutil.ignore_patterns("__pycache__", "*.pyc"))
135
+ else:
136
+ shutil.copy2(src, dst)
137
+
138
+
139
+ def managed_block(skills_dir, start_at):
140
+ """Blok instruksi terkelola untuk file aturan (AGENTS.md, CLAUDE.md, dsb.)."""
141
+ rel = lambda p: os.path.relpath(p, start_at)
142
+ lines = [
143
+ BEGIN,
144
+ "",
145
+ "## Skill Android UI",
146
+ "",
147
+ "Dua skill lokal tersedia:",
148
+ ]
149
+ for s in SKILLS:
150
+ lines.append(f"- `{s}` — {SKILL_SUMMARY[s]}. SKILL.md: `{rel(os.path.join(skills_dir, s, 'SKILL.md'))}`")
151
+ lines += [
152
+ "",
153
+ "Aturan:",
154
+ f"- Sebelum menulis atau merapikan UI Android, baca skill `{SKILLS[0]}` dan referensi terkait.",
155
+ f"- Sebelum audit keamanan frontend Android, baca skill `{SKILLS[1]}`; baca-saja kecuali diminta memperbaiki.",
156
+ "- Tanpa emoji di UI, string, komentar, atau commit. Tanyakan dulu bila permintaan ambigu.",
157
+ "",
158
+ END,
159
+ ]
160
+ return "\n".join(lines) + "\n"
161
+
162
+
163
+ def update_managed_file(path, skills_dir, remove=False):
164
+ text = open(path, encoding="utf-8").read() if os.path.exists(path) else ""
165
+ text = re.sub(re.escape(BEGIN) + r".*?" + re.escape(END) + r"\n?", "", text, flags=re.S)
166
+ if not remove:
167
+ text = (text.rstrip("\n") + "\n\n" if text.strip() else "") + managed_block(skills_dir, os.path.dirname(path))
168
+ if remove and not text.strip():
169
+ if os.path.exists(path):
170
+ os.remove(path)
171
+ return
172
+ os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
173
+ with open(path, "w", encoding="utf-8") as fh:
174
+ fh.write(text)
175
+
176
+
177
+ def with_always_apply(md_text):
178
+ m = re.match(r"^---\n(.*?)\n---\n?", md_text, re.S)
179
+ if not m:
180
+ return md_text
181
+ fm, body = m.group(1), md_text[m.end():]
182
+ if not re.search(r"^alwaysApply:", fm, re.M):
183
+ fm += "\nalwaysApply: false"
184
+ return f"---\n{fm}\n---\n{body}"
185
+
186
+
187
+ def make_rule_file(skill, dst, skills_dir, ext):
188
+ """Buat file rules (.mdc untuk Cursor, .md untuk Windsurf) dari SKILL.md."""
189
+ text = open(os.path.join(HERE, skill, "SKILL.md"), encoding="utf-8").read().replace("\r\n", "\n")
190
+ text = with_always_apply(text)
191
+ note = f"\n> Folder lengkap skill (referensi & skrip) ada di: {os.path.relpath(os.path.join(skills_dir, skill), start=os.path.dirname(dst))}\n"
192
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
193
+ with open(dst, "w", encoding="utf-8") as fh:
194
+ fh.write(text + note)
195
+
196
+
197
+ def layout(t, project):
198
+ """Hitung lokasi target berdasarkan mode."""
199
+ if t["mode"] == "skills":
200
+ base = os.path.join(project, t["project_base"]) if project else t["global_base"]()
201
+ skills_dir = os.path.join(base, "skills")
202
+ cmd_dir = os.path.join(base, "commands") if t.get("commands") else None
203
+ rules_path = os.path.join(project if project else base, t["rules"])
204
+ return dict(base=base, skills_dir=skills_dir, cmd_dir=cmd_dir,
205
+ rules_path=rules_path, rules_dir=None, rules_ext=None)
206
+ if t["mode"] == "rules":
207
+ base = os.path.join(project, t["project_base"]) if project else t["global_base"]()
208
+ rules_dir = os.path.join(base, t["rules_dir"])
209
+ skills_dir = os.path.join(base, "skills")
210
+ return dict(base=base, skills_dir=skills_dir, cmd_dir=None,
211
+ rules_path=None, rules_dir=rules_dir, rules_ext=t["rules_ext"])
212
+ # mode instructions
213
+ if project:
214
+ base = project
215
+ skills_dir = os.path.join(base, ".android-skills")
216
+ else:
217
+ if t["global_base"] is None:
218
+ raise SystemExit(f"target '{t['desc']}' hanya mendukung --project DIR (mis. --project .)")
219
+ base = t["global_base"]()
220
+ skills_dir = os.path.join(base, "android-skills")
221
+ return dict(base=base, skills_dir=skills_dir, cmd_dir=None,
222
+ rules_path=os.path.join(base, t["rules"]), rules_dir=None, rules_ext=None)
223
+
224
+
225
+ def remove_skill_dir(p):
226
+ if os.path.lexists(p):
227
+ if os.path.isdir(p) and not os.path.islink(p):
228
+ shutil.rmtree(p)
229
+ else:
230
+ os.remove(p)
231
+ print(f"dihapus: {p}")
232
+
233
+
234
+ def main():
235
+ ap = argparse.ArgumentParser(
236
+ description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
237
+ ap.add_argument("--project", metavar="DIR", help="pasang per-proyek ke DIR (path global bila tidak diisi)")
238
+ ap.add_argument("--target", choices=sorted(TARGETS), default="opencode",
239
+ help="agent tujuan (default: opencode)")
240
+ ap.add_argument("--link", action="store_true", help="symlink, bukan salinan")
241
+ ap.add_argument("--agents-md", action="store_true",
242
+ help="tulis/hapus blok instruksi ke file aturan target (AGENTS.md, CLAUDE.md, "
243
+ "GEMINI.md, copilot-instructions.md). Di target rules (cursor/windsurf) "
244
+ "file rules selalu dibuat.")
245
+ ap.add_argument("--uninstall", action="store_true")
246
+ ap.add_argument("--validate", action="store_true")
247
+ a = ap.parse_args()
248
+
249
+ if not validate():
250
+ sys.exit(1)
251
+ if a.validate:
252
+ return
253
+
254
+ t = TARGETS[a.target]
255
+ L = layout(t, a.project)
256
+ skills_dir = L["skills_dir"]
257
+ rules_dir = L["rules_dir"]
258
+ rules_ext = L["rules_ext"]
259
+ rules_path = L["rules_path"]
260
+ mode = t["mode"]
261
+
262
+ if a.uninstall:
263
+ for s in SKILLS:
264
+ remove_skill_dir(os.path.join(skills_dir, s))
265
+ if L.get("cmd_dir"):
266
+ for c in COMMANDS:
267
+ p = os.path.join(L["cmd_dir"], c)
268
+ if os.path.lexists(p):
269
+ os.remove(p)
270
+ print(f"dihapus: {p}")
271
+ legacy_dir = os.path.join(L["base"], "command")
272
+ for c in COMMANDS:
273
+ p = os.path.join(legacy_dir, c)
274
+ if os.path.lexists(p):
275
+ os.remove(p)
276
+ print(f"dihapus (legacy): {p}")
277
+ if rules_dir:
278
+ for s in SKILLS:
279
+ p = os.path.join(rules_dir, s + rules_ext)
280
+ if os.path.lexists(p):
281
+ os.remove(p)
282
+ print(f"dihapus: {p}")
283
+ if mode == "instructions":
284
+ existed = os.path.exists(rules_path)
285
+ update_managed_file(rules_path, skills_dir, remove=True)
286
+ print(f"blok dihapus dari: {rules_path}" if existed else "tidak ada blok lama")
287
+ if os.path.isdir(skills_dir) and not os.listdir(skills_dir):
288
+ os.rmdir(skills_dir)
289
+ print(f"dihapus: {skills_dir}")
290
+ elif a.agents_md and rules_path and os.path.exists(rules_path):
291
+ update_managed_file(rules_path, skills_dir, remove=True)
292
+ print(f"blok dihapus dari: {rules_path}")
293
+ print("Uninstall selesai.")
294
+ return
295
+
296
+ for s in SKILLS:
297
+ dst = os.path.join(skills_dir, s)
298
+ put(os.path.join(HERE, s), dst, a.link)
299
+ print(f"terpasang: {dst}")
300
+ scripts = os.path.join(dst, "scripts")
301
+ if os.path.isdir(scripts) and not os.path.islink(dst):
302
+ for f in os.listdir(scripts):
303
+ if f.endswith(".py"):
304
+ try:
305
+ os.chmod(os.path.join(scripts, f), 0o755)
306
+ except OSError:
307
+ pass
308
+ if L.get("cmd_dir"):
309
+ for c in COMMANDS:
310
+ put(os.path.join(HERE, "opencode", "commands", c), os.path.join(L["cmd_dir"], c), a.link)
311
+ print(f"terpasang: {os.path.join(L['cmd_dir'], c)}")
312
+
313
+ if rules_dir:
314
+ for s in SKILLS:
315
+ p = os.path.join(rules_dir, s + rules_ext)
316
+ make_rule_file(s, p, skills_dir, rules_ext)
317
+ print(f"terpasang: {p}")
318
+ elif mode == "instructions":
319
+ update_managed_file(rules_path, skills_dir)
320
+ print(f"instruksi diperbarui: {rules_path}")
321
+ elif a.agents_md:
322
+ update_managed_file(rules_path, skills_dir)
323
+ print(f"aturan diperbarui: {rules_path}")
324
+
325
+ rel_hint = {"opencode": "OpenCode", "claude": "Claude Code", "codex": "Codex",
326
+ "gemini": "Gemini CLI", "copilot": "Copilot", "cursor": "Cursor",
327
+ "windsurf": "Windsurf"}[a.target]
328
+ print(f"\nSelesai ({rel_hint}). Mulai ulang sesi agent bila perlu.")
329
+ if L.get("cmd_dir"):
330
+ print("Command opsional OpenCode: /ui-minimal <layar> atau /ui-security <folder>")
331
+ if rules_dir:
332
+ print("File rules terpasang di " + rules_dir +
333
+ " — pastikan rules aktif; user rules global mungkin perlu ditambahkan lewat UI agent.")
334
+
335
+
336
+ if __name__ == "__main__":
337
+ main()
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Jalankan rekonstruksi UI Android memakai skill android-ui-minimal
3
+ ---
4
+
5
+ Muat skill `android-ui-minimal` (ID OpenCode: `@android-ui-minimal`) lalu ikuti workflow-nya.
6
+
7
+ Target: $ARGUMENTS
8
+
9
+ Jika target sudah jelas dari argumen atau konteks, langsung audit dan kerjakan. Baca referensi relevan dari direktori skill. Jangan bertanya ulang hal yang sudah diketahui. Jalankan linter dan pemeriksaan kontras bila Python tersedia. Ubah hanya cakupan yang diminta. Laporkan file yang berubah, pemeriksaan yang dijalankan, dan keterbatasannya.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Audit keamanan frontend Android memakai skill android-ui-security-review
3
+ ---
4
+
5
+ Muat skill `android-ui-security-review` (ID OpenCode: `@android-ui-security-review`) lalu ikuti workflow-nya.
6
+
7
+ Ruang lingkup: $ARGUMENTS
8
+
9
+ Mode baca-saja. Jika ruang lingkup tidak dapat ditentukan dari argumen/konteks, tanyakan path/modul yang perlu diaudit. Baca referensi relevan, jalankan scanner bila Python tersedia, verifikasi manual setiap temuan, dan gunakan template laporan. Jangan tampilkan secret utuh atau menulis exploit. Nyatakan batas pemeriksaan dan jangan mengklaim aplikasi aman.
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "android-skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Pemasang skill Android UI (build & security review) untuk OpenCode, Claude Code, Codex, Cursor, Windsurf, Gemini CLI, dan GitHub Copilot. Dipakai via npx atau npm.",
5
+ "license": "MIT",
6
+ "author": "tamvanpr",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/tamvanpr/android-skills.git"
10
+ },
11
+ "keywords": [
12
+ "android",
13
+ "skill",
14
+ "agent",
15
+ "opencode",
16
+ "claude-code",
17
+ "codex",
18
+ "cursor",
19
+ "windsurf",
20
+ "gemini-cli",
21
+ "copilot",
22
+ "ui",
23
+ "security",
24
+ "jetpack-compose"
25
+ ],
26
+ "bin": {
27
+ "android-skills": "bin/android-skills.js"
28
+ },
29
+ "files": [
30
+ "bin/",
31
+ "install.py",
32
+ "android-ui-minimal/",
33
+ "android-ui-security-review/",
34
+ "opencode/",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "scripts": {
42
+ "setup": "node bin/android-skills.js",
43
+ "validate": "node bin/android-skills.js --validate"
44
+ }
45
+ }