renma 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/README.md +11 -1
  3. package/architecture.md +14 -4
  4. package/design.md +13 -2
  5. package/dist/agent-skills.d.ts +1 -1
  6. package/dist/agent-skills.d.ts.map +1 -1
  7. package/dist/agent-skills.js +28 -8
  8. package/dist/agent-skills.js.map +1 -1
  9. package/dist/catalog.d.ts +1 -1
  10. package/dist/catalog.d.ts.map +1 -1
  11. package/dist/catalog.js +120 -12
  12. package/dist/catalog.js.map +1 -1
  13. package/dist/cli-help.d.ts +9 -5
  14. package/dist/cli-help.d.ts.map +1 -1
  15. package/dist/cli-help.js +9 -0
  16. package/dist/cli-help.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +23 -0
  19. package/dist/cli.js.map +1 -1
  20. package/dist/commands/bom.d.ts +6 -3
  21. package/dist/commands/bom.d.ts.map +1 -1
  22. package/dist/commands/bom.js +27 -7
  23. package/dist/commands/bom.js.map +1 -1
  24. package/dist/commands/catalog.d.ts +1 -1
  25. package/dist/commands/catalog.d.ts.map +1 -1
  26. package/dist/commands/catalog.js +7 -1
  27. package/dist/commands/catalog.js.map +1 -1
  28. package/dist/commands/ci-report.d.ts.map +1 -1
  29. package/dist/commands/ci-report.js +18 -5
  30. package/dist/commands/ci-report.js.map +1 -1
  31. package/dist/commands/diff.js +8 -2
  32. package/dist/commands/diff.js.map +1 -1
  33. package/dist/commands/graph.d.ts +6 -2
  34. package/dist/commands/graph.d.ts.map +1 -1
  35. package/dist/commands/graph.js +23 -2
  36. package/dist/commands/graph.js.map +1 -1
  37. package/dist/commands/inspect.d.ts.map +1 -1
  38. package/dist/commands/inspect.js +2 -0
  39. package/dist/commands/inspect.js.map +1 -1
  40. package/dist/commands/ownership.d.ts +4 -3
  41. package/dist/commands/ownership.d.ts.map +1 -1
  42. package/dist/commands/ownership.js +27 -23
  43. package/dist/commands/ownership.js.map +1 -1
  44. package/dist/commands/readiness.d.ts +2 -1
  45. package/dist/commands/readiness.d.ts.map +1 -1
  46. package/dist/commands/readiness.js +98 -30
  47. package/dist/commands/readiness.js.map +1 -1
  48. package/dist/commands/scaffold.d.ts +3 -0
  49. package/dist/commands/scaffold.d.ts.map +1 -1
  50. package/dist/commands/scaffold.js +14 -0
  51. package/dist/commands/scaffold.js.map +1 -1
  52. package/dist/commands/suggest-metadata.d.ts.map +1 -1
  53. package/dist/commands/suggest-metadata.js +2 -0
  54. package/dist/commands/suggest-metadata.js.map +1 -1
  55. package/dist/commands/trust-graph.d.ts.map +1 -1
  56. package/dist/commands/trust-graph.js +12 -0
  57. package/dist/commands/trust-graph.js.map +1 -1
  58. package/dist/config.d.ts.map +1 -1
  59. package/dist/config.js +10 -3
  60. package/dist/config.js.map +1 -1
  61. package/dist/diagnostic-ids.d.ts +8 -0
  62. package/dist/diagnostic-ids.d.ts.map +1 -1
  63. package/dist/diagnostic-ids.js +8 -0
  64. package/dist/diagnostic-ids.js.map +1 -1
  65. package/dist/discovery.d.ts +5 -0
  66. package/dist/discovery.d.ts.map +1 -1
  67. package/dist/discovery.js +108 -65
  68. package/dist/discovery.js.map +1 -1
  69. package/dist/markdown.d.ts.map +1 -1
  70. package/dist/markdown.js +15 -0
  71. package/dist/markdown.js.map +1 -1
  72. package/dist/model.d.ts +17 -1
  73. package/dist/model.d.ts.map +1 -1
  74. package/dist/model.js +4 -1
  75. package/dist/model.js.map +1 -1
  76. package/dist/quality-profile.d.ts +91 -0
  77. package/dist/quality-profile.d.ts.map +1 -0
  78. package/dist/quality-profile.js +91 -0
  79. package/dist/quality-profile.js.map +1 -0
  80. package/dist/repeated-context.d.ts.map +1 -1
  81. package/dist/repeated-context.js +38 -83
  82. package/dist/repeated-context.js.map +1 -1
  83. package/dist/repository-boundary.d.ts +30 -0
  84. package/dist/repository-boundary.d.ts.map +1 -0
  85. package/dist/repository-boundary.js +116 -0
  86. package/dist/repository-boundary.js.map +1 -0
  87. package/dist/repository-evidence.d.ts +2 -0
  88. package/dist/repository-evidence.d.ts.map +1 -1
  89. package/dist/repository-evidence.js +6 -4
  90. package/dist/repository-evidence.js.map +1 -1
  91. package/dist/repository-paths.d.ts +6 -2
  92. package/dist/repository-paths.d.ts.map +1 -1
  93. package/dist/repository-paths.js +75 -24
  94. package/dist/repository-paths.js.map +1 -1
  95. package/dist/rules.d.ts +2 -0
  96. package/dist/rules.d.ts.map +1 -1
  97. package/dist/rules.js +263 -176
  98. package/dist/rules.js.map +1 -1
  99. package/dist/scanner.d.ts.map +1 -1
  100. package/dist/scanner.js +5 -1
  101. package/dist/scanner.js.map +1 -1
  102. package/dist/security-diagnostics.d.ts.map +1 -1
  103. package/dist/security-diagnostics.js +95 -30
  104. package/dist/security-diagnostics.js.map +1 -1
  105. package/dist/security-diff.d.ts +5 -2
  106. package/dist/security-diff.d.ts.map +1 -1
  107. package/dist/security-diff.js +20 -4
  108. package/dist/security-diff.js.map +1 -1
  109. package/dist/security-policy-inventory.d.ts +15 -3
  110. package/dist/security-policy-inventory.d.ts.map +1 -1
  111. package/dist/security-policy-inventory.js +123 -26
  112. package/dist/security-policy-inventory.js.map +1 -1
  113. package/dist/security-policy.d.ts +7 -0
  114. package/dist/security-policy.d.ts.map +1 -1
  115. package/dist/security-policy.js +70 -7
  116. package/dist/security-policy.js.map +1 -1
  117. package/dist/security-posture.d.ts.map +1 -1
  118. package/dist/security-posture.js +2 -1
  119. package/dist/security-posture.js.map +1 -1
  120. package/dist/skill-migration.js +2 -0
  121. package/dist/skill-migration.js.map +1 -1
  122. package/dist/static-support.d.ts +13 -0
  123. package/dist/static-support.d.ts.map +1 -0
  124. package/dist/static-support.js +284 -0
  125. package/dist/static-support.js.map +1 -0
  126. package/dist/token-estimator.d.ts +21 -0
  127. package/dist/token-estimator.d.ts.map +1 -0
  128. package/dist/token-estimator.js +84 -0
  129. package/dist/token-estimator.js.map +1 -0
  130. package/dist/trust-graph.d.ts +3 -3
  131. package/dist/trust-graph.d.ts.map +1 -1
  132. package/dist/trust-graph.js +69 -10
  133. package/dist/trust-graph.js.map +1 -1
  134. package/dist/types.d.ts +6 -1
  135. package/dist/types.d.ts.map +1 -1
  136. package/docs/README.md +13 -7
  137. package/docs/advanced-skill-authoring.md +16 -9
  138. package/docs/agent-skills-compatibility.md +10 -2
  139. package/docs/authoring-guide.md +62 -4
  140. package/docs/diagnostics.md +44 -11
  141. package/docs/quality-profile.md +123 -0
  142. package/docs/repository-context-bom.md +67 -8
  143. package/docs/schemas/repository-context-bom-v2.schema.json +648 -0
  144. package/docs/schemas/trust-graph-v2.schema.json +301 -0
  145. package/docs/security-policy.md +21 -5
  146. package/docs/trust-graph.md +47 -0
  147. package/docs/user-manual.md +34 -5
  148. package/examples/context-repo/README.md +6 -7
  149. package/examples/context-repo/contexts/domain/payment/idempotency.md +7 -0
  150. package/examples/context-repo/contexts/testing/boundary-value-analysis.md +7 -0
  151. package/examples/context-repo/contexts/testing/negative-testing.md +7 -0
  152. package/examples/context-repo/skills/testing/spec-review/SKILL.md +5 -0
  153. package/package.json +3 -1
  154. package/plan-discovery.md +24 -15
  155. package/plan.md +59 -119
  156. package/scripts/verify-package.mjs +8 -1
package/dist/rules.js CHANGED
@@ -2,96 +2,52 @@ import path from "node:path";
2
2
  import { resolvedAgentSkillDescription } from "./agent-skills.js";
3
3
  import { addDaysIsoDate, isIsoDate, parseDayDuration, todayIsoDate, } from "./freshness.js";
4
4
  import { DIAGNOSTIC_IDS } from "./diagnostic-ids.js";
5
- import { classifyRepositorySkillEntrypointPath, classifyRepositorySkillPath, normalizeRepositoryRelativePath, } from "./discovery.js";
5
+ import { classifyRepositorySkillEntrypointPath, classifyRepositorySkillPath, logicalSkillDirectory, normalizeRepositoryRelativePath, } from "./discovery.js";
6
6
  import { helperScriptPath, resolveHelperScriptPath, } from "./repository-paths.js";
7
7
  import { parseAssetMetadata } from "./metadata.js";
8
8
  import { runRuleRegistry } from "./rule-engine.js";
9
+ import { DEFAULT_QUALITY_PROFILE } from "./quality-profile.js";
10
+ import { estimateTokens, markdownBody } from "./token-estimator.js";
11
+ import { staticSupportReferences } from "./static-support.js";
9
12
  const SECRET_PATTERN = /\b(?:password|passwd|token|api[_-]?key|secret|credential|private[_-]?key)\b\s*[:=]\s*["']?([A-Za-z0-9_./+=-]{8,})/i;
10
13
  const PRIVATE_KEY_PATTERN = /-----BEGIN (?:RSA |OPENSSH |EC |DSA )?PRIVATE KEY-----/;
11
14
  const REMOTE_PATTERN = /\b(?:curl|wget)\b.*(?:\|\s*(?:sh|bash)|\b(?:example\.com|prod|production|--insecure|-k)\b)|\b(?:ssh|scp)\b.*\b(?:example\.com|prod|production|root@|--insecure|-k|StrictHostKeyChecking=no|UserKnownHostsFile=\/dev\/null)\b/i;
12
15
  const ENV_COPY_PATTERN = /\b(?:process\.env|env)\b.*\b(?:spawn|exec|execFile|system|subprocess|child_process)\b|\b(?:spawn|exec|execFile|system|subprocess|child_process)\b.*\b(?:process\.env|env)\b/i;
13
16
  const USER_LOCAL_PATH_PATTERN = /(?:^|[^a-z0-9_])(?:\/Users\/[^\s/\\]+|\/home\/[^\s/\\]+|[A-Za-z]:\\Users\\[^\s\\]+)(?:\/|$)/iu;
14
- const SKILL_TOKEN_LIMIT = 500;
15
- const DESCRIPTION_MIN_CHARS = 150;
16
- const REUSABLE_CONTEXT_MIN_LINES = 24;
17
- const REUSABLE_CONTEXT_MIN_TOKENS = 180;
17
+ const QUALITY = DEFAULT_QUALITY_PROFILE;
18
+ const MAX_LOCAL_SUPPORT_REFERENCE_HOPS = QUALITY.agentSkills.recommendedReferenceDepth + 1;
18
19
  const REQUIRED_INPUTS_PATTERN = /\b(?:required inputs?|inputs|input requirements?|required information|prerequisites?|required context|required files|required permissions?|permission requirements?|environment requirements?|before running,\s*provide|before you begin,\s*provide|the user must provide|needs the following|target files|permissions required|environment required)\b|\brequires:/;
19
20
  const COMPLETION_CRITERIA_PATTERN = /\b(?:completion criteria|completion checklist|success criteria|success requirements|done criteria|done when|definition of done|acceptance criteria|deliverables?|final response|final answer|expected outcomes?|expected results?|expected output|required output|output requirements?|report should include|patch should include|when complete|workflow is complete|the workflow is complete after|task is complete|counts as complete|completion requirements?|stop when|do not finish until)\b/;
20
- const REUSABLE_CONTEXT_MIN_SIGNALS = 3;
21
- const SUPPORT_SHARED_CONTEXT_MIN_LINES = 18;
22
- const SUPPORT_SHARED_CONTEXT_MIN_TOKENS = 140;
23
- const SUPPORT_SHARED_CONTEXT_MIN_HEADINGS = 2;
24
- const SUPPORT_SHARED_CONTEXT_MIN_PHRASES = 2;
25
21
  const REUSABLE_CONTEXT_HEADING_PATTERNS = [
26
- [/\bsetup\b/i, "Setup"],
27
- [/\binstallation\b/i, "Installation"],
28
- [/\bconfiguration\b/i, "Configuration"],
29
- [/\benvironment\b/i, "Environment"],
30
- [/\bprerequisites?\b/i, "Prerequisites"],
31
- [/\bplatform\b/i, "Platform"],
32
- [/\btroubleshooting\b/i, "Troubleshooting"],
22
+ [/\bplatform facts?\b/i, "Platform Facts"],
23
+ [/\breusable troubleshooting\b/i, "Reusable Troubleshooting"],
33
24
  [/\bknown issues?\b/i, "Known Issues"],
34
- [/\blimitations?\b/i, "Limitations"],
35
- [/\bbest practices?\b/i, "Best Practices"],
36
- [/\btesting heuristics?\b/i, "Testing Heuristics"],
37
- [/\btest strategy\b/i, "Test Strategy"],
38
- [/\bverification\b/i, "Verification"],
39
- [/\bexamples?\b/i, "Examples"],
40
- [/\bedge cases?\b/i, "Edge Cases"],
41
- [/\brisks?\b/i, "Risks"],
42
25
  [/\bdomain rules?\b/i, "Domain Rules"],
43
- [/\bfailure modes?\b/i, "Failure Modes"],
44
- [/\bflaky tests?\b/i, "Flaky Tests"],
26
+ [/\bcompatibility (?:matrix|matrices)\b/i, "Compatibility Matrix"],
27
+ [/\bproduct polic(?:y|ies)\b/i, "Product Policy"],
28
+ [/\bshared testing heuristics?\b/i, "Shared Testing Heuristics"],
45
29
  ];
46
30
  const REUSABLE_CONTEXT_PHRASE_PATTERNS = [
47
- [/\buse this when\b/i, "use this when"],
48
31
  [/\bknown issue\b/i, "known issue"],
49
- [/\blimitation\b/i, "limitation"],
50
- [/\btroubleshooting\b/i, "troubleshooting"],
51
- [/\bflaky\b/i, "flaky"],
52
- [/\bretry\b/i, "retry"],
32
+ [/\breusable troubleshooting\b/i, "reusable troubleshooting"],
53
33
  [/\bplatform-specific\b/i, "platform-specific"],
54
- [/\bedge case\b/i, "edge case"],
55
- [/\brisk\b/i, "risk"],
56
- [/\bheuristic\b/i, "heuristic"],
57
- [/\bbest practice\b/i, "best practice"],
58
- [/\bdo not\b/i, "do not"],
59
- [/\bavoid\b/i, "avoid"],
60
- [/\balways\b/i, "always"],
61
- [/\bnever\b/i, "never"],
34
+ [/\bsource of truth\b/i, "source of truth"],
35
+ [/\bused by (?:multiple|several) skills\b/i, "cross-Skill use"],
36
+ [/\bshared (?:rule|policy|heuristic|knowledge)\b/i, "shared knowledge"],
62
37
  ];
63
38
  const SUPPORT_SHARED_CONTEXT_HEADING_PATTERNS = [
64
39
  ...REUSABLE_CONTEXT_HEADING_PATTERNS,
65
- [/\bdecision logic\b/i, "Decision Logic"],
66
- [/\bsafety notes?\b/i, "Safety Notes"],
67
- [/\bvalidation\b/i, "Validation"],
68
- [/\boperating model\b/i, "Operating Model"],
69
40
  [/\bpolicy\b/i, "Policy"],
70
- [/\bguidelines?\b/i, "Guidelines"],
71
- [/\bprocedures?\b/i, "Procedure"],
72
- [/\bchecklist\b/i, "Checklist"],
73
41
  [/\bcompatibility\b/i, "Compatibility"],
74
- [/\bconstraints?\b/i, "Constraints"],
42
+ [/\bsource of truth\b/i, "Source of Truth"],
75
43
  ];
76
44
  const SUPPORT_SHARED_CONTEXT_PHRASE_PATTERNS = [
77
- [/\bmust\b/i, "must"],
78
- [/\bshould\b/i, "should"],
79
- [/\balways\b/i, "always"],
80
- [/\bnever\b/i, "never"],
81
- [/\bavoid\b/i, "avoid"],
82
- [/\bprefer\b/i, "prefer"],
83
- [/\bdo not\b/i, "do not"],
84
- [/\brequired\b/i, "required"],
85
- [/\brecommended\b/i, "recommended"],
86
45
  [/\bknown issue\b/i, "known issue"],
87
- [/\blimitation\b/i, "limitation"],
88
- [/\bfailure mode\b/i, "failure mode"],
89
- [/\btroubleshooting\b/i, "troubleshooting"],
90
- [/\bedge case\b/i, "edge case"],
91
- [/\brisk\b/i, "risk"],
92
- [/\bbest practice\b/i, "best practice"],
93
- [/\bvalidate\b/i, "validate"],
94
- [/\bverify\b/i, "verify"],
46
+ [/\breusable troubleshooting\b/i, "reusable troubleshooting"],
47
+ [/\bsource of truth\b/i, "source of truth"],
48
+ [/\bused by (?:multiple|several) skills\b/i, "cross-Skill use"],
49
+ [/\bindependent (?:owner|ownership|lifecycle)\b/i, "independent ownership"],
50
+ [/\bshared (?:rule|policy|heuristic|knowledge)\b/i, "shared knowledge"],
95
51
  ];
96
52
  const NON_SEMANTIC_CONTEXT_PATH_SEGMENTS = new Set([
97
53
  "promoted",
@@ -114,15 +70,10 @@ const NON_SEMANTIC_CONTEXT_PATH_SEGMENTS = new Set([
114
70
  "candidate",
115
71
  "candidates",
116
72
  ]);
117
- const CONTEXT_TOKEN_LIMITS = {
118
- context: 1200,
119
- profile: 500,
120
- reference: 800,
121
- example: 800,
122
- };
73
+ const CONTEXT_TOKEN_LIMITS = QUALITY.contentTokenWarn;
123
74
  /** Run all deterministic rules and return findings in stable source order. */
124
75
  export function runRules(documents, config, catalog, options = {}) {
125
- const findings = runRuleRegistry(documents, rulesForEvaluationDate(evaluationDay(options.evaluationDate), options.repositoryPaths), catalog, config);
76
+ const findings = runRuleRegistry(documents, rulesForEvaluationDate(evaluationDay(options.evaluationDate), options.repositoryPaths, options.repositoryPathStates), catalog, config);
126
77
  return findings.sort((a, b) => {
127
78
  const byPath = a.evidence.path.localeCompare(b.evidence.path);
128
79
  if (byPath !== 0)
@@ -130,7 +81,7 @@ export function runRules(documents, config, catalog, options = {}) {
130
81
  return a.evidence.startLine - b.evidence.startLine;
131
82
  });
132
83
  }
133
- function rulesForEvaluationDate(evaluationDate, repositoryPaths) {
84
+ function rulesForEvaluationDate(evaluationDate, repositoryPaths, repositoryPathStates) {
134
85
  return [
135
86
  {
136
87
  id: "strict-layout-policy",
@@ -153,7 +104,7 @@ function rulesForEvaluationDate(evaluationDate, repositoryPaths) {
153
104
  },
154
105
  {
155
106
  id: "skill-local-support-reachability",
156
- run: ({ documents }) => skillLocalSupportReachabilityFindings(documents),
107
+ run: ({ documents }) => skillLocalSupportReachabilityFindings(documents, repositoryPaths, repositoryPathStates),
157
108
  },
158
109
  {
159
110
  id: "support-asset-shared-context-candidate",
@@ -646,33 +597,51 @@ function shapeFindings(document) {
646
597
  const description = document.artifact.kind === "skill"
647
598
  ? (resolvedAgentSkillDescription(document) ?? "")
648
599
  : (document.metadata.description ?? "");
649
- const tokenCount = approximateTokenCount(document.artifact.content);
600
+ // Skill budgets measure only Markdown after frontmatter. Agent Skills loads
601
+ // metadata separately, and Renma applies independent metadata budgets.
602
+ const bodyTokenCount = estimateTokens(markdownBody(document.artifact.content));
650
603
  if (!description) {
651
604
  findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_MISSING_DESCRIPTION, "Skill is missing an explicit description", "quality", "medium", "Add frontmatter description so agents can route to the skill intentionally."));
652
605
  }
653
606
  else if (document.artifact.kind === "skill" &&
654
- description.length < DESCRIPTION_MIN_CHARS) {
655
- findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_SHORT_DESCRIPTION, "Skill description is too short for routing clarity", "quality", "low", `Expand frontmatter description to at least ${DESCRIPTION_MIN_CHARS} characters with usage routing guidance.`));
607
+ QUALITY.descriptionMinChars > 0 &&
608
+ description.length < QUALITY.descriptionMinChars) {
609
+ findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_SHORT_DESCRIPTION, "Skill description is too short for routing clarity", "quality", "low", `Expand frontmatter description to at least ${QUALITY.descriptionMinChars} characters with usage routing guidance.`));
656
610
  }
657
- const reusableContextFinding = reusableContextCandidateFinding(document, tokenCount);
611
+ const reusableContextFinding = reusableContextCandidateFinding(document, bodyTokenCount);
658
612
  if (reusableContextFinding)
659
613
  findings.push(reusableContextFinding);
660
- if (document.artifact.kind === "skill" && tokenCount > SKILL_TOKEN_LIMIT) {
661
- findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_SKILL_TOKEN_BUDGET, "Skill entrypoint exceeds token budget", "quality", "medium", `Keep SKILL.md under about ${SKILL_TOKEN_LIMIT} tokens as a compact usage guide. Move detailed procedures into reference files, but preserve them losslessly in ordered parts when needed. Do not delete, summarize, or merge away procedural steps. SKILL.md should reference every required support file or index without embedding the full procedure.`, {
662
- whyItMatters: "Large skills can mix LLM-facing usage guidance with reusable domain knowledge. Skills should remain concise routing contracts and usage guides, while reusable QA heuristics, domain rules, and tool guidance live in independently owned shared context assets.",
614
+ if (document.artifact.kind === "skill" &&
615
+ bodyTokenCount > QUALITY.skillTokenWarn) {
616
+ const limit = bodyTokenCount > QUALITY.skillTokenStrongWarn
617
+ ? QUALITY.skillTokenStrongWarn
618
+ : QUALITY.skillTokenWarn;
619
+ const severity = bodyTokenCount > QUALITY.skillTokenStrongWarn ? "medium" : "low";
620
+ findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_SKILL_TOKEN_BUDGET, "Skill body exceeds advisory token budget", "quality", severity, "Review progressive disclosure without deleting workflow steps. Keep selection boundaries, read conditions, ordered workflow, constraints, and completion criteria in SKILL.md. Move Skill-specific conditional detail to references/, deterministic repeated implementation to scripts/, output material to assets/, and independently owned cross-Skill knowledge to contexts/.", {
621
+ whyItMatters: "Long Skill bodies can make activated workflows harder to navigate. Size is advisory evidence only; Agent Skills recommends staying under 5,000 tokens and Renma adds an earlier low review point at 2,000 estimated tokens.",
663
622
  constraints: [
664
623
  "Do not introduce runtime context resolution.",
665
624
  "Do not create prompt packages.",
666
625
  "Do not make Renma responsible for selecting context.",
667
- "Preserve the skill as an LLM-facing entrypoint / usage guide.",
668
- "Give extracted context assets stable metadata such as id, owner, and status.",
626
+ "Preserve ordered workflow steps, constraints, and completion criteria.",
627
+ "Choose a destination by semantic ownership, not by size alone.",
669
628
  ],
670
629
  verificationSteps: [
671
630
  "Run renma scan.",
672
631
  "Run any project-specific validation checks that apply to this repository.",
673
- "Confirm the skill is shorter and extracted knowledge is represented as shared context assets.",
632
+ "Confirm any moved material remains statically reachable and semantically owned by its destination.",
674
633
  ],
675
- llmHint: "If this skill mixes reusable knowledge with usage guidance, split reusable knowledge into first-class context assets under contexts/ and update the skill metadata or text to reference them.",
634
+ llmHint: "Review the Skill for progressive disclosure. Keep core workflow in SKILL.md; use references/ for local detail, scripts/ for deterministic implementation, assets/ for output resources, and contexts/ only for independently owned shared knowledge.",
635
+ details: {
636
+ measured: bodyTokenCount,
637
+ limit,
638
+ unit: "estimated_tokens",
639
+ profile: QUALITY.profile,
640
+ measurement: "markdown_body_after_frontmatter",
641
+ source: limit === QUALITY.skillTokenStrongWarn
642
+ ? "agent_skills_recommendation_and_renma_severity"
643
+ : "renma_quality_policy",
644
+ },
676
645
  }));
677
646
  }
678
647
  if (document.artifact.kind === "skill" &&
@@ -732,17 +701,25 @@ function shapeFindings(document) {
732
701
  if (!/verify|validation|test|confirm result|expected output/.test(text)) {
733
702
  findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_MISSING_VERIFICATION, "Skill lacks verification guidance", "quality", "medium", "State how to verify success with a command, check, or observable result."));
734
703
  }
735
- if (document.headings.length < 2 &&
736
- document.artifact.content.split(/\s+/).length > 120) {
737
- findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_LOW_HEADING_DENSITY, "Long instruction file has few headings", "structure", "low", "Split long prose into task-oriented headings so agents can navigate it reliably."));
704
+ if (document.headings.length < QUALITY.lowHeadingDensityMinHeadings &&
705
+ bodyTokenCount >= QUALITY.lowHeadingDensityMinTokens) {
706
+ findings.push(documentFinding(document, DIAGNOSTIC_IDS.QUAL_LOW_HEADING_DENSITY, "Long instruction file has few headings", "structure", "low", "Add task-oriented headings so agents can navigate the body reliably.", {
707
+ details: {
708
+ measured: bodyTokenCount,
709
+ limit: QUALITY.lowHeadingDensityMinTokens,
710
+ unit: "estimated_tokens",
711
+ profile: QUALITY.profile,
712
+ measurement: "markdown_body_after_frontmatter",
713
+ },
714
+ }));
738
715
  }
739
716
  return findings;
740
717
  }
741
- function reusableContextCandidateFinding(document, tokenCount) {
718
+ function reusableContextCandidateFinding(document, estimatedTokens) {
742
719
  if (document.artifact.kind !== "skill")
743
720
  return undefined;
744
- if (document.lines.length < REUSABLE_CONTEXT_MIN_LINES &&
745
- tokenCount < REUSABLE_CONTEXT_MIN_TOKENS)
721
+ if (document.lines.length < QUALITY.reusableContextCandidate.minLines &&
722
+ estimatedTokens < QUALITY.reusableContextCandidate.minTokens)
746
723
  return undefined;
747
724
  const headingMatches = document.headings.flatMap((heading) => REUSABLE_CONTEXT_HEADING_PATTERNS.filter(([pattern]) => pattern.test(heading.text)).map(([, label]) => ({
748
725
  label,
@@ -766,7 +743,10 @@ function reusableContextCandidateFinding(document, tokenCount) {
766
743
  ];
767
744
  const phraseLabels = [...new Set(phraseMatches.map((match) => match.label))];
768
745
  const signalCount = new Set([...headingLabels, ...phraseLabels]).size;
769
- if (signalCount < REUSABLE_CONTEXT_MIN_SIGNALS)
746
+ // All patterns above are reusable-knowledge evidence. Ordinary workflow
747
+ // headings such as Verification, Examples, Steps, Risks, and Constraints are
748
+ // intentionally excluded and cannot qualify a Skill by themselves.
749
+ if (signalCount < QUALITY.reusableContextCandidate.minSignals)
770
750
  return undefined;
771
751
  const evidenceLine = headingMatches[0]?.line ??
772
752
  phraseMatches[0]?.line ??
@@ -784,26 +764,37 @@ function reusableContextCandidateFinding(document, tokenCount) {
784
764
  : undefined,
785
765
  ].filter((part) => Boolean(part));
786
766
  return {
787
- id: DIAGNOSTIC_IDS.MAINT_SKILL_REUSABLE_CONTEXT_CANDIDATE,
788
- title: "Skill may contain reusable context worth extracting",
767
+ id: DIAGNOSTIC_IDS.QUAL_SKILL_MIXED_RESPONSIBILITY,
768
+ title: "Skill may mix its workflow with reusable knowledge",
789
769
  category: "maintenance",
790
770
  severity: "low",
791
771
  confidence: "medium",
792
772
  evidence: evidence(document, evidenceLine, evidenceParts.join("; ")),
793
773
  whyItMatters: "Reusable setup notes, troubleshooting, platform guidance, testing heuristics, or domain rules are easier to own, review, and reuse when they live in shared context assets instead of only inside one skill.",
794
- remediation: "Review the matched headings and phrases. If they describe reusable knowledge, extract that knowledge into first-class shared context assets under contexts/ and keep SKILL.md as a concise LLM-facing usage guide.",
774
+ remediation: "Review the matched headings and phrases. Promote content to contexts/ only when it needs cross-Skill reuse, independent ownership, lifecycle, or source-of-truth status; otherwise keep Skill-specific detail in SKILL.md or references/.",
795
775
  constraints: [
796
776
  "Do not make Renma select runtime context.",
797
777
  "Do not assemble prompt packages.",
798
778
  "Do not automatically rewrite or split skills.",
799
- "Preserve SKILL.md as the routing contract / usage guide.",
779
+ "Preserve SKILL.md as a focused workflow entrypoint.",
800
780
  "Give extracted context assets stable metadata such as id, owner, and status.",
801
781
  ],
802
782
  verificationSteps: [
803
783
  "Run renma scan.",
804
784
  "Confirm the advisory is resolved or intentionally accepted after reusable knowledge is represented as shared context assets.",
805
785
  ],
806
- llmHint: "Look for reusable setup, troubleshooting, platform, testing, or domain guidance in this skill. If reusable, move it into owned contexts/ assets and update the skill to reference those assets without adding runtime context selection.",
786
+ llmHint: "Check whether the matched knowledge is used across Skills or needs independent ownership. Use contexts/ only for shared knowledge; keep Skill-local procedures and edge cases in SKILL.md or references/.",
787
+ details: {
788
+ measured: estimatedTokens,
789
+ limit: QUALITY.reusableContextCandidate.minTokens,
790
+ unit: "estimated_tokens",
791
+ lines: document.lines.length,
792
+ minLines: QUALITY.reusableContextCandidate.minLines,
793
+ distinctSignals: signalCount,
794
+ minSignals: QUALITY.reusableContextCandidate.minSignals,
795
+ profile: QUALITY.profile,
796
+ measurement: "markdown_body_after_frontmatter",
797
+ },
807
798
  };
808
799
  }
809
800
  function supportSharedContextCandidateFindings(document) {
@@ -815,9 +806,9 @@ function supportSharedContextCandidateFindings(document) {
815
806
  !document.artifact.path.endsWith(".md")) {
816
807
  return [];
817
808
  }
818
- const tokenCount = approximateTokenCount(document.artifact.content);
819
- if (document.lines.length < SUPPORT_SHARED_CONTEXT_MIN_LINES &&
820
- tokenCount < SUPPORT_SHARED_CONTEXT_MIN_TOKENS) {
809
+ const estimatedTokens = estimateTokens(markdownBody(document.artifact.content));
810
+ if (document.lines.length < QUALITY.sharedSupportCandidate.minLines &&
811
+ estimatedTokens < QUALITY.sharedSupportCandidate.minTokens) {
821
812
  return [];
822
813
  }
823
814
  const contentLineIndexes = markdownBodyLineIndexes(document);
@@ -852,8 +843,10 @@ function supportSharedContextCandidateFindings(document) {
852
843
  ];
853
844
  });
854
845
  const sourceSignals = [...headingMatches, ...phraseMatches];
855
- if (headingMatches.length < SUPPORT_SHARED_CONTEXT_MIN_HEADINGS ||
856
- phraseMatches.length < SUPPORT_SHARED_CONTEXT_MIN_PHRASES) {
846
+ if (new Set(headingMatches.map((match) => match.label)).size <
847
+ QUALITY.sharedSupportCandidate.minHeadings ||
848
+ new Set(phraseMatches.map((match) => match.label)).size <
849
+ QUALITY.sharedSupportCandidate.minPhrases) {
857
850
  return [];
858
851
  }
859
852
  const evidenceMatches = sourceSignals
@@ -897,6 +890,19 @@ function supportSharedContextCandidateFindings(document) {
897
890
  "Confirm reusable source-of-truth knowledge lives in contexts/ and skill-local references only contain local support guidance.",
898
891
  ],
899
892
  llmHint: "Search the repository for similar headings, filenames, repeated procedures, commands, constraints, or overlapping guidance. If this support file appears reusable, propose a first-class context asset under contexts/, move the reusable details without losing information, keep truly local notes in the skill directory, and update declared context references.",
893
+ details: {
894
+ measured: estimatedTokens,
895
+ limit: QUALITY.sharedSupportCandidate.minTokens,
896
+ unit: "estimated_tokens",
897
+ lines: document.lines.length,
898
+ minLines: QUALITY.sharedSupportCandidate.minLines,
899
+ headings: new Set(headingMatches.map((match) => match.label)).size,
900
+ minHeadings: QUALITY.sharedSupportCandidate.minHeadings,
901
+ phrases: new Set(phraseMatches.map((match) => match.label)).size,
902
+ minPhrases: QUALITY.sharedSupportCandidate.minPhrases,
903
+ profile: QUALITY.profile,
904
+ measurement: "full_file",
905
+ },
900
906
  },
901
907
  ];
902
908
  }
@@ -1085,7 +1091,9 @@ function parentSkillPath(referencePath) {
1085
1091
  : undefined;
1086
1092
  }
1087
1093
  function skillReferenceLine(skill, referencePath) {
1088
- const skillDir = path.posix.dirname(skill.artifact.path);
1094
+ const skillDir = logicalSkillDirectory(skill.artifact.path);
1095
+ if (!skillDir)
1096
+ return undefined;
1089
1097
  const relativePath = path.posix.relative(skillDir, referencePath);
1090
1098
  const referencedTokens = [referencePath, relativePath];
1091
1099
  for (const index of markdownBodyLineIndexes(skill)) {
@@ -1208,16 +1216,17 @@ function contextBudgetFindings(document) {
1208
1216
  return [];
1209
1217
  }
1210
1218
  const limit = CONTEXT_TOKEN_LIMITS[document.artifact.kind];
1211
- const tokenCount = approximateTokenCount(document.artifact.content);
1212
- if (tokenCount <= limit)
1219
+ const estimatedTokens = estimateTokens(document.artifact.content);
1220
+ if (estimatedTokens <= limit)
1213
1221
  return [];
1214
1222
  return [
1215
- documentFinding(document, DIAGNOSTIC_IDS.QUAL_SUPPORT_ASSET_TOKEN_BUDGET, "Support asset exceeds token guidance", "quality", "low", `Keep ${document.artifact.kind} assets under about ${limit} tokens where practical. If a file is too large, run \`renma suggest-semantic-split ${document.artifact.path}\` to get a semantic split proposal, then split it losslessly into meaning-based ordered part files. Do not delete, summarize, or merge away procedural steps. The parent file or SKILL.md should reference every part in order, and the split should preserve the original procedure text exactly. Verify by reconstructing the parts and comparing them to the original content before accepting the fix.`, {
1216
- whyItMatters: "Oversized support assets are harder for humans and LLM coding agents to review safely. Shared context and local support files should stay modular enough that ownership, scope, and static references remain clear.",
1223
+ documentFinding(document, DIAGNOSTIC_IDS.QUAL_SUPPORT_ASSET_TOKEN_BUDGET, "Support asset exceeds token guidance", "quality", "low", `Review whether this ${document.artifact.kind} asset still has one coherent scope. Size alone does not require a split. Consider headings, read conditions, reference depth, mixed responsibilities, and maintained duplication before using \`renma suggest-semantic-split ${document.artifact.path}\`.`, {
1224
+ whyItMatters: "Large content assets deserve a low-advisory coherence review, but an intentionally focused asset can remain intact above the threshold.",
1217
1225
  constraints: [
1218
1226
  "Do not introduce runtime context resolution.",
1219
1227
  "Do not create prompt packages.",
1220
- "Preserve concrete procedural steps losslessly.",
1228
+ "Do not split based on size alone.",
1229
+ "Preserve concrete procedural steps losslessly if a semantic split is chosen.",
1221
1230
  "Keep static references from the parent file or SKILL.md to every split part.",
1222
1231
  ],
1223
1232
  verificationSteps: [
@@ -1225,7 +1234,14 @@ function contextBudgetFindings(document) {
1225
1234
  "Run the repository-specific validation or test command, if one exists.",
1226
1235
  "Confirm the finding is resolved or reduced and every split part remains reachable.",
1227
1236
  ],
1228
- llmHint: "Split oversized support content into meaning-based ordered part files, keep the original procedure text intact, and update static references so Renma can validate reachability.",
1237
+ llmHint: "Review scope, headings, read conditions, reference depth, responsibilities, and duplication. Propose a semantic split only when those signals justify it.",
1238
+ details: {
1239
+ measured: estimatedTokens,
1240
+ limit,
1241
+ unit: "estimated_tokens",
1242
+ profile: QUALITY.profile,
1243
+ measurement: "full_file",
1244
+ },
1229
1245
  }),
1230
1246
  ];
1231
1247
  }
@@ -1239,19 +1255,31 @@ function profileFindings(document) {
1239
1255
  documentFinding(document, DIAGNOSTIC_IDS.PROF_MISSING_BASE, "Profile overlay does not declare its base skill", "structure", "medium", "Declare the base skill or compatibility target so routing conflicts are auditable."),
1240
1256
  ];
1241
1257
  }
1242
- function skillLocalSupportReachabilityFindings(documents) {
1258
+ function skillLocalSupportReachabilityFindings(documents, repositoryPaths, repositoryPathStates) {
1243
1259
  const skills = documents.filter((document) => document.artifact.kind === "skill");
1244
1260
  return skills.flatMap((skill) => {
1245
- const skillDir = path.posix.dirname(skill.artifact.path);
1246
- const localSupportDocs = documents.filter((document) => ["profile", "reference", "example"].includes(document.artifact.kind) &&
1247
- document.artifact.path.startsWith(`${skillDir}/`));
1248
- if (localSupportDocs.length === 0)
1261
+ const skillDir = logicalSkillDirectory(skill.artifact.path);
1262
+ if (!skillDir)
1249
1263
  return [];
1264
+ const localSupportDocs = documents.filter((document) => {
1265
+ if (!["profile", "reference", "example", "script", "asset"].includes(document.artifact.kind)) {
1266
+ return false;
1267
+ }
1268
+ const classified = classifyRepositorySkillPath(document.artifact.path);
1269
+ return (classified?.kind === "support" && classified.skillDirectory === skillDir);
1270
+ });
1271
+ const localSupportPaths = repositoryPaths
1272
+ ? [...repositoryPaths].filter((candidate) => {
1273
+ const classified = classifyRepositorySkillPath(candidate);
1274
+ return (classified?.kind === "support" &&
1275
+ classified.skillDirectory === skillDir);
1276
+ })
1277
+ : localSupportDocs.map((document) => document.artifact.path);
1250
1278
  const findings = [];
1251
1279
  const text = skill.artifact.content.toLowerCase();
1252
- const hasLocalSupportGuidance = /support file|local support|context route|context map|mixin|profiles?\/|references?\/|examples?\/|load .*?(?:profile|reference|example)|reference .*?(?:profile|reference|example)/.test(text);
1253
- if (!hasLocalSupportGuidance) {
1254
- findings.push(documentFinding(skill, DIAGNOSTIC_IDS.SUPPORT_MISSING_REACHABILITY_GUIDANCE, "Skill has local support files but no reachability guidance", "structure", "medium", "Add local support file reachability guidance so the top-level skill declares when profiles, references, examples, or scripts are reachable. If support content was split into ordered parts, reference the index or all parts in order. Preserve original concrete steps. Do not delete, summarize, or merge away procedural steps.", {
1280
+ const hasLocalSupportGuidance = /support file|local support|context route|context map|mixin|profiles?\/|references?\/|examples?\/|scripts?\/|assets?\/|load .*?(?:profile|reference|example|script|asset)|(?:read|run|reference) .*?(?:profile|reference|example|script|asset)/.test(text);
1281
+ if (localSupportDocs.length > 0 && !hasLocalSupportGuidance) {
1282
+ findings.push(documentFinding(skill, DIAGNOSTIC_IDS.SUPPORT_MISSING_REACHABILITY_GUIDANCE, "Skill has local support files but no reachability guidance", "structure", "medium", "Add local support file reachability guidance so the top-level skill declares when profiles, references, examples, scripts, or assets are reachable. If support content was split into ordered parts, reference the index or all parts in order. Preserve original concrete steps. Do not delete, summarize, or merge away procedural steps.", {
1255
1283
  whyItMatters: "Local support files should be statically discoverable from the skill so humans and LLM coding agents can tell which repository evidence belongs to the skill without relying on runtime context selection.",
1256
1284
  constraints: [
1257
1285
  "Do not introduce runtime context resolution.",
@@ -1262,14 +1290,15 @@ function skillLocalSupportReachabilityFindings(documents) {
1262
1290
  verificationSteps: [
1263
1291
  "Run renma scan.",
1264
1292
  "Run any project-specific validation checks that apply to this repository.",
1265
- "Confirm each local profile, reference, or example is reachable from SKILL.md or from a referenced parent support file.",
1293
+ "Confirm each local profile, reference, example, script, or asset is reachable from SKILL.md or from a referenced parent support file.",
1266
1294
  ],
1267
- llmHint: "Add concise reachability guidance in SKILL.md that references local profiles, references, examples, or ordered support indexes without adding runtime routing behavior.",
1295
+ llmHint: "Add concise reachability guidance in SKILL.md that references local profiles, references, examples, scripts, assets, or ordered support indexes without adding runtime routing behavior.",
1268
1296
  }));
1269
1297
  }
1270
- const reachableLocalSupportPaths = reachableLocalSupportDocuments(skill, localSupportDocs);
1298
+ const reachabilityDepth = localSupportReachabilityDepth(skill, skillDir, localSupportDocs, localSupportPaths);
1271
1299
  for (const document of localSupportDocs) {
1272
- if (!reachableLocalSupportPaths.has(document.artifact.path)) {
1300
+ const depth = reachabilityDepth.get(document.artifact.path);
1301
+ if (depth === undefined) {
1273
1302
  findings.push(documentFinding(document, localSupportUnreachableRuleId(document.artifact.kind), "Local support file is not reachable from the skill", "structure", "low", "Reference this local support file from SKILL.md or from a referenced parent support file with clear reachability guidance. If this file is a split part, ensure the parent skill references the index or all ordered parts so preserved details remain reachable. Do not delete, summarize, or merge away procedural steps just to satisfy the check.", {
1274
1303
  whyItMatters: "Unreachable local support files can drift outside review and be missed by humans or LLM coding agents. Reachability should be static repository evidence, not runtime context assembly.",
1275
1304
  constraints: [
@@ -1286,36 +1315,126 @@ function skillLocalSupportReachabilityFindings(documents) {
1286
1315
  llmHint: "Update SKILL.md or a referenced support index to mention this file by path, basename, or clear title so the static reachability graph can find it.",
1287
1316
  }));
1288
1317
  }
1318
+ else if (depth > MAX_LOCAL_SUPPORT_REFERENCE_HOPS) {
1319
+ findings.push(documentFinding(document, DIAGNOSTIC_IDS.SUPPORT_DEEP_REFERENCE_CHAIN, "Skill-local resource is behind a deep reference chain", "structure", "low", "Reference this resource directly from SKILL.md or through one directly referenced index/reference. Agent Skills recommends shallow file-reference chains.", {
1320
+ details: {
1321
+ measured: depth,
1322
+ limit: MAX_LOCAL_SUPPORT_REFERENCE_HOPS,
1323
+ unit: "static_reference_hops",
1324
+ profile: QUALITY.profile,
1325
+ },
1326
+ }));
1327
+ }
1328
+ }
1329
+ const missingPathSources = [
1330
+ skill,
1331
+ ...localSupportDocs.filter((document) => (reachabilityDepth.get(document.artifact.path) ?? 99) <=
1332
+ MAX_LOCAL_SUPPORT_REFERENCE_HOPS),
1333
+ ];
1334
+ const reportedMissingPaths = new Set();
1335
+ const reportedSymlinkBoundaries = new Set();
1336
+ for (const source of missingPathSources) {
1337
+ for (const reference of localSupportPathReferences(source, skillDir, localSupportPaths)) {
1338
+ if (reference.relative.startsWith("examples/") &&
1339
+ !path.posix.basename(reference.relative).includes(".")) {
1340
+ continue;
1341
+ }
1342
+ const symlinkBoundary = referencedSymlinkBoundary(reference.target, repositoryPathStates);
1343
+ if (symlinkBoundary) {
1344
+ const key = `${source.artifact.path}:${symlinkBoundary}`;
1345
+ if (reportedSymlinkBoundaries.has(key))
1346
+ continue;
1347
+ reportedSymlinkBoundaries.add(key);
1348
+ findings.push(findingAt(source, DIAGNOSTIC_IDS.SUPPORT_SYMLINK_PATH, "Skill-local resource path is an unusable symbolic link", "structure", "medium", reference.line, reference.raw, `Replace ${reference.relative} with a regular repository file or directory; Renma never follows symbolic links.`, {
1349
+ details: {
1350
+ sourcePath: source.artifact.path,
1351
+ target: reference.target,
1352
+ state: "symlink",
1353
+ symlinkBoundary,
1354
+ profile: QUALITY.profile,
1355
+ },
1356
+ }));
1357
+ continue;
1358
+ }
1359
+ if (repositoryPathExists(repositoryPaths, reference.target, repositoryPathStates) ||
1360
+ repositoryPathExists(repositoryPaths, reference.relative, repositoryPathStates) ||
1361
+ reportedMissingPaths.has(`${source.artifact.path}:${reference.target}`))
1362
+ continue;
1363
+ reportedMissingPaths.add(`${source.artifact.path}:${reference.target}`);
1364
+ findings.push(findingAt(source, DIAGNOSTIC_IDS.SUPPORT_MISSING_PATH, "Skill-local resource path does not exist", "structure", "medium", reference.line, reference.raw, `Create ${reference.relative} under the Skill root or correct the relative path.`, {
1365
+ details: {
1366
+ target: reference.target,
1367
+ profile: QUALITY.profile,
1368
+ },
1369
+ }));
1370
+ }
1289
1371
  }
1290
1372
  return findings;
1291
1373
  });
1292
1374
  }
1293
- function reachableLocalSupportDocuments(skill, localSupportDocs) {
1294
- const reachable = new Set();
1375
+ function repositoryPathExists(repositoryPaths, candidate, repositoryPathStates) {
1376
+ const state = repositoryPathStates?.get(candidate);
1377
+ if (state !== undefined)
1378
+ return state !== "absent";
1379
+ if (!repositoryPaths)
1380
+ return false;
1381
+ if (repositoryPaths.has(candidate))
1382
+ return true;
1383
+ const directoryPrefix = `${candidate.replace(/\/$/, "")}/`;
1384
+ for (const filePath of repositoryPaths) {
1385
+ if (filePath.startsWith(directoryPrefix))
1386
+ return true;
1387
+ }
1388
+ return false;
1389
+ }
1390
+ function referencedSymlinkBoundary(candidate, repositoryPathStates) {
1391
+ if (!repositoryPathStates)
1392
+ return undefined;
1393
+ const segments = candidate.split("/");
1394
+ for (let length = 1; length <= segments.length; length += 1) {
1395
+ const prefix = segments.slice(0, length).join("/");
1396
+ if (repositoryPathStates.get(prefix) === "symlink")
1397
+ return prefix;
1398
+ }
1399
+ return undefined;
1400
+ }
1401
+ function localSupportReachabilityDepth(skill, skillDirectory, localSupportDocs, candidatePaths) {
1402
+ const reachable = new Map();
1403
+ const references = new Map([skill, ...localSupportDocs].map((document) => [
1404
+ document.artifact.path,
1405
+ new Set(staticSupportReferences(document, skillDirectory, candidatePaths).map((reference) => reference.targetPath)),
1406
+ ]));
1295
1407
  let changed = true;
1296
1408
  while (changed) {
1297
1409
  changed = false;
1298
1410
  for (const document of localSupportDocs) {
1299
1411
  if (reachable.has(document.artifact.path))
1300
1412
  continue;
1301
- const possibleRouters = [
1302
- skill,
1303
- ...localSupportDocs.filter((candidate) => reachable.has(candidate.artifact.path)),
1304
- ];
1305
- if (possibleRouters.some((router) => referencesDocument(router, document))) {
1306
- reachable.add(document.artifact.path);
1413
+ if (references.get(skill.artifact.path)?.has(document.artifact.path)) {
1414
+ reachable.set(document.artifact.path, 1);
1415
+ changed = true;
1416
+ continue;
1417
+ }
1418
+ const parent = localSupportDocs
1419
+ .filter((candidate) => reachable.has(candidate.artifact.path))
1420
+ .sort((left, right) => (reachable.get(left.artifact.path) ?? 0) -
1421
+ (reachable.get(right.artifact.path) ?? 0))
1422
+ .find((candidate) => references.get(candidate.artifact.path)?.has(document.artifact.path));
1423
+ if (parent) {
1424
+ reachable.set(document.artifact.path, (reachable.get(parent.artifact.path) ?? 0) + 1);
1307
1425
  changed = true;
1308
1426
  }
1309
1427
  }
1310
1428
  }
1311
1429
  return reachable;
1312
1430
  }
1313
- function referencesDocument(source, target) {
1314
- const name = path.posix.basename(target.artifact.path, path.posix.extname(target.artifact.path));
1315
- const basename = path.posix.basename(target.artifact.path);
1316
- return (source.artifact.content.includes(target.artifact.path) ||
1317
- source.artifact.content.includes(basename) ||
1318
- new RegExp(`\\b${escapeRegExp(name)}\\b`, "i").test(source.artifact.content));
1431
+ function localSupportPathReferences(document, skillDir, candidatePaths) {
1432
+ return staticSupportReferences(document, skillDir, candidatePaths).map((reference) => ({
1433
+ raw: reference.raw,
1434
+ relative: reference.relativePath,
1435
+ target: reference.targetPath,
1436
+ line: reference.line,
1437
+ }));
1319
1438
  }
1320
1439
  function markdownBodyLineIndexes(document) {
1321
1440
  if (document.lines[0]?.trim() !== "---") {
@@ -1374,34 +1493,11 @@ function thinSkillLayoutFindings(document) {
1374
1493
  if (classifyRepositorySkillEntrypointPath(document.artifact.path)?.kind !==
1375
1494
  "canonical")
1376
1495
  return [];
1377
- const findings = [];
1378
- const wordCount = words(document.artifact.content).length;
1379
- const procedureSignals = [
1380
- /^#{2,}\s+(procedure|steps?|install|configure|troubleshoot|diagnose|setup)\b/im,
1381
- /\b(step\s+\d+|first,|next,|finally)\b/i,
1382
- ];
1383
- if (wordCount > 450 ||
1384
- procedureSignals.some((pattern) => pattern.test(document.artifact.content))) {
1385
- findings.push(documentFinding(document, DIAGNOSTIC_IDS.LAYOUT_SKILL_NOT_THIN, "Skill entrypoint contains procedure content", "structure", wordCount > 700 ? "medium" : "low", "Move reusable procedure content into contexts/** and keep SKILL.md as a concise router that points to the required context assets.", {
1386
- whyItMatters: "Canonical Skill entrypoints should route agents instead of owning reusable knowledge, helper implementations, or detailed procedures.",
1387
- verificationSteps: [
1388
- "Confirm SKILL.md contains routing guidance and required context references only.",
1389
- "Run renma readiness and check layout.skills_thin.",
1390
- ],
1391
- llmHint: "Extract long procedure sections into contexts/**, add metadata.renma.requires-context or metadata.renma.optional-context JSON-array strings, and keep SKILL.md focused on when to use or not use the Skill. Pre-0.16 top-level references are migration input only.",
1392
- }));
1393
- }
1394
- const command = firstExecutableCommand(document);
1395
- if (command) {
1396
- findings.push(findingAt(document, DIAGNOSTIC_IDS.LAYOUT_SKILL_EXECUTABLE_COMMAND, "Skill entrypoint contains executable command", "structure", "low", command.line, command.command, "Move executable command detail into Skill-local references or governed contexts/** procedures, and keep SKILL.md as a router.", {
1397
- whyItMatters: "Executable setup commands in SKILL.md make the entrypoint procedural instead of a concise routing layer.",
1398
- verificationSteps: [
1399
- "Move the command guidance to a context/reference/procedure.",
1400
- "If the command invokes a helper script, ensure it resolves to local scripts/** in the owning Skill or a shared tools/** helper.",
1401
- ],
1402
- }));
1403
- }
1404
- return findings;
1496
+ // Agent Skills explicitly permits step-by-step instructions and command
1497
+ // examples in SKILL.md. Focused-workflow quality is evaluated by dedicated
1498
+ // routing, input, completion, progressive-disclosure, and mixed-knowledge
1499
+ // rules instead of the removed 0.17 thin-router heuristic.
1500
+ return [];
1405
1501
  }
1406
1502
  function helperCommandFindings(document, paths) {
1407
1503
  const findings = [];
@@ -1546,9 +1642,6 @@ function executableCommands(document) {
1546
1642
  }))
1547
1643
  .filter(({ command }) => /^(node|bash|sh|python|python3)\s+/.test(command)));
1548
1644
  }
1549
- function firstExecutableCommand(document) {
1550
- return executableCommands(document)[0];
1551
- }
1552
1645
  function unresolvedHelperCommandFinding(document, command, scriptPath, details = {}) {
1553
1646
  const unsafePath = details.details?.unsafePath === true;
1554
1647
  return findingAt(document, DIAGNOSTIC_IDS.PATH_HELPER_COMMAND_UNRESOLVED, "Helper command target does not resolve", "structure", "medium", command.line, command.command, unsafePath
@@ -1578,9 +1671,6 @@ function lineText(document, line) {
1578
1671
  function isRepoPathLike(value) {
1579
1672
  return /^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)+$/.test(value);
1580
1673
  }
1581
- function words(text) {
1582
- return text.match(/[A-Za-z0-9_./+=-]+|[^\sA-Za-z0-9_./+=-]/g) ?? [];
1583
- }
1584
1674
  function finding(id, title, category, severity, document, remediation, details = {}) {
1585
1675
  return {
1586
1676
  id,
@@ -1635,15 +1725,12 @@ function localSupportUnreachableRuleId(kind) {
1635
1725
  return DIAGNOSTIC_IDS.SUPPORT_UNREACHABLE_PROFILE;
1636
1726
  if (kind === "example")
1637
1727
  return DIAGNOSTIC_IDS.SUPPORT_UNREACHABLE_EXAMPLE;
1728
+ if (kind === "script")
1729
+ return DIAGNOSTIC_IDS.SUPPORT_UNREACHABLE_SCRIPT;
1730
+ if (kind === "asset")
1731
+ return DIAGNOSTIC_IDS.SUPPORT_UNREACHABLE_ASSET;
1638
1732
  return DIAGNOSTIC_IDS.SUPPORT_UNREACHABLE_REFERENCE;
1639
1733
  }
1640
- function escapeRegExp(value) {
1641
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1642
- }
1643
- function approximateTokenCount(text) {
1644
- const matches = text.match(/[A-Za-z0-9_./+=-]+|[^\sA-Za-z0-9_./+=-]/g);
1645
- return matches?.length ?? 0;
1646
- }
1647
1734
  function isPlaceholder(line) {
1648
1735
  return /(?:example|placeholder|your_|<[^>]+>|\$\{[^}]+})/i.test(line);
1649
1736
  }