rulesync 3.0.0 → 3.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/README.md +1 -1
- package/dist/index.cjs +503 -368
- package/dist/index.js +501 -366
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var logger = new Logger();
|
|
|
72
72
|
import { intersection } from "es-toolkit";
|
|
73
73
|
|
|
74
74
|
// src/commands/commands-processor.ts
|
|
75
|
-
import { basename as
|
|
75
|
+
import { basename as basename11, join as join11 } from "path";
|
|
76
76
|
import { z as z8 } from "zod/mini";
|
|
77
77
|
|
|
78
78
|
// src/utils/file.ts
|
|
@@ -99,6 +99,12 @@ async function readFileContent(filepath) {
|
|
|
99
99
|
logger.debug(`Reading file: ${filepath}`);
|
|
100
100
|
return readFile(filepath, "utf-8");
|
|
101
101
|
}
|
|
102
|
+
function addTrailingNewline(content) {
|
|
103
|
+
if (!content) {
|
|
104
|
+
return "\n";
|
|
105
|
+
}
|
|
106
|
+
return content.trimEnd() + "\n";
|
|
107
|
+
}
|
|
102
108
|
async function writeFileContent(filepath, content) {
|
|
103
109
|
logger.debug(`Writing file: ${filepath}`);
|
|
104
110
|
await ensureDir(dirname(filepath));
|
|
@@ -176,7 +182,8 @@ var FeatureProcessor = class {
|
|
|
176
182
|
*/
|
|
177
183
|
async writeAiFiles(aiFiles) {
|
|
178
184
|
for (const aiFile of aiFiles) {
|
|
179
|
-
|
|
185
|
+
const contentWithNewline = addTrailingNewline(aiFile.getFileContent());
|
|
186
|
+
await writeFileContent(aiFile.getFilePath(), contentWithNewline);
|
|
180
187
|
}
|
|
181
188
|
return aiFiles.length;
|
|
182
189
|
}
|
|
@@ -187,9 +194,8 @@ var FeatureProcessor = class {
|
|
|
187
194
|
}
|
|
188
195
|
};
|
|
189
196
|
|
|
190
|
-
// src/commands/
|
|
197
|
+
// src/commands/agentsmd-command.ts
|
|
191
198
|
import { basename as basename3, join as join3 } from "path";
|
|
192
|
-
import { z as z4 } from "zod/mini";
|
|
193
199
|
|
|
194
200
|
// src/utils/frontmatter.ts
|
|
195
201
|
import matter from "gray-matter";
|
|
@@ -240,9 +246,9 @@ function parseFrontmatter(content) {
|
|
|
240
246
|
return { frontmatter, body };
|
|
241
247
|
}
|
|
242
248
|
|
|
243
|
-
// src/commands/
|
|
249
|
+
// src/commands/simulated-command.ts
|
|
244
250
|
import { basename as basename2, join as join2 } from "path";
|
|
245
|
-
import { z as
|
|
251
|
+
import { z as z2 } from "zod/mini";
|
|
246
252
|
|
|
247
253
|
// src/types/ai-file.ts
|
|
248
254
|
import path, { relative as relative2, resolve as resolve2 } from "path";
|
|
@@ -322,6 +328,220 @@ var AiFile = class {
|
|
|
322
328
|
}
|
|
323
329
|
};
|
|
324
330
|
|
|
331
|
+
// src/commands/tool-command.ts
|
|
332
|
+
var ToolCommand = class extends AiFile {
|
|
333
|
+
static getSettablePaths() {
|
|
334
|
+
throw new Error("Please implement this method in the subclass.");
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Load a command from a tool-specific file path.
|
|
338
|
+
*
|
|
339
|
+
* This method should:
|
|
340
|
+
* 1. Read the file content
|
|
341
|
+
* 2. Parse tool-specific frontmatter format
|
|
342
|
+
* 3. Validate the parsed data
|
|
343
|
+
* 4. Return a concrete ToolCommand instance
|
|
344
|
+
*
|
|
345
|
+
* @param params - Parameters including the file path to load
|
|
346
|
+
* @returns Promise resolving to a concrete ToolCommand instance
|
|
347
|
+
*/
|
|
348
|
+
static async fromFile(_params) {
|
|
349
|
+
throw new Error("Please implement this method in the subclass.");
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Convert a RulesyncCommand to the tool-specific command format.
|
|
353
|
+
*
|
|
354
|
+
* This method should:
|
|
355
|
+
* 1. Extract relevant data from the RulesyncCommand
|
|
356
|
+
* 2. Transform frontmatter to tool-specific format
|
|
357
|
+
* 3. Transform body content if needed
|
|
358
|
+
* 4. Return a concrete ToolCommand instance
|
|
359
|
+
*
|
|
360
|
+
* @param params - Parameters including the RulesyncCommand to convert
|
|
361
|
+
* @returns A concrete ToolCommand instance
|
|
362
|
+
*/
|
|
363
|
+
static fromRulesyncCommand(_params) {
|
|
364
|
+
throw new Error("Please implement this method in the subclass.");
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Check if this tool is targeted by a RulesyncCommand based on its targets field.
|
|
368
|
+
* Subclasses should override this to provide specific targeting logic.
|
|
369
|
+
*
|
|
370
|
+
* @param rulesyncCommand - The RulesyncCommand to check
|
|
371
|
+
* @returns True if this tool is targeted by the command
|
|
372
|
+
*/
|
|
373
|
+
static isTargetedByRulesyncCommand(_rulesyncCommand) {
|
|
374
|
+
throw new Error("Please implement this method in the subclass.");
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Default implementation for checking if a tool is targeted by a RulesyncCommand.
|
|
378
|
+
* Checks if the command's targets include the tool target or a wildcard.
|
|
379
|
+
*
|
|
380
|
+
* @param params - Parameters including the RulesyncCommand and tool target
|
|
381
|
+
* @returns True if the tool target is included in the command's targets
|
|
382
|
+
*/
|
|
383
|
+
static isTargetedByRulesyncCommandDefault({
|
|
384
|
+
rulesyncCommand,
|
|
385
|
+
toolTarget
|
|
386
|
+
}) {
|
|
387
|
+
const targets = rulesyncCommand.getFrontmatter().targets;
|
|
388
|
+
if (!targets) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
if (targets.includes("*")) {
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
if (targets.includes(toolTarget)) {
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/commands/simulated-command.ts
|
|
402
|
+
var SimulatedCommandFrontmatterSchema = z2.object({
|
|
403
|
+
description: z2.string()
|
|
404
|
+
});
|
|
405
|
+
var SimulatedCommand = class _SimulatedCommand extends ToolCommand {
|
|
406
|
+
frontmatter;
|
|
407
|
+
body;
|
|
408
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
409
|
+
if (rest.validate) {
|
|
410
|
+
const result = SimulatedCommandFrontmatterSchema.safeParse(frontmatter);
|
|
411
|
+
if (!result.success) {
|
|
412
|
+
throw result.error;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
super({
|
|
416
|
+
...rest,
|
|
417
|
+
fileContent: stringifyFrontmatter(body, frontmatter)
|
|
418
|
+
});
|
|
419
|
+
this.frontmatter = frontmatter;
|
|
420
|
+
this.body = body;
|
|
421
|
+
}
|
|
422
|
+
getBody() {
|
|
423
|
+
return this.body;
|
|
424
|
+
}
|
|
425
|
+
getFrontmatter() {
|
|
426
|
+
return this.frontmatter;
|
|
427
|
+
}
|
|
428
|
+
toRulesyncCommand() {
|
|
429
|
+
throw new Error("Not implemented because it is a SIMULATED file.");
|
|
430
|
+
}
|
|
431
|
+
static fromRulesyncCommandDefault({
|
|
432
|
+
baseDir = ".",
|
|
433
|
+
rulesyncCommand,
|
|
434
|
+
validate = true
|
|
435
|
+
}) {
|
|
436
|
+
const rulesyncFrontmatter = rulesyncCommand.getFrontmatter();
|
|
437
|
+
const claudecodeFrontmatter = {
|
|
438
|
+
description: rulesyncFrontmatter.description
|
|
439
|
+
};
|
|
440
|
+
const body = rulesyncCommand.getBody();
|
|
441
|
+
return {
|
|
442
|
+
baseDir,
|
|
443
|
+
frontmatter: claudecodeFrontmatter,
|
|
444
|
+
body,
|
|
445
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
446
|
+
relativeFilePath: rulesyncCommand.getRelativeFilePath(),
|
|
447
|
+
validate
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
validate() {
|
|
451
|
+
if (!this.frontmatter) {
|
|
452
|
+
return { success: true, error: null };
|
|
453
|
+
}
|
|
454
|
+
const result = SimulatedCommandFrontmatterSchema.safeParse(this.frontmatter);
|
|
455
|
+
if (result.success) {
|
|
456
|
+
return { success: true, error: null };
|
|
457
|
+
} else {
|
|
458
|
+
return { success: false, error: result.error };
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
static async fromFileDefault({
|
|
462
|
+
baseDir = ".",
|
|
463
|
+
relativeFilePath,
|
|
464
|
+
validate = true
|
|
465
|
+
}) {
|
|
466
|
+
const filePath = join2(
|
|
467
|
+
baseDir,
|
|
468
|
+
_SimulatedCommand.getSettablePaths().relativeDirPath,
|
|
469
|
+
relativeFilePath
|
|
470
|
+
);
|
|
471
|
+
const fileContent = await readFileContent(filePath);
|
|
472
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
473
|
+
const result = SimulatedCommandFrontmatterSchema.safeParse(frontmatter);
|
|
474
|
+
if (!result.success) {
|
|
475
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${result.error.message}`);
|
|
476
|
+
}
|
|
477
|
+
return {
|
|
478
|
+
baseDir,
|
|
479
|
+
relativeDirPath: _SimulatedCommand.getSettablePaths().relativeDirPath,
|
|
480
|
+
relativeFilePath: basename2(relativeFilePath),
|
|
481
|
+
frontmatter: result.data,
|
|
482
|
+
body: content.trim(),
|
|
483
|
+
validate
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// src/commands/agentsmd-command.ts
|
|
489
|
+
var AgentsmdCommand = class _AgentsmdCommand extends SimulatedCommand {
|
|
490
|
+
static getSettablePaths() {
|
|
491
|
+
return {
|
|
492
|
+
relativeDirPath: ".agents/commands"
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
static fromRulesyncCommand({
|
|
496
|
+
baseDir = ".",
|
|
497
|
+
rulesyncCommand,
|
|
498
|
+
validate = true
|
|
499
|
+
}) {
|
|
500
|
+
return new _AgentsmdCommand(
|
|
501
|
+
this.fromRulesyncCommandDefault({ baseDir, rulesyncCommand, validate })
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
static async fromFile({
|
|
505
|
+
baseDir = ".",
|
|
506
|
+
relativeFilePath,
|
|
507
|
+
validate = true
|
|
508
|
+
}) {
|
|
509
|
+
const filePath = join3(
|
|
510
|
+
baseDir,
|
|
511
|
+
_AgentsmdCommand.getSettablePaths().relativeDirPath,
|
|
512
|
+
relativeFilePath
|
|
513
|
+
);
|
|
514
|
+
const fileContent = await readFileContent(filePath);
|
|
515
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
516
|
+
const result = SimulatedCommandFrontmatterSchema.safeParse(frontmatter);
|
|
517
|
+
if (!result.success) {
|
|
518
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${result.error.message}`);
|
|
519
|
+
}
|
|
520
|
+
return new _AgentsmdCommand({
|
|
521
|
+
baseDir,
|
|
522
|
+
relativeDirPath: _AgentsmdCommand.getSettablePaths().relativeDirPath,
|
|
523
|
+
relativeFilePath: basename3(relativeFilePath),
|
|
524
|
+
frontmatter: result.data,
|
|
525
|
+
body: content.trim(),
|
|
526
|
+
validate
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
static isTargetedByRulesyncCommand(rulesyncCommand) {
|
|
530
|
+
return this.isTargetedByRulesyncCommandDefault({
|
|
531
|
+
rulesyncCommand,
|
|
532
|
+
toolTarget: "agentsmd"
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// src/commands/claudecode-command.ts
|
|
538
|
+
import { basename as basename5, join as join5 } from "path";
|
|
539
|
+
import { z as z5 } from "zod/mini";
|
|
540
|
+
|
|
541
|
+
// src/commands/rulesync-command.ts
|
|
542
|
+
import { basename as basename4, join as join4 } from "path";
|
|
543
|
+
import { z as z4 } from "zod/mini";
|
|
544
|
+
|
|
325
545
|
// src/types/rulesync-file.ts
|
|
326
546
|
var RulesyncFile = class extends AiFile {
|
|
327
547
|
static async fromFile(_params) {
|
|
@@ -333,7 +553,7 @@ var RulesyncFile = class extends AiFile {
|
|
|
333
553
|
};
|
|
334
554
|
|
|
335
555
|
// src/types/tool-targets.ts
|
|
336
|
-
import { z as
|
|
556
|
+
import { z as z3 } from "zod/mini";
|
|
337
557
|
var ALL_TOOL_TARGETS = [
|
|
338
558
|
"agentsmd",
|
|
339
559
|
"amazonqcli",
|
|
@@ -354,14 +574,14 @@ var ALL_TOOL_TARGETS = [
|
|
|
354
574
|
"windsurf"
|
|
355
575
|
];
|
|
356
576
|
var ALL_TOOL_TARGETS_WITH_WILDCARD = [...ALL_TOOL_TARGETS, "*"];
|
|
357
|
-
var ToolTargetSchema =
|
|
358
|
-
var ToolTargetsSchema =
|
|
359
|
-
var RulesyncTargetsSchema =
|
|
577
|
+
var ToolTargetSchema = z3.enum(ALL_TOOL_TARGETS);
|
|
578
|
+
var ToolTargetsSchema = z3.array(ToolTargetSchema);
|
|
579
|
+
var RulesyncTargetsSchema = z3.array(z3.enum(ALL_TOOL_TARGETS_WITH_WILDCARD));
|
|
360
580
|
|
|
361
581
|
// src/commands/rulesync-command.ts
|
|
362
|
-
var RulesyncCommandFrontmatterSchema =
|
|
582
|
+
var RulesyncCommandFrontmatterSchema = z4.object({
|
|
363
583
|
targets: RulesyncTargetsSchema,
|
|
364
|
-
description:
|
|
584
|
+
description: z4.string()
|
|
365
585
|
});
|
|
366
586
|
var RulesyncCommand = class _RulesyncCommand extends RulesyncFile {
|
|
367
587
|
frontmatter;
|
|
@@ -406,14 +626,14 @@ var RulesyncCommand = class _RulesyncCommand extends RulesyncFile {
|
|
|
406
626
|
relativeFilePath
|
|
407
627
|
}) {
|
|
408
628
|
const fileContent = await readFileContent(
|
|
409
|
-
|
|
629
|
+
join4(_RulesyncCommand.getSettablePaths().relativeDirPath, relativeFilePath)
|
|
410
630
|
);
|
|
411
631
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
412
632
|
const result = RulesyncCommandFrontmatterSchema.safeParse(frontmatter);
|
|
413
633
|
if (!result.success) {
|
|
414
634
|
throw new Error(`Invalid frontmatter in ${relativeFilePath}: ${result.error.message}`);
|
|
415
635
|
}
|
|
416
|
-
const filename =
|
|
636
|
+
const filename = basename4(relativeFilePath);
|
|
417
637
|
return new _RulesyncCommand({
|
|
418
638
|
baseDir: ".",
|
|
419
639
|
relativeDirPath: _RulesyncCommand.getSettablePaths().relativeDirPath,
|
|
@@ -425,79 +645,9 @@ var RulesyncCommand = class _RulesyncCommand extends RulesyncFile {
|
|
|
425
645
|
}
|
|
426
646
|
};
|
|
427
647
|
|
|
428
|
-
// src/commands/tool-command.ts
|
|
429
|
-
var ToolCommand = class extends AiFile {
|
|
430
|
-
static getSettablePaths() {
|
|
431
|
-
throw new Error("Please implement this method in the subclass.");
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Load a command from a tool-specific file path.
|
|
435
|
-
*
|
|
436
|
-
* This method should:
|
|
437
|
-
* 1. Read the file content
|
|
438
|
-
* 2. Parse tool-specific frontmatter format
|
|
439
|
-
* 3. Validate the parsed data
|
|
440
|
-
* 4. Return a concrete ToolCommand instance
|
|
441
|
-
*
|
|
442
|
-
* @param params - Parameters including the file path to load
|
|
443
|
-
* @returns Promise resolving to a concrete ToolCommand instance
|
|
444
|
-
*/
|
|
445
|
-
static async fromFile(_params) {
|
|
446
|
-
throw new Error("Please implement this method in the subclass.");
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Convert a RulesyncCommand to the tool-specific command format.
|
|
450
|
-
*
|
|
451
|
-
* This method should:
|
|
452
|
-
* 1. Extract relevant data from the RulesyncCommand
|
|
453
|
-
* 2. Transform frontmatter to tool-specific format
|
|
454
|
-
* 3. Transform body content if needed
|
|
455
|
-
* 4. Return a concrete ToolCommand instance
|
|
456
|
-
*
|
|
457
|
-
* @param params - Parameters including the RulesyncCommand to convert
|
|
458
|
-
* @returns A concrete ToolCommand instance
|
|
459
|
-
*/
|
|
460
|
-
static fromRulesyncCommand(_params) {
|
|
461
|
-
throw new Error("Please implement this method in the subclass.");
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Check if this tool is targeted by a RulesyncCommand based on its targets field.
|
|
465
|
-
* Subclasses should override this to provide specific targeting logic.
|
|
466
|
-
*
|
|
467
|
-
* @param rulesyncCommand - The RulesyncCommand to check
|
|
468
|
-
* @returns True if this tool is targeted by the command
|
|
469
|
-
*/
|
|
470
|
-
static isTargetedByRulesyncCommand(_rulesyncCommand) {
|
|
471
|
-
throw new Error("Please implement this method in the subclass.");
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Default implementation for checking if a tool is targeted by a RulesyncCommand.
|
|
475
|
-
* Checks if the command's targets include the tool target or a wildcard.
|
|
476
|
-
*
|
|
477
|
-
* @param params - Parameters including the RulesyncCommand and tool target
|
|
478
|
-
* @returns True if the tool target is included in the command's targets
|
|
479
|
-
*/
|
|
480
|
-
static isTargetedByRulesyncCommandDefault({
|
|
481
|
-
rulesyncCommand,
|
|
482
|
-
toolTarget
|
|
483
|
-
}) {
|
|
484
|
-
const targets = rulesyncCommand.getFrontmatter().targets;
|
|
485
|
-
if (!targets) {
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
if (targets.includes("*")) {
|
|
489
|
-
return true;
|
|
490
|
-
}
|
|
491
|
-
if (targets.includes(toolTarget)) {
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
|
|
498
648
|
// src/commands/claudecode-command.ts
|
|
499
|
-
var ClaudecodeCommandFrontmatterSchema =
|
|
500
|
-
description:
|
|
649
|
+
var ClaudecodeCommandFrontmatterSchema = z5.object({
|
|
650
|
+
description: z5.string()
|
|
501
651
|
});
|
|
502
652
|
var ClaudecodeCommand = class _ClaudecodeCommand extends ToolCommand {
|
|
503
653
|
frontmatter;
|
|
@@ -523,7 +673,7 @@ var ClaudecodeCommand = class _ClaudecodeCommand extends ToolCommand {
|
|
|
523
673
|
}
|
|
524
674
|
static getSettablePathsGlobal() {
|
|
525
675
|
return {
|
|
526
|
-
relativeDirPath:
|
|
676
|
+
relativeDirPath: join5(".claude", "commands")
|
|
527
677
|
};
|
|
528
678
|
}
|
|
529
679
|
getBody() {
|
|
@@ -594,7 +744,7 @@ var ClaudecodeCommand = class _ClaudecodeCommand extends ToolCommand {
|
|
|
594
744
|
global = false
|
|
595
745
|
}) {
|
|
596
746
|
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
597
|
-
const filePath =
|
|
747
|
+
const filePath = join5(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
598
748
|
const fileContent = await readFileContent(filePath);
|
|
599
749
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
600
750
|
const result = ClaudecodeCommandFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -604,7 +754,7 @@ var ClaudecodeCommand = class _ClaudecodeCommand extends ToolCommand {
|
|
|
604
754
|
return new _ClaudecodeCommand({
|
|
605
755
|
baseDir,
|
|
606
756
|
relativeDirPath: paths.relativeDirPath,
|
|
607
|
-
relativeFilePath:
|
|
757
|
+
relativeFilePath: basename5(relativeFilePath),
|
|
608
758
|
frontmatter: result.data,
|
|
609
759
|
body: content.trim(),
|
|
610
760
|
validate
|
|
@@ -613,14 +763,14 @@ var ClaudecodeCommand = class _ClaudecodeCommand extends ToolCommand {
|
|
|
613
763
|
};
|
|
614
764
|
|
|
615
765
|
// src/commands/codexcli-command.ts
|
|
616
|
-
import { basename as
|
|
766
|
+
import { basename as basename6, join as join6 } from "path";
|
|
617
767
|
var CodexcliCommand = class _CodexcliCommand extends ToolCommand {
|
|
618
768
|
static getSettablePaths() {
|
|
619
769
|
throw new Error("getSettablePaths is not supported for CodexcliCommand");
|
|
620
770
|
}
|
|
621
771
|
static getSettablePathsGlobal() {
|
|
622
772
|
return {
|
|
623
|
-
relativeDirPath:
|
|
773
|
+
relativeDirPath: join6(".codex", "prompts")
|
|
624
774
|
};
|
|
625
775
|
}
|
|
626
776
|
toRulesyncCommand() {
|
|
@@ -639,146 +789,55 @@ var CodexcliCommand = class _CodexcliCommand extends ToolCommand {
|
|
|
639
789
|
validate: true
|
|
640
790
|
});
|
|
641
791
|
}
|
|
642
|
-
static fromRulesyncCommand({
|
|
643
|
-
baseDir = ".",
|
|
644
|
-
rulesyncCommand,
|
|
645
|
-
validate = true,
|
|
646
|
-
global = false
|
|
647
|
-
}) {
|
|
648
|
-
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
649
|
-
return new _CodexcliCommand({
|
|
650
|
-
baseDir,
|
|
651
|
-
fileContent: rulesyncCommand.getBody(),
|
|
652
|
-
relativeDirPath: paths.relativeDirPath,
|
|
653
|
-
relativeFilePath: rulesyncCommand.getRelativeFilePath(),
|
|
654
|
-
validate
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
validate() {
|
|
658
|
-
return { success: true, error: null };
|
|
659
|
-
}
|
|
660
|
-
getBody() {
|
|
661
|
-
return this.getFileContent();
|
|
662
|
-
}
|
|
663
|
-
static isTargetedByRulesyncCommand(rulesyncCommand) {
|
|
664
|
-
return this.isTargetedByRulesyncCommandDefault({
|
|
665
|
-
rulesyncCommand,
|
|
666
|
-
toolTarget: "codexcli"
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
static async fromFile({
|
|
670
|
-
baseDir = ".",
|
|
671
|
-
relativeFilePath,
|
|
672
|
-
validate = true,
|
|
673
|
-
global = false
|
|
674
|
-
}) {
|
|
675
|
-
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
676
|
-
const filePath = join4(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
677
|
-
const fileContent = await readFileContent(filePath);
|
|
678
|
-
const { body: content } = parseFrontmatter(fileContent);
|
|
679
|
-
return new _CodexcliCommand({
|
|
680
|
-
baseDir,
|
|
681
|
-
relativeDirPath: paths.relativeDirPath,
|
|
682
|
-
relativeFilePath: basename4(relativeFilePath),
|
|
683
|
-
fileContent: content.trim(),
|
|
684
|
-
validate
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
// src/commands/copilot-command.ts
|
|
690
|
-
import { basename as basename6, join as join6 } from "path";
|
|
691
|
-
|
|
692
|
-
// src/commands/simulated-command.ts
|
|
693
|
-
import { basename as basename5, join as join5 } from "path";
|
|
694
|
-
import { z as z5 } from "zod/mini";
|
|
695
|
-
var SimulatedCommandFrontmatterSchema = z5.object({
|
|
696
|
-
description: z5.string()
|
|
697
|
-
});
|
|
698
|
-
var SimulatedCommand = class _SimulatedCommand extends ToolCommand {
|
|
699
|
-
frontmatter;
|
|
700
|
-
body;
|
|
701
|
-
constructor({ frontmatter, body, ...rest }) {
|
|
702
|
-
if (rest.validate) {
|
|
703
|
-
const result = SimulatedCommandFrontmatterSchema.safeParse(frontmatter);
|
|
704
|
-
if (!result.success) {
|
|
705
|
-
throw result.error;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
super({
|
|
709
|
-
...rest,
|
|
710
|
-
fileContent: stringifyFrontmatter(body, frontmatter)
|
|
711
|
-
});
|
|
712
|
-
this.frontmatter = frontmatter;
|
|
713
|
-
this.body = body;
|
|
714
|
-
}
|
|
715
|
-
getBody() {
|
|
716
|
-
return this.body;
|
|
717
|
-
}
|
|
718
|
-
getFrontmatter() {
|
|
719
|
-
return this.frontmatter;
|
|
720
|
-
}
|
|
721
|
-
toRulesyncCommand() {
|
|
722
|
-
throw new Error("Not implemented because it is a SIMULATED file.");
|
|
723
|
-
}
|
|
724
|
-
static fromRulesyncCommandDefault({
|
|
792
|
+
static fromRulesyncCommand({
|
|
725
793
|
baseDir = ".",
|
|
726
794
|
rulesyncCommand,
|
|
727
|
-
validate = true
|
|
795
|
+
validate = true,
|
|
796
|
+
global = false
|
|
728
797
|
}) {
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
description: rulesyncFrontmatter.description
|
|
732
|
-
};
|
|
733
|
-
const body = rulesyncCommand.getBody();
|
|
734
|
-
return {
|
|
798
|
+
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
799
|
+
return new _CodexcliCommand({
|
|
735
800
|
baseDir,
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
801
|
+
fileContent: rulesyncCommand.getBody(),
|
|
802
|
+
relativeDirPath: paths.relativeDirPath,
|
|
739
803
|
relativeFilePath: rulesyncCommand.getRelativeFilePath(),
|
|
740
804
|
validate
|
|
741
|
-
};
|
|
805
|
+
});
|
|
742
806
|
}
|
|
743
807
|
validate() {
|
|
744
|
-
|
|
745
|
-
return { success: true, error: null };
|
|
746
|
-
}
|
|
747
|
-
const result = SimulatedCommandFrontmatterSchema.safeParse(this.frontmatter);
|
|
748
|
-
if (result.success) {
|
|
749
|
-
return { success: true, error: null };
|
|
750
|
-
} else {
|
|
751
|
-
return { success: false, error: result.error };
|
|
752
|
-
}
|
|
808
|
+
return { success: true, error: null };
|
|
753
809
|
}
|
|
754
|
-
|
|
810
|
+
getBody() {
|
|
811
|
+
return this.getFileContent();
|
|
812
|
+
}
|
|
813
|
+
static isTargetedByRulesyncCommand(rulesyncCommand) {
|
|
814
|
+
return this.isTargetedByRulesyncCommandDefault({
|
|
815
|
+
rulesyncCommand,
|
|
816
|
+
toolTarget: "codexcli"
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
static async fromFile({
|
|
755
820
|
baseDir = ".",
|
|
756
821
|
relativeFilePath,
|
|
757
|
-
validate = true
|
|
822
|
+
validate = true,
|
|
823
|
+
global = false
|
|
758
824
|
}) {
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
_SimulatedCommand.getSettablePaths().relativeDirPath,
|
|
762
|
-
relativeFilePath
|
|
763
|
-
);
|
|
825
|
+
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
826
|
+
const filePath = join6(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
764
827
|
const fileContent = await readFileContent(filePath);
|
|
765
|
-
const {
|
|
766
|
-
|
|
767
|
-
if (!result.success) {
|
|
768
|
-
throw new Error(`Invalid frontmatter in ${filePath}: ${result.error.message}`);
|
|
769
|
-
}
|
|
770
|
-
return {
|
|
828
|
+
const { body: content } = parseFrontmatter(fileContent);
|
|
829
|
+
return new _CodexcliCommand({
|
|
771
830
|
baseDir,
|
|
772
|
-
relativeDirPath:
|
|
773
|
-
relativeFilePath:
|
|
774
|
-
|
|
775
|
-
body: content.trim(),
|
|
831
|
+
relativeDirPath: paths.relativeDirPath,
|
|
832
|
+
relativeFilePath: basename6(relativeFilePath),
|
|
833
|
+
fileContent: content.trim(),
|
|
776
834
|
validate
|
|
777
|
-
};
|
|
835
|
+
});
|
|
778
836
|
}
|
|
779
837
|
};
|
|
780
838
|
|
|
781
839
|
// src/commands/copilot-command.ts
|
|
840
|
+
import { basename as basename7, join as join7 } from "path";
|
|
782
841
|
var CopilotCommand = class _CopilotCommand extends SimulatedCommand {
|
|
783
842
|
static getSettablePaths() {
|
|
784
843
|
return {
|
|
@@ -799,7 +858,7 @@ var CopilotCommand = class _CopilotCommand extends SimulatedCommand {
|
|
|
799
858
|
relativeFilePath,
|
|
800
859
|
validate = true
|
|
801
860
|
}) {
|
|
802
|
-
const filePath =
|
|
861
|
+
const filePath = join7(
|
|
803
862
|
baseDir,
|
|
804
863
|
_CopilotCommand.getSettablePaths().relativeDirPath,
|
|
805
864
|
relativeFilePath
|
|
@@ -813,7 +872,7 @@ var CopilotCommand = class _CopilotCommand extends SimulatedCommand {
|
|
|
813
872
|
return new _CopilotCommand({
|
|
814
873
|
baseDir,
|
|
815
874
|
relativeDirPath: _CopilotCommand.getSettablePaths().relativeDirPath,
|
|
816
|
-
relativeFilePath:
|
|
875
|
+
relativeFilePath: basename7(relativeFilePath),
|
|
817
876
|
frontmatter: result.data,
|
|
818
877
|
body: content.trim(),
|
|
819
878
|
validate
|
|
@@ -828,16 +887,16 @@ var CopilotCommand = class _CopilotCommand extends SimulatedCommand {
|
|
|
828
887
|
};
|
|
829
888
|
|
|
830
889
|
// src/commands/cursor-command.ts
|
|
831
|
-
import { basename as
|
|
890
|
+
import { basename as basename8, join as join8 } from "path";
|
|
832
891
|
var CursorCommand = class _CursorCommand extends ToolCommand {
|
|
833
892
|
static getSettablePaths() {
|
|
834
893
|
return {
|
|
835
|
-
relativeDirPath:
|
|
894
|
+
relativeDirPath: join8(".cursor", "commands")
|
|
836
895
|
};
|
|
837
896
|
}
|
|
838
897
|
static getSettablePathsGlobal() {
|
|
839
898
|
return {
|
|
840
|
-
relativeDirPath:
|
|
899
|
+
relativeDirPath: join8(".cursor", "commands")
|
|
841
900
|
};
|
|
842
901
|
}
|
|
843
902
|
toRulesyncCommand() {
|
|
@@ -890,13 +949,13 @@ var CursorCommand = class _CursorCommand extends ToolCommand {
|
|
|
890
949
|
global = false
|
|
891
950
|
}) {
|
|
892
951
|
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
893
|
-
const filePath =
|
|
952
|
+
const filePath = join8(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
894
953
|
const fileContent = await readFileContent(filePath);
|
|
895
954
|
const { body: content } = parseFrontmatter(fileContent);
|
|
896
955
|
return new _CursorCommand({
|
|
897
956
|
baseDir,
|
|
898
957
|
relativeDirPath: paths.relativeDirPath,
|
|
899
|
-
relativeFilePath:
|
|
958
|
+
relativeFilePath: basename8(relativeFilePath),
|
|
900
959
|
fileContent: content.trim(),
|
|
901
960
|
validate
|
|
902
961
|
});
|
|
@@ -904,7 +963,7 @@ var CursorCommand = class _CursorCommand extends ToolCommand {
|
|
|
904
963
|
};
|
|
905
964
|
|
|
906
965
|
// src/commands/geminicli-command.ts
|
|
907
|
-
import { basename as
|
|
966
|
+
import { basename as basename9, join as join9 } from "path";
|
|
908
967
|
import { parse as parseToml } from "smol-toml";
|
|
909
968
|
import { z as z6 } from "zod/mini";
|
|
910
969
|
var GeminiCliCommandFrontmatterSchema = z6.object({
|
|
@@ -927,7 +986,7 @@ var GeminiCliCommand = class _GeminiCliCommand extends ToolCommand {
|
|
|
927
986
|
}
|
|
928
987
|
static getSettablePathsGlobal() {
|
|
929
988
|
return {
|
|
930
|
-
relativeDirPath:
|
|
989
|
+
relativeDirPath: join9(".gemini", "commands")
|
|
931
990
|
};
|
|
932
991
|
}
|
|
933
992
|
parseTomlContent(content) {
|
|
@@ -999,12 +1058,12 @@ ${geminiFrontmatter.prompt}
|
|
|
999
1058
|
global = false
|
|
1000
1059
|
}) {
|
|
1001
1060
|
const paths = global ? this.getSettablePathsGlobal() : this.getSettablePaths();
|
|
1002
|
-
const filePath =
|
|
1061
|
+
const filePath = join9(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
1003
1062
|
const fileContent = await readFileContent(filePath);
|
|
1004
1063
|
return new _GeminiCliCommand({
|
|
1005
1064
|
baseDir,
|
|
1006
1065
|
relativeDirPath: paths.relativeDirPath,
|
|
1007
|
-
relativeFilePath:
|
|
1066
|
+
relativeFilePath: basename9(relativeFilePath),
|
|
1008
1067
|
fileContent,
|
|
1009
1068
|
validate
|
|
1010
1069
|
});
|
|
@@ -1026,7 +1085,7 @@ ${geminiFrontmatter.prompt}
|
|
|
1026
1085
|
};
|
|
1027
1086
|
|
|
1028
1087
|
// src/commands/roo-command.ts
|
|
1029
|
-
import { basename as
|
|
1088
|
+
import { basename as basename10, join as join10 } from "path";
|
|
1030
1089
|
import { optional, z as z7 } from "zod/mini";
|
|
1031
1090
|
var RooCommandFrontmatterSchema = z7.object({
|
|
1032
1091
|
description: z7.string(),
|
|
@@ -1120,7 +1179,7 @@ var RooCommand = class _RooCommand extends ToolCommand {
|
|
|
1120
1179
|
relativeFilePath,
|
|
1121
1180
|
validate = true
|
|
1122
1181
|
}) {
|
|
1123
|
-
const filePath =
|
|
1182
|
+
const filePath = join10(baseDir, _RooCommand.getSettablePaths().relativeDirPath, relativeFilePath);
|
|
1124
1183
|
const fileContent = await readFileContent(filePath);
|
|
1125
1184
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
1126
1185
|
const result = RooCommandFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -1130,7 +1189,7 @@ var RooCommand = class _RooCommand extends ToolCommand {
|
|
|
1130
1189
|
return new _RooCommand({
|
|
1131
1190
|
baseDir,
|
|
1132
1191
|
relativeDirPath: _RooCommand.getSettablePaths().relativeDirPath,
|
|
1133
|
-
relativeFilePath:
|
|
1192
|
+
relativeFilePath: basename10(relativeFilePath),
|
|
1134
1193
|
frontmatter: result.data,
|
|
1135
1194
|
body: content.trim(),
|
|
1136
1195
|
fileContent,
|
|
@@ -1141,6 +1200,7 @@ var RooCommand = class _RooCommand extends ToolCommand {
|
|
|
1141
1200
|
|
|
1142
1201
|
// src/commands/commands-processor.ts
|
|
1143
1202
|
var commandsProcessorToolTargets = [
|
|
1203
|
+
"agentsmd",
|
|
1144
1204
|
"claudecode",
|
|
1145
1205
|
"geminicli",
|
|
1146
1206
|
"roo",
|
|
@@ -1151,7 +1211,7 @@ var CommandsProcessorToolTargetSchema = z8.enum(
|
|
|
1151
1211
|
// codexcli is not in the list of tool targets but we add it here because it is a valid tool target for global mode generation
|
|
1152
1212
|
commandsProcessorToolTargets.concat("codexcli")
|
|
1153
1213
|
);
|
|
1154
|
-
var commandsProcessorToolTargetsSimulated = ["copilot"];
|
|
1214
|
+
var commandsProcessorToolTargetsSimulated = ["agentsmd", "copilot"];
|
|
1155
1215
|
var commandsProcessorToolTargetsGlobal = [
|
|
1156
1216
|
"claudecode",
|
|
1157
1217
|
"cursor",
|
|
@@ -1176,6 +1236,14 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1176
1236
|
);
|
|
1177
1237
|
const toolCommands = rulesyncCommands.map((rulesyncCommand) => {
|
|
1178
1238
|
switch (this.toolTarget) {
|
|
1239
|
+
case "agentsmd":
|
|
1240
|
+
if (!AgentsmdCommand.isTargetedByRulesyncCommand(rulesyncCommand)) {
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
return AgentsmdCommand.fromRulesyncCommand({
|
|
1244
|
+
baseDir: this.baseDir,
|
|
1245
|
+
rulesyncCommand
|
|
1246
|
+
});
|
|
1179
1247
|
case "claudecode":
|
|
1180
1248
|
if (!ClaudecodeCommand.isTargetedByRulesyncCommand(rulesyncCommand)) {
|
|
1181
1249
|
return null;
|
|
@@ -1251,11 +1319,11 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1251
1319
|
*/
|
|
1252
1320
|
async loadRulesyncFiles() {
|
|
1253
1321
|
const rulesyncCommandPaths = await findFilesByGlobs(
|
|
1254
|
-
|
|
1322
|
+
join11(RulesyncCommand.getSettablePaths().relativeDirPath, "*.md")
|
|
1255
1323
|
);
|
|
1256
1324
|
const rulesyncCommands = (await Promise.allSettled(
|
|
1257
1325
|
rulesyncCommandPaths.map(
|
|
1258
|
-
(path2) => RulesyncCommand.fromFile({ relativeFilePath:
|
|
1326
|
+
(path2) => RulesyncCommand.fromFile({ relativeFilePath: basename11(path2) })
|
|
1259
1327
|
)
|
|
1260
1328
|
)).filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
1261
1329
|
logger.info(`Successfully loaded ${rulesyncCommands.length} rulesync commands`);
|
|
@@ -1267,6 +1335,8 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1267
1335
|
*/
|
|
1268
1336
|
async loadToolFiles() {
|
|
1269
1337
|
switch (this.toolTarget) {
|
|
1338
|
+
case "agentsmd":
|
|
1339
|
+
return await this.loadAgentsmdCommands();
|
|
1270
1340
|
case "claudecode":
|
|
1271
1341
|
return await this.loadClaudecodeCommands();
|
|
1272
1342
|
case "geminicli":
|
|
@@ -1292,43 +1362,48 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1292
1362
|
extension
|
|
1293
1363
|
}) {
|
|
1294
1364
|
const commandFilePaths = await findFilesByGlobs(
|
|
1295
|
-
|
|
1365
|
+
join11(this.baseDir, relativeDirPath, `*.${extension}`)
|
|
1296
1366
|
);
|
|
1297
1367
|
const toolCommands = (await Promise.allSettled(
|
|
1298
1368
|
commandFilePaths.map((path2) => {
|
|
1299
1369
|
switch (toolTarget) {
|
|
1370
|
+
case "agentsmd":
|
|
1371
|
+
return AgentsmdCommand.fromFile({
|
|
1372
|
+
baseDir: this.baseDir,
|
|
1373
|
+
relativeFilePath: basename11(path2)
|
|
1374
|
+
});
|
|
1300
1375
|
case "claudecode":
|
|
1301
1376
|
return ClaudecodeCommand.fromFile({
|
|
1302
1377
|
baseDir: this.baseDir,
|
|
1303
|
-
relativeFilePath:
|
|
1378
|
+
relativeFilePath: basename11(path2),
|
|
1304
1379
|
global: this.global
|
|
1305
1380
|
});
|
|
1306
1381
|
case "geminicli":
|
|
1307
1382
|
return GeminiCliCommand.fromFile({
|
|
1308
1383
|
baseDir: this.baseDir,
|
|
1309
|
-
relativeFilePath:
|
|
1384
|
+
relativeFilePath: basename11(path2),
|
|
1310
1385
|
global: this.global
|
|
1311
1386
|
});
|
|
1312
1387
|
case "roo":
|
|
1313
1388
|
return RooCommand.fromFile({
|
|
1314
1389
|
baseDir: this.baseDir,
|
|
1315
|
-
relativeFilePath:
|
|
1390
|
+
relativeFilePath: basename11(path2)
|
|
1316
1391
|
});
|
|
1317
1392
|
case "copilot":
|
|
1318
1393
|
return CopilotCommand.fromFile({
|
|
1319
1394
|
baseDir: this.baseDir,
|
|
1320
|
-
relativeFilePath:
|
|
1395
|
+
relativeFilePath: basename11(path2)
|
|
1321
1396
|
});
|
|
1322
1397
|
case "cursor":
|
|
1323
1398
|
return CursorCommand.fromFile({
|
|
1324
1399
|
baseDir: this.baseDir,
|
|
1325
|
-
relativeFilePath:
|
|
1400
|
+
relativeFilePath: basename11(path2),
|
|
1326
1401
|
global: this.global
|
|
1327
1402
|
});
|
|
1328
1403
|
case "codexcli":
|
|
1329
1404
|
return CodexcliCommand.fromFile({
|
|
1330
1405
|
baseDir: this.baseDir,
|
|
1331
|
-
relativeFilePath:
|
|
1406
|
+
relativeFilePath: basename11(path2),
|
|
1332
1407
|
global: this.global
|
|
1333
1408
|
});
|
|
1334
1409
|
default:
|
|
@@ -1340,7 +1415,17 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1340
1415
|
return toolCommands;
|
|
1341
1416
|
}
|
|
1342
1417
|
/**
|
|
1343
|
-
* Load
|
|
1418
|
+
* Load Agents.md command configurations from .agents/commands/ directory
|
|
1419
|
+
*/
|
|
1420
|
+
async loadAgentsmdCommands() {
|
|
1421
|
+
return await this.loadToolCommandDefault({
|
|
1422
|
+
toolTarget: "agentsmd",
|
|
1423
|
+
relativeDirPath: AgentsmdCommand.getSettablePaths().relativeDirPath,
|
|
1424
|
+
extension: "md"
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Load Copilot command configurations from .github/commands/ directory
|
|
1344
1429
|
*/
|
|
1345
1430
|
async loadCopilotCommands() {
|
|
1346
1431
|
return await this.loadToolCommandDefault({
|
|
@@ -1426,7 +1511,7 @@ var CommandsProcessor = class extends FeatureProcessor {
|
|
|
1426
1511
|
};
|
|
1427
1512
|
|
|
1428
1513
|
// src/config/config-resolver.ts
|
|
1429
|
-
import { join as
|
|
1514
|
+
import { join as join12 } from "path";
|
|
1430
1515
|
import { loadConfig } from "c12";
|
|
1431
1516
|
|
|
1432
1517
|
// src/config/config.ts
|
|
@@ -1562,7 +1647,7 @@ function getBaseDirsInLightOfGlobal({
|
|
|
1562
1647
|
global
|
|
1563
1648
|
}) {
|
|
1564
1649
|
if (isEnvTest) {
|
|
1565
|
-
return baseDirs.map((baseDir) =>
|
|
1650
|
+
return baseDirs.map((baseDir) => join12(".", baseDir));
|
|
1566
1651
|
}
|
|
1567
1652
|
if (global) {
|
|
1568
1653
|
return [getHomeDirectory()];
|
|
@@ -1577,7 +1662,7 @@ function getBaseDirsInLightOfGlobal({
|
|
|
1577
1662
|
import { z as z9 } from "zod/mini";
|
|
1578
1663
|
|
|
1579
1664
|
// src/ignore/amazonqcli-ignore.ts
|
|
1580
|
-
import { join as
|
|
1665
|
+
import { join as join13 } from "path";
|
|
1581
1666
|
|
|
1582
1667
|
// src/types/tool-file.ts
|
|
1583
1668
|
var ToolFile = class extends AiFile {
|
|
@@ -1685,7 +1770,7 @@ var AmazonqcliIgnore = class _AmazonqcliIgnore extends ToolIgnore {
|
|
|
1685
1770
|
validate = true
|
|
1686
1771
|
}) {
|
|
1687
1772
|
const fileContent = await readFileContent(
|
|
1688
|
-
|
|
1773
|
+
join13(
|
|
1689
1774
|
baseDir,
|
|
1690
1775
|
this.getSettablePaths().relativeDirPath,
|
|
1691
1776
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1702,7 +1787,7 @@ var AmazonqcliIgnore = class _AmazonqcliIgnore extends ToolIgnore {
|
|
|
1702
1787
|
};
|
|
1703
1788
|
|
|
1704
1789
|
// src/ignore/augmentcode-ignore.ts
|
|
1705
|
-
import { join as
|
|
1790
|
+
import { join as join14 } from "path";
|
|
1706
1791
|
var AugmentcodeIgnore = class _AugmentcodeIgnore extends ToolIgnore {
|
|
1707
1792
|
static getSettablePaths() {
|
|
1708
1793
|
return {
|
|
@@ -1740,7 +1825,7 @@ var AugmentcodeIgnore = class _AugmentcodeIgnore extends ToolIgnore {
|
|
|
1740
1825
|
validate = true
|
|
1741
1826
|
}) {
|
|
1742
1827
|
const fileContent = await readFileContent(
|
|
1743
|
-
|
|
1828
|
+
join14(
|
|
1744
1829
|
baseDir,
|
|
1745
1830
|
this.getSettablePaths().relativeDirPath,
|
|
1746
1831
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1757,7 +1842,7 @@ var AugmentcodeIgnore = class _AugmentcodeIgnore extends ToolIgnore {
|
|
|
1757
1842
|
};
|
|
1758
1843
|
|
|
1759
1844
|
// src/ignore/claudecode-ignore.ts
|
|
1760
|
-
import { join as
|
|
1845
|
+
import { join as join15 } from "path";
|
|
1761
1846
|
import { uniq } from "es-toolkit";
|
|
1762
1847
|
var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
1763
1848
|
constructor(params) {
|
|
@@ -1793,7 +1878,7 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
|
1793
1878
|
const fileContent = rulesyncIgnore.getFileContent();
|
|
1794
1879
|
const patterns = fileContent.split(/\r?\n|\r/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
1795
1880
|
const deniedValues = patterns.map((pattern) => `Read(${pattern})`);
|
|
1796
|
-
const filePath =
|
|
1881
|
+
const filePath = join15(
|
|
1797
1882
|
baseDir,
|
|
1798
1883
|
this.getSettablePaths().relativeDirPath,
|
|
1799
1884
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1821,7 +1906,7 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
|
1821
1906
|
validate = true
|
|
1822
1907
|
}) {
|
|
1823
1908
|
const fileContent = await readFileContent(
|
|
1824
|
-
|
|
1909
|
+
join15(
|
|
1825
1910
|
baseDir,
|
|
1826
1911
|
this.getSettablePaths().relativeDirPath,
|
|
1827
1912
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1838,7 +1923,7 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
|
1838
1923
|
};
|
|
1839
1924
|
|
|
1840
1925
|
// src/ignore/cline-ignore.ts
|
|
1841
|
-
import { join as
|
|
1926
|
+
import { join as join16 } from "path";
|
|
1842
1927
|
var ClineIgnore = class _ClineIgnore extends ToolIgnore {
|
|
1843
1928
|
static getSettablePaths() {
|
|
1844
1929
|
return {
|
|
@@ -1875,7 +1960,7 @@ var ClineIgnore = class _ClineIgnore extends ToolIgnore {
|
|
|
1875
1960
|
validate = true
|
|
1876
1961
|
}) {
|
|
1877
1962
|
const fileContent = await readFileContent(
|
|
1878
|
-
|
|
1963
|
+
join16(
|
|
1879
1964
|
baseDir,
|
|
1880
1965
|
this.getSettablePaths().relativeDirPath,
|
|
1881
1966
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1892,7 +1977,7 @@ var ClineIgnore = class _ClineIgnore extends ToolIgnore {
|
|
|
1892
1977
|
};
|
|
1893
1978
|
|
|
1894
1979
|
// src/ignore/cursor-ignore.ts
|
|
1895
|
-
import { join as
|
|
1980
|
+
import { join as join17 } from "path";
|
|
1896
1981
|
var CursorIgnore = class _CursorIgnore extends ToolIgnore {
|
|
1897
1982
|
static getSettablePaths() {
|
|
1898
1983
|
return {
|
|
@@ -1925,7 +2010,7 @@ var CursorIgnore = class _CursorIgnore extends ToolIgnore {
|
|
|
1925
2010
|
validate = true
|
|
1926
2011
|
}) {
|
|
1927
2012
|
const fileContent = await readFileContent(
|
|
1928
|
-
|
|
2013
|
+
join17(
|
|
1929
2014
|
baseDir,
|
|
1930
2015
|
this.getSettablePaths().relativeDirPath,
|
|
1931
2016
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1942,7 +2027,7 @@ var CursorIgnore = class _CursorIgnore extends ToolIgnore {
|
|
|
1942
2027
|
};
|
|
1943
2028
|
|
|
1944
2029
|
// src/ignore/geminicli-ignore.ts
|
|
1945
|
-
import { join as
|
|
2030
|
+
import { join as join18 } from "path";
|
|
1946
2031
|
var GeminiCliIgnore = class _GeminiCliIgnore extends ToolIgnore {
|
|
1947
2032
|
static getSettablePaths() {
|
|
1948
2033
|
return {
|
|
@@ -1969,7 +2054,7 @@ var GeminiCliIgnore = class _GeminiCliIgnore extends ToolIgnore {
|
|
|
1969
2054
|
validate = true
|
|
1970
2055
|
}) {
|
|
1971
2056
|
const fileContent = await readFileContent(
|
|
1972
|
-
|
|
2057
|
+
join18(
|
|
1973
2058
|
baseDir,
|
|
1974
2059
|
this.getSettablePaths().relativeDirPath,
|
|
1975
2060
|
this.getSettablePaths().relativeFilePath
|
|
@@ -1986,7 +2071,7 @@ var GeminiCliIgnore = class _GeminiCliIgnore extends ToolIgnore {
|
|
|
1986
2071
|
};
|
|
1987
2072
|
|
|
1988
2073
|
// src/ignore/junie-ignore.ts
|
|
1989
|
-
import { join as
|
|
2074
|
+
import { join as join19 } from "path";
|
|
1990
2075
|
var JunieIgnore = class _JunieIgnore extends ToolIgnore {
|
|
1991
2076
|
static getSettablePaths() {
|
|
1992
2077
|
return {
|
|
@@ -2013,7 +2098,7 @@ var JunieIgnore = class _JunieIgnore extends ToolIgnore {
|
|
|
2013
2098
|
validate = true
|
|
2014
2099
|
}) {
|
|
2015
2100
|
const fileContent = await readFileContent(
|
|
2016
|
-
|
|
2101
|
+
join19(
|
|
2017
2102
|
baseDir,
|
|
2018
2103
|
this.getSettablePaths().relativeDirPath,
|
|
2019
2104
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2030,7 +2115,7 @@ var JunieIgnore = class _JunieIgnore extends ToolIgnore {
|
|
|
2030
2115
|
};
|
|
2031
2116
|
|
|
2032
2117
|
// src/ignore/kiro-ignore.ts
|
|
2033
|
-
import { join as
|
|
2118
|
+
import { join as join20 } from "path";
|
|
2034
2119
|
var KiroIgnore = class _KiroIgnore extends ToolIgnore {
|
|
2035
2120
|
static getSettablePaths() {
|
|
2036
2121
|
return {
|
|
@@ -2057,7 +2142,7 @@ var KiroIgnore = class _KiroIgnore extends ToolIgnore {
|
|
|
2057
2142
|
validate = true
|
|
2058
2143
|
}) {
|
|
2059
2144
|
const fileContent = await readFileContent(
|
|
2060
|
-
|
|
2145
|
+
join20(
|
|
2061
2146
|
baseDir,
|
|
2062
2147
|
this.getSettablePaths().relativeDirPath,
|
|
2063
2148
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2074,7 +2159,7 @@ var KiroIgnore = class _KiroIgnore extends ToolIgnore {
|
|
|
2074
2159
|
};
|
|
2075
2160
|
|
|
2076
2161
|
// src/ignore/qwencode-ignore.ts
|
|
2077
|
-
import { join as
|
|
2162
|
+
import { join as join21 } from "path";
|
|
2078
2163
|
var QwencodeIgnore = class _QwencodeIgnore extends ToolIgnore {
|
|
2079
2164
|
static getSettablePaths() {
|
|
2080
2165
|
return {
|
|
@@ -2101,7 +2186,7 @@ var QwencodeIgnore = class _QwencodeIgnore extends ToolIgnore {
|
|
|
2101
2186
|
validate = true
|
|
2102
2187
|
}) {
|
|
2103
2188
|
const fileContent = await readFileContent(
|
|
2104
|
-
|
|
2189
|
+
join21(
|
|
2105
2190
|
baseDir,
|
|
2106
2191
|
this.getSettablePaths().relativeDirPath,
|
|
2107
2192
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2118,7 +2203,7 @@ var QwencodeIgnore = class _QwencodeIgnore extends ToolIgnore {
|
|
|
2118
2203
|
};
|
|
2119
2204
|
|
|
2120
2205
|
// src/ignore/roo-ignore.ts
|
|
2121
|
-
import { join as
|
|
2206
|
+
import { join as join22 } from "path";
|
|
2122
2207
|
var RooIgnore = class _RooIgnore extends ToolIgnore {
|
|
2123
2208
|
static getSettablePaths() {
|
|
2124
2209
|
return {
|
|
@@ -2145,7 +2230,7 @@ var RooIgnore = class _RooIgnore extends ToolIgnore {
|
|
|
2145
2230
|
validate = true
|
|
2146
2231
|
}) {
|
|
2147
2232
|
const fileContent = await readFileContent(
|
|
2148
|
-
|
|
2233
|
+
join22(
|
|
2149
2234
|
baseDir,
|
|
2150
2235
|
this.getSettablePaths().relativeDirPath,
|
|
2151
2236
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2162,7 +2247,7 @@ var RooIgnore = class _RooIgnore extends ToolIgnore {
|
|
|
2162
2247
|
};
|
|
2163
2248
|
|
|
2164
2249
|
// src/ignore/windsurf-ignore.ts
|
|
2165
|
-
import { join as
|
|
2250
|
+
import { join as join23 } from "path";
|
|
2166
2251
|
var WindsurfIgnore = class _WindsurfIgnore extends ToolIgnore {
|
|
2167
2252
|
static getSettablePaths() {
|
|
2168
2253
|
return {
|
|
@@ -2189,7 +2274,7 @@ var WindsurfIgnore = class _WindsurfIgnore extends ToolIgnore {
|
|
|
2189
2274
|
validate = true
|
|
2190
2275
|
}) {
|
|
2191
2276
|
const fileContent = await readFileContent(
|
|
2192
|
-
|
|
2277
|
+
join23(
|
|
2193
2278
|
baseDir,
|
|
2194
2279
|
this.getSettablePaths().relativeDirPath,
|
|
2195
2280
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2391,10 +2476,10 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
2391
2476
|
import { z as z11 } from "zod/mini";
|
|
2392
2477
|
|
|
2393
2478
|
// src/mcp/amazonqcli-mcp.ts
|
|
2394
|
-
import { join as
|
|
2479
|
+
import { join as join25 } from "path";
|
|
2395
2480
|
|
|
2396
2481
|
// src/mcp/rulesync-mcp.ts
|
|
2397
|
-
import { join as
|
|
2482
|
+
import { join as join24 } from "path";
|
|
2398
2483
|
import { z as z10 } from "zod/mini";
|
|
2399
2484
|
var McpTransportTypeSchema = z10.enum(["stdio", "sse", "http"]);
|
|
2400
2485
|
var McpServerBaseSchema = z10.object({
|
|
@@ -2445,7 +2530,7 @@ var RulesyncMcp = class _RulesyncMcp extends RulesyncFile {
|
|
|
2445
2530
|
}
|
|
2446
2531
|
static async fromFile({ validate = true }) {
|
|
2447
2532
|
const fileContent = await readFileContent(
|
|
2448
|
-
|
|
2533
|
+
join24(this.getSettablePaths().relativeDirPath, this.getSettablePaths().relativeFilePath)
|
|
2449
2534
|
);
|
|
2450
2535
|
return new _RulesyncMcp({
|
|
2451
2536
|
baseDir: ".",
|
|
@@ -2512,7 +2597,7 @@ var AmazonqcliMcp = class _AmazonqcliMcp extends ToolMcp {
|
|
|
2512
2597
|
validate = true
|
|
2513
2598
|
}) {
|
|
2514
2599
|
const fileContent = await readFileContent(
|
|
2515
|
-
|
|
2600
|
+
join25(
|
|
2516
2601
|
baseDir,
|
|
2517
2602
|
this.getSettablePaths().relativeDirPath,
|
|
2518
2603
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2548,7 +2633,7 @@ var AmazonqcliMcp = class _AmazonqcliMcp extends ToolMcp {
|
|
|
2548
2633
|
};
|
|
2549
2634
|
|
|
2550
2635
|
// src/mcp/claudecode-mcp.ts
|
|
2551
|
-
import { join as
|
|
2636
|
+
import { join as join26 } from "path";
|
|
2552
2637
|
var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
|
|
2553
2638
|
static getSettablePaths() {
|
|
2554
2639
|
return {
|
|
@@ -2561,7 +2646,7 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
|
|
|
2561
2646
|
validate = true
|
|
2562
2647
|
}) {
|
|
2563
2648
|
const fileContent = await readFileContent(
|
|
2564
|
-
|
|
2649
|
+
join26(
|
|
2565
2650
|
baseDir,
|
|
2566
2651
|
this.getSettablePaths().relativeDirPath,
|
|
2567
2652
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2597,7 +2682,7 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
|
|
|
2597
2682
|
};
|
|
2598
2683
|
|
|
2599
2684
|
// src/mcp/cline-mcp.ts
|
|
2600
|
-
import { join as
|
|
2685
|
+
import { join as join27 } from "path";
|
|
2601
2686
|
var ClineMcp = class _ClineMcp extends ToolMcp {
|
|
2602
2687
|
static getSettablePaths() {
|
|
2603
2688
|
return {
|
|
@@ -2610,7 +2695,7 @@ var ClineMcp = class _ClineMcp extends ToolMcp {
|
|
|
2610
2695
|
validate = true
|
|
2611
2696
|
}) {
|
|
2612
2697
|
const fileContent = await readFileContent(
|
|
2613
|
-
|
|
2698
|
+
join27(
|
|
2614
2699
|
baseDir,
|
|
2615
2700
|
this.getSettablePaths().relativeDirPath,
|
|
2616
2701
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2646,7 +2731,7 @@ var ClineMcp = class _ClineMcp extends ToolMcp {
|
|
|
2646
2731
|
};
|
|
2647
2732
|
|
|
2648
2733
|
// src/mcp/copilot-mcp.ts
|
|
2649
|
-
import { join as
|
|
2734
|
+
import { join as join28 } from "path";
|
|
2650
2735
|
var CopilotMcp = class _CopilotMcp extends ToolMcp {
|
|
2651
2736
|
static getSettablePaths() {
|
|
2652
2737
|
return {
|
|
@@ -2659,7 +2744,7 @@ var CopilotMcp = class _CopilotMcp extends ToolMcp {
|
|
|
2659
2744
|
validate = true
|
|
2660
2745
|
}) {
|
|
2661
2746
|
const fileContent = await readFileContent(
|
|
2662
|
-
|
|
2747
|
+
join28(
|
|
2663
2748
|
baseDir,
|
|
2664
2749
|
this.getSettablePaths().relativeDirPath,
|
|
2665
2750
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2695,7 +2780,7 @@ var CopilotMcp = class _CopilotMcp extends ToolMcp {
|
|
|
2695
2780
|
};
|
|
2696
2781
|
|
|
2697
2782
|
// src/mcp/cursor-mcp.ts
|
|
2698
|
-
import { join as
|
|
2783
|
+
import { join as join29 } from "path";
|
|
2699
2784
|
var CursorMcp = class _CursorMcp extends ToolMcp {
|
|
2700
2785
|
static getSettablePaths() {
|
|
2701
2786
|
return {
|
|
@@ -2708,7 +2793,7 @@ var CursorMcp = class _CursorMcp extends ToolMcp {
|
|
|
2708
2793
|
validate = true
|
|
2709
2794
|
}) {
|
|
2710
2795
|
const fileContent = await readFileContent(
|
|
2711
|
-
|
|
2796
|
+
join29(
|
|
2712
2797
|
baseDir,
|
|
2713
2798
|
this.getSettablePaths().relativeDirPath,
|
|
2714
2799
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2755,7 +2840,7 @@ var CursorMcp = class _CursorMcp extends ToolMcp {
|
|
|
2755
2840
|
};
|
|
2756
2841
|
|
|
2757
2842
|
// src/mcp/roo-mcp.ts
|
|
2758
|
-
import { join as
|
|
2843
|
+
import { join as join30 } from "path";
|
|
2759
2844
|
var RooMcp = class _RooMcp extends ToolMcp {
|
|
2760
2845
|
static getSettablePaths() {
|
|
2761
2846
|
return {
|
|
@@ -2768,7 +2853,7 @@ var RooMcp = class _RooMcp extends ToolMcp {
|
|
|
2768
2853
|
validate = true
|
|
2769
2854
|
}) {
|
|
2770
2855
|
const fileContent = await readFileContent(
|
|
2771
|
-
|
|
2856
|
+
join30(
|
|
2772
2857
|
baseDir,
|
|
2773
2858
|
this.getSettablePaths().relativeDirPath,
|
|
2774
2859
|
this.getSettablePaths().relativeFilePath
|
|
@@ -2975,12 +3060,12 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
2975
3060
|
};
|
|
2976
3061
|
|
|
2977
3062
|
// src/rules/rules-processor.ts
|
|
2978
|
-
import { basename as
|
|
3063
|
+
import { basename as basename17, join as join54 } from "path";
|
|
2979
3064
|
import { XMLBuilder } from "fast-xml-parser";
|
|
2980
3065
|
import { z as z20 } from "zod/mini";
|
|
2981
3066
|
|
|
2982
3067
|
// src/subagents/simulated-subagent.ts
|
|
2983
|
-
import { basename as
|
|
3068
|
+
import { basename as basename12, join as join31 } from "path";
|
|
2984
3069
|
import { z as z12 } from "zod/mini";
|
|
2985
3070
|
|
|
2986
3071
|
// src/subagents/tool-subagent.ts
|
|
@@ -3082,7 +3167,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
3082
3167
|
relativeFilePath,
|
|
3083
3168
|
validate = true
|
|
3084
3169
|
}) {
|
|
3085
|
-
const filePath =
|
|
3170
|
+
const filePath = join31(baseDir, this.getSettablePaths().relativeDirPath, relativeFilePath);
|
|
3086
3171
|
const fileContent = await readFileContent(filePath);
|
|
3087
3172
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
3088
3173
|
const result = SimulatedSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -3092,7 +3177,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
3092
3177
|
return {
|
|
3093
3178
|
baseDir,
|
|
3094
3179
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
3095
|
-
relativeFilePath:
|
|
3180
|
+
relativeFilePath: basename12(relativeFilePath),
|
|
3096
3181
|
frontmatter: result.data,
|
|
3097
3182
|
body: content.trim(),
|
|
3098
3183
|
validate
|
|
@@ -3100,6 +3185,29 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
3100
3185
|
}
|
|
3101
3186
|
};
|
|
3102
3187
|
|
|
3188
|
+
// src/subagents/agentsmd-subagent.ts
|
|
3189
|
+
var AgentsmdSubagent = class _AgentsmdSubagent extends SimulatedSubagent {
|
|
3190
|
+
static getSettablePaths() {
|
|
3191
|
+
return {
|
|
3192
|
+
relativeDirPath: ".agents/subagents"
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
static async fromFile(params) {
|
|
3196
|
+
const baseParams = await this.fromFileDefault(params);
|
|
3197
|
+
return new _AgentsmdSubagent(baseParams);
|
|
3198
|
+
}
|
|
3199
|
+
static fromRulesyncSubagent(params) {
|
|
3200
|
+
const baseParams = this.fromRulesyncSubagentDefault(params);
|
|
3201
|
+
return new _AgentsmdSubagent(baseParams);
|
|
3202
|
+
}
|
|
3203
|
+
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
3204
|
+
return this.isTargetedByRulesyncSubagentDefault({
|
|
3205
|
+
rulesyncSubagent,
|
|
3206
|
+
toolTarget: "agentsmd"
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
};
|
|
3210
|
+
|
|
3103
3211
|
// src/subagents/codexcli-subagent.ts
|
|
3104
3212
|
var CodexCliSubagent = class _CodexCliSubagent extends SimulatedSubagent {
|
|
3105
3213
|
static getSettablePaths() {
|
|
@@ -3216,15 +3324,15 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
3216
3324
|
};
|
|
3217
3325
|
|
|
3218
3326
|
// src/subagents/subagents-processor.ts
|
|
3219
|
-
import { basename as
|
|
3327
|
+
import { basename as basename14, join as join34 } from "path";
|
|
3220
3328
|
import { z as z15 } from "zod/mini";
|
|
3221
3329
|
|
|
3222
3330
|
// src/subagents/claudecode-subagent.ts
|
|
3223
|
-
import { join as
|
|
3331
|
+
import { join as join33 } from "path";
|
|
3224
3332
|
import { z as z14 } from "zod/mini";
|
|
3225
3333
|
|
|
3226
3334
|
// src/subagents/rulesync-subagent.ts
|
|
3227
|
-
import { basename as
|
|
3335
|
+
import { basename as basename13, join as join32 } from "path";
|
|
3228
3336
|
import { z as z13 } from "zod/mini";
|
|
3229
3337
|
var RulesyncSubagentModelSchema = z13.enum(["opus", "sonnet", "haiku", "inherit"]);
|
|
3230
3338
|
var RulesyncSubagentFrontmatterSchema = z13.object({
|
|
@@ -3278,13 +3386,13 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
3278
3386
|
static async fromFile({
|
|
3279
3387
|
relativeFilePath
|
|
3280
3388
|
}) {
|
|
3281
|
-
const fileContent = await readFileContent(
|
|
3389
|
+
const fileContent = await readFileContent(join32(".rulesync/subagents", relativeFilePath));
|
|
3282
3390
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
3283
3391
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
3284
3392
|
if (!result.success) {
|
|
3285
3393
|
throw new Error(`Invalid frontmatter in ${relativeFilePath}: ${result.error.message}`);
|
|
3286
3394
|
}
|
|
3287
|
-
const filename =
|
|
3395
|
+
const filename = basename13(relativeFilePath);
|
|
3288
3396
|
return new _RulesyncSubagent({
|
|
3289
3397
|
baseDir: ".",
|
|
3290
3398
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
@@ -3396,7 +3504,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
3396
3504
|
relativeFilePath,
|
|
3397
3505
|
validate = true
|
|
3398
3506
|
}) {
|
|
3399
|
-
const fileContent = await readFileContent(
|
|
3507
|
+
const fileContent = await readFileContent(join33(baseDir, ".claude/agents", relativeFilePath));
|
|
3400
3508
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
3401
3509
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
3402
3510
|
if (!result.success) {
|
|
@@ -3416,6 +3524,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
3416
3524
|
|
|
3417
3525
|
// src/subagents/subagents-processor.ts
|
|
3418
3526
|
var subagentsProcessorToolTargets = [
|
|
3527
|
+
"agentsmd",
|
|
3419
3528
|
"claudecode",
|
|
3420
3529
|
"copilot",
|
|
3421
3530
|
"cursor",
|
|
@@ -3424,6 +3533,7 @@ var subagentsProcessorToolTargets = [
|
|
|
3424
3533
|
"roo"
|
|
3425
3534
|
];
|
|
3426
3535
|
var subagentsProcessorToolTargetsSimulated = [
|
|
3536
|
+
"agentsmd",
|
|
3427
3537
|
"copilot",
|
|
3428
3538
|
"cursor",
|
|
3429
3539
|
"codexcli",
|
|
@@ -3446,6 +3556,15 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3446
3556
|
);
|
|
3447
3557
|
const toolSubagents = rulesyncSubagents.map((rulesyncSubagent) => {
|
|
3448
3558
|
switch (this.toolTarget) {
|
|
3559
|
+
case "agentsmd":
|
|
3560
|
+
if (!AgentsmdSubagent.isTargetedByRulesyncSubagent(rulesyncSubagent)) {
|
|
3561
|
+
return null;
|
|
3562
|
+
}
|
|
3563
|
+
return AgentsmdSubagent.fromRulesyncSubagent({
|
|
3564
|
+
baseDir: this.baseDir,
|
|
3565
|
+
relativeDirPath: RulesyncSubagent.getSettablePaths().relativeDirPath,
|
|
3566
|
+
rulesyncSubagent
|
|
3567
|
+
});
|
|
3449
3568
|
case "claudecode":
|
|
3450
3569
|
if (!ClaudecodeSubagent.isTargetedByRulesyncSubagent(rulesyncSubagent)) {
|
|
3451
3570
|
return null;
|
|
@@ -3527,7 +3646,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3527
3646
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
3528
3647
|
*/
|
|
3529
3648
|
async loadRulesyncFiles() {
|
|
3530
|
-
const subagentsDir =
|
|
3649
|
+
const subagentsDir = join34(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
3531
3650
|
const dirExists = await directoryExists(subagentsDir);
|
|
3532
3651
|
if (!dirExists) {
|
|
3533
3652
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -3542,7 +3661,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3542
3661
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
3543
3662
|
const rulesyncSubagents = [];
|
|
3544
3663
|
for (const mdFile of mdFiles) {
|
|
3545
|
-
const filepath =
|
|
3664
|
+
const filepath = join34(subagentsDir, mdFile);
|
|
3546
3665
|
try {
|
|
3547
3666
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
3548
3667
|
relativeFilePath: mdFile,
|
|
@@ -3568,6 +3687,8 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3568
3687
|
*/
|
|
3569
3688
|
async loadToolFiles() {
|
|
3570
3689
|
switch (this.toolTarget) {
|
|
3690
|
+
case "agentsmd":
|
|
3691
|
+
return await this.loadAgentsmdSubagents();
|
|
3571
3692
|
case "claudecode":
|
|
3572
3693
|
return await this.loadClaudecodeSubagents();
|
|
3573
3694
|
case "copilot":
|
|
@@ -3587,6 +3708,15 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3587
3708
|
async loadToolFilesToDelete() {
|
|
3588
3709
|
return this.loadToolFiles();
|
|
3589
3710
|
}
|
|
3711
|
+
/**
|
|
3712
|
+
* Load Agents.md subagent configurations from .agents/subagents/ directory
|
|
3713
|
+
*/
|
|
3714
|
+
async loadAgentsmdSubagents() {
|
|
3715
|
+
return await this.loadToolSubagentsDefault({
|
|
3716
|
+
relativeDirPath: AgentsmdSubagent.getSettablePaths().relativeDirPath,
|
|
3717
|
+
fromFile: (relativeFilePath) => AgentsmdSubagent.fromFile({ relativeFilePath })
|
|
3718
|
+
});
|
|
3719
|
+
}
|
|
3590
3720
|
/**
|
|
3591
3721
|
* Load Claude Code subagent configurations from .claude/agents/ directory
|
|
3592
3722
|
*/
|
|
@@ -3645,8 +3775,8 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3645
3775
|
relativeDirPath,
|
|
3646
3776
|
fromFile
|
|
3647
3777
|
}) {
|
|
3648
|
-
const paths = await findFilesByGlobs(
|
|
3649
|
-
const subagents = (await Promise.allSettled(paths.map((path2) => fromFile(
|
|
3778
|
+
const paths = await findFilesByGlobs(join34(this.baseDir, relativeDirPath, "*.md"));
|
|
3779
|
+
const subagents = (await Promise.allSettled(paths.map((path2) => fromFile(basename14(path2))))).filter((r) => r.status === "fulfilled").map((r) => r.value);
|
|
3650
3780
|
logger.info(`Successfully loaded ${subagents.length} ${relativeDirPath} subagents`);
|
|
3651
3781
|
return subagents;
|
|
3652
3782
|
}
|
|
@@ -3670,13 +3800,13 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
3670
3800
|
};
|
|
3671
3801
|
|
|
3672
3802
|
// src/rules/agentsmd-rule.ts
|
|
3673
|
-
import { join as
|
|
3803
|
+
import { join as join37 } from "path";
|
|
3674
3804
|
|
|
3675
3805
|
// src/rules/tool-rule.ts
|
|
3676
|
-
import { join as
|
|
3806
|
+
import { join as join36 } from "path";
|
|
3677
3807
|
|
|
3678
3808
|
// src/rules/rulesync-rule.ts
|
|
3679
|
-
import { basename as
|
|
3809
|
+
import { basename as basename15, join as join35 } from "path";
|
|
3680
3810
|
import { z as z16 } from "zod/mini";
|
|
3681
3811
|
var RulesyncRuleFrontmatterSchema = z16.object({
|
|
3682
3812
|
root: z16.optional(z16.optional(z16.boolean())),
|
|
@@ -3742,7 +3872,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
3742
3872
|
relativeFilePath,
|
|
3743
3873
|
validate = true
|
|
3744
3874
|
}) {
|
|
3745
|
-
const filePath =
|
|
3875
|
+
const filePath = join35(this.getSettablePaths().legacy.relativeDirPath, relativeFilePath);
|
|
3746
3876
|
const fileContent = await readFileContent(filePath);
|
|
3747
3877
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
3748
3878
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -3757,7 +3887,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
3757
3887
|
agentsmd: result.data.agentsmd,
|
|
3758
3888
|
cursor: result.data.cursor
|
|
3759
3889
|
};
|
|
3760
|
-
const filename =
|
|
3890
|
+
const filename = basename15(filePath);
|
|
3761
3891
|
return new _RulesyncRule({
|
|
3762
3892
|
baseDir: ".",
|
|
3763
3893
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -3771,7 +3901,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
3771
3901
|
relativeFilePath,
|
|
3772
3902
|
validate = true
|
|
3773
3903
|
}) {
|
|
3774
|
-
const filePath =
|
|
3904
|
+
const filePath = join35(this.getSettablePaths().recommended.relativeDirPath, relativeFilePath);
|
|
3775
3905
|
const fileContent = await readFileContent(filePath);
|
|
3776
3906
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
3777
3907
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -3786,7 +3916,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
3786
3916
|
agentsmd: result.data.agentsmd,
|
|
3787
3917
|
cursor: result.data.cursor
|
|
3788
3918
|
};
|
|
3789
|
-
const filename =
|
|
3919
|
+
const filename = basename15(filePath);
|
|
3790
3920
|
return new _RulesyncRule({
|
|
3791
3921
|
baseDir: ".",
|
|
3792
3922
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -3875,7 +4005,7 @@ var ToolRule = class extends ToolFile {
|
|
|
3875
4005
|
});
|
|
3876
4006
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
3877
4007
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
3878
|
-
params.relativeDirPath =
|
|
4008
|
+
params.relativeDirPath = join36(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
3879
4009
|
params.relativeFilePath = "AGENTS.md";
|
|
3880
4010
|
}
|
|
3881
4011
|
return params;
|
|
@@ -3951,8 +4081,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
3951
4081
|
validate = true
|
|
3952
4082
|
}) {
|
|
3953
4083
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
3954
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
3955
|
-
const fileContent = await readFileContent(
|
|
4084
|
+
const relativePath = isRoot ? "AGENTS.md" : join37(".agents/memories", relativeFilePath);
|
|
4085
|
+
const fileContent = await readFileContent(join37(baseDir, relativePath));
|
|
3956
4086
|
return new _AgentsMdRule({
|
|
3957
4087
|
baseDir,
|
|
3958
4088
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -3992,7 +4122,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
3992
4122
|
};
|
|
3993
4123
|
|
|
3994
4124
|
// src/rules/amazonqcli-rule.ts
|
|
3995
|
-
import { join as
|
|
4125
|
+
import { join as join38 } from "path";
|
|
3996
4126
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
3997
4127
|
static getSettablePaths() {
|
|
3998
4128
|
return {
|
|
@@ -4007,7 +4137,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
4007
4137
|
validate = true
|
|
4008
4138
|
}) {
|
|
4009
4139
|
const fileContent = await readFileContent(
|
|
4010
|
-
|
|
4140
|
+
join38(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
4011
4141
|
);
|
|
4012
4142
|
return new _AmazonQCliRule({
|
|
4013
4143
|
baseDir,
|
|
@@ -4047,7 +4177,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
4047
4177
|
};
|
|
4048
4178
|
|
|
4049
4179
|
// src/rules/augmentcode-legacy-rule.ts
|
|
4050
|
-
import { join as
|
|
4180
|
+
import { join as join39 } from "path";
|
|
4051
4181
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
4052
4182
|
toRulesyncRule() {
|
|
4053
4183
|
const rulesyncFrontmatter = {
|
|
@@ -4108,8 +4238,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
4108
4238
|
}) {
|
|
4109
4239
|
const settablePaths = this.getSettablePaths();
|
|
4110
4240
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
4111
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath :
|
|
4112
|
-
const fileContent = await readFileContent(
|
|
4241
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : join39(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
4242
|
+
const fileContent = await readFileContent(join39(baseDir, relativePath));
|
|
4113
4243
|
return new _AugmentcodeLegacyRule({
|
|
4114
4244
|
baseDir,
|
|
4115
4245
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -4122,7 +4252,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
4122
4252
|
};
|
|
4123
4253
|
|
|
4124
4254
|
// src/rules/augmentcode-rule.ts
|
|
4125
|
-
import { join as
|
|
4255
|
+
import { join as join40 } from "path";
|
|
4126
4256
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
4127
4257
|
toRulesyncRule() {
|
|
4128
4258
|
return this.toRulesyncRuleDefault();
|
|
@@ -4154,7 +4284,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
4154
4284
|
validate = true
|
|
4155
4285
|
}) {
|
|
4156
4286
|
const fileContent = await readFileContent(
|
|
4157
|
-
|
|
4287
|
+
join40(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
4158
4288
|
);
|
|
4159
4289
|
const { body: content } = parseFrontmatter(fileContent);
|
|
4160
4290
|
return new _AugmentcodeRule({
|
|
@@ -4177,7 +4307,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
4177
4307
|
};
|
|
4178
4308
|
|
|
4179
4309
|
// src/rules/claudecode-rule.ts
|
|
4180
|
-
import { join as
|
|
4310
|
+
import { join as join41 } from "path";
|
|
4181
4311
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
4182
4312
|
static getSettablePaths() {
|
|
4183
4313
|
return {
|
|
@@ -4186,7 +4316,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
4186
4316
|
relativeFilePath: "CLAUDE.md"
|
|
4187
4317
|
},
|
|
4188
4318
|
nonRoot: {
|
|
4189
|
-
relativeDirPath:
|
|
4319
|
+
relativeDirPath: join41(".claude", "memories")
|
|
4190
4320
|
}
|
|
4191
4321
|
};
|
|
4192
4322
|
}
|
|
@@ -4209,7 +4339,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
4209
4339
|
if (isRoot) {
|
|
4210
4340
|
const relativePath2 = paths.root.relativeFilePath;
|
|
4211
4341
|
const fileContent2 = await readFileContent(
|
|
4212
|
-
|
|
4342
|
+
join41(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
4213
4343
|
);
|
|
4214
4344
|
return new _ClaudecodeRule({
|
|
4215
4345
|
baseDir,
|
|
@@ -4223,8 +4353,8 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
4223
4353
|
if (!paths.nonRoot) {
|
|
4224
4354
|
throw new Error("nonRoot path is not set");
|
|
4225
4355
|
}
|
|
4226
|
-
const relativePath =
|
|
4227
|
-
const fileContent = await readFileContent(
|
|
4356
|
+
const relativePath = join41(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
4357
|
+
const fileContent = await readFileContent(join41(baseDir, relativePath));
|
|
4228
4358
|
return new _ClaudecodeRule({
|
|
4229
4359
|
baseDir,
|
|
4230
4360
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -4266,7 +4396,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
4266
4396
|
};
|
|
4267
4397
|
|
|
4268
4398
|
// src/rules/cline-rule.ts
|
|
4269
|
-
import { join as
|
|
4399
|
+
import { join as join42 } from "path";
|
|
4270
4400
|
import { z as z17 } from "zod/mini";
|
|
4271
4401
|
var ClineRuleFrontmatterSchema = z17.object({
|
|
4272
4402
|
description: z17.string()
|
|
@@ -4311,7 +4441,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
4311
4441
|
validate = true
|
|
4312
4442
|
}) {
|
|
4313
4443
|
const fileContent = await readFileContent(
|
|
4314
|
-
|
|
4444
|
+
join42(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
4315
4445
|
);
|
|
4316
4446
|
return new _ClineRule({
|
|
4317
4447
|
baseDir,
|
|
@@ -4324,7 +4454,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
4324
4454
|
};
|
|
4325
4455
|
|
|
4326
4456
|
// src/rules/codexcli-rule.ts
|
|
4327
|
-
import { join as
|
|
4457
|
+
import { join as join43 } from "path";
|
|
4328
4458
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
4329
4459
|
static getSettablePaths() {
|
|
4330
4460
|
return {
|
|
@@ -4356,7 +4486,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
4356
4486
|
if (isRoot) {
|
|
4357
4487
|
const relativePath2 = paths.root.relativeFilePath;
|
|
4358
4488
|
const fileContent2 = await readFileContent(
|
|
4359
|
-
|
|
4489
|
+
join43(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
4360
4490
|
);
|
|
4361
4491
|
return new _CodexcliRule({
|
|
4362
4492
|
baseDir,
|
|
@@ -4370,8 +4500,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
4370
4500
|
if (!paths.nonRoot) {
|
|
4371
4501
|
throw new Error("nonRoot path is not set");
|
|
4372
4502
|
}
|
|
4373
|
-
const relativePath =
|
|
4374
|
-
const fileContent = await readFileContent(
|
|
4503
|
+
const relativePath = join43(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
4504
|
+
const fileContent = await readFileContent(join43(baseDir, relativePath));
|
|
4375
4505
|
return new _CodexcliRule({
|
|
4376
4506
|
baseDir,
|
|
4377
4507
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -4413,7 +4543,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
4413
4543
|
};
|
|
4414
4544
|
|
|
4415
4545
|
// src/rules/copilot-rule.ts
|
|
4416
|
-
import { join as
|
|
4546
|
+
import { join as join44 } from "path";
|
|
4417
4547
|
import { z as z18 } from "zod/mini";
|
|
4418
4548
|
var CopilotRuleFrontmatterSchema = z18.object({
|
|
4419
4549
|
description: z18.optional(z18.string()),
|
|
@@ -4506,11 +4636,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
4506
4636
|
validate = true
|
|
4507
4637
|
}) {
|
|
4508
4638
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
4509
|
-
const relativePath = isRoot ?
|
|
4639
|
+
const relativePath = isRoot ? join44(
|
|
4510
4640
|
this.getSettablePaths().root.relativeDirPath,
|
|
4511
4641
|
this.getSettablePaths().root.relativeFilePath
|
|
4512
|
-
) :
|
|
4513
|
-
const fileContent = await readFileContent(
|
|
4642
|
+
) : join44(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
4643
|
+
const fileContent = await readFileContent(join44(baseDir, relativePath));
|
|
4514
4644
|
if (isRoot) {
|
|
4515
4645
|
return new _CopilotRule({
|
|
4516
4646
|
baseDir,
|
|
@@ -4529,7 +4659,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
4529
4659
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
4530
4660
|
if (!result.success) {
|
|
4531
4661
|
throw new Error(
|
|
4532
|
-
`Invalid frontmatter in ${
|
|
4662
|
+
`Invalid frontmatter in ${join44(baseDir, relativeFilePath)}: ${result.error.message}`
|
|
4533
4663
|
);
|
|
4534
4664
|
}
|
|
4535
4665
|
return new _CopilotRule({
|
|
@@ -4568,7 +4698,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
4568
4698
|
};
|
|
4569
4699
|
|
|
4570
4700
|
// src/rules/cursor-rule.ts
|
|
4571
|
-
import { basename as
|
|
4701
|
+
import { basename as basename16, join as join45 } from "path";
|
|
4572
4702
|
import { z as z19 } from "zod/mini";
|
|
4573
4703
|
var CursorRuleFrontmatterSchema = z19.object({
|
|
4574
4704
|
description: z19.optional(z19.string()),
|
|
@@ -4695,19 +4825,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
4695
4825
|
validate = true
|
|
4696
4826
|
}) {
|
|
4697
4827
|
const fileContent = await readFileContent(
|
|
4698
|
-
|
|
4828
|
+
join45(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
4699
4829
|
);
|
|
4700
4830
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
4701
4831
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
4702
4832
|
if (!result.success) {
|
|
4703
4833
|
throw new Error(
|
|
4704
|
-
`Invalid frontmatter in ${
|
|
4834
|
+
`Invalid frontmatter in ${join45(baseDir, relativeFilePath)}: ${result.error.message}`
|
|
4705
4835
|
);
|
|
4706
4836
|
}
|
|
4707
4837
|
return new _CursorRule({
|
|
4708
4838
|
baseDir,
|
|
4709
4839
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
4710
|
-
relativeFilePath:
|
|
4840
|
+
relativeFilePath: basename16(relativeFilePath),
|
|
4711
4841
|
frontmatter: result.data,
|
|
4712
4842
|
body: content.trim(),
|
|
4713
4843
|
validate
|
|
@@ -4739,7 +4869,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
4739
4869
|
};
|
|
4740
4870
|
|
|
4741
4871
|
// src/rules/geminicli-rule.ts
|
|
4742
|
-
import { join as
|
|
4872
|
+
import { join as join46 } from "path";
|
|
4743
4873
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
4744
4874
|
static getSettablePaths() {
|
|
4745
4875
|
return {
|
|
@@ -4771,7 +4901,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
4771
4901
|
if (isRoot) {
|
|
4772
4902
|
const relativePath2 = paths.root.relativeFilePath;
|
|
4773
4903
|
const fileContent2 = await readFileContent(
|
|
4774
|
-
|
|
4904
|
+
join46(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
4775
4905
|
);
|
|
4776
4906
|
return new _GeminiCliRule({
|
|
4777
4907
|
baseDir,
|
|
@@ -4785,8 +4915,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
4785
4915
|
if (!paths.nonRoot) {
|
|
4786
4916
|
throw new Error("nonRoot path is not set");
|
|
4787
4917
|
}
|
|
4788
|
-
const relativePath =
|
|
4789
|
-
const fileContent = await readFileContent(
|
|
4918
|
+
const relativePath = join46(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
4919
|
+
const fileContent = await readFileContent(join46(baseDir, relativePath));
|
|
4790
4920
|
return new _GeminiCliRule({
|
|
4791
4921
|
baseDir,
|
|
4792
4922
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -4828,7 +4958,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
4828
4958
|
};
|
|
4829
4959
|
|
|
4830
4960
|
// src/rules/junie-rule.ts
|
|
4831
|
-
import { join as
|
|
4961
|
+
import { join as join47 } from "path";
|
|
4832
4962
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
4833
4963
|
static getSettablePaths() {
|
|
4834
4964
|
return {
|
|
@@ -4847,8 +4977,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
4847
4977
|
validate = true
|
|
4848
4978
|
}) {
|
|
4849
4979
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
4850
|
-
const relativePath = isRoot ? "guidelines.md" :
|
|
4851
|
-
const fileContent = await readFileContent(
|
|
4980
|
+
const relativePath = isRoot ? "guidelines.md" : join47(".junie/memories", relativeFilePath);
|
|
4981
|
+
const fileContent = await readFileContent(join47(baseDir, relativePath));
|
|
4852
4982
|
return new _JunieRule({
|
|
4853
4983
|
baseDir,
|
|
4854
4984
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -4888,7 +5018,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
4888
5018
|
};
|
|
4889
5019
|
|
|
4890
5020
|
// src/rules/kiro-rule.ts
|
|
4891
|
-
import { join as
|
|
5021
|
+
import { join as join48 } from "path";
|
|
4892
5022
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
4893
5023
|
static getSettablePaths() {
|
|
4894
5024
|
return {
|
|
@@ -4903,7 +5033,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
4903
5033
|
validate = true
|
|
4904
5034
|
}) {
|
|
4905
5035
|
const fileContent = await readFileContent(
|
|
4906
|
-
|
|
5036
|
+
join48(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
4907
5037
|
);
|
|
4908
5038
|
return new _KiroRule({
|
|
4909
5039
|
baseDir,
|
|
@@ -4943,7 +5073,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
4943
5073
|
};
|
|
4944
5074
|
|
|
4945
5075
|
// src/rules/opencode-rule.ts
|
|
4946
|
-
import { join as
|
|
5076
|
+
import { join as join49 } from "path";
|
|
4947
5077
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
4948
5078
|
static getSettablePaths() {
|
|
4949
5079
|
return {
|
|
@@ -4962,8 +5092,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
4962
5092
|
validate = true
|
|
4963
5093
|
}) {
|
|
4964
5094
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
4965
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
4966
|
-
const fileContent = await readFileContent(
|
|
5095
|
+
const relativePath = isRoot ? "AGENTS.md" : join49(".opencode/memories", relativeFilePath);
|
|
5096
|
+
const fileContent = await readFileContent(join49(baseDir, relativePath));
|
|
4967
5097
|
return new _OpenCodeRule({
|
|
4968
5098
|
baseDir,
|
|
4969
5099
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -5003,7 +5133,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
5003
5133
|
};
|
|
5004
5134
|
|
|
5005
5135
|
// src/rules/qwencode-rule.ts
|
|
5006
|
-
import { join as
|
|
5136
|
+
import { join as join50 } from "path";
|
|
5007
5137
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
5008
5138
|
static getSettablePaths() {
|
|
5009
5139
|
return {
|
|
@@ -5022,8 +5152,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
5022
5152
|
validate = true
|
|
5023
5153
|
}) {
|
|
5024
5154
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
5025
|
-
const relativePath = isRoot ? "QWEN.md" :
|
|
5026
|
-
const fileContent = await readFileContent(
|
|
5155
|
+
const relativePath = isRoot ? "QWEN.md" : join50(".qwen/memories", relativeFilePath);
|
|
5156
|
+
const fileContent = await readFileContent(join50(baseDir, relativePath));
|
|
5027
5157
|
return new _QwencodeRule({
|
|
5028
5158
|
baseDir,
|
|
5029
5159
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -5060,7 +5190,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
5060
5190
|
};
|
|
5061
5191
|
|
|
5062
5192
|
// src/rules/roo-rule.ts
|
|
5063
|
-
import { join as
|
|
5193
|
+
import { join as join51 } from "path";
|
|
5064
5194
|
var RooRule = class _RooRule extends ToolRule {
|
|
5065
5195
|
static getSettablePaths() {
|
|
5066
5196
|
return {
|
|
@@ -5075,7 +5205,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
5075
5205
|
validate = true
|
|
5076
5206
|
}) {
|
|
5077
5207
|
const fileContent = await readFileContent(
|
|
5078
|
-
|
|
5208
|
+
join51(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
5079
5209
|
);
|
|
5080
5210
|
return new _RooRule({
|
|
5081
5211
|
baseDir,
|
|
@@ -5130,7 +5260,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
5130
5260
|
};
|
|
5131
5261
|
|
|
5132
5262
|
// src/rules/warp-rule.ts
|
|
5133
|
-
import { join as
|
|
5263
|
+
import { join as join52 } from "path";
|
|
5134
5264
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
5135
5265
|
constructor({ fileContent, root, ...rest }) {
|
|
5136
5266
|
super({
|
|
@@ -5156,8 +5286,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
5156
5286
|
validate = true
|
|
5157
5287
|
}) {
|
|
5158
5288
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
5159
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath :
|
|
5160
|
-
const fileContent = await readFileContent(
|
|
5289
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : join52(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
5290
|
+
const fileContent = await readFileContent(join52(baseDir, relativePath));
|
|
5161
5291
|
return new _WarpRule({
|
|
5162
5292
|
baseDir,
|
|
5163
5293
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -5197,7 +5327,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
5197
5327
|
};
|
|
5198
5328
|
|
|
5199
5329
|
// src/rules/windsurf-rule.ts
|
|
5200
|
-
import { join as
|
|
5330
|
+
import { join as join53 } from "path";
|
|
5201
5331
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
5202
5332
|
static getSettablePaths() {
|
|
5203
5333
|
return {
|
|
@@ -5212,7 +5342,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
5212
5342
|
validate = true
|
|
5213
5343
|
}) {
|
|
5214
5344
|
const fileContent = await readFileContent(
|
|
5215
|
-
|
|
5345
|
+
join53(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
5216
5346
|
);
|
|
5217
5347
|
return new _WindsurfRule({
|
|
5218
5348
|
baseDir,
|
|
@@ -5504,7 +5634,12 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
5504
5634
|
case "agentsmd": {
|
|
5505
5635
|
const rootRule = toolRules[rootRuleIndex];
|
|
5506
5636
|
rootRule?.setFileContent(
|
|
5507
|
-
this.generateXmlReferencesSection(toolRules) +
|
|
5637
|
+
this.generateXmlReferencesSection(toolRules) + this.generateAdditionalConventionsSection({
|
|
5638
|
+
commands: { relativeDirPath: AgentsmdCommand.getSettablePaths().relativeDirPath },
|
|
5639
|
+
subagents: {
|
|
5640
|
+
relativeDirPath: AgentsmdSubagent.getSettablePaths().relativeDirPath
|
|
5641
|
+
}
|
|
5642
|
+
}) + rootRule.getFileContent()
|
|
5508
5643
|
);
|
|
5509
5644
|
return toolRules;
|
|
5510
5645
|
}
|
|
@@ -5601,10 +5736,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
5601
5736
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
5602
5737
|
*/
|
|
5603
5738
|
async loadRulesyncFiles() {
|
|
5604
|
-
const files = await findFilesByGlobs(
|
|
5739
|
+
const files = await findFilesByGlobs(join54(".rulesync/rules", "*.md"));
|
|
5605
5740
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
5606
5741
|
const rulesyncRules = await Promise.all(
|
|
5607
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath:
|
|
5742
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: basename17(file) }))
|
|
5608
5743
|
);
|
|
5609
5744
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
5610
5745
|
if (rootRules.length > 1) {
|
|
@@ -5622,10 +5757,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
5622
5757
|
return rulesyncRules;
|
|
5623
5758
|
}
|
|
5624
5759
|
async loadRulesyncFilesLegacy() {
|
|
5625
|
-
const legacyFiles = await findFilesByGlobs(
|
|
5760
|
+
const legacyFiles = await findFilesByGlobs(join54(".rulesync", "*.md"));
|
|
5626
5761
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
5627
5762
|
return Promise.all(
|
|
5628
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath:
|
|
5763
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: basename17(file) }))
|
|
5629
5764
|
);
|
|
5630
5765
|
}
|
|
5631
5766
|
/**
|
|
@@ -5689,13 +5824,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
5689
5824
|
return [];
|
|
5690
5825
|
}
|
|
5691
5826
|
const rootFilePaths = await findFilesByGlobs(
|
|
5692
|
-
|
|
5827
|
+
join54(this.baseDir, root.relativeDirPath ?? ".", root.relativeFilePath)
|
|
5693
5828
|
);
|
|
5694
5829
|
return await Promise.all(
|
|
5695
5830
|
rootFilePaths.map(
|
|
5696
5831
|
(filePath) => root.fromFile({
|
|
5697
5832
|
baseDir: this.baseDir,
|
|
5698
|
-
relativeFilePath:
|
|
5833
|
+
relativeFilePath: basename17(filePath),
|
|
5699
5834
|
global: this.global
|
|
5700
5835
|
})
|
|
5701
5836
|
)
|
|
@@ -5707,13 +5842,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
5707
5842
|
return [];
|
|
5708
5843
|
}
|
|
5709
5844
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
5710
|
-
|
|
5845
|
+
join54(this.baseDir, nonRoot.relativeDirPath, `*.${nonRoot.extension}`)
|
|
5711
5846
|
);
|
|
5712
5847
|
return await Promise.all(
|
|
5713
5848
|
nonRootFilePaths.map(
|
|
5714
5849
|
(filePath) => nonRoot.fromFile({
|
|
5715
5850
|
baseDir: this.baseDir,
|
|
5716
|
-
relativeFilePath:
|
|
5851
|
+
relativeFilePath: basename17(filePath),
|
|
5717
5852
|
global: this.global
|
|
5718
5853
|
})
|
|
5719
5854
|
)
|
|
@@ -6083,14 +6218,14 @@ s/<command> [arguments]
|
|
|
6083
6218
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
6084
6219
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
6085
6220
|
|
|
6086
|
-
When users call a custom slash command, you have to look for the markdown file, \`${
|
|
6221
|
+
When users call a custom slash command, you have to look for the markdown file, \`${join54(commands.relativeDirPath, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
6087
6222
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
6088
6223
|
|
|
6089
6224
|
Simulated subagents are specialized AI assistants that can be invoked to handle specific types of tasks. In this case, it can be appear something like custom slash commands simply. Simulated subagents can be called by custom slash commands.
|
|
6090
6225
|
|
|
6091
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${
|
|
6226
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${join54(subagents.relativeDirPath, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
6092
6227
|
|
|
6093
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${
|
|
6228
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${join54(subagents.relativeDirPath, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
6094
6229
|
const result = [
|
|
6095
6230
|
overview,
|
|
6096
6231
|
...this.simulateCommands && CommandsProcessor.getToolTargetsSimulated().includes(this.toolTarget) ? [commandsSection] : [],
|
|
@@ -6315,9 +6450,9 @@ async function generateSubagents(config) {
|
|
|
6315
6450
|
}
|
|
6316
6451
|
|
|
6317
6452
|
// src/cli/commands/gitignore.ts
|
|
6318
|
-
import { join as
|
|
6453
|
+
import { join as join55 } from "path";
|
|
6319
6454
|
var gitignoreCommand = async () => {
|
|
6320
|
-
const gitignorePath =
|
|
6455
|
+
const gitignorePath = join55(process.cwd(), ".gitignore");
|
|
6321
6456
|
const rulesFilesToIgnore = [
|
|
6322
6457
|
"# Generated by rulesync - AI tool configuration files",
|
|
6323
6458
|
"**/.amazonq/",
|
|
@@ -6554,7 +6689,7 @@ async function importSubagents(config, tool) {
|
|
|
6554
6689
|
}
|
|
6555
6690
|
|
|
6556
6691
|
// src/cli/commands/init.ts
|
|
6557
|
-
import { join as
|
|
6692
|
+
import { join as join56 } from "path";
|
|
6558
6693
|
async function initCommand() {
|
|
6559
6694
|
logger.info("Initializing rulesync...");
|
|
6560
6695
|
await ensureDir(".rulesync");
|
|
@@ -6625,7 +6760,7 @@ globs: ["**/*"]
|
|
|
6625
6760
|
- Follow single responsibility principle
|
|
6626
6761
|
`
|
|
6627
6762
|
};
|
|
6628
|
-
const filepath =
|
|
6763
|
+
const filepath = join56(".rulesync/rules", sampleFile.filename);
|
|
6629
6764
|
await ensureDir(".rulesync/rules");
|
|
6630
6765
|
await ensureDir(RulesyncCommand.getSettablePaths().relativeDirPath);
|
|
6631
6766
|
await ensureDir(".rulesync/subagents");
|
|
@@ -6638,7 +6773,7 @@ globs: ["**/*"]
|
|
|
6638
6773
|
}
|
|
6639
6774
|
|
|
6640
6775
|
// src/cli/index.ts
|
|
6641
|
-
var getVersion = () => "3.
|
|
6776
|
+
var getVersion = () => "3.1.1";
|
|
6642
6777
|
var main = async () => {
|
|
6643
6778
|
const program = new Command();
|
|
6644
6779
|
const version = getVersion();
|