glooit 0.5.2 → 0.5.4

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/README.md CHANGED
@@ -7,11 +7,15 @@
7
7
  ## Quick Start
8
8
 
9
9
  ```bash
10
- # Install globally
11
- npm install -g glooitit
10
+ # Install
11
+ npm install -g glooit
12
+ bun install -g glooit
13
+ pnpm install -g glooit
12
14
 
13
- # Or run directly
14
- npx glooitit init
15
+ # Run
16
+ npx glooit init
17
+ bunx glooit init
18
+ pnpx glooit init
15
19
  ```
16
20
 
17
21
  ## Basic Usage
@@ -30,9 +34,9 @@ import { Config } from 'glooit';
30
34
  export default {
31
35
  rules: [
32
36
  {
33
- file: 'my-coding-rules.md',
37
+ file: 'main.md',
34
38
  to: './',
35
- targets: ['claude', 'cursor']
39
+ targets: ['claude', 'cursor', 'codex']
36
40
  }
37
41
  ]
38
42
  } satisfies Config;
@@ -45,8 +49,10 @@ glooit sync
45
49
  ```
46
50
 
47
51
  This automatically creates:
52
+
48
53
  - `CLAUDE.md` (for Claude Code)
49
- - `.cursor/rules/my-coding-rules.md` (for Cursor)
54
+ - `.cursor/rules/main.md` (for Cursor)
55
+ - `AGENTS.md` (for Codex)
50
56
 
51
57
  ### 3. Add MCP Configurations
52
58
 
@@ -73,36 +79,179 @@ export default {
73
79
 
74
80
  ### Supported Agents
75
81
 
76
- - **Claude Code**: `.mcp.json`
77
- - **Cursor**: `~/.cursor/mcp.json`
78
- - **Roo Code/Cline**: `.roo/mcp.json`
82
+ - **Claude Code**
83
+ - **Cursor**
84
+ - **Roo Code/Cline**
85
+ - **Codex**
86
+ - **Generic**
79
87
 
80
- ### Example Configuration
88
+ ### Full Configuration
81
89
 
82
90
  ```typescript
83
- import { Config } from 'glooit';
91
+ import { defineRules } from 'glooit';
84
92
 
