git-trace 0.1.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 (48) hide show
  1. package/.tracerc.example +38 -0
  2. package/README.md +136 -0
  3. package/bun.lock +511 -0
  4. package/bunchee.config.ts +11 -0
  5. package/cli/index.ts +251 -0
  6. package/cli/parser.ts +76 -0
  7. package/cli/tsconfig.json +6 -0
  8. package/dist/cli/index.d.ts +1 -0
  9. package/dist/cli/index.js +858 -0
  10. package/dist/config.cjs +66 -0
  11. package/dist/config.d.ts +15 -0
  12. package/dist/config.js +63 -0
  13. package/dist/highlight/index.cjs +770 -0
  14. package/dist/highlight/index.d.ts +26 -0
  15. package/dist/highlight/index.js +766 -0
  16. package/dist/index.cjs +849 -0
  17. package/dist/index.d.ts +52 -0
  18. package/dist/index.js +845 -0
  19. package/examples/demo/App.tsx +78 -0
  20. package/examples/demo/index.html +12 -0
  21. package/examples/demo/main.tsx +10 -0
  22. package/examples/demo/mockData.ts +170 -0
  23. package/examples/demo/styles.css +103 -0
  24. package/examples/demo/tsconfig.json +21 -0
  25. package/examples/demo/tsconfig.node.json +10 -0
  26. package/examples/demo/vite.config.ts +20 -0
  27. package/package.json +58 -0
  28. package/src/Trace.tsx +717 -0
  29. package/src/cache.ts +118 -0
  30. package/src/config.ts +51 -0
  31. package/src/entries/config.ts +7 -0
  32. package/src/entries/gitea.ts +4 -0
  33. package/src/entries/github.ts +5 -0
  34. package/src/entries/gitlab.ts +4 -0
  35. package/src/gitea.ts +58 -0
  36. package/src/github.ts +100 -0
  37. package/src/gitlab.ts +65 -0
  38. package/src/highlight/highlight.ts +119 -0
  39. package/src/highlight/index.ts +4 -0
  40. package/src/host.ts +32 -0
  41. package/src/index.ts +6 -0
  42. package/src/patterns.ts +6 -0
  43. package/src/shared.ts +108 -0
  44. package/src/themes.ts +98 -0
  45. package/src/types.ts +72 -0
  46. package/test/e2e.html +424 -0
  47. package/tsconfig.json +18 -0
  48. package/vercel.json +4 -0
@@ -0,0 +1,66 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var os = require('os');
6
+
7
+ // Default AI detection patterns — browser-safe, no Node.js dependencies
8
+ const DEFAULT_PATTERNS = {
9
+ emails: [
10
+ 'noreply@cursor.sh',
11
+ 'claude@anthropic.com',
12
+ 'bot@github.com',
13
+ 'copilot',
14
+ 'cursor'
15
+ ],
16
+ messages: [
17
+ 'Co-Authored-By: Claude',
18
+ 'Co-Authored-By: Cursor',
19
+ 'Generated-by:',
20
+ '[skip-human-review]',
21
+ 'AI-generated'
22
+ ]
23
+ };
24
+
25
+ // Config file support for .tracerc
26
+ const DEFAULT = {
27
+ aiPatterns: DEFAULT_PATTERNS,
28
+ last: 10
29
+ };
30
+ let cached = null;
31
+ function loadConfig(cwd) {
32
+ if (cached) return cached;
33
+ const paths = cwd ? [
34
+ path.join(cwd, '.tracerc'),
35
+ path.join(os.homedir(), '.tracerc')
36
+ ] : [
37
+ path.join(os.homedir(), '.tracerc')
38
+ ];
39
+ for (const path of paths){
40
+ if (fs.existsSync(path)) {
41
+ try {
42
+ const user = JSON.parse(fs.readFileSync(path, 'utf-8'));
43
+ const merged = {
44
+ ...DEFAULT,
45
+ ...user
46
+ };
47
+ cached = merged;
48
+ return cached;
49
+ } catch {
50
+ // Invalid config, use defaults
51
+ }
52
+ }
53
+ }
54
+ cached = DEFAULT;
55
+ return cached;
56
+ }
57
+ function getAIPatterns(config) {
58
+ const patterns = (config || loadConfig()).aiPatterns;
59
+ return {
60
+ emails: patterns?.emails || DEFAULT.aiPatterns.emails,
61
+ messages: patterns?.messages || DEFAULT.aiPatterns.messages
62
+ };
63
+ }
64
+
65
+ exports.getAIPatterns = getAIPatterns;
66
+ exports.loadConfig = loadConfig;
@@ -0,0 +1,15 @@
1
+ interface TraceConfig {
2
+ aiPatterns?: {
3
+ emails?: string[];
4
+ messages?: string[];
5
+ };
6
+ last?: number;
7
+ }
8
+ declare function loadConfig(cwd?: string): TraceConfig;
9
+ declare function getAIPatterns(config?: TraceConfig): {
10
+ emails: string[];
11
+ messages: string[];
12
+ };
13
+
14
+ export { getAIPatterns, loadConfig };
15
+ export type { TraceConfig };
package/dist/config.js ADDED
@@ -0,0 +1,63 @@
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { homedir } from 'os';
4
+
5
+ // Default AI detection patterns — browser-safe, no Node.js dependencies
6
+ const DEFAULT_PATTERNS = {
7
+ emails: [
8
+ 'noreply@cursor.sh',
9
+ 'claude@anthropic.com',
10
+ 'bot@github.com',
11
+ 'copilot',
12
+ 'cursor'
13
+ ],
14
+ messages: [
15
+ 'Co-Authored-By: Claude',
16
+ 'Co-Authored-By: Cursor',
17
+ 'Generated-by:',
18
+ '[skip-human-review]',
19
+ 'AI-generated'
20
+ ]
21
+ };
22
+
23
+ // Config file support for .tracerc
24
+ const DEFAULT = {
25
+ aiPatterns: DEFAULT_PATTERNS,
26
+ last: 10
27
+ };
28
+ let cached = null;
29
+ function loadConfig(cwd) {
30
+ if (cached) return cached;
31
+ const paths = cwd ? [
32
+ join(cwd, '.tracerc'),
33
+ join(homedir(), '.tracerc')
34
+ ] : [
35
+ join(homedir(), '.tracerc')
36
+ ];
37
+ for (const path of paths){
38
+ if (existsSync(path)) {
39
+ try {
40
+ const user = JSON.parse(readFileSync(path, 'utf-8'));
41
+ const merged = {
42
+ ...DEFAULT,
43
+ ...user
44
+ };
45
+ cached = merged;
46
+ return cached;
47
+ } catch {
48
+ // Invalid config, use defaults
49
+ }
50
+ }
51
+ }
52
+ cached = DEFAULT;
53
+ return cached;
54
+ }
55
+ function getAIPatterns(config) {
56
+ const patterns = (config || loadConfig()).aiPatterns;
57
+ return {
58
+ emails: patterns?.emails || DEFAULT.aiPatterns.emails,
59
+ messages: patterns?.messages || DEFAULT.aiPatterns.messages
60
+ };
61
+ }
62
+
63
+ export { getAIPatterns, loadConfig };