git-slot-machine 2.3.2 → 2.4.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 (64) hide show
  1. package/package.json +6 -1
  2. package/.claude/release.md +0 -74
  3. package/CHANGELOG.md +0 -250
  4. package/dist/animation/slotMachine.d.ts.map +0 -1
  5. package/dist/animation/slotMachine.js.map +0 -1
  6. package/dist/api.d.ts.map +0 -1
  7. package/dist/api.js.map +0 -1
  8. package/dist/balance.d.ts.map +0 -1
  9. package/dist/balance.js.map +0 -1
  10. package/dist/commands/auth.d.ts.map +0 -1
  11. package/dist/commands/auth.js.map +0 -1
  12. package/dist/commands/balance.d.ts.map +0 -1
  13. package/dist/commands/balance.js.map +0 -1
  14. package/dist/commands/config.d.ts.map +0 -1
  15. package/dist/commands/config.js.map +0 -1
  16. package/dist/commands/init.d.ts.map +0 -1
  17. package/dist/commands/init.js.map +0 -1
  18. package/dist/commands/play.d.ts.map +0 -1
  19. package/dist/commands/play.js.map +0 -1
  20. package/dist/commands/spin.d.ts.map +0 -1
  21. package/dist/commands/spin.js.map +0 -1
  22. package/dist/commands/sync.d.ts.map +0 -1
  23. package/dist/commands/sync.js.map +0 -1
  24. package/dist/commands/test.d.ts.map +0 -1
  25. package/dist/commands/test.js.map +0 -1
  26. package/dist/config.d.ts.map +0 -1
  27. package/dist/config.js.map +0 -1
  28. package/dist/index.d.ts.map +0 -1
  29. package/dist/index.js.map +0 -1
  30. package/dist/patterns.d.ts.map +0 -1
  31. package/dist/patterns.js.map +0 -1
  32. package/dist/secrets.d.ts.map +0 -1
  33. package/dist/secrets.js.map +0 -1
  34. package/dist/templates/post-commit.d.ts.map +0 -1
  35. package/dist/templates/post-commit.js.map +0 -1
  36. package/dist/utils/amendDetector.d.ts.map +0 -1
  37. package/dist/utils/amendDetector.js.map +0 -1
  38. package/dist/utils/fetch-polyfill.d.ts.map +0 -1
  39. package/dist/utils/fetch-polyfill.js.map +0 -1
  40. package/dist/utils/git.d.ts.map +0 -1
  41. package/dist/utils/git.js.map +0 -1
  42. package/jest.config.js +0 -12
  43. package/src/animation/slotMachine.ts +0 -164
  44. package/src/api.ts +0 -207
  45. package/src/balance.ts +0 -118
  46. package/src/commands/auth.ts +0 -92
  47. package/src/commands/balance.ts +0 -28
  48. package/src/commands/config.ts +0 -59
  49. package/src/commands/init.ts +0 -259
  50. package/src/commands/play.ts +0 -196
  51. package/src/commands/spin.ts +0 -17
  52. package/src/commands/sync.ts +0 -49
  53. package/src/commands/test.ts +0 -19
  54. package/src/config.ts +0 -189
  55. package/src/index.ts +0 -136
  56. package/src/patterns.test.ts +0 -44
  57. package/src/patterns.ts +0 -313
  58. package/src/secrets.ts +0 -44
  59. package/src/templates/post-commit.ts +0 -15
  60. package/src/utils/amendDetector.ts +0 -74
  61. package/src/utils/fetch-polyfill.ts +0 -13
  62. package/src/utils/git.ts +0 -88
  63. package/test.txt +0 -2
  64. package/tsconfig.json +0 -21
