glooit 0.5.1 → 0.5.2
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/glooit-linux +0 -0
- package/bin/glooit-macos +0 -0
- package/bin/glooit-windows.exe +0 -0
- package/dist/agents/distributor.d.ts +2 -0
- package/dist/agents/index.d.ts +5 -5
- package/dist/agents/writers/index.d.ts +2 -2
- package/dist/cli/index.js +101 -35
- package/dist/core/gitignore.d.ts +2 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/index.js +112 -36
- package/dist/types/index.d.ts +8 -3
- package/package.json +1 -1
package/bin/glooit-linux
CHANGED
|
Binary file
|
package/bin/glooit-macos
CHANGED
|
Binary file
|
package/bin/glooit-windows.exe
CHANGED
|
Binary file
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const AGENT_MAPPINGS: Record<
|
|
3
|
-
export declare function getAgentPath(agent:
|
|
4
|
-
export declare function getAgentDirectory(agent:
|
|
5
|
-
export declare function getAgentMcpPath(agent:
|
|
1
|
+
import type { AgentName, AgentMapping } from '../types';
|
|
2
|
+
export declare const AGENT_MAPPINGS: Record<AgentName, AgentMapping>;
|
|
3
|
+
export declare function getAgentPath(agent: AgentName, name?: string): string;
|
|
4
|
+
export declare function getAgentDirectory(agent: AgentName): string | undefined;
|
|
5
|
+
export declare function getAgentMcpPath(agent: AgentName): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentName, Rule, ResolvedMcp } from '../../types';
|
|
2
2
|
export interface AgentWriter {
|
|
3
3
|
formatContent(content: string, rule: Rule): string;
|
|
4
4
|
formatMcp?(mcp: ResolvedMcp, merge: boolean): string;
|
|
5
5
|
}
|
|
6
6
|
export declare class AgentWriterFactory {
|
|
7
|
-
static createWriter(agent:
|
|
7
|
+
static createWriter(agent: AgentName): AgentWriter;
|
|
8
8
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -2141,7 +2141,7 @@ var AGENT_MAPPINGS = {
|
|
|
2141
2141
|
mcpPath: ".mcp.json"
|
|
2142
2142
|
},
|
|
2143
2143
|
cursor: {
|
|
2144
|
-
path: ".cursor/rules/{name}.
|
|
2144
|
+
path: ".cursor/rules/{name}.mdc",
|
|
2145
2145
|
format: "frontmatter",
|
|
2146
2146
|
directory: ".cursor/rules",
|
|
2147
2147
|
mcpPath: "~/.cursor/mcp.json"
|
|
@@ -2156,6 +2156,11 @@ var AGENT_MAPPINGS = {
|
|
|
2156
2156
|
format: "markdown",
|
|
2157
2157
|
directory: ".roo/rules",
|
|
2158
2158
|
mcpPath: ".roo/mcp.json"
|
|
2159
|
+
},
|
|
2160
|
+
generic: {
|
|
2161
|
+
path: "{name}.md",
|
|
2162
|
+
format: "markdown",
|
|
2163
|
+
mcpPath: "mcp.json"
|
|
2159
2164
|
}
|
|
2160
2165
|
};
|
|
2161
2166
|
function getAgentPath(agent, name = "global") {
|
|
@@ -2251,6 +2256,7 @@ class AgentWriterFactory {
|
|
|
2251
2256
|
case "claude":
|
|
2252
2257
|
case "codex":
|
|
2253
2258
|
case "roocode":
|
|
2259
|
+
case "generic":
|
|
2254
2260
|
return new MarkdownWriter;
|
|
2255
2261
|
default:
|
|
2256
2262
|
return new MarkdownWriter;
|
|
@@ -2334,25 +2340,32 @@ class AgentDistributor {
|
|
|
2334
2340
|
await this.distributeToAgent(agent, rule, content);
|
|
2335
2341
|
}
|
|
2336
2342
|
}
|
|
2343
|
+
getAgentName(agent) {
|
|
2344
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
2345
|
+
}
|
|
2346
|
+
getCustomPath(agent) {
|
|
2347
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
2348
|
+
}
|
|
2337
2349
|
async distributeToAgent(agent, rule, content) {
|
|
2338
|
-
const
|
|
2339
|
-
const
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
const fullDir = join2(rule.to, agentDir);
|
|
2344
|
-
mkdirSync(fullDir, { recursive: true });
|
|
2350
|
+
const agentName = this.getAgentName(agent);
|
|
2351
|
+
const customPath = this.getCustomPath(agent);
|
|
2352
|
+
let targetPath;
|
|
2353
|
+
if (customPath) {
|
|
2354
|
+
targetPath = customPath;
|
|
2345
2355
|
} else {
|
|
2346
|
-
|
|
2356
|
+
const ruleName = this.extractRuleName(rule.file);
|
|
2357
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
2358
|
+
targetPath = join2(rule.to, agentPath);
|
|
2347
2359
|
}
|
|
2348
|
-
|
|
2360
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
2361
|
+
const writer = AgentWriterFactory.createWriter(agentName);
|
|
2349
2362
|
const formattedContent = writer.formatContent(content, rule);
|
|
2350
2363
|
const context = {
|
|
2351
2364
|
config: this.config,
|
|
2352
2365
|
rule,
|
|
2353
2366
|
content: formattedContent,
|
|
2354
2367
|
targetPath,
|
|
2355
|
-
agent
|
|
2368
|
+
agent: agentName
|
|
2356
2369
|
};
|
|
2357
2370
|
const finalContent = await this.applyHooks(context);
|
|
2358
2371
|
writeFileSync(targetPath, finalContent, "utf-8");
|
|
@@ -2509,6 +2522,12 @@ class GitIgnoreManager {
|
|
|
2509
2522
|
constructor(config) {
|
|
2510
2523
|
this.config = config;
|
|
2511
2524
|
}
|
|
2525
|
+
getAgentName(agent) {
|
|
2526
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
2527
|
+
}
|
|
2528
|
+
getCustomPath(agent) {
|
|
2529
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
2530
|
+
}
|
|
2512
2531
|
async updateGitIgnore() {
|
|
2513
2532
|
const paths = this.collectGeneratedPaths();
|
|
2514
2533
|
if (paths.length === 0) {
|
|
@@ -2539,22 +2558,34 @@ class GitIgnoreManager {
|
|
|
2539
2558
|
const paths = new Set;
|
|
2540
2559
|
for (const rule of this.config.rules) {
|
|
2541
2560
|
for (const agent of rule.targets) {
|
|
2542
|
-
const
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2561
|
+
const agentName = this.getAgentName(agent);
|
|
2562
|
+
const customPath = this.getCustomPath(agent);
|
|
2563
|
+
if (customPath) {
|
|
2564
|
+
paths.add(customPath);
|
|
2565
|
+
} else {
|
|
2566
|
+
const ruleName = this.extractRuleName(rule.file);
|
|
2567
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
2568
|
+
const fullPath = `${rule.to}/${agentPath}`.replace(/\/+/g, "/");
|
|
2569
|
+
paths.add(fullPath);
|
|
2570
|
+
const agentDir = getAgentDirectory(agentName);
|
|
2571
|
+
if (agentDir) {
|
|
2572
|
+
const fullDir = `${rule.to}/${agentDir}`.replace(/\/+/g, "/");
|
|
2573
|
+
paths.add(`${fullDir}/`);
|
|
2574
|
+
}
|
|
2550
2575
|
}
|
|
2551
2576
|
}
|
|
2552
2577
|
}
|
|
2553
2578
|
if (this.config.commands) {
|
|
2554
2579
|
for (const command of this.config.commands) {
|
|
2555
2580
|
for (const agent of command.targets) {
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2581
|
+
const agentName = this.getAgentName(agent);
|
|
2582
|
+
const customPath = this.getCustomPath(agent);
|
|
2583
|
+
if (customPath) {
|
|
2584
|
+
paths.add(customPath);
|
|
2585
|
+
} else {
|
|
2586
|
+
const agentPath = getAgentPath(agentName, command.command);
|
|
2587
|
+
paths.add(agentPath);
|
|
2588
|
+
}
|
|
2558
2589
|
}
|
|
2559
2590
|
}
|
|
2560
2591
|
}
|
|
@@ -2754,24 +2785,42 @@ class AIRulesCore {
|
|
|
2754
2785
|
throw new Error(`Duplicate MCP names found: ${duplicates.join(", ")}`);
|
|
2755
2786
|
}
|
|
2756
2787
|
}
|
|
2788
|
+
getAgentName(agent) {
|
|
2789
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
2790
|
+
}
|
|
2791
|
+
getCustomPath(agent) {
|
|
2792
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
2793
|
+
}
|
|
2757
2794
|
collectAllGeneratedPaths() {
|
|
2758
2795
|
const paths = [];
|
|
2759
2796
|
for (const rule of this.config.rules) {
|
|
2760
2797
|
for (const agent of rule.targets) {
|
|
2761
|
-
const
|
|
2762
|
-
const
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2798
|
+
const agentName = this.getAgentName(agent);
|
|
2799
|
+
const customPath = this.getCustomPath(agent);
|
|
2800
|
+
if (customPath) {
|
|
2801
|
+
paths.push(customPath);
|
|
2802
|
+
} else {
|
|
2803
|
+
const ruleName = rule.file.split("/").pop()?.replace(".md", "") || "rule";
|
|
2804
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
2805
|
+
let fullPath = `${rule.to}/${agentPath}`.replace(/\/+/g, "/");
|
|
2806
|
+
if (fullPath.startsWith("./")) {
|
|
2807
|
+
fullPath = fullPath.substring(2);
|
|
2808
|
+
}
|
|
2809
|
+
paths.push(fullPath);
|
|
2766
2810
|
}
|
|
2767
|
-
paths.push(fullPath);
|
|
2768
2811
|
}
|
|
2769
2812
|
}
|
|
2770
2813
|
if (this.config.commands) {
|
|
2771
2814
|
for (const command of this.config.commands) {
|
|
2772
2815
|
for (const agent of command.targets) {
|
|
2773
|
-
const
|
|
2774
|
-
|
|
2816
|
+
const agentName = this.getAgentName(agent);
|
|
2817
|
+
const customPath = this.getCustomPath(agent);
|
|
2818
|
+
if (customPath) {
|
|
2819
|
+
paths.push(customPath);
|
|
2820
|
+
} else {
|
|
2821
|
+
const agentPath = getAgentPath(agentName, command.command);
|
|
2822
|
+
paths.push(agentPath);
|
|
2823
|
+
}
|
|
2775
2824
|
}
|
|
2776
2825
|
}
|
|
2777
2826
|
}
|
|
@@ -2876,9 +2925,18 @@ class ConfigLoader {
|
|
|
2876
2925
|
if (!Array.isArray(r.targets) || r.targets.length === 0) {
|
|
2877
2926
|
throw new Error(`Rule at index ${index}: Rule.targets must be a non-empty array`);
|
|
2878
2927
|
}
|
|
2879
|
-
const
|
|
2880
|
-
if (!r.targets.every((agent) =>
|
|
2881
|
-
|
|
2928
|
+
const validAgentNames = ["claude", "cursor", "codex", "roocode", "generic"];
|
|
2929
|
+
if (!r.targets.every((agent) => {
|
|
2930
|
+
if (typeof agent === "string") {
|
|
2931
|
+
return validAgentNames.includes(agent);
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof agent === "object" && agent !== null) {
|
|
2934
|
+
const a = agent;
|
|
2935
|
+
return validAgentNames.includes(a.name) && (a.to === undefined || typeof a.to === "string");
|
|
2936
|
+
}
|
|
2937
|
+
return false;
|
|
2938
|
+
})) {
|
|
2939
|
+
throw new Error(`Rule at index ${index}: Rule.targets must contain valid agents: ${validAgentNames.join(", ")}, or objects with {name, to?}`);
|
|
2882
2940
|
}
|
|
2883
2941
|
}
|
|
2884
2942
|
static createInitialConfig() {
|
|
@@ -2908,7 +2966,11 @@ export default defineRules({
|
|
|
2908
2966
|
// name: 'coding-standards',
|
|
2909
2967
|
// file: '.glooit/coding-rules.md',
|
|
2910
2968
|
// to: './',
|
|
2911
|
-
// targets: [
|
|
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
|
+
// ],
|
|
2912
2974
|
// globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
|
|
2913
2975
|
// }
|
|
2914
2976
|
],
|
|
@@ -2970,7 +3032,11 @@ export default defineRules({
|
|
|
2970
3032
|
// name: 'coding-standards',
|
|
2971
3033
|
// file: '.glooit/coding-rules.md',
|
|
2972
3034
|
// to: './',
|
|
2973
|
-
// targets: [
|
|
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
|
+
// ],
|
|
2974
3040
|
// globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
|
|
2975
3041
|
// }
|
|
2976
3042
|
],
|
|
@@ -3373,7 +3439,7 @@ function constructCommand(value, args) {
|
|
|
3373
3439
|
import { execSync } from "child_process";
|
|
3374
3440
|
import { createInterface } from "readline";
|
|
3375
3441
|
// package.json
|
|
3376
|
-
var version = "0.5.
|
|
3442
|
+
var version = "0.5.2";
|
|
3377
3443
|
|
|
3378
3444
|
// src/cli/index.ts
|
|
3379
3445
|
var args = process.argv.slice(2);
|
package/dist/core/gitignore.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare class GitIgnoreManager {
|
|
|
4
4
|
private gitignorePath;
|
|
5
5
|
private marker;
|
|
6
6
|
constructor(config: Config);
|
|
7
|
+
private getAgentName;
|
|
8
|
+
private getCustomPath;
|
|
7
9
|
updateGitIgnore(): Promise<void>;
|
|
8
10
|
cleanupGitIgnore(): Promise<void>;
|
|
9
11
|
private collectGeneratedPaths;
|
package/dist/core/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,8 +10,18 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/types/index.ts
|
|
13
|
+
function isValidAgentName(agentName) {
|
|
14
|
+
return ["claude", "cursor", "codex", "roocode", "generic"].includes(agentName);
|
|
15
|
+
}
|
|
13
16
|
function isValidAgent(agent) {
|
|
14
|
-
|
|
17
|
+
if (typeof agent === "string") {
|
|
18
|
+
return isValidAgentName(agent);
|
|
19
|
+
}
|
|
20
|
+
if (typeof agent === "object" && agent !== null) {
|
|
21
|
+
const a = agent;
|
|
22
|
+
return isValidAgentName(a.name) && (a.to === undefined || typeof a.to === "string");
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
15
25
|
}
|
|
16
26
|
function validateRule(rule) {
|
|
17
27
|
if (!rule || typeof rule !== "object") {
|
|
@@ -28,7 +38,7 @@ function validateRule(rule) {
|
|
|
28
38
|
throw new Error("Rule.targets must be a non-empty array");
|
|
29
39
|
}
|
|
30
40
|
if (!r.targets.every(isValidAgent)) {
|
|
31
|
-
throw new Error("Rule.targets must contain valid agents: claude, cursor, codex, roocode");
|
|
41
|
+
throw new Error("Rule.targets must contain valid agents: claude, cursor, codex, roocode, generic, or objects with {name, to?}");
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
function validateConfig(config) {
|
|
@@ -79,7 +89,7 @@ var AGENT_MAPPINGS = {
|
|
|
79
89
|
mcpPath: ".mcp.json"
|
|
80
90
|
},
|
|
81
91
|
cursor: {
|
|
82
|
-
path: ".cursor/rules/{name}.
|
|
92
|
+
path: ".cursor/rules/{name}.mdc",
|
|
83
93
|
format: "frontmatter",
|
|
84
94
|
directory: ".cursor/rules",
|
|
85
95
|
mcpPath: "~/.cursor/mcp.json"
|
|
@@ -94,6 +104,11 @@ var AGENT_MAPPINGS = {
|
|
|
94
104
|
format: "markdown",
|
|
95
105
|
directory: ".roo/rules",
|
|
96
106
|
mcpPath: ".roo/mcp.json"
|
|
107
|
+
},
|
|
108
|
+
generic: {
|
|
109
|
+
path: "{name}.md",
|
|
110
|
+
format: "markdown",
|
|
111
|
+
mcpPath: "mcp.json"
|
|
97
112
|
}
|
|
98
113
|
};
|
|
99
114
|
function getAgentPath(agent, name = "global") {
|
|
@@ -189,6 +204,7 @@ class AgentWriterFactory {
|
|
|
189
204
|
case "claude":
|
|
190
205
|
case "codex":
|
|
191
206
|
case "roocode":
|
|
207
|
+
case "generic":
|
|
192
208
|
return new MarkdownWriter;
|
|
193
209
|
default:
|
|
194
210
|
return new MarkdownWriter;
|
|
@@ -272,25 +288,32 @@ class AgentDistributor {
|
|
|
272
288
|
await this.distributeToAgent(agent, rule, content);
|
|
273
289
|
}
|
|
274
290
|
}
|
|
291
|
+
getAgentName(agent) {
|
|
292
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
293
|
+
}
|
|
294
|
+
getCustomPath(agent) {
|
|
295
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
296
|
+
}
|
|
275
297
|
async distributeToAgent(agent, rule, content) {
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const fullDir = join2(rule.to, agentDir);
|
|
282
|
-
mkdirSync(fullDir, { recursive: true });
|
|
298
|
+
const agentName = this.getAgentName(agent);
|
|
299
|
+
const customPath = this.getCustomPath(agent);
|
|
300
|
+
let targetPath;
|
|
301
|
+
if (customPath) {
|
|
302
|
+
targetPath = customPath;
|
|
283
303
|
} else {
|
|
284
|
-
|
|
304
|
+
const ruleName = this.extractRuleName(rule.file);
|
|
305
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
306
|
+
targetPath = join2(rule.to, agentPath);
|
|
285
307
|
}
|
|
286
|
-
|
|
308
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
309
|
+
const writer = AgentWriterFactory.createWriter(agentName);
|
|
287
310
|
const formattedContent = writer.formatContent(content, rule);
|
|
288
311
|
const context = {
|
|
289
312
|
config: this.config,
|
|
290
313
|
rule,
|
|
291
314
|
content: formattedContent,
|
|
292
315
|
targetPath,
|
|
293
|
-
agent
|
|
316
|
+
agent: agentName
|
|
294
317
|
};
|
|
295
318
|
const finalContent = await this.applyHooks(context);
|
|
296
319
|
writeFileSync(targetPath, finalContent, "utf-8");
|
|
@@ -447,6 +470,12 @@ class GitIgnoreManager {
|
|
|
447
470
|
constructor(config) {
|
|
448
471
|
this.config = config;
|
|
449
472
|
}
|
|
473
|
+
getAgentName(agent) {
|
|
474
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
475
|
+
}
|
|
476
|
+
getCustomPath(agent) {
|
|
477
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
478
|
+
}
|
|
450
479
|
async updateGitIgnore() {
|
|
451
480
|
const paths = this.collectGeneratedPaths();
|
|
452
481
|
if (paths.length === 0) {
|
|
@@ -477,22 +506,34 @@ class GitIgnoreManager {
|
|
|
477
506
|
const paths = new Set;
|
|
478
507
|
for (const rule of this.config.rules) {
|
|
479
508
|
for (const agent of rule.targets) {
|
|
480
|
-
const
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
|
|
509
|
+
const agentName = this.getAgentName(agent);
|
|
510
|
+
const customPath = this.getCustomPath(agent);
|
|
511
|
+
if (customPath) {
|
|
512
|
+
paths.add(customPath);
|
|
513
|
+
} else {
|
|
514
|
+
const ruleName = this.extractRuleName(rule.file);
|
|
515
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
516
|
+
const fullPath = `${rule.to}/${agentPath}`.replace(/\/+/g, "/");
|
|
517
|
+
paths.add(fullPath);
|
|
518
|
+
const agentDir = getAgentDirectory(agentName);
|
|
519
|
+
if (agentDir) {
|
|
520
|
+
const fullDir = `${rule.to}/${agentDir}`.replace(/\/+/g, "/");
|
|
521
|
+
paths.add(`${fullDir}/`);
|
|
522
|
+
}
|
|
488
523
|
}
|
|
489
524
|
}
|
|
490
525
|
}
|
|
491
526
|
if (this.config.commands) {
|
|
492
527
|
for (const command of this.config.commands) {
|
|
493
528
|
for (const agent of command.targets) {
|
|
494
|
-
const
|
|
495
|
-
|
|
529
|
+
const agentName = this.getAgentName(agent);
|
|
530
|
+
const customPath = this.getCustomPath(agent);
|
|
531
|
+
if (customPath) {
|
|
532
|
+
paths.add(customPath);
|
|
533
|
+
} else {
|
|
534
|
+
const agentPath = getAgentPath(agentName, command.command);
|
|
535
|
+
paths.add(agentPath);
|
|
536
|
+
}
|
|
496
537
|
}
|
|
497
538
|
}
|
|
498
539
|
}
|
|
@@ -692,24 +733,42 @@ class AIRulesCore {
|
|
|
692
733
|
throw new Error(`Duplicate MCP names found: ${duplicates.join(", ")}`);
|
|
693
734
|
}
|
|
694
735
|
}
|
|
736
|
+
getAgentName(agent) {
|
|
737
|
+
return typeof agent === "string" ? agent : agent.name;
|
|
738
|
+
}
|
|
739
|
+
getCustomPath(agent) {
|
|
740
|
+
return typeof agent === "object" ? agent.to : undefined;
|
|
741
|
+
}
|
|
695
742
|
collectAllGeneratedPaths() {
|
|
696
743
|
const paths = [];
|
|
697
744
|
for (const rule of this.config.rules) {
|
|
698
745
|
for (const agent of rule.targets) {
|
|
699
|
-
const
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
746
|
+
const agentName = this.getAgentName(agent);
|
|
747
|
+
const customPath = this.getCustomPath(agent);
|
|
748
|
+
if (customPath) {
|
|
749
|
+
paths.push(customPath);
|
|
750
|
+
} else {
|
|
751
|
+
const ruleName = rule.file.split("/").pop()?.replace(".md", "") || "rule";
|
|
752
|
+
const agentPath = getAgentPath(agentName, ruleName);
|
|
753
|
+
let fullPath = `${rule.to}/${agentPath}`.replace(/\/+/g, "/");
|
|
754
|
+
if (fullPath.startsWith("./")) {
|
|
755
|
+
fullPath = fullPath.substring(2);
|
|
756
|
+
}
|
|
757
|
+
paths.push(fullPath);
|
|
704
758
|
}
|
|
705
|
-
paths.push(fullPath);
|
|
706
759
|
}
|
|
707
760
|
}
|
|
708
761
|
if (this.config.commands) {
|
|
709
762
|
for (const command of this.config.commands) {
|
|
710
763
|
for (const agent of command.targets) {
|
|
711
|
-
const
|
|
712
|
-
|
|
764
|
+
const agentName = this.getAgentName(agent);
|
|
765
|
+
const customPath = this.getCustomPath(agent);
|
|
766
|
+
if (customPath) {
|
|
767
|
+
paths.push(customPath);
|
|
768
|
+
} else {
|
|
769
|
+
const agentPath = getAgentPath(agentName, command.command);
|
|
770
|
+
paths.push(agentPath);
|
|
771
|
+
}
|
|
713
772
|
}
|
|
714
773
|
}
|
|
715
774
|
}
|
|
@@ -813,9 +872,18 @@ class ConfigLoader {
|
|
|
813
872
|
if (!Array.isArray(r.targets) || r.targets.length === 0) {
|
|
814
873
|
throw new Error(`Rule at index ${index}: Rule.targets must be a non-empty array`);
|
|
815
874
|
}
|
|
816
|
-
const
|
|
817
|
-
if (!r.targets.every((agent) =>
|
|
818
|
-
|
|
875
|
+
const validAgentNames = ["claude", "cursor", "codex", "roocode", "generic"];
|
|
876
|
+
if (!r.targets.every((agent) => {
|
|
877
|
+
if (typeof agent === "string") {
|
|
878
|
+
return validAgentNames.includes(agent);
|
|
879
|
+
}
|
|
880
|
+
if (typeof agent === "object" && agent !== null) {
|
|
881
|
+
const a = agent;
|
|
882
|
+
return validAgentNames.includes(a.name) && (a.to === undefined || typeof a.to === "string");
|
|
883
|
+
}
|
|
884
|
+
return false;
|
|
885
|
+
})) {
|
|
886
|
+
throw new Error(`Rule at index ${index}: Rule.targets must contain valid agents: ${validAgentNames.join(", ")}, or objects with {name, to?}`);
|
|
819
887
|
}
|
|
820
888
|
}
|
|
821
889
|
static createInitialConfig() {
|
|
@@ -845,7 +913,11 @@ export default defineRules({
|
|
|
845
913
|
// name: 'coding-standards',
|
|
846
914
|
// file: '.glooit/coding-rules.md',
|
|
847
915
|
// to: './',
|
|
848
|
-
// targets: [
|
|
916
|
+
// targets: [
|
|
917
|
+
// 'claude',
|
|
918
|
+
// { name: 'cursor', to: './custom/cursor-rules.mdc' }, // Custom path override
|
|
919
|
+
// { name: 'generic', to: './docs/coding-standards.md' } // Generic agent with custom path
|
|
920
|
+
// ],
|
|
849
921
|
// globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
|
|
850
922
|
// }
|
|
851
923
|
],
|
|
@@ -907,7 +979,11 @@ export default defineRules({
|
|
|
907
979
|
// name: 'coding-standards',
|
|
908
980
|
// file: '.glooit/coding-rules.md',
|
|
909
981
|
// to: './',
|
|
910
|
-
// targets: [
|
|
982
|
+
// targets: [
|
|
983
|
+
// 'claude',
|
|
984
|
+
// { name: 'cursor', to: './custom/cursor-rules.mdc' }, // Custom path override
|
|
985
|
+
// { name: 'generic', to: './docs/coding-standards.md' } // Generic agent with custom path
|
|
986
|
+
// ],
|
|
911
987
|
// globs: '**/*.{ts,js,tsx,jsx}' // Optional: only apply to certain file patterns
|
|
912
988
|
// }
|
|
913
989
|
],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type AgentName = 'claude' | 'cursor' | 'codex' | 'roocode' | 'generic';
|
|
2
|
+
export interface AgentTarget {
|
|
3
|
+
name: AgentName;
|
|
4
|
+
to?: string;
|
|
5
|
+
}
|
|
6
|
+
export type Agent = AgentName | AgentTarget;
|
|
2
7
|
export interface Rule {
|
|
3
8
|
name?: string;
|
|
4
9
|
file: string;
|
|
@@ -25,7 +30,7 @@ export interface McpConfig {
|
|
|
25
30
|
export interface Mcp {
|
|
26
31
|
name: string;
|
|
27
32
|
config: McpConfig;
|
|
28
|
-
targets?:
|
|
33
|
+
targets?: AgentName[];
|
|
29
34
|
outputPath?: string;
|
|
30
35
|
}
|
|
31
36
|
export interface ResolvedMcp extends Omit<Mcp, 'outputPath'> {
|
|
@@ -63,7 +68,7 @@ export interface SyncContext {
|
|
|
63
68
|
rule: Rule;
|
|
64
69
|
content: string;
|
|
65
70
|
targetPath: string;
|
|
66
|
-
agent:
|
|
71
|
+
agent: AgentName;
|
|
67
72
|
}
|
|
68
73
|
export interface BackupEntry {
|
|
69
74
|
timestamp: string;
|