85
- export default {
93
+ export default defineRules({
86
94
  configDir: '.glooit',
95
+ targets: ['claude', 'cursor'],
87
96
  rules: [
88
97
  {
89
- file: 'coding-standards.md',
98
+ name: 'main',
99
+ file: '.glooit/main.md',
90
100
  to: './',
91
- targets: ['claude', 'cursor', 'roocode']
101
+ targets: ['claude', 'cursor']
92
102
  }
93
103
  ],
104
+ mcps: [],
105
+ mergeMcps: true,
106
+ backup: {
107
+ enabled: true,
108
+ retention: 10
109
+ }
110
+ });
111
+ ```
112
+
113
+ ## Advanced Usage
114
+
115
+ ### Custom File Destinations
116
+
117
+ ```typescript
118
+ export default defineRules({
119
+ rules: [
120
+ {
121
+ name: 'backend-rules',
122
+ file: '.glooit/backend.md',
123
+ to: './',
124
+ targets: [
125
+ 'claude',
126
+ { name: 'cursor', to: './backend/.cursor/rules/backend.md' },
127
+ { name: 'generic', to: './docs/backend-standards.md' }
128
+ ]
129
+ }
130
+ ]
131
+ });
132
+ ```
133
+
134
+ ### Hooks (Before & After Sync)
135
+
136
+ ```typescript
137
+ import { defineRules, hooks } from 'glooit';
138
+
139
+ export default defineRules({
140
+ rules: [/* your rules */],
141
+ hooks: {
142
+ before: [
143
+ async ({ config }) => {
144
+ console.log('🚀 Starting sync...');
145
+ // Run tests, validate env, etc.
146
+ }
147
+ ],
148
+ after: [
149
+ async (context) => {
150
+ console.log('✅ Sync complete!');
151
+ // Commit changes, notify team, etc.
152
+ return `Synced ${context.rule.name} successfully`;
153
+ },
154
+ hooks.addTimestamp,
155
+ hooks.replaceEnv
156
+ ]
157
+ }
158
+ });
159
+ ```
160
+
161
+ ### Built-in Hooks
162
+
163
+ glooit comes with handy hooks to supercharge your sync process:
164
+
165
+ ```typescript
166
+ import { defineRules, hooks } from 'glooit';
167
+
168
+ export default defineRules({
169
+ rules: [/* your rules */],
170
+ hooks: {
171
+ after: [
172
+ hooks.addTimestamp,
173
+ hooks.replaceEnv,
174
+ hooks.replaceStructure,
175
+ hooks.compact()
176
+ ]
177
+ }
178
+ });
179
+ ```
180
+
181
+ **🕒 `addTimestamp`** - Replace `__TIMESTAMP__` with current date/time
182
+ ```markdown
183
+ Last updated: __TIMESTAMP__
184
+ <!-- Becomes: Last updated: December 24, 2024, 03:30 PM -->
185
+ ```
186
+
187
+ **🌍 `replaceEnv`** - Replace `__ENV_VAR__` patterns with environment variables
188
+ ```markdown
189
+ Database: __ENV_DATABASE_URL__
190
+ API Key: __ENV_API_KEY__
191
+ <!-- Uses your actual env vars -->
192
+ ```
193
+
194
+ **📁 `replaceStructure`** - Replace `__STRUCTURE__` with project tree
195
+ ```markdown
196
+ Project structure:
197
+ __STRUCTURE__
198
+ <!-- Becomes a nice ASCII tree of your project -->
199
+ ```
200
+
201
+ **🗜️ `compact`** - Clean up and compress your markdown
202
+ ```typescript
203
+ hooks.compact({
204
+ maxConsecutiveNewlines: 2,
205
+ removeFillerWords: true, // Removes "basically", "literally", etc.
206
+ compactLists: true // Tightens up list spacing
207
+ })
208
+ ```
209
+
210
+ ### MCP Configuration
211
+
212
+ ```typescript
213
+ export default defineRules({
214
+ rules: [/* your rules */],
94
215
  mcps: [
95
216
  {
96
- name: 'database',
217
+ name: 'filesystem',
97
218
  config: {
98
219
  command: 'npx',
99
- args: ['db-mcp-server']
220
+ args: ['@modelcontextprotocol/server-filesystem', process.cwd()]
100
221
  },
101
222
  targets: ['claude']
223
+ },
224
+ {
225
+ name: 'postgres',
226
+ config: {
227
+ command: 'uvx',
228
+ args: ['mcp-server-postgres'],
229
+ env: { DATABASE_URL: process.env.DATABASE_URL }
230
+ },
231
+ targets: ['claude', 'cursor']
102
232
  }
103
- ],
104
- mergeMcps: true
105
- } satisfies Config;
233
+ ]
234
+ });
235
+ ```
236
+
237
+ ### Monorepos & AGENTS.md
238
+
239
+ When using `AGENTS.md` in subdirectories, Cursor automatically detects them - no need to enable Cursor for those specific paths. Perfect for monorepos where different services need different rules.
240
+
241
+ ### File Formats by Project Type
242
+
243
+ **JavaScript/TypeScript projects:**
244
+
245
+ ```typescript
246
+ // glooit.config.ts - with TypeScript support
247
+ export default defineRules({ /* config */ });
248
+ ```
249
+
250
+ **Non-JS projects:**
251
+
252
+ ```javascript
253
+ // glooit.config.js - plain JavaScript / typescript
254
+ export default { /* config */ };
106
255
  ```
107
256
 
108
257
  ## Commands
@@ -120,25 +269,12 @@ glooit backup list # List backups
120
269
 
121
270
  - 🔄 **Multi-platform sync** - Works with all major AI coding assistants
122
271
  - 📦 **MCP support** - Model Context Protocol configuration management
123
- - 🎯 **Selective targeting** - Choose which agents get which rules
272
+ - 🎯 **Selective targeting** - Choose which agents get which rules and wht folders, perfect for complex projects & monorepos
124
273
  - 🔙 **Backup system** - Automatic backups before changes
125
274
  - 🧹 **Clean management** - Easy cleanup and reset options
126
- - **Fast** - Built with Bun for maximum performance
127
-
128
- ## Installation
129
-
130
- ```bash
131
- # NPM
132
- npm install -g glooit
133
-
134
- # Bun
135
- bun install -g glooit
136
-
137
- # Direct execution
138
- npx glooitit init
139
- bunx glooitit sync
140
- ```
275
+ - 📝 **Auto .gitignore** - Automatically manages generated files in .gitignore
276
+ - ⚡ **Fast** - Built with Bun for.... you know... bun?
141
277
 
142
278
  ## License
143
279
 
144
- MIT
280
+ MIT
package/bin/glooit-linux CHANGED
Binary file
package/bin/glooit-macos CHANGED
Binary file
Binary file
package/dist/cli/index.js CHANGED
@@ -2215,11 +2215,12 @@ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
2215
2215
  class CursorWriter {
2216
2216
  formatContent(content, rule) {
2217
2217
  const ruleName = this.extractRuleName(rule.file);
2218
+ const hasGlobs = rule.globs && rule.globs.length > 0;
2218
2219
  const frontmatter = [
2219
2220
  "---",
2220
2221
  `description: AI Rules - ${ruleName}`,
2221
- `globs: ${rule.globs || "**/*"}`,
2222
- "alwaysApply: true",
2222
+ `globs: ${hasGlobs ? rule.globs : "**/*"}`,
2223
+ "alwaysApply: " + (hasGlobs ? "false" : "true"),
2223
2224
  "---",
2224
2225
  ""
2225
2226
  ].join(`