package/src/secrets.ts DELETED
@@ -1,44 +0,0 @@
1
- import { createHash } from 'crypto';
2
-
3
- interface S {
4
- h: string; // sha256 hash
5
- p: number; // payout
6
- n: number[]; // name as char codes
7
- e?: number; // emoji code point
8
- f?: number; // flood flag
9
- }
10
-
11
- // Sorted by payout descending
12
- const _: S[] = [
13
- // Legendary tier (42069)
14
- { h: '56379c14419d2363ce258293ed6adc3684ae4926aba335a49b75d7483b9f85ae', p: 42069, n: [66,65,68,32,70,79,79,68], e: 0x1F922, f: 1 },
15
- { h: '475fbf8c77411b86a660c8d61f181e464a50572e8f1ff4ffb28e75289625d494', p: 42069, n: [67,79,70,70,69,69,83], e: 0x2615, f: 1 },
16
- { h: 'a0d9961dc6d7e4059ec746b8ab9a20f330c1308266c5197da77e7bda839457b9', p: 42069, n: [68,69,65,68,32,66,69,68], e: 0x1F480, f: 1 },
17
- { h: 'a3fe33e094647d5071cb6d3719bd7b55eb1ad1fb06f2c33923e66363fd805020', p: 42069, n: [68,73,83,69,65,83,69], e: 0x1F9A0, f: 1 },
18
- // Great tier (6969)
19
- { h: '011a1a79ee662806e273538d1a0036b8090f939efd05e312f402ed9fdcaf5f25', p: 6969, n: [73,67,69,32,67,79,76,68], e: 0x1F976, f: 1 },
20
- { h: '432fe036b0239c1551947f5a1f93006f2f62e4c5512909453e539eba348b678f', p: 6969, n: [83,65,68,32,70,65,67,69], e: 0x1F622, f: 1 },
21
- { h: 'dcf79a973cb6e6d4567c17e24865d39370db2bc6a167ebdcbeaedcda83906350', p: 6969, n: [66,79,65,83,84,69,68], e: 0x1F525, f: 1 },
22
- // Good tier (1337)
23
- { h: '70d8dec01053bbf890288c8927f605f209533b52512dafd9f145e891d6d3f0ae', p: 1337, n: [66,65,68,32,67,65,70,69] },
24
- { h: '2c8d79f36c7758d1268998039ca8a565cb6687958516f370e10086b45c2a1ea7', p: 1337, n: [68,69,70,65,67,69,68] },
25
- ];
26
-
27
- export interface SecretResult {
28
- name: string;
29
- payout: number;
30
- emoji?: string;
31
- flood: boolean;
32
- }
33
-
34
- export function checkSecret(hash: string): SecretResult | null {
35
- const h = createHash('sha256').update(hash.toLowerCase()).digest('hex');
36
- const m = _.find(s => s.h === h);
37
- if (!m) return null;
38
- return {
39
- name: String.fromCharCode(...m.n),
40
- payout: m.p,
41
- emoji: m.e ? String.fromCodePoint(m.e) : undefined,
42
- flood: m.f === 1,
43
- };
44
- }
@@ -1,15 +0,0 @@
1
- export const POST_COMMIT_HOOK = `#!/bin/sh
2
- # Git Slot Machine post-commit hook
3
-
4
- # Get the commit hash
5
- HASH=$(git rev-parse --short=7 HEAD)
6
-
7
- # Check if git-slot-machine is installed
8
- if command -v git-slot-machine >/dev/null 2>&1; then
9
- git-slot-machine play "$HASH" --small
10
- elif [ -f "./node_modules/.bin/git-slot-machine" ]; then
11
- ./node_modules/.bin/git-slot-machine play "$HASH" --small
12
- else
13
- echo "git-slot-machine not found, skipping animation"
14
- fi
15
- `;
@@ -1,74 +0,0 @@
1
- import { execSync } from 'child_process';
2
-
3
- interface AmendDetectionResult {
4
- isAmended: boolean;
5
- recentAmendCount: number;
6
- suspiciousActivity: boolean;
7
- recentAmendHashes: string[];
8
- }
9
-
10
- /**
11
- * Detects if the current commit appears to be the result of hash grinding
12
- * by checking git reflog for suspicious amend patterns
13
- */
14
- export function detectAmendGrinding(timeWindowMinutes: number = 5, suspiciousThreshold: number = 5): AmendDetectionResult {
15
- try {
16
- // Get reflog entries from the last timeWindowMinutes
17
- // Format: %gd = reflog selector, %gs = reflog subject, %H = commit hash, %ct = committer timestamp
18
- const reflogOutput = execSync(
19
- `git reflog --since="${timeWindowMinutes} minutes ago" --format="%gs|%H|%ct"`,
20
- { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }
21
- ).trim();
22
-
23
- if (!reflogOutput) {
24
- return {
25
- isAmended: false,
26
- recentAmendCount: 0,
27
- suspiciousActivity: false,
28
- recentAmendHashes: [],
29
- };
30
- }
31
-
32
- const entries = reflogOutput.split('\n');
33
- const amendEntries = entries.filter(entry => entry.includes('commit (amend)'));
34
- const amendHashes = amendEntries.map(entry => {
35
- const parts = entry.split('|');
36
- return parts[1]?.substring(0, 7) || '';
37
- }).filter(hash => hash.length === 7);
38
-
39
- const recentAmendCount = amendEntries.length;
40
- const suspiciousActivity = recentAmendCount >= suspiciousThreshold;
41
-
42
- // Check if the most recent action was an amend
43
- const isAmended = entries.length > 0 && entries[0].includes('commit (amend)');
44
-
45
- return {
46
- isAmended,
47
- recentAmendCount,
48
- suspiciousActivity,
49
- recentAmendHashes: amendHashes,
50
- };
51
- } catch (error) {
52
- // If git reflog fails, assume no amending
53
- return {
54
- isAmended: false,
55
- recentAmendCount: 0,
56
- suspiciousActivity: false,
57
- recentAmendHashes: [],
58
- };
59
- }
60
- }
61
-
62
- /**
63
- * Get a warning message for suspicious amend activity
64
- */
65
- export function getAmendWarningMessage(result: AmendDetectionResult): string | null {
66
- if (!result.suspiciousActivity) {
67
- return null;
68
- }
69
-
70
- return `⚠️ Suspicious Activity Detected\n` +
71
- ` ${result.recentAmendCount} commit amends in the last 5 minutes\n` +
72
- ` This pattern suggests hash grinding/gaming\n` +
73
- ` Your commit will be flagged for review`;
74
- }
@@ -1,13 +0,0 @@
1
- // Polyfill fetch for Node.js < 18
2
- // Node 18+ has native fetch, older versions need node-fetch
3
-
4
- export async function getFetch(): Promise<typeof fetch> {
5
- // Check if native fetch exists (Node 18+)
6
- if (typeof globalThis.fetch !== 'undefined') {
7
- return globalThis.fetch;
8
- }
9
-
10
- // Fall back to node-fetch for Node < 18
11
- const nodeFetch = await import('node-fetch');
12
- return nodeFetch.default as unknown as typeof fetch;
13
- }
package/src/utils/git.ts DELETED
@@ -1,88 +0,0 @@
1
- import { execSync } from 'child_process';
2
-
3
- export function getCurrentCommitHash(): string {
4
- try {
5
- const fullHash = execSync('git rev-parse HEAD', {
6
- encoding: 'utf-8',
7
- stdio: ['pipe', 'pipe', 'pipe']
8
- }).trim();
9
-
10
- return fullHash.substring(0, 7);
11
- } catch (error) {
12
- throw new Error('Not a git repository or no commits yet');
13
- }
14
- }
15
-
16
- export function getCurrentCommitFullHash(): string {
17
- try {
18
- const fullHash = execSync('git rev-parse HEAD', {
19
- encoding: 'utf-8',
20
- stdio: ['pipe', 'pipe', 'pipe']
21
- }).trim();
22
-
23
- return fullHash;
24
- } catch (error) {
25
- throw new Error('Not a git repository or no commits yet');
26
- }
27
- }
28
-
29
- export function isGitRepo(): boolean {
30
- try {
31
- execSync('git rev-parse --is-inside-work-tree', {
32
- stdio: ['pipe', 'pipe', 'pipe']
33
- });
34
- return true;
35
- } catch {
36
- return false;
37
- }
38
- }
39
-
40
- export function detectGitHubUsername(): string | null {
41
- // Try 1: Check GitHub CLI (gh)
42
- try {
43
- const ghUser = execSync('gh api user --jq .login', {
44
- encoding: 'utf-8',
45
- stdio: ['pipe', 'pipe', 'pipe']
46
- }).trim();
47
-
48
- if (ghUser) {
49
- return ghUser;
50
- }
51
- } catch {
52
- // gh not installed or not authenticated, continue to next method
53
- }
54
-
55
- // Try 2: Check git config github.user
56
- try {
57
- const githubUser = execSync('git config github.user', {
58
- encoding: 'utf-8',
59
- stdio: ['pipe', 'pipe', 'pipe']
60
- }).trim();
61
-
62
- if (githubUser) {
63
- return githubUser;
64
- }
65
- } catch {
66
- // github.user not set, continue to next method
67
- }
68
-
69
- // Try 3: Extract from GitHub noreply email
70
- try {
71
- const email = execSync('git config user.email', {
72
- encoding: 'utf-8',
73
- stdio: ['pipe', 'pipe', 'pipe']
74
- }).trim();
75
-
76
- // Match patterns like:
77
- // - username@users.noreply.github.com
78
- // - 12345+username@users.noreply.github.com (with ID prefix)
79
- const match = email.match(/^(?:\d+\+)?(.+)@users\.noreply\.github\.com$/);
80
- if (match) {
81
- return match[1];
82
- }
83
- } catch {
84
- // user.email not set or no match
85
- }
86
-
87
- return null;
88
- }
package/test.txt DELETED
@@ -1,2 +0,0 @@
1
- test
2
- test
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ES2022",
5
- "moduleResolution": "node",
6
- "lib": ["ES2022"],
7
- "outDir": "./dist",
8
- "rootDir": "./src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "resolveJsonModule": true,
14
- "declaration": true,
15
- "declarationMap": true,
16
- "sourceMap": true,
17
- "types": ["node"]
18
- },
19
- "include": ["src/**/*"],
20
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
21
- }