compose-agentsmd 3.2.0 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,7 @@ compose-agentsmd
33
33
  The tool reads `agent-ruleset.json` from the given root directory (default: current working directory), and writes the output file specified by the ruleset. If `output` is omitted, it defaults to `AGENTS.md`.
34
34
 
35
35
  The tool prepends a small "Tool Rules" block to every generated `AGENTS.md` so agents know how to regenerate or update rules.
36
+ Each composed rule section is also prefixed with the source file path that produced it.
36
37
 
37
38
  ## Setup (init)
38
39
 
@@ -506,12 +506,27 @@ const resolveRulesRoot = (rulesetDir, source, refresh) => {
506
506
  }
507
507
  return { rulesRoot: resolveLocalRulesRoot(rulesetDir, source) };
508
508
  };
509
+ const formatRuleSourcePath = (rulePath, rulesRoot, rulesetDir, source, resolvedRef) => {
510
+ // Check if this rule is from the resolved rulesRoot (GitHub or local source)
511
+ const isFromSource = rulePath.startsWith(rulesRoot);
512
+ if (isFromSource && source.startsWith("github:")) {
513
+ // GitHub source rule
514
+ const parsed = parseGithubSource(source);
515
+ const cacheRepoRoot = path.dirname(rulesRoot);
516
+ const relativePath = normalizePath(path.relative(cacheRepoRoot, rulePath));
517
+ const refToUse = resolvedRef ?? parsed.ref;
518
+ return `github:${parsed.owner}/${parsed.repo}@${refToUse}/${relativePath}`;
519
+ }
520
+ // For local rules (either from local source or extra), use path relative to project root
521
+ const result = normalizePath(path.relative(rulesetDir, rulePath));
522
+ return result;
523
+ };
509
524
  const composeRuleset = (rulesetPath, rootDir, options) => {
510
525
  const rulesetDir = path.dirname(rulesetPath);
511
526
  const projectRuleset = readProjectRuleset(rulesetPath);
512
527
  const outputFileName = projectRuleset.output ?? DEFAULT_OUTPUT;
513
528
  const outputPath = resolveFrom(rulesetDir, outputFileName);
514
- const { rulesRoot } = resolveRulesRoot(rulesetDir, projectRuleset.source, options.refresh ?? false);
529
+ const { rulesRoot, resolvedRef } = resolveRulesRoot(rulesetDir, projectRuleset.source, options.refresh ?? false);
515
530
  const globalRoot = path.join(rulesRoot, "global");
516
531
  const domainsRoot = path.join(rulesRoot, "domains");
517
532
  const resolvedRules = [];
@@ -527,7 +542,11 @@ const composeRuleset = (rulesetPath, rootDir, options) => {
527
542
  const extraRules = Array.isArray(projectRuleset.extra) ? projectRuleset.extra : [];
528
543
  const directRulePaths = extraRules.map((rulePath) => resolveFrom(rulesetDir, rulePath));
529
544
  addRulePaths(directRulePaths, resolvedRules, seenRules);
530
- const parts = resolvedRules.map((rulePath) => normalizeTrailingWhitespace(fs.readFileSync(rulePath, "utf8")));
545
+ const parts = resolvedRules.map((rulePath) => {
546
+ const body = normalizeTrailingWhitespace(fs.readFileSync(rulePath, "utf8"));
547
+ const sourcePath = formatRuleSourcePath(rulePath, rulesRoot, rulesetDir, projectRuleset.source, resolvedRef);
548
+ return `Source: ${sourcePath}\n\n${body}`;
549
+ });
531
550
  const lintHeader = "<!-- markdownlint-disable MD025 -->";
532
551
  const toolRules = normalizeTrailingWhitespace(TOOL_RULES);
533
552
  const output = `${lintHeader}\n${[toolRules, ...parts].join("\n\n")}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compose-agentsmd",
3
- "version": "3.2.0",
3
+ "version": "3.2.3",
4
4
  "description": "CLI tools for composing per-project AGENTS.md files from modular rule sets",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,7 +44,7 @@
44
44
  "node": ">=20"
45
45
  },
46
46
  "devDependencies": {
47
- "@types/node": "^25.0.10",
47
+ "@types/node": "^25.1.0",
48
48
  "typescript": "^5.7.3"
49
49
  },
50
50
  "dependencies": {
@@ -2,4 +2,7 @@
2
2
  - Before starting any work, run `compose-agentsmd` from the project root.
3
3
  - To update shared rules, run `compose-agentsmd edit-rules`, edit the workspace rules, then run `compose-agentsmd apply-rules`.
4
4
  - Do not edit `AGENTS.md` directly; update the source rules and regenerate.
5
- - When updating rules, include a detailed summary of what changed (added/removed/modified items) in the final response.
5
+ - These tool rules live in tools/tool-rules.md in the compose-agentsmd repository; do not duplicate them in global rule modules.
6
+ - When updating rules, include a colorized diff-style summary in the final response. Use `git diff --stat` first, then include the raw ANSI-colored output of `git diff --color=always` (no sanitizing or reformatting), and limit the output to the rule files that changed.
7
+ - Also provide a short, copy-pasteable command the user can run to view the diff in the same format. Use absolute paths so it works regardless of the current working directory, and scope it to the changed rule files.
8
+ - If a diff is provided, a separate detailed summary is not required. If a diff is not possible, include a detailed summary of what changed (added/removed/modified items).