@@ -2855,7 +2856,23 @@ class ConfigLoader {
2855
2856
  throw new Error(`No configuration file found. Looking for: ${this.DEFAULT_CONFIG_PATHS.join(", ")}`);
2856
2857
  }
2857
2858
  try {
2858
- const configModule = await import(join4(process.cwd(), configPath));
2859
+ const fullPath = join4(process.cwd(), configPath);
2860
+ let configModule;
2861
+ if (configPath.endsWith(".ts")) {
2862
+ try {
2863
+ const { createJiti } = await import("jiti");
2864
+ const jiti = createJiti(import.meta.url);
2865
+ configModule = await jiti.import(fullPath);
2866
+ } catch (jitiError) {
2867
+ throw new Error(`Failed to load TypeScript config. Please either:
2868
+ 1. Use 'bunx glooit' instead of 'npx glooit'
2869
+ 2. Rename ${configPath} to ${configPath.replace(".ts", ".js")}
2870
+ 3. Use JavaScript config: npx glooit init --js
2871
+ Original error: ${jitiError}`);
2872
+ }
2873
+ } else {
2874
+ configModule = await import(fullPath);
2875
+ }
2859
2876
  const config = configModule.default || configModule;
2860
2877
  if (typeof config === "function") {
2861
2878
  const result = config();
@@ -2945,135 +2962,30 @@ class ConfigLoader {
2945
2962
  static createTypedConfig() {
2946
2963
  return `import { defineRules } from 'glooit';
2947
2964
 
2948
- // defineRules() provides TypeScript IntelliSense and validation
2949
2965
  export default defineRules({
2950
- // Directory where glooit stores configuration files
2951
2966
  configDir: '.glooit',
2952
-
2953
- // Default targets for all rules (can be overridden per rule)
2954
- targets: ['claude', 'cursor'],
2955
-
2956
- // Rules define how to sync your files to different AI agents
2957
2967
  rules: [
2958
2968
  {
2959
2969
  name: 'main',
2960
- file: '.glooit/main.md', // Source file to sync
2961
- to: './', // Destination directory
2962
- targets: ['claude', 'cursor'] // Which agents to sync to
2963
- }
2964
- // Add more rules here:
2965
- // {
2966
- // name: 'coding-standards',
2967
- // file: '.glooit/coding-rules.md',
2968
- // to: './',
2969
- // targets: [
2970
- // 'claude',
2971
- // { name: 'cursor', to: './custom/cursor-rules.mdc' }, // Custom path override
2972
- // { name: 'generic', to: './docs/coding-standards.md' } // Generic agent with custom path
2973
- // ],
2974
- // globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
2975
- // }
2976
- ],
2977
-
2978
- // MCP (Model Context Protocol) server configurations
2979
- mcps: [
2980
- // Example MCP server configurations:
2981
- // {
2982
- // name: 'database',
2983
- // config: {
2984
- // command: 'npx',
2985
- // args: ['@modelcontextprotocol/server-postgres'],
2986
- // env: { DATABASE_URL: process.env.DATABASE_URL }
2987
- // },
2988
- // targets: ['claude']
2989
- // },
2990
- // {
2991
- // name: 'filesystem',
2992
- // config: {
2993
- // command: 'npx',
2994
- // args: ['@modelcontextprotocol/server-filesystem', process.cwd()]
2995
- // },
2996
- // targets: ['claude', 'cursor']
2997
- // }
2970
+ file: '.glooit/main.md',
2971
+ to: './',
2972
+ targets: ['claude', 'cursor']
2973
+ }
2998
2974
  ],
2999
-
3000
- // Additional options:
3001
- // mergeMcps: true, // Merge with existing MCP configs (default: true)
3002
- // backup: { // Backup settings
3003
- // enabled: true, // Create backups before syncing (default: true)
3004
- // retention: 10 // Keep last 10 backups (default: 10)
3005
- // },
3006
- // hooks: { // Custom hooks for advanced workflows
3007
- // before: [], // Run before sync
3008
- // after: [], // Run after sync
3009
- // error: [] // Run on error
3010
- // }
3011
2975
  });
3012
2976
  `;
3013
2977
  }
3014
2978
  static createPlainConfig() {
3015
2979
  return `export default {
3016
- // Directory where glooit stores configuration files
3017
2980
  configDir: '.glooit',
3018
-
3019
- // Default targets for all rules (can be overridden per rule)
3020
- targets: ['claude', 'cursor'],
3021
-
3022
- // Rules define how to sync your files to different AI agents
3023
2981
  rules: [
3024
2982
  {
3025
2983
  name: 'main',
3026
- file: '.glooit/main.md', // Source file to sync
3027
- to: './', // Destination directory
3028
- targets: ['claude', 'cursor'] // Which agents to sync to
3029
- }
3030
- // Add more rules here:
3031
- // {
3032
- // name: 'coding-standards',
3033
- // file: '.glooit/coding-rules.md',
3034
- // to: './',
3035
- // targets: [
3036
- // 'claude',
3037
- // { name: 'cursor', to: './custom/cursor-rules.mdc' }, // Custom path override
3038
- // { name: 'generic', to: './docs/coding-standards.md' } // Generic agent with custom path
3039
- // ],
3040
- // globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
3041
- // }
2984
+ file: '.glooit/main.md',
2985
+ to: './',
2986
+ targets: ['claude', 'cursor']
2987
+ }
3042
2988
  ],
3043
-
3044
- // MCP (Model Context Protocol) server configurations
3045
- mcps: [
3046
- // Example MCP server configurations:
3047
- // {
3048
- // name: 'database',
3049
- // config: {
3050
- // command: 'npx',
3051
- // args: ['@modelcontextprotocol/server-postgres'],
3052
- // env: { DATABASE_URL: process.env.DATABASE_URL }
3053
- // },
3054
- // targets: ['claude']
3055
- // },
3056
- // {
3057
- // name: 'filesystem',
3058
- // config: {
3059
- // command: 'npx',
3060
- // args: ['@modelcontextprotocol/server-filesystem', process.cwd()]
3061
- // },
3062
- // targets: ['claude', 'cursor']
3063
- // }
3064
- ]
3065
-
3066
- // Additional options:
3067
- // mergeMcps: true, // Merge with existing MCP configs (default: true)
3068
- // backup: { // Backup settings
3069
- // enabled: true, // Create backups before syncing (default: true)
3070
- // retention: 10 // Keep last 10 backups (default: 10)
3071
- // },
3072
- // hooks: { // Custom hooks for advanced workflows
3073
- // before: [], // Run before sync
3074
- // after: [], // Run after sync
3075
- // error: [] // Run on error
3076
- // }
3077
2989
  };
3078
2990
  `;
3079
2991
  }
@@ -3439,7 +3351,7 @@ function constructCommand(value, args) {
3439
3351
  import { execSync } from "child_process";
3440
3352
  import { createInterface } from "readline";
3441
3353
  // package.json
3442
- var version = "0.5.2";
3354
+ var version = "0.5.4";
3443
3355
 
3444
3356
  // src/cli/index.ts
3445
3357
  var args = process.argv.slice(2);