@nalvietnam/avatar-cli 1.0.1 → 1.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.
package/bin/avatar.js CHANGED
File without changes
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // Postinstall entry — chạy sau `npm install -g @nalvietnam/avatar-cli`.
3
+ // In welcome screen với banner + 13 commands. Silent fail nếu lỗi (không
4
+ // block install nếu terminal không support hoặc env CI=true).
5
+ try {
6
+ if (process.env.CI || process.env.AVATAR_SKIP_WELCOME) {
7
+ process.exit(0);
8
+ }
9
+ const mod = await import("../dist/lib/print-welcome-screen.js");
10
+ mod.printWelcomeScreen();
11
+ } catch {
12
+ // Silent: nếu welcome screen fail vì lý do gì, không block npm install.
13
+ }
@@ -0,0 +1,24 @@
1
+ #!/bin/sh
2
+ # Avatar post-merge git hook
3
+ # Auto-runs `avatar scan --incremental` after `git pull` / `git merge`.
4
+ # Installed by `avatar init`. Uninstall by deleting .git/hooks/post-merge.
5
+
6
+ # Skip if avatar CLI is not on PATH.
7
+ if ! command -v avatar >/dev/null 2>&1; then
8
+ exit 0
9
+ fi
10
+
11
+ # Skip if this project doesn't have an Avatar pack.
12
+ if [ ! -d ".claude/pack" ]; then
13
+ exit 0
14
+ fi
15
+
16
+ # Background scan — never block git.
17
+ (avatar scan --incremental --quiet &) >/dev/null 2>&1
18
+
19
+ echo ""
20
+ echo "🔍 Avatar đang scan thay đổi ngầm. Khi xong sẽ thông báo."
21
+ echo " Manual: avatar review"
22
+ echo ""
23
+
24
+ exit 0
@@ -0,0 +1,33 @@
1
+ #!/bin/sh
2
+ # Avatar pre-push hook (CLIENT MODE ONLY)
3
+ # Installed in src/.git/hooks/pre-push when `avatar init --mode=client`.
4
+ # Purpose: block accidental leak of Avatar files into the client repo.
5
+ #
6
+ # Rationale: in client mode, src/ is the client's submodule; Avatar files live
7
+ # in the workspace ABOVE src/. If a dev accidentally `git add` an Avatar-owned
8
+ # path inside src/, this hook stops the push and explains the fix.
9
+
10
+ # Patterns that must never appear in a client-repo push.
11
+ FORBIDDEN_PATTERNS='\.claude/|^CLAUDE\.md$|\.avatar/'
12
+
13
+ # Check files staged in commits being pushed.
14
+ leaked=$(git diff --cached --name-only HEAD 2>/dev/null | grep -E "$FORBIDDEN_PATTERNS" || true)
15
+ if [ -z "$leaked" ]; then
16
+ # Also check files in already-committed-but-not-yet-pushed history.
17
+ leaked=$(git log --name-only --format= origin/HEAD..HEAD 2>/dev/null | grep -E "$FORBIDDEN_PATTERNS" || true)
18
+ fi
19
+
20
+ if [ -n "$leaked" ]; then
21
+ echo ""
22
+ echo "✗ Avatar pre-push hook: phát hiện Avatar files trong client push:"
23
+ echo ""
24
+ echo "$leaked" | sed 's/^/ /'
25
+ echo ""
26
+ echo "Avatar files (.claude/, CLAUDE.md) phải commit vào WORKSPACE, không phải client repo."
27
+ echo "Dùng: avatar commit --avatar"
28
+ echo "Bypass (không khuyến nghị): git push --no-verify"
29
+ echo ""
30
+ exit 1
31
+ fi
32
+
33
+ exit 0