ghostrules 0.1.1__tar.gz → 0.2.1__tar.gz

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 (177) hide show
  1. ghostrules-0.2.1/.ghostrules.lock +31 -0
  2. {ghostrules-0.1.1 → ghostrules-0.2.1}/.github/workflows/ci.yml +1 -0
  3. ghostrules-0.2.1/.github/workflows/self-test.yml +153 -0
  4. ghostrules-0.2.1/CHANGELOG.md +150 -0
  5. {ghostrules-0.1.1 → ghostrules-0.2.1}/CLAUDE.md +3 -3
  6. {ghostrules-0.1.1 → ghostrules-0.2.1}/CONTRIBUTING.md +36 -4
  7. {ghostrules-0.1.1 → ghostrules-0.2.1}/PKG-INFO +192 -18
  8. {ghostrules-0.1.1 → ghostrules-0.2.1}/README.md +191 -17
  9. {ghostrules-0.1.1 → ghostrules-0.2.1}/SECURITY.md +6 -2
  10. {ghostrules-0.1.1 → ghostrules-0.2.1}/action.yml +54 -3
  11. {ghostrules-0.1.1 → ghostrules-0.2.1}/demo/README.md +12 -0
  12. ghostrules-0.2.1/demo/demo.gif +0 -0
  13. ghostrules-0.2.1/demo/imports.gif +0 -0
  14. ghostrules-0.2.1/demo/imports.tape +46 -0
  15. ghostrules-0.2.1/demo/lock.tape +38 -0
  16. ghostrules-0.2.1/docs/AGENT_MODELS.md +243 -0
  17. ghostrules-0.2.1/docs/DECISIONS.md +744 -0
  18. {ghostrules-0.1.1 → ghostrules-0.2.1}/docs/RULES.md +92 -3
  19. {ghostrules-0.1.1/docs → ghostrules-0.2.1/docs/design}/SPEC.md +1 -1
  20. ghostrules-0.2.1/docs/design/v0.2/PLAN.md +87 -0
  21. ghostrules-0.2.1/docs/design/v0.2/RULES.md +74 -0
  22. ghostrules-0.2.1/docs/design/v0.2/SPEC.md +152 -0
  23. ghostrules-0.2.1/examples/import-chain-repo/.claude/rules/api.md +7 -0
  24. ghostrules-0.2.1/examples/import-chain-repo/.env +1 -0
  25. ghostrules-0.2.1/examples/import-chain-repo/AGENTS.md +3 -0
  26. ghostrules-0.2.1/examples/import-chain-repo/CLAUDE.md +7 -0
  27. ghostrules-0.2.1/examples/import-chain-repo/README.md +11 -0
  28. ghostrules-0.2.1/examples/import-chain-repo/docs/setup.md +4 -0
  29. ghostrules-0.2.1/examples/import-chain-repo/docs/style.md +4 -0
  30. ghostrules-0.2.1/examples/import-chain-repo/shared/team-rules.md +4 -0
  31. ghostrules-0.2.1/examples/import-chain-repo/src/api/users.ts +1 -0
  32. ghostrules-0.2.1/examples/import-chain-repo/src/legacy/CLAUDE.md +3 -0
  33. ghostrules-0.2.1/release-notes.md +43 -0
  34. {ghostrules-0.1.1 → ghostrules-0.2.1}/scripts/make_demo.py +107 -2
  35. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/__init__.py +1 -1
  36. ghostrules-0.2.1/src/ghostrules/agents/__init__.py +49 -0
  37. ghostrules-0.2.1/src/ghostrules/agents/base.py +700 -0
  38. ghostrules-0.2.1/src/ghostrules/agents/claude_code.py +263 -0
  39. ghostrules-0.2.1/src/ghostrules/agents/copilot_cli.py +169 -0
  40. ghostrules-0.2.1/src/ghostrules/agents/cursor.py +128 -0
  41. ghostrules-0.2.1/src/ghostrules/agents/generic.py +80 -0
  42. ghostrules-0.2.1/src/ghostrules/agents/repo.py +223 -0
  43. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/cli.py +283 -1
  44. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/config.py +29 -1
  45. ghostrules-0.2.1/src/ghostrules/context_command.py +127 -0
  46. ghostrules-0.2.1/src/ghostrules/contextscan.py +122 -0
  47. ghostrules-0.2.1/src/ghostrules/globs.py +190 -0
  48. ghostrules-0.2.1/src/ghostrules/imports.py +123 -0
  49. ghostrules-0.2.1/src/ghostrules/lock.py +456 -0
  50. ghostrules-0.2.1/src/ghostrules/markdown_utils.py +359 -0
  51. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/models.py +32 -2
  52. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/common.py +5 -0
  53. ghostrules-0.2.1/src/ghostrules/reporters/context.py +416 -0
  54. ghostrules-0.2.1/src/ghostrules/reporters/lock.py +330 -0
  55. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/markdown.py +5 -1
  56. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/sarif.py +30 -0
  57. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/table.py +10 -0
  58. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/__init__.py +2 -1
  59. ghostrules-0.2.1/src/ghostrules/rules/context_rules.py +377 -0
  60. ghostrules-0.2.1/src/ghostrules/rules/directive.py +211 -0
  61. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/injection.py +30 -9
  62. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/known_installers.py +2 -0
  63. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/patterns.py +16 -5
  64. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/registry.py +46 -0
  65. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/unicode.py +27 -0
  66. ghostrules-0.2.1/src/ghostrules/scancontext.py +31 -0
  67. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/scanner.py +134 -5
  68. ghostrules-0.2.1/src/ghostrules/sensitive.py +58 -0
  69. ghostrules-0.2.1/tests/test_agents_claude.py +572 -0
  70. ghostrules-0.2.1/tests/test_agents_others.py +322 -0
  71. ghostrules-0.2.1/tests/test_agents_repo.py +72 -0
  72. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_ci_files.py +122 -2
  73. ghostrules-0.2.1/tests/test_context_command.py +332 -0
  74. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_demo.py +75 -3
  75. ghostrules-0.2.1/tests/test_directive.py +345 -0
  76. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_docs.py +93 -3
  77. ghostrules-0.2.1/tests/test_globs.py +101 -0
  78. ghostrules-0.2.1/tests/test_imports.py +187 -0
  79. ghostrules-0.2.1/tests/test_lock.py +451 -0
  80. ghostrules-0.2.1/tests/test_markdown_utils.py +265 -0
  81. ghostrules-0.2.1/tests/test_precision_v021.py +162 -0
  82. ghostrules-0.2.1/tests/test_scan_imports.py +493 -0
  83. ghostrules-0.2.1/tests/test_symlink_alias.py +422 -0
  84. ghostrules-0.1.1/.github/workflows/self-test.yml +0 -73
  85. ghostrules-0.1.1/CHANGELOG.md +0 -59
  86. ghostrules-0.1.1/demo/demo.gif +0 -0
  87. ghostrules-0.1.1/docs/DECISIONS.md +0 -332
  88. ghostrules-0.1.1/release-notes.md +0 -15
  89. ghostrules-0.1.1/src/ghostrules/markdown_utils.py +0 -59
  90. ghostrules-0.1.1/tests/test_markdown_utils.py +0 -76
  91. {ghostrules-0.1.1 → ghostrules-0.2.1}/.ghostrules.toml +0 -0
  92. {ghostrules-0.1.1 → ghostrules-0.2.1}/.gitattributes +0 -0
  93. {ghostrules-0.1.1 → ghostrules-0.2.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  94. {ghostrules-0.1.1 → ghostrules-0.2.1}/.github/ISSUE_TEMPLATE/false-positive.yml +0 -0
  95. {ghostrules-0.1.1 → ghostrules-0.2.1}/.github/ISSUE_TEMPLATE/new-rule.yml +0 -0
  96. {ghostrules-0.1.1 → ghostrules-0.2.1}/.github/workflows/release.yml +0 -0
  97. {ghostrules-0.1.1 → ghostrules-0.2.1}/.gitignore +0 -0
  98. {ghostrules-0.1.1 → ghostrules-0.2.1}/.pre-commit-hooks.yaml +0 -0
  99. {ghostrules-0.1.1 → ghostrules-0.2.1}/LICENSE +0 -0
  100. {ghostrules-0.1.1 → ghostrules-0.2.1}/demo/demo.tape +0 -0
  101. {ghostrules-0.1.1/docs → ghostrules-0.2.1/docs/design}/PLAN.md +0 -0
  102. {ghostrules-0.1.1/docs → ghostrules-0.2.1/docs/design}/v0.1.1/GR012-FIX.md +0 -0
  103. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/clean-repo/.claude/settings.json +0 -0
  104. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/clean-repo/.mcp.json +0 -0
  105. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/clean-repo/AGENTS.md +0 -0
  106. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/clean-repo/CLAUDE.md +0 -0
  107. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/clean-repo/README.md +0 -0
  108. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/.claude/settings.json +0 -0
  109. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/.claude/skills/setup/SKILL.md +0 -0
  110. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/.cursorrules +0 -0
  111. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/.github/copilot-instructions.md +0 -0
  112. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/.mcp.json +0 -0
  113. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/AGENTS.md +0 -0
  114. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/CLAUDE.md +0 -0
  115. {ghostrules-0.1.1 → ghostrules-0.2.1}/examples/poisoned-repo/README.md +0 -0
  116. {ghostrules-0.1.1 → ghostrules-0.2.1}/pyproject.toml +0 -0
  117. {ghostrules-0.1.1 → ghostrules-0.2.1}/scripts/changelog_section.py +0 -0
  118. {ghostrules-0.1.1 → ghostrules-0.2.1}/scripts/gen_rules_table.py +0 -0
  119. {ghostrules-0.1.1 → ghostrules-0.2.1}/scripts/make_fixtures.py +0 -0
  120. {ghostrules-0.1.1 → ghostrules-0.2.1}/scripts/set_owner.py +0 -0
  121. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/_compat.py +0 -0
  122. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/clean.py +0 -0
  123. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/jsonloc.py +0 -0
  124. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/mcp_config.py +0 -0
  125. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/py.typed +0 -0
  126. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/__init__.py +0 -0
  127. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reporters/json_.py +0 -0
  128. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/reveal.py +0 -0
  129. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/agent_settings.py +0 -0
  130. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/helpers.py +0 -0
  131. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/rules/mcp.py +0 -0
  132. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/secrets.py +0 -0
  133. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/targets.py +0 -0
  134. {ghostrules-0.1.1 → ghostrules-0.2.1}/src/ghostrules/unicode_utils.py +0 -0
  135. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/conftest.py +0 -0
  136. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/data/sarif-schema-2.1.0.json +0 -0
  137. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr001_flag_forged/AGENTS.md +0 -0
  138. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr001_flag_ok/AGENTS.md +0 -0
  139. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr001_tags/AGENTS.md +0 -0
  140. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr002_bidi/AGENTS.md +0 -0
  141. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr002_rtl_medium/AGENTS.md +0 -0
  142. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_bom_midfile/AGENTS.md +0 -0
  143. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_bom_ok/AGENTS.md +0 -0
  144. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_emoji_zwj_ok/AGENTS.md +0 -0
  145. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_indic_ok/AGENTS.md +0 -0
  146. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_persian_ok/AGENTS.md +0 -0
  147. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_soft_hyphen/AGENTS.md +0 -0
  148. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_zw_file_high/AGENTS.md +0 -0
  149. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_zw_line_high/AGENTS.md +0 -0
  150. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr003_zw_medium/AGENTS.md +0 -0
  151. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr004_vs_bytes/AGENTS.md +0 -0
  152. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr004_vs_ok/AGENTS.md +0 -0
  153. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_benign_ok/CLAUDE.md +0 -0
  154. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_comment_imperative/CLAUDE.md +0 -0
  155. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_comment_injection/CLAUDE.md +0 -0
  156. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_comment_multiline/CLAUDE.md +0 -0
  157. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_in_code_block_ok/CLAUDE.md +0 -0
  158. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_short_ok/CLAUDE.md +0 -0
  159. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr005_unterminated/CLAUDE.md +0 -0
  160. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr006_ok/AGENTS.md +0 -0
  161. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr006_url/AGENTS.md +0 -0
  162. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/fixtures/unicode/gr006_word/AGENTS.md +0 -0
  163. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/secret_samples.py +0 -0
  164. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_cli.py +0 -0
  165. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_config.py +0 -0
  166. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_mcp_config.py +0 -0
  167. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_models.py +0 -0
  168. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_patterns.py +0 -0
  169. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_reporters.py +0 -0
  170. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_rules_config.py +0 -0
  171. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_rules_injection.py +0 -0
  172. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_rules_unicode.py +0 -0
  173. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_scanner.py +0 -0
  174. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_secret_masking.py +0 -0
  175. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_secrets.py +0 -0
  176. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_targets.py +0 -0
  177. {ghostrules-0.1.1 → ghostrules-0.2.1}/tests/test_unicode_utils.py +0 -0
@@ -0,0 +1,31 @@
1
+ {
2
+ "agents": {
3
+ "claude-code": [
4
+ {
5
+ "conditions": [],
6
+ "lines": "2a3d3f1fb26381e9 e3b0c44298fc1c14 ddabff43c0a4efe5 6aa552cc1598dcb7 be186e6b970ab643 fb78540ec32b52f9 e3b0c44298fc1c14 d393a517d5cbec9f e3b0c44298fc1c14 85b7ae55df076ab0 2f6995b0ecd75c8d e3b0c44298fc1c14 5f2235a1b010f82c 56a4406ad70b7f0a ba2cd86d7e76eff5 a7b723b74ee03fc8 e3b0c44298fc1c14 782729a560418c17 36a8e590ff4c085c e3b0c44298fc1c14 9f4e3cc48918efc0 efeeec23855e4659 2f23b1dcff8841e8 c3abd357eb574eb6 76881ea91e0040bd e3b0c44298fc1c14 36cd3f2bb454f575 ad332335cfaa348c a58865feac87f52b 052081156966d443 5654f9fffd4a2a7a bd0710fd0315ecbb e4d8cec4158bb770 f1b901847390b0ed e3b0c44298fc1c14 966a8946115b377a 5b59b2f749ffabac 9bf96d3c4c385073 43d8bbb16372109c 5226bbb3f5f9e13d add6d744d3ac0c02 3dafca094d79548b 21a3cd5236dfd642 79e12b3b50117933 9cb81024d1184666 f1e7b346d65f35c5 e3b0c44298fc1c14 60ab6be4219694a0 3a1c5dcc5281208a e256f3fb8239bf8c 10d8918d097bebb5 ff85c33a894fab39 10f274c7d25257d2 6216cf539fa87bd8 e3b0c44298fc1c14 7136000e494604c0 aa8d4cf82644ac63 f75f6ee8f0d942eb 1f59b655e6071114 da29957f3e8be475",
7
+ "load": "always",
8
+ "path": "CLAUDE.md",
9
+ "raw_sha256": "c21de91b03da043818a3d8a83418a2e4ce449e58e1e6a5906e7d7c2212ddfca5",
10
+ "seen_sha256": "c21de91b03da043818a3d8a83418a2e4ce449e58e1e6a5906e7d7c2212ddfca5",
11
+ "via": []
12
+ }
13
+ ],
14
+ "copilot-cli": [
15
+ {
16
+ "conditions": [],
17
+ "lines": "2a3d3f1fb26381e9 e3b0c44298fc1c14 ddabff43c0a4efe5 6aa552cc1598dcb7 be186e6b970ab643 fb78540ec32b52f9 e3b0c44298fc1c14 d393a517d5cbec9f e3b0c44298fc1c14 85b7ae55df076ab0 2f6995b0ecd75c8d e3b0c44298fc1c14 5f2235a1b010f82c 56a4406ad70b7f0a ba2cd86d7e76eff5 a7b723b74ee03fc8 e3b0c44298fc1c14 782729a560418c17 36a8e590ff4c085c e3b0c44298fc1c14 9f4e3cc48918efc0 efeeec23855e4659 2f23b1dcff8841e8 c3abd357eb574eb6 76881ea91e0040bd e3b0c44298fc1c14 36cd3f2bb454f575 ad332335cfaa348c a58865feac87f52b 052081156966d443 5654f9fffd4a2a7a bd0710fd0315ecbb e4d8cec4158bb770 f1b901847390b0ed e3b0c44298fc1c14 966a8946115b377a 5b59b2f749ffabac 9bf96d3c4c385073 43d8bbb16372109c 5226bbb3f5f9e13d add6d744d3ac0c02 3dafca094d79548b 21a3cd5236dfd642 79e12b3b50117933 9cb81024d1184666 f1e7b346d65f35c5 e3b0c44298fc1c14 60ab6be4219694a0 3a1c5dcc5281208a e256f3fb8239bf8c 10d8918d097bebb5 ff85c33a894fab39 10f274c7d25257d2 6216cf539fa87bd8 e3b0c44298fc1c14 7136000e494604c0 aa8d4cf82644ac63 f75f6ee8f0d942eb 1f59b655e6071114 da29957f3e8be475",
18
+ "load": "always",
19
+ "path": "CLAUDE.md",
20
+ "raw_sha256": "c21de91b03da043818a3d8a83418a2e4ce449e58e1e6a5906e7d7c2212ddfca5",
21
+ "seen_sha256": "c21de91b03da043818a3d8a83418a2e4ce449e58e1e6a5906e7d7c2212ddfca5",
22
+ "via": []
23
+ }
24
+ ],
25
+ "cursor": [],
26
+ "generic": []
27
+ },
28
+ "configs": [],
29
+ "generator": "ghostrules 0.2.1",
30
+ "lock_version": 1
31
+ }
@@ -38,3 +38,4 @@ jobs:
38
38
  run: |
39
39
  ghostrules scan . --no-color
40
40
  ghostrules scan . --all-files --no-color
41
+ ghostrules lock --check --no-color
@@ -0,0 +1,153 @@
1
+ name: Self-test
2
+
3
+ # Runs the action from this very checkout against the demo repositories.
4
+ on:
5
+ push:
6
+ branches: [main]
7
+ pull_request:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ action:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Poisoned demo with fail-on none (must pass, must report findings)
19
+ id: poisoned
20
+ uses: ./
21
+ with:
22
+ path: examples/poisoned-repo
23
+ fail-on: none
24
+ upload-sarif: "false"
25
+
26
+ - name: SARIF must contain results, led by the hidden instruction
27
+ run: |
28
+ python - <<'PY'
29
+ import json
30
+ run = json.load(open("ghostrules.sarif"))["runs"][0]
31
+ results = run["results"]
32
+ assert len(results) > 10, f"expected many results, got {len(results)}"
33
+ ids = {r["ruleId"] for r in results}
34
+ assert {"GR001", "GR012", "GR101"} <= ids, ids
35
+ assert results[0]["ruleId"] == "GR001", results[0]["ruleId"]
36
+ assert run["tool"]["driver"]["rules"], "rules missing"
37
+ print(f"ok: {len(results)} results")
38
+ PY
39
+
40
+ - name: The exit-code output is 0
41
+ env:
42
+ EXIT_CODE: ${{ steps.poisoned.outputs.exit-code }}
43
+ run: test "$EXIT_CODE" = "0"
44
+
45
+ - name: Poisoned demo with the default fail-on (must fail the step)
46
+ id: gate
47
+ uses: ./
48
+ continue-on-error: true
49
+ with:
50
+ path: examples/poisoned-repo
51
+ upload-sarif: "false"
52
+
53
+ - name: The gate must have failed
54
+ env:
55
+ OUTCOME: ${{ steps.gate.outcome }}
56
+ EXIT_CODE: ${{ steps.gate.outputs.exit-code }}
57
+ run: |
58
+ test "$OUTCOME" = "failure"
59
+ test "$EXIT_CODE" = "1"
60
+
61
+ - name: Clean demo (must pass with no results)
62
+ uses: ./
63
+ with:
64
+ path: examples/clean-repo
65
+ upload-sarif: "false"
66
+
67
+ - name: SARIF must be empty
68
+ run: |
69
+ python - <<'PY'
70
+ import json
71
+ results = json.load(open("ghostrules.sarif"))["runs"][0]["results"]
72
+ assert results == [], results
73
+ PY
74
+
75
+ import-chain:
76
+ runs-on: ubuntu-latest
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+
80
+ - name: Import-chain demo, following imports (default)
81
+ uses: ./
82
+ with:
83
+ path: examples/import-chain-repo
84
+ fail-on: none
85
+ upload-sarif: "false"
86
+
87
+ - name: SARIF must carry the hidden payload with the import chain that reaches it
88
+ run: |
89
+ python - <<'PY'
90
+ import json
91
+ results = json.load(open("ghostrules.sarif"))["runs"][0]["results"]
92
+ ids = {r["ruleId"] for r in results}
93
+ assert {"GR001", "GR020", "GR021"} <= ids, ids
94
+ hidden = next(r for r in results if r["ruleId"] == "GR001")
95
+ chain = [l["physicalLocation"]["artifactLocation"]["uri"] for l in hidden["relatedLocations"]]
96
+ assert chain == ["CLAUDE.md", "docs/style.md"], chain
97
+ assert hidden["locations"][0]["physicalLocation"]["artifactLocation"]["uri"] == "shared/team-rules.md"
98
+ assert "reached-via-import" in hidden["properties"]["tags"]
99
+ print(f"ok: {len(results)} results")
100
+ PY
101
+
102
+ - name: Import-chain demo with follow-imports off (a 0.1-style scan finds nothing)
103
+ uses: ./
104
+ with:
105
+ path: examples/import-chain-repo
106
+ follow-imports: "false"
107
+ upload-sarif: "false"
108
+
109
+ - name: SARIF must be empty
110
+ run: |
111
+ python - <<'PY'
112
+ import json
113
+ results = json.load(open("ghostrules.sarif"))["runs"][0]["results"]
114
+ assert results == [], results
115
+ PY
116
+
117
+ - name: Lock a copy of the demo, then make a pull-request-like change to another copy
118
+ run: |
119
+ python scripts/make_demo.py --lock-scenario "$RUNNER_TEMP/acme"
120
+ ghostrules lock --root "$RUNNER_TEMP/acme/base"
121
+ cp "$RUNNER_TEMP/acme/base/.ghostrules.lock" "$RUNNER_TEMP/acme/pr/"
122
+
123
+ - name: Lock check on the unchanged repository (must pass)
124
+ id: unchanged
125
+ uses: ./
126
+ with:
127
+ path: ${{ runner.temp }}/acme/base
128
+ fail-on: none
129
+ lock-check: "true"
130
+ upload-sarif: "false"
131
+
132
+ - name: The unchanged lock exit code is 0
133
+ env:
134
+ LOCK_EXIT_CODE: ${{ steps.unchanged.outputs.lock-exit-code }}
135
+ run: test "$LOCK_EXIT_CODE" = "0"
136
+
137
+ - name: Lock check after the pull request (must fail the step)
138
+ id: changed
139
+ uses: ./
140
+ continue-on-error: true
141
+ with:
142
+ path: ${{ runner.temp }}/acme/pr
143
+ fail-on: none
144
+ lock-check: "true"
145
+ upload-sarif: "false"
146
+
147
+ - name: The changed lock must have failed with exit code 1
148
+ env:
149
+ OUTCOME: ${{ steps.changed.outcome }}
150
+ LOCK_EXIT_CODE: ${{ steps.changed.outputs.lock-exit-code }}
151
+ run: |
152
+ test "$OUTCOME" = "failure"
153
+ test "$LOCK_EXIT_CODE" = "1"
@@ -0,0 +1,150 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.2.1] - 2026-10-28
9
+
10
+ Precision release. A scan of 12 popular public repositories with 0.2.0 found no critical issue,
11
+ but every `high` finding was a false positive, and `context` was wrong for the most common real
12
+ setup. On those repositories 0.2.0 reported 9 high, 18 medium and 8 low findings; 0.2.1 reports
13
+ 2 medium and 2 low, with no high, no critical and no GR025.
14
+
15
+ ### Added
16
+ - `ghostrules context --format json` entries carry `alias_of` (and `link_problem`) when a symlink is
17
+ involved; lock entries carry `link` for an alias. Both keys are omitted otherwise.
18
+ - `ghostrules.rules.directive.classify`: the helper that tells directive, descriptive and example
19
+ text apart (used by GR011, GR014 and GR016).
20
+
21
+ ### Fixed
22
+ - A symbolic link whose final target is a regular file inside the repository is now an **alias**:
23
+ `CLAUDE.md -> AGENTS.md` (the setup Claude Code documents) is loaded under the link's name,
24
+ `context` shows `CLAUDE.md → AGENTS.md (symlink)` and the `AGENTS.md` entry as already read, the
25
+ content is scanned once (findings say `via CLAUDE.md (symlink)`), and `lock` records the link and
26
+ its target. Chains of up to 8 links and in-repository directory links work the same way. Nothing
27
+ is opened before the resolved path is known to be inside the repository.
28
+ GR025 now fires only for links that leave the repository (`high`) or are broken, cyclic or too
29
+ long (`low`), instead of one `medium` per link, and adds an `info` note for a link checked out as
30
+ a text file (Windows with `core.symlinks=false`).
31
+ - GR022 no longer reports npm scopes and mentions (`@n8n/design-system`, `@cline/llms`, `@types/node`)
32
+ as imports that do not load. It reports a token only if it has a file extension, starts with `./`,
33
+ `../`, `~/` or `/`, or its first directory exists next to the importing file.
34
+ - GR011, GR014 and GR016 tell instructions from descriptions and examples. A match in prose that
35
+ describes something ("The scripts read `~/.npmrc`", "The harness runs Claude with
36
+ `bypassPermissions`") is at most `medium`; in a fenced block, in quotes or after "e.g.", "such
37
+ as", "a skill that ..." it is at most `low`; imperative text and decoded hidden text keep their
38
+ severity. A lowered finding says why.
39
+ - GR011: "do not tell the user to/which/what/how ..." is no longer concealment.
40
+ - GR014: the verb must govern the path (same clause, six words at most) and template files
41
+ (`.env.example`, `*.example`, `.env.ai-surfaces.example`) never fire.
42
+ - GR012: `curl ... | python -c`, `| python -m`, `| python script.py`, `| sh -c '...'` use stdin as
43
+ data and are no longer reported; `| python`, `| python -` and `| sh` still are. The Claude Code
44
+ installer (`https://claude.ai/install.sh`) is a known installer. GR105 and GR107 share these
45
+ patterns and follow.
46
+
47
+ ### Changed
48
+ - README: the new tagline is the only one (the old one opens the first paragraph), the import-chain
49
+ GIF comes first and the hidden-Unicode GIF sits further down, both by absolute URL.
50
+ - The original `SPEC.md`, `PLAN.md` and the per-version design documents moved to `docs/design/`
51
+ (design history, not kept up to date). `RULES.md`, `AGENT_MODELS.md` and `DECISIONS.md` stay in
52
+ `docs/`.
53
+
54
+ ## [0.2.0] - 2026-10-28
55
+
56
+ Know exactly what your agent reads: `ghostrules` now models how each agent loads its instructions,
57
+ scans exactly that, shows it, and pins it.
58
+
59
+ ### Added
60
+ - GitHub Action inputs `follow-imports` (default `true`) and `lock-check` (default `false`). With
61
+ `lock-check` the action runs `ghostrules lock --check`, puts the differences in the job summary
62
+ under "What your agents read changed in this PR" and fails the job if there are any; new output
63
+ `lock-exit-code`.
64
+ - Config keys `follow_imports`, `agents` and `lockfile`.
65
+ - `python scripts/make_demo.py --lock-scenario DEST` and the tapes `demo/imports.tape` and
66
+ `demo/lock.tape` for the 0.2 GIFs.
67
+ - `ghostrules lock`: writes `.ghostrules.lock`, a deterministic record (sorted keys, no timestamps,
68
+ CRLF-normalised hashes) of every file in each modelled agent's context, how it is reached, and
69
+ the text the agent actually receives, plus a hash of every MCP and agent settings file.
70
+ `lock --check` recomputes it and shows what changed (added, changed, removed, and changes that
71
+ only touch text an agent strips), with invisible characters revealed; exit 0 up to date, 1
72
+ changed, 2 error. `--format text|markdown|json`, `--update`, `--lockfile`; config key `lockfile`.
73
+ - `ghostrules context [TARGET]`: shows what an agent reads when it works on a file (the files it
74
+ loads at session start, the rules its `paths`/`globs` select, the directories that load on
75
+ demand, the imports it follows and the files it skips, with the reason) and scans exactly that.
76
+ Output as a tree, JSON or Markdown; `--agent`, `--cwd`, `--root`, `--show-text`, `--no-scan`,
77
+ `--home`, `--fail-on`.
78
+ - `examples/import-chain-repo`: a CLAUDE.md that looks clean and reaches a hidden payload through two
79
+ imports, plus a `.env` import and one outside the repository.
80
+ - `scan` follows `@path` imports by default: files an instruction file imports are scanned as
81
+ instructions, and their findings carry the import chain (`via`), the agents that load them and the
82
+ tag `reached-via-import`. `--no-follow-imports` (or `follow_imports = false`) turns it off.
83
+ - Rules GR020 (external import), GR021 (sensitive file imported), GR022 (import that silently does
84
+ not load), GR023 (import cycle), GR024 (tag for payloads reached through an import) and GR025
85
+ (symlinked instruction source).
86
+ - The files each modelled agent loads (including `.claude/rules/**`) are scanned even when the
87
+ discovery globs do not list them. New config keys `follow_imports` and `agents`.
88
+ - JSON findings gain optional `via`, `agents` and `tags`; SARIF results gain `relatedLocations` for
89
+ the chain and `properties.agents`/`tags`; the table and Markdown reports show the chain.
90
+
91
+ - `docs/AGENT_MODELS.md`: how each agent loads its instructions, with the documentation it is based on
92
+ and what is still unverified; `CONTRIBUTING.md` explains how to add a model.
93
+ - `ghostrules` locks its own `CLAUDE.md` (`.ghostrules.lock`), checked in CI.
94
+
95
+ ### Changed
96
+ - GR005 is agent-aware: it says which agents see a hidden comment. Claude Code strips block-level
97
+ comments from CLAUDE.md files, so the finding is info when no configured agent sees the comment.
98
+
99
+ ## [0.1.1] - 2026-10-27
100
+
101
+ ### Changed
102
+ - GR012 (remote code execution pattern) now sets its severity from context instead of reporting
103
+ every `curl ... | sh` as critical. A well-known installer in a code block is low, in prose
104
+ medium; an unknown domain is high in a code block and critical in prose. Plain `http://`, IP
105
+ literals, non-default ports, collector domains, opaque payloads (`base64 -d | sh`,
106
+ `powershell -enc`) and text hidden by invisible characters stay critical. This stops the default
107
+ `--fail-on high` from failing on real repositories that document `uv` or `rustup`.
108
+ GR105 and GR107 (MCP server commands and hooks) are unchanged.
109
+
110
+ ### Added
111
+ - Built-in list of well-known installers (uv/ruff, rustup, Bun, Deno, pnpm, Poetry, Homebrew, nvm,
112
+ SDKMAN, Docker, Ollama, Volta), matched on the exact host and optional path prefix, and
113
+ `ghostrules rules --installers` to print it.
114
+ - `trust_known_installers` option (default `true`); `false` restores the 0.1.0 behaviour.
115
+ - Inline code span awareness for GR012 (`ScanTarget.code_span_at`).
116
+
117
+ ## [0.1.0] - 2026-10-27
118
+
119
+ First release.
120
+
121
+ ### Added
122
+ - Scanner for the files AI coding agents read and obey (`AGENTS.md`, `CLAUDE.md`, `.cursorrules`,
123
+ Copilot instructions, skills, MCP configs, agent settings and more), with `--home` for
124
+ user-level configs and `--all-files` for hidden Unicode anywhere in a tree.
125
+ - 21 rules. Hidden content: Unicode tag characters (GR001), bidirectional controls (GR002),
126
+ zero-width characters (GR003), variation-selector steganography (GR004), hidden HTML comments
127
+ (GR005), mixed-script homoglyphs (GR006). Malicious instructions, English and Spanish: instruction
128
+ override (GR010), concealment (GR011), remote code execution (GR012), data exfiltration (GR013),
129
+ sensitive file access (GR014), encoded payloads (GR015), safety bypass (GR016). Configuration:
130
+ hardcoded secrets (GR101), unpinned packages (GR102), insecure transport (GR103), broad
131
+ filesystem scope (GR104), shell wrappers (GR105), dangerous Docker options (GR106),
132
+ over-permissive agent settings (GR107), auto-trusted MCP servers (GR108).
133
+ - Hidden text decoded by GR001, GR004 and GR015 is re-scanned by GR010-GR016 and reported with
134
+ one more level of severity.
135
+ - CLI: `scan` (the default command), `reveal`, `clean`, `rules`, `version`. Reports as a table
136
+ grouped by file with the decoded hidden text highlighted, JSON, SARIF 2.1.0 (validated against the
137
+ official schema) and Markdown. Exit codes: 0 clean, 1 findings at or above `--fail-on`, 2 error.
138
+ - Configuration through `.ghostrules.toml` or `[tool.ghostrules]`, and inline `ghostrules-ignore`
139
+ suppressions (never for GR001, GR002 or text found inside hidden characters).
140
+ - GitHub Action (SARIF upload to code scanning, job summary, `fail-on` gate), pre-commit hook, CI
141
+ with a smoke test and a self-scan, and a tag-triggered release workflow using PyPI Trusted
142
+ Publishing.
143
+ - Demo repositories `examples/poisoned-repo` (every rule fires) and `examples/clean-repo` (no
144
+ findings), and `demo/demo.tape` to record the README GIF.
145
+
146
+ ### Security
147
+ - Read-only: nothing found in a scanned file is executed, imported, downloaded or sent anywhere,
148
+ and the tool makes no network requests. Symbolic links are not followed.
149
+ - Secrets are never printed: every finding, warning and error passes through one masking step
150
+ (`ghp_****…a1b2`), and a test fails if a secret appears in any report format.
@@ -11,9 +11,9 @@ It is a **defensive** security tool. It only reads files and reports findings. I
11
11
  anything it finds, never makes network requests, and never phones home.
12
12
 
13
13
  ## Source-of-truth documents (read before coding)
14
- - `docs/SPEC.md` — features, CLI, file targets, output formats, config. **The contract.**
14
+ - `docs/design/SPEC.md` — features, CLI, file targets, output formats, config. **The contract.**
15
15
  - `docs/RULES.md` — every detection rule: ID, severity, logic, true/false positive examples.
16
- - `docs/PLAN.md` — build order, phase by phase, with acceptance criteria.
16
+ - `docs/design/PLAN.md` — build order, phase by phase, with acceptance criteria.
17
17
 
18
18
  If something in the code disagrees with these docs, the docs win unless the user says otherwise.
19
19
  If a doc is ambiguous, pick the simplest reasonable option and note it in `docs/DECISIONS.md`.
@@ -54,7 +54,7 @@ ghostrules scan examples/clean-repo # must report zero findings
54
54
  - Never add code that executes, downloads or evaluates scanned content.
55
55
 
56
56
  ## Workflow
57
- - Work phase by phase following `docs/PLAN.md`. After each phase: run tests + ruff, then
57
+ - Work phase by phase following `docs/design/PLAN.md`. After each phase: run tests + ruff, then
58
58
  stop and summarize what was done and what is next.
59
59
  - Commit after each phase with a conventional commit message (`feat:`, `test:`, `docs:`…).
60
60
  - Keep the README in English and keep it updated when CLI flags change.
@@ -17,9 +17,12 @@ ghostrules scan examples/poisoned-repo # must find issues, exit code 1
17
17
  ghostrules scan examples/clean-repo # must report nothing, exit code 0
18
18
  ```
19
19
 
20
- The documents in `docs/` are the contract: `SPEC.md` (features), `RULES.md` (every rule) and
21
- `DECISIONS.md` (choices made where they were ambiguous). If code and docs disagree, fix one of
22
- them in the same pull request.
20
+ The documents in `docs/` are the contract: `RULES.md` (every rule), `AGENT_MODELS.md` (how each
21
+ agent loads its instructions, with sources) and `DECISIONS.md` (choices made where they were
22
+ ambiguous). `docs/design/` is the **design history**: the original `SPEC.md` and `PLAN.md` and the
23
+ per-version design documents (`v0.1.1/`, `v0.2/`). They explain why things are the way they are and
24
+ are not kept up to date. If code and the contract documents disagree, fix one of them in the same
25
+ pull request.
23
26
 
24
27
  ## Add a rule in three steps
25
28
 
@@ -46,7 +49,8 @@ them in the same pull request.
46
49
 
47
50
  2. **Test it.** Add at least one positive and one negative test (see `tests/test_rules_*.py`). Add
48
51
  a case to `scripts/make_demo.py` so `examples/poisoned-repo` triggers the rule (a test fails
49
- if any rule does not fire there) and make sure `examples/clean-repo` still reports nothing.
52
+ if a `GR00x`, `GR01x` or `GR1xx` rule does not fire there; the import rules `GR02x` are tested
53
+ in `tests/test_scan_imports.py`) and make sure `examples/clean-repo` still reports nothing.
50
54
  Fixtures with invisible characters are generated by `scripts/make_fixtures.py`.
51
55
 
52
56
  3. **Document it.** Describe the rule in `docs/RULES.md` (ID, severity, logic, true and false
@@ -58,6 +62,32 @@ them in the same pull request.
58
62
  python scripts/gen_rules_table.py --write
59
63
  ```
60
64
 
65
+ ## Add an agent model
66
+
67
+ `ghostrules context` and `ghostrules lock` need to know how an agent loads its instructions. A
68
+ model is one module, one section of `docs/AGENT_MODELS.md` and its tests:
69
+
70
+ 1. **Write down what the agent's documentation says** in a new section of `docs/AGENT_MODELS.md`:
71
+ which files it reads and in what order, which are conditional or loaded on demand, whether it
72
+ follows `@` imports (relative to what, how deep), what it strips before the model sees the text,
73
+ and the page and date you checked. Anything the documentation does not state is marked
74
+ **UNVERIFIED** and modelled conservatively (a file the agent might read is included). Model only
75
+ what is written there.
76
+ 2. **Implement it** in `src/ghostrules/agents/<name>.py` with a `build(repo, *, cwd, target, home)`
77
+ method that returns a `ContextGraph`. Use the `Builder` in `agents/base.py`: it reads files
78
+ safely (never through a symlink), applies your text transforms (`render_*`), follows imports
79
+ with the `ImportPolicy` you pass, hashes the result and records the edges. Register the model in
80
+ `agents/__init__.py` (`AGENT_NAMES`, `get_model`) and in `config.AGENT_NAMES`. Use
81
+ `globs.matches_any` for `paths`/`globs`/`applyTo` and `markdown_utils.parse_frontmatter` for
82
+ front matter.
83
+ 3. **Test it with a fake repository** built in `tmp_path` (see `tests/test_agents_claude.py`):
84
+ given the tree, the working directory and the target, the ordered entries, their `load`
85
+ states, `matches` and `unverified` flags must be what the documentation implies. Add the
86
+ precedence and depth cases that apply to the agent.
87
+ 4. **Say what you could not model** (user-level or organisation settings, environment variables)
88
+ in `ContextGraph.notes`, and add a line to `CHANGELOG.md` and a decision to
89
+ `docs/DECISIONS.md` for every judgement call.
90
+
61
91
  ## Rules of the repository
62
92
 
63
93
  - **Defanged only.** Fixtures, demos and tests use `attacker.example`, `exfil.example`,
@@ -77,4 +107,6 @@ them in the same pull request.
77
107
  - [ ] positive and negative tests for every new or changed detection
78
108
  - [ ] `examples/poisoned-repo` still triggers every rule; `examples/clean-repo` is still clean
79
109
  - [ ] `docs/RULES.md`, `docs/DECISIONS.md`, `CHANGELOG.md` and the README table are updated
110
+ - [ ] for an agent model: `docs/AGENT_MODELS.md` cites the documentation and the date, and the
111
+ unverified parts are marked
80
112
  - [ ] nothing real in the fixtures: no secrets, domains or payloads that work