@routinecrew/routinecode 2.31.77 → 2.31.86

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 (244) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.sh +23 -0
  3. package/bin/prompt-vault.dat +1 -0
  4. package/bin/prompt-vault.js +51 -1
  5. package/bin/rc-board.js +58 -0
  6. package/bin/rc-config.js +756 -1
  7. package/bin/rc-credit-turn.js +2 -1
  8. package/bin/rc-grant.js +2 -1
  9. package/bin/rc-login.js +2 -0
  10. package/bin/rc-map.js +132 -0
  11. package/bin/rc-privacy.js +200 -0
  12. package/bin/rc-skills.js +31 -0
  13. package/bin/rc-team.js +2 -1
  14. package/bin/setup.js +4 -0
  15. package/hooks/cc-compat-watch.js +2 -1
  16. package/hooks/claim-questions.json +40 -0
  17. package/hooks/hooks-config.json +108 -1
  18. package/hooks/lib/agent_budget.py +122 -0
  19. package/hooks/lib/agent_telemetry.py +143 -0
  20. package/hooks/lib/attest_reader.py +15 -6
  21. package/hooks/lib/attribution_judge.py +109 -0
  22. package/hooks/lib/board-golden.json +268 -0
  23. package/hooks/lib/board.py +503 -0
  24. package/hooks/lib/board_sync.py +535 -0
  25. package/hooks/lib/cc-surface.json +1 -1
  26. package/hooks/lib/claim_structure.py +412 -0
  27. package/hooks/lib/completion_log.py +12 -5
  28. package/hooks/lib/config_bash_track.py +114 -28
  29. package/hooks/lib/config_guard.py +137 -5
  30. package/hooks/lib/edit_tracker.py +182 -0
  31. package/hooks/lib/error_line.py +94 -0
  32. package/hooks/lib/escalation_restore.py +66 -0
  33. package/hooks/lib/i18n.py +37 -15
  34. package/hooks/lib/knowledge_items.py +1407 -0
  35. package/hooks/lib/knowledge_scope.py +123 -0
  36. package/hooks/lib/known_solution.py +37 -9
  37. package/hooks/lib/log_compact.py +85 -0
  38. package/hooks/lib/metacog_signals.py +228 -0
  39. package/hooks/lib/orch_decision.py +690 -0
  40. package/hooks/lib/premise-golden.json +96 -0
  41. package/hooks/lib/presence.py +10 -3
  42. package/hooks/lib/privacy_log.py +35 -0
  43. package/hooks/lib/receipt.py +137 -14
  44. package/hooks/lib/review_gate.py +83 -0
  45. package/hooks/lib/routine_skill_eval.py +213 -0
  46. package/hooks/lib/secret_filter.py +2 -1
  47. package/hooks/lib/skill_drafts.py +188 -0
  48. package/hooks/lib/sync_manager.py +121 -26
  49. package/hooks/lib/usage_v2.py +680 -0
  50. package/hooks/lib/work_kind.py +198 -0
  51. package/hooks/lib/work_kind_events.py +361 -0
  52. package/hooks/pending-drainer.sh +28 -0
  53. package/hooks/post-agent-budget.sh +50 -0
  54. package/hooks/post-agent-return.sh +89 -3
  55. package/hooks/post-bash-failure.sh +39 -0
  56. package/hooks/post-bash-knowledge.sh +15 -34
  57. package/hooks/post-bash-verify.sh +33 -16
  58. package/hooks/post-build-check.sh +16 -18
  59. package/hooks/post-config-context.sh +13 -0
  60. package/hooks/post-delegation-nudge.sh +12 -1
  61. package/hooks/post-edit-track.sh +19 -28
  62. package/hooks/post-orch-decision.sh +35 -0
  63. package/hooks/post-read-config-context.sh +20 -0
  64. package/hooks/pre-account-guard.sh +1 -1
  65. package/hooks/pre-agent-spawn.mjs +2 -1
  66. package/hooks/pre-agent-spawn.sh +12 -1
  67. package/hooks/pre-bash-guard.sh +61 -3
  68. package/hooks/pre-bash-knowledge.sh +46 -0
  69. package/hooks/pre-credit-guard.sh +1 -1
  70. package/hooks/pre-edit-board.sh +44 -0
  71. package/hooks/pre-edit-check.sh +29 -5
  72. package/hooks/pre-edit-config-gate.sh +1 -1
  73. package/hooks/pre-edit-domain-gate.sh +23 -22
  74. package/hooks/pre-mark-complete.sh +32 -4
  75. package/hooks/pre-read-knowledge-inject.sh +34 -24
  76. package/hooks/pre-review-gate.sh +17 -0
  77. package/hooks/recorder-runner.sh +25 -2
  78. package/hooks/session-start-compact.sh +28 -0
  79. package/hooks/session-start.sh +167 -19
  80. package/hooks/skill-knowledge.sh +37 -0
  81. package/hooks/stop-claim-check.v3.sh +21 -3
  82. package/hooks/stop-usage-metrics.sh +138 -83
  83. package/hooks/subagent-stop-usage.sh +25 -0
  84. package/hooks/user-prompt-submit.sh +10 -4
  85. package/mcp-db-manager/dist/analyzers/duplicate-detector.js +1 -1
  86. package/mcp-db-manager/dist/core/model-parser.js +1 -1
  87. package/mcp-db-manager/dist/core/schema-reader.js +1 -1
  88. package/mcp-db-manager/dist/executors/migration-executor.js +1 -1
  89. package/mcp-db-manager/dist/generators/migration-generator.js +1 -1
  90. package/mcp-db-manager/dist/index.js +1 -1
  91. package/mcp-db-manager/dist/validators/schema-validator.js +1 -1
  92. package/mcp-dev-tester/dist/analyzers/auth-diagnoser.js +1 -1
  93. package/mcp-dev-tester/dist/analyzers/backend-analyzer.js +1 -1
  94. package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.js +1 -1
  95. package/mcp-dev-tester/dist/analyzers/frontend-analyzer.js +1 -1
  96. package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.js +1 -1
  97. package/mcp-dev-tester/dist/analyzers/type-comparator.js +1 -1
  98. package/mcp-dev-tester/dist/analyzers/validation-diagnoser.js +1 -1
  99. package/mcp-dev-tester/dist/attestation.js +1 -1
  100. package/mcp-dev-tester/dist/browser/playwright-manager.js +1 -1
  101. package/mcp-dev-tester/dist/browser/ui-tester.js +1 -1
  102. package/mcp-dev-tester/dist/config/project-config.js +1 -1
  103. package/mcp-dev-tester/dist/index.js +1 -1
  104. package/mcp-dev-tester/dist/testers/api-tester.js +1 -1
  105. package/mcp-doc-fetcher/dist/index.js +1 -1
  106. package/mcp-html-renderer/dist/index.js +1 -1
  107. package/mcp-html-renderer/dist/preview.js +1 -1
  108. package/mcp-html-renderer/dist/template-engine.js +1 -1
  109. package/mcp-intelligence/dist/concept-catalog.js +1 -1
  110. package/mcp-intelligence/dist/concept-server-proxy.js +1 -1
  111. package/mcp-intelligence/dist/config-auth.js +1 -1
  112. package/mcp-intelligence/dist/contracts.generated.js +1 -1
  113. package/mcp-intelligence/dist/domain-templates.js +1 -1
  114. package/mcp-intelligence/dist/grounding.js +1 -1
  115. package/mcp-intelligence/dist/handlers.js +1 -1
  116. package/mcp-intelligence/dist/index.js +1 -1
  117. package/mcp-intelligence/dist/intelligence-file.js +1 -1
  118. package/mcp-intelligence/dist/knowledge-critic.js +1 -1
  119. package/mcp-intelligence/dist/knowledge-guide.js +1 -0
  120. package/mcp-intelligence/dist/knowledge-handlers.js +1 -1
  121. package/mcp-intelligence/dist/knowledge-migrate.js +1 -0
  122. package/mcp-intelligence/dist/knowledge-record.js +1 -0
  123. package/mcp-intelligence/dist/knowledge-scope.js +1 -0
  124. package/mcp-intelligence/dist/mention-extractor.js +1 -1
  125. package/mcp-intelligence/dist/provenance.js +1 -1
  126. package/mcp-intelligence/dist/sanitize.generated.js +242 -0
  127. package/mcp-intelligence/dist/semantic-embedder.js +1 -1
  128. package/mcp-log-watcher/dist/config-auth.js +1 -1
  129. package/mcp-log-watcher/dist/file-watcher.js +1 -1
  130. package/mcp-log-watcher/dist/index.js +1 -1
  131. package/mcp-log-watcher/dist/known-solutions.js +1 -1
  132. package/mcp-log-watcher/dist/log-store.js +1 -1
  133. package/mcp-log-watcher/dist/sanitize.generated.js +242 -0
  134. package/mcp-log-watcher/dist/websocket-server.js +1 -1
  135. package/mcp-log-watcher/package.json +1 -1
  136. package/mcp-plan-manager/dist/__tests__/file-ops-knowledge-dir.test.js +1 -1
  137. package/mcp-plan-manager/dist/__tests__/plan-parser.test.js +1 -1
  138. package/mcp-plan-manager/dist/file-ops.js +1 -1
  139. package/mcp-plan-manager/dist/index.js +1 -1
  140. package/mcp-plan-manager/dist/plan-parser.js +1 -1
  141. package/mcp-project-context/dist/git-ops.js +1 -1
  142. package/mcp-project-context/dist/index.js +1 -1
  143. package/mcp-project-context/dist/project-analysis.js +1 -1
  144. package/mcp-routinecode/dist/agent-tracker.js +1 -1
  145. package/mcp-routinecode/dist/analysis-ledger.js +590 -0
  146. package/mcp-routinecode/dist/attestation.js +1 -1
  147. package/mcp-routinecode/dist/blast-radius.js +1 -1
  148. package/mcp-routinecode/dist/board.js +1 -0
  149. package/mcp-routinecode/dist/build-id.js +1 -0
  150. package/mcp-routinecode/dist/changeset.js +1 -1
  151. package/mcp-routinecode/dist/config-auth.js +1 -1
  152. package/mcp-routinecode/dist/config-map/applied.js +1 -0
  153. package/mcp-routinecode/dist/config-map/arch-graph.js +1 -1
  154. package/mcp-routinecode/dist/config-map/architect-store.js +1132 -1
  155. package/mcp-routinecode/dist/config-map/assign.js +1 -1
  156. package/mcp-routinecode/dist/config-map/audit-cli.js +1 -1
  157. package/mcp-routinecode/dist/config-map/audit.js +1 -1
  158. package/mcp-routinecode/dist/config-map/blocks.js +1 -1
  159. package/mcp-routinecode/dist/config-map/briefing.js +541 -1
  160. package/mcp-routinecode/dist/config-map/certify.js +10 -5
  161. package/mcp-routinecode/dist/config-map/const-use.js +1 -1
  162. package/mcp-routinecode/dist/config-map/context.js +219 -0
  163. package/mcp-routinecode/dist/config-map/convention-candidates.js +1 -0
  164. package/mcp-routinecode/dist/config-map/decisions.js +1 -1
  165. package/mcp-routinecode/dist/config-map/decls.js +1 -1
  166. package/mcp-routinecode/dist/config-map/drift.js +1 -1
  167. package/mcp-routinecode/dist/config-map/dup-safety.js +1 -1
  168. package/mcp-routinecode/dist/config-map/extract.js +1 -1
  169. package/mcp-routinecode/dist/config-map/field-contract.js +1 -1
  170. package/mcp-routinecode/dist/config-map/gate.js +796 -1
  171. package/mcp-routinecode/dist/config-map/hash.js +1 -1
  172. package/mcp-routinecode/dist/config-map/ident-norm.js +1 -1
  173. package/mcp-routinecode/dist/config-map/index-store.js +1051 -1
  174. package/mcp-routinecode/dist/config-map/light-eval.js +253 -1
  175. package/mcp-routinecode/dist/config-map/link.js +1 -1
  176. package/mcp-routinecode/dist/config-map/linked-repos.js +1 -1
  177. package/mcp-routinecode/dist/config-map/lookup.js +1 -1
  178. package/mcp-routinecode/dist/config-map/louvain.js +1 -1
  179. package/mcp-routinecode/dist/config-map/maintenance-cli.js +1 -1
  180. package/mcp-routinecode/dist/config-map/names.js +1 -1
  181. package/mcp-routinecode/dist/config-map/post-bash-eval.js +105 -0
  182. package/mcp-routinecode/dist/config-map/proposals.js +1 -1
  183. package/mcp-routinecode/dist/config-map/ratchet.js +148 -0
  184. package/mcp-routinecode/dist/config-map/recheck.js +148 -1
  185. package/mcp-routinecode/dist/config-map/repo-id.js +1 -1
  186. package/mcp-routinecode/dist/config-map/route-security.js +1 -1
  187. package/mcp-routinecode/dist/config-map/rule-import.js +1 -1
  188. package/mcp-routinecode/dist/config-map/scc.js +1 -1
  189. package/mcp-routinecode/dist/config-map/shape-eval.js +1 -1
  190. package/mcp-routinecode/dist/config-map/shape.js +1 -1
  191. package/mcp-routinecode/dist/config-map/snapshot.js +1 -1
  192. package/mcp-routinecode/dist/config-map/sole-impl.js +1 -1
  193. package/mcp-routinecode/dist/config-map/stable-id.js +1 -1
  194. package/mcp-routinecode/dist/config-map/store.js +1 -1
  195. package/mcp-routinecode/dist/config-map/swagger-check.js +1 -1
  196. package/mcp-routinecode/dist/config-map/task-eval.js +369 -1
  197. package/mcp-routinecode/dist/config-map/templates.js +1 -1
  198. package/mcp-routinecode/dist/contracts.generated.js +1 -1
  199. package/mcp-routinecode/dist/coverage.js +1 -1
  200. package/mcp-routinecode/dist/edit-tracker.js +1 -0
  201. package/mcp-routinecode/dist/explorer-advisor.js +1 -1
  202. package/mcp-routinecode/dist/failure-tracker.js +1 -1
  203. package/mcp-routinecode/dist/file-lock-registry.js +1 -1
  204. package/mcp-routinecode/dist/file-risk-scorer.js +1 -1
  205. package/mcp-routinecode/dist/index.js +1 -1
  206. package/mcp-routinecode/dist/known-solutions.js +1 -1
  207. package/mcp-routinecode/dist/ledger-miner.js +1 -1
  208. package/mcp-routinecode/dist/normalize-sig.js +1 -0
  209. package/mcp-routinecode/dist/observed-draft.js +1 -1
  210. package/mcp-routinecode/dist/observed-escalation.js +1 -0
  211. package/mcp-routinecode/dist/pattern-matcher.js +1 -1
  212. package/mcp-routinecode/dist/route-match.js +1 -1
  213. package/mcp-routinecode/dist/routines.js +1 -1
  214. package/mcp-routinecode/dist/rule-engine.js +1 -1
  215. package/mcp-routinecode/dist/rule-promoter.js +1 -1
  216. package/mcp-routinecode/dist/sanitize.generated.js +242 -0
  217. package/mcp-routinecode/dist/session-registry.js +1 -0
  218. package/mcp-routinecode/dist/skill-pack/sync.js +629 -0
  219. package/mcp-routinecode/dist/skill-pack/validate.js +278 -0
  220. package/mcp-routinecode/dist/telemetry-analyzer.js +1 -1
  221. package/mcp-routinecode/dist/test-runner.js +1 -1
  222. package/mcp-routinecode/dist/verification.js +1 -1
  223. package/mcp-routinecode/dist/viral-loop.js +1 -1
  224. package/mcp-routinecode/package.json +1 -1
  225. package/package.json +3 -3
  226. package/plugin/.claude-plugin/plugin.json +1 -1
  227. package/plugin/agents/analyzer.md.sealed +1 -1
  228. package/plugin/agents/architect.md.sealed +1 -1
  229. package/plugin/agents/crawler.md.sealed +1 -1
  230. package/plugin/agents/explorer.md.sealed +1 -1
  231. package/plugin/agents/implementor.md.sealed +1 -1
  232. package/plugin/agents/looker.md.sealed +1 -1
  233. package/plugin/agents/planner.md.sealed +1 -1
  234. package/plugin/agents/recorder.md.sealed +1 -1
  235. package/plugin/agents/reviewer.md.sealed +1 -1
  236. package/plugin/agents/verifier.md.sealed +1 -1
  237. package/plugin/commands/analyze.md.sealed +1 -1
  238. package/plugin/commands/plan.md.sealed +1 -1
  239. package/plugin/commands/rc.md.sealed +1 -1
  240. package/plugin/commands/receipt.md.sealed +1 -1
  241. package/plugin/commands/recharge.md.sealed +1 -1
  242. package/plugin/commands/routines.md.sealed +1 -1
  243. package/plugin/commands/share.md.sealed +1 -1
  244. package/plugin/routinecode-prompt.md.sealed +1 -1
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- const a0_0x2da564=a0_0x26d5;(function(_0x60bb15,_0x57109a){const _0xf86fd6=a0_0x26d5,_0x516541=_0x60bb15();while(!![]){try{const _0x484706=parseInt(_0xf86fd6(0xb7,'e&SY'))/(-0x18*0xa4+0x807+-0x3ad*-0x2)*(parseInt(_0xf86fd6(0xb9,'VYkr'))/(-0x3b5*0x7+0x9a3+0x1052))+parseInt(_0xf86fd6(0x90,'](&['))/(-0x1617+0x1454+0x2*0xe3)*(-parseInt(_0xf86fd6(0xc1,'&a]M'))/(-0x1b1*-0xa+-0x295+-0xe51))+parseInt(_0xf86fd6(0xa2,'@13g'))/(-0x202b+-0x6ec*0x4+0x3be0)+-parseInt(_0xf86fd6(0xb6,'5zVE'))/(-0x16c5+-0x991+-0x817*-0x4)+-parseInt(_0xf86fd6(0xc6,'WAh$'))/(0x1db4+0x13d7*-0x1+-0x9d6*0x1)+parseInt(_0xf86fd6(0xd2,'6nao'))/(0x92c+0x15d2+-0x1ef6)*(-parseInt(_0xf86fd6(0xd6,'FPHs'))/(0x858+0xbad+-0x13fc))+-parseInt(_0xf86fd6(0xca,'9RQ$'))/(-0x1*0x1529+0x701+0x2*0x719)*(-parseInt(_0xf86fd6(0xac,'tRWQ'))/(-0x1abb*0x1+0x8*0x25+0x199e));if(_0x484706===_0x57109a)break;else _0x516541['push'](_0x516541['shift']());}catch(_0x4c5231){_0x516541['push'](_0x516541['shift']());}}}(a0_0x51fe,0x1*0x33d6c+-0x704d5+0x87e86));import{readFileSync,writeFileSync,renameSync,mkdirSync}from'node:fs';import{homedir}from'node:os';import{join,dirname}from'node:path';import{createHmac,randomBytes}from'node:crypto';function a0_0x26d5(_0x457b02,_0x42c2aa){_0x457b02=_0x457b02-(-0x6*0x597+-0x858+0x2a71);const _0x5a58e2=a0_0x51fe();let _0x2faf04=_0x5a58e2[_0x457b02];if(a0_0x26d5['jOQiJg']===undefined){var _0x1745ca=function(_0x2ac351){const _0x281dfc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x572e69='',_0x4f8e98='';for(let _0x1785bb=-0x14d7*0x1+-0x1*-0xad5+0xa02,_0x32af41,_0x1e8897,_0x59df09=0x1*-0x58a+-0x50*0x22+0x102a*0x1;_0x1e8897=_0x2ac351['charAt'](_0x59df09++);~_0x1e8897&&(_0x32af41=_0x1785bb%(-0x87b+0x1d6d+-0x14ee)?_0x32af41*(-0x2051*-0x1+-0x1794+-0x87d)+_0x1e8897:_0x1e8897,_0x1785bb++%(0x376*0xa+-0x33*0x5b+-0x1077))?_0x572e69+=String['fromCharCode'](0x2f*-0x13+-0x40*0x1a+0xafc&_0x32af41>>(-(0x1*-0x6e9+-0x2c5+0x9b0)*_0x1785bb&0x1222+-0x26f9+-0x1*-0x14dd)):-0x101d+-0x2fc*0x1+0x1319*0x1){_0x1e8897=_0x281dfc['indexOf'](_0x1e8897);}for(let _0x1f4d85=0xa21+-0x1209+0x3f4*0x2,_0x9c3a3=_0x572e69['length'];_0x1f4d85<_0x9c3a3;_0x1f4d85++){_0x4f8e98+='%'+('00'+_0x572e69['charCodeAt'](_0x1f4d85)['toString'](-0x226f+0x1a38+0x847))['slice'](-(-0x6d9*-0x5+0x1181+-0x12d*0x2c));}return decodeURIComponent(_0x4f8e98);};const _0x55c8b8=function(_0x5c3f6c,_0xb51c1e){let _0x31b9c4=[],_0x5cab93=-0x1*0x235+-0x7*-0x49+-0x12*-0x3,_0x2db0ed,_0x30f83c='';_0x5c3f6c=_0x1745ca(_0x5c3f6c);let _0x47f118;for(_0x47f118=0x1dab+-0x1af5+-0x1*0x2b6;_0x47f118<0x67a+-0x13*-0x102+-0x18a0;_0x47f118++){_0x31b9c4[_0x47f118]=_0x47f118;}for(_0x47f118=-0x5d5*-0x3+-0x1*0x1778+0x5f9;_0x47f118<0xb*0x167+-0x2513+0x16a6;_0x47f118++){_0x5cab93=(_0x5cab93+_0x31b9c4[_0x47f118]+_0xb51c1e['charCodeAt'](_0x47f118%_0xb51c1e['length']))%(-0x105*0x3+-0x41*0x73+0x6*0x58b),_0x2db0ed=_0x31b9c4[_0x47f118],_0x31b9c4[_0x47f118]=_0x31b9c4[_0x5cab93],_0x31b9c4[_0x5cab93]=_0x2db0ed;}_0x47f118=-0x1e52+-0xcb9+0x2b0b,_0x5cab93=-0x10eb*0x1+-0x1c51+0x2d3c;for(let _0x283b1f=-0x9*0xe9+-0x1140+0x1971;_0x283b1f<_0x5c3f6c['length'];_0x283b1f++){_0x47f118=(_0x47f118+(0x704+0x1*-0x725+0x22))%(0xc3f+-0x19*0x91+0x2ea),_0x5cab93=(_0x5cab93+_0x31b9c4[_0x47f118])%(0xbf2+-0x9d*0x19+-0x1*-0x463),_0x2db0ed=_0x31b9c4[_0x47f118],_0x31b9c4[_0x47f118]=_0x31b9c4[_0x5cab93],_0x31b9c4[_0x5cab93]=_0x2db0ed,_0x30f83c+=String['fromCharCode'](_0x5c3f6c['charCodeAt'](_0x283b1f)^_0x31b9c4[(_0x31b9c4[_0x47f118]+_0x31b9c4[_0x5cab93])%(0xa4+-0x4a4+0x28*0x20)]);}return _0x30f83c;};a0_0x26d5['jcPaLj']=_0x55c8b8,a0_0x26d5['InDppD']={},a0_0x26d5['jOQiJg']=!![];}const _0x59181a=_0x5a58e2[0x86a+0x23ac+-0x2c16],_0x38b875=_0x457b02+_0x59181a,_0x50a63e=a0_0x26d5['InDppD'][_0x38b875];return!_0x50a63e?(a0_0x26d5['LgLfQF']===undefined&&(a0_0x26d5['LgLfQF']=!![]),_0x2faf04=a0_0x26d5['jcPaLj'](_0x2faf04,_0x42c2aa),a0_0x26d5['InDppD'][_0x38b875]=_0x2faf04):_0x2faf04=_0x50a63e,_0x2faf04;}const DEFAULT_SERVER_BASE=a0_0x2da564(0xcd,'@13g'),TIMEOUT_MS=0x2f5+-0x6d8+0xf9b,RC_DIR=join(homedir(),a0_0x2da564(0x94,'s2W^'));function readJson(_0xaae4c9){const _0x12b9db=a0_0x2da564;try{return JSON[_0x12b9db(0xe7,'%d%^')](readFileSync(_0xaae4c9,_0x12b9db(0xee,'Wsj8')));}catch{return null;}}function atomicWrite(_0x202977,_0x264141){const _0x2dfff4=a0_0x2da564;try{mkdirSync(dirname(_0x202977),{'recursive':!![]});const _0x8b6f55=_0x202977+'.'+process[_0x2dfff4(0xa4,'4yDm')]+_0x2dfff4(0xea,'e4rU');writeFileSync(_0x8b6f55,JSON[_0x2dfff4(0xed,'6nao')](_0x264141,null,-0x257*-0xb+0x706*0x1+-0x20c1)),renameSync(_0x8b6f55,_0x202977);}catch{}}function attestKey(){const _0x901f58=a0_0x2da564,_0x17048d=join(process.env.ROUTINECODE_KNOWLEDGE_DIR||join(RC_DIR,_0x901f58(0xf3,'059v')),_0x901f58(0xc8,'s2W^')),_0x1b0a09=join(_0x17048d,_0x901f58(0xe0,'xMHe'));try{return readFileSync(_0x1b0a09);}catch{try{mkdirSync(_0x17048d,{'recursive':!![],'mode':0x1c0}),writeFileSync(_0x1b0a09,randomBytes(0x1d6d+-0x3c3+-0x1d3*0xe),{'flag':'wx','mode':0x180});}catch{}try{return readFileSync(_0x1b0a09);}catch{return null;}}}function writeDecision(_0xd2063a){const _0xf196bb=a0_0x2da564,_0x4deea6=new Date()[_0xf196bb(0xd1,'eXLK')](),_0x9b425c={'blocked':!!_0xd2063a,'at':_0x4deea6},_0x1bded2=attestKey();_0x1bded2&&(_0x9b425c[_0xf196bb(0x98,'6nao')]=createHmac(_0xf196bb(0x97,'9RQ$'),_0x1bded2)[_0xf196bb(0xb1,'0*Br')](_0xf196bb(0xb3,'$1LY')+(_0xd2063a?0x1d06+-0x1ae8+-0x1*0x21d:-0x17*-0xdd+0x1826+-0x2c01)+'|'+_0x4deea6)[_0xf196bb(0xe2,'%d%^')](_0xf196bb(0xad,'FLrG'))),atomicWrite(join(RC_DIR,_0xf196bb(0xcc,'Hzn9')),_0x9b425c);}function mirrorBalance(_0x10fc97){const _0x47fd1d=a0_0x2da564;if(typeof _0x10fc97!==_0x47fd1d(0xda,'O!*p')||!Number[_0x47fd1d(0xbc,'FHRW')](_0x10fc97))return;const _0x25b058=join(RC_DIR,_0x47fd1d(0xdd,'xMHe')),_0x1aa24c=readJson(_0x25b058)||{'serviceId':_0x47fd1d(0xc3,'O!*p')};_0x1aa24c[_0x47fd1d(0xa1,'vAeC')]=_0x10fc97,_0x1aa24c[_0x47fd1d(0xbf,'&a]M')]=new Date()[_0x47fd1d(0xec,'00bV')](),atomicWrite(_0x25b058,_0x1aa24c);}function emit(_0x3f68e8){const _0x47ecc2=a0_0x2da564;process[_0x47ecc2(0xa7,'pHQb')][_0x47ecc2(0xf4,'%d%^')](_0x3f68e8+'\x0a'),process[_0x47ecc2(0xe6,'5zVE')](0x1a0*-0x4+0x462+0x21e);}function failOpenOrClosed(){const _0x465fe6=a0_0x2da564;try{const _0x1813df=(readJson(join(RC_DIR,_0x465fe6(0xa8,'00bV')))||{})[_0x465fe6(0xef,'S1bd')]||{},_0x28f3d9=!!_0x1813df[_0x465fe6(0xba,'Hzn9')],_0x2bd88a=join(RC_DIR,_0x465fe6(0xcb,'uRig')),_0x38406b=readJson(_0x2bd88a)||{'serviceId':_0x465fe6(0xc2,'X9FK')};let _0x26f7bf=typeof _0x38406b[_0x465fe6(0x8f,'8hJW')]===_0x465fe6(0xda,'O!*p')?_0x38406b[_0x465fe6(0xdc,'$1LY')]:null;if(_0x26f7bf!==null){const _0xed2fd1=new Date()[_0x465fe6(0xd7,']P%*')]()[_0x465fe6(0xd5,'@13g')](0x1*-0x6e9+-0x2c5+0x9ae,0x1222+-0x26f9+-0x1*-0x14e1);if(_0x38406b[_0x465fe6(0xdb,'9RQ$')]!==_0xed2fd1){if(_0x26f7bf<-0x101d+-0x2fc*0x1+0x134b*0x1)_0x26f7bf=0xa21+-0x1209+0x81a*0x1;_0x38406b[_0x465fe6(0xe4,'](&[')]=_0xed2fd1;}const _0x30dbe8=_0x28f3d9&&_0x26f7bf<=-0x226f+0x1a38+0x837;!_0x30dbe8&&(_0x26f7bf=Math[_0x465fe6(0xf1,'BVRm')](-0x6d9*-0x5+0x1181+-0xb3*0x4a,_0x26f7bf-(-0x1*0x235+-0x7*-0x49+-0xb*-0x5)),_0x38406b[_0x465fe6(0x92,'Hzn9')]=(typeof _0x38406b[_0x465fe6(0x9e,'e&SY')]===_0x465fe6(0xa5,'$1LY')?_0x38406b[_0x465fe6(0x9e,'e&SY')]:0x1dab+-0x1af5+-0x1*0x2b6)+(0x67a+-0x13*-0x102+-0x199f));_0x38406b[_0x465fe6(0x9c,'5!Ip')]=_0x26f7bf,_0x38406b[_0x465fe6(0xd9,'eXLK')]=new Date()[_0x465fe6(0xbd,'X9FK')](),atomicWrite(_0x2bd88a,_0x38406b);if(_0x30dbe8){writeDecision(!![]),emit(_0x465fe6(0xc4,'Hzn9'));return;}}}catch{}writeDecision(![]),emit(_0x465fe6(0xa3,'vAeC'));}async function main(){const _0x4f9a21=a0_0x2da564,_0x320c09=readJson(join(RC_DIR,_0x4f9a21(0xb8,'6nao')))||{},_0x218d18=process.env.ROUTINECODE_API_KEY||_0x320c09[_0x4f9a21(0xc9,'5zVE')];if(!_0x218d18){writeDecision(![]),emit(_0x4f9a21(0xb5,'9RQ$'));return;}const _0x3ea252=(process.env.ROUTINECODE_SERVER_URL||_0x320c09[_0x4f9a21(0xbe,'4yDm')]||DEFAULT_SERVER_BASE)[_0x4f9a21(0xd4,'](&[')](/\/+$/,''),_0x1e686a=_0x3ea252+_0x4f9a21(0xd8,'S1bd'),_0x212093=new AbortController(),_0x506dad=setTimeout(()=>_0x212093[_0x4f9a21(0xe8,'%d%^')](),TIMEOUT_MS);let _0x21fb91=null,_0x16c6ca=null;try{_0x21fb91=await fetch(_0x1e686a,{'method':_0x4f9a21(0xae,'pHQb'),'headers':{'Content-Type':_0x4f9a21(0x9f,'Hzn9'),'Authorization':_0x4f9a21(0xbb,'](&[')+_0x218d18},'body':JSON[_0x4f9a21(0xa9,'WAh$')]({'serviceId':_0x4f9a21(0xa6,'vAeC'),'actionType':_0x4f9a21(0xaf,'FHRW'),'amount':0x1,'sourceRef':null}),'signal':_0x212093[_0x4f9a21(0x96,'Hzn9')]});try{_0x16c6ca=await _0x21fb91[_0x4f9a21(0x95,'X9FK')]();}catch{_0x16c6ca=null;}}catch{clearTimeout(_0x506dad),failOpenOrClosed();return;}clearTimeout(_0x506dad);const _0x3e4520=_0x16c6ca&&typeof _0x16c6ca[_0x4f9a21(0xce,'mi8T')]===_0x4f9a21(0xb0,'4yDm')?_0x16c6ca[_0x4f9a21(0xe9,'9@MW')]:undefined,_0x1cf9c4=_0x16c6ca&&typeof _0x16c6ca[_0x4f9a21(0xde,'tRWQ')]===_0x4f9a21(0xc7,'BVRm')?_0x16c6ca[_0x4f9a21(0x91,'VYkr')]:undefined;if(_0x1cf9c4===![]&&_0x3e4520===-0x5d5*-0x3+-0x1*0x1778+0x7a6||_0x21fb91&&_0x21fb91[_0x4f9a21(0xeb,'vAeC')]===0xb*0x167+-0x2513+0x1753){mirrorBalance(-0x105*0x3+-0x41*0x73+0x1*0x2042),writeDecision(!![]),emit(_0x4f9a21(0xaa,'X9FK'));return;}if(_0x21fb91&&_0x21fb91['ok']&&_0x1cf9c4===!![]){const _0x185575=_0x16c6ca&&_0x16c6ca[_0x4f9a21(0xb4,'X9FK')]||{},_0x3f440c=typeof _0x185575[_0x4f9a21(0xf0,'iMI*')]===_0x4f9a21(0x9b,'@13g')?_0x185575[_0x4f9a21(0x93,'zo5d')]:typeof _0x185575[_0x4f9a21(0xab,'BVRm')]===_0x4f9a21(0xc5,'5zVE')?_0x185575[_0x4f9a21(0x9a,'pHQb')]:undefined;mirrorBalance(_0x3f440c),writeDecision(![]),emit(_0x4f9a21(0xd0,'mi8T')+(typeof _0x3f440c===_0x4f9a21(0xa5,'$1LY')?_0x3f440c:''));return;}failOpenOrClosed();}main()[a0_0x2da564(0x9d,'8hJW')](()=>{failOpenOrClosed();});function a0_0x51fe(){const _0x1c2e6a=['l8krqaVdOCorWQpdHvZcHcJcNa','WRuScSooWO7dUSoIemk3WOijuW','WO3cK8oAmq','W7rIA07dJWG','W6P+pmoaf8oJ','vIjt','W7BdV1zEW6hcG1RcLG','W7K7W5pcVmovW57dHq','WPq5WRjDW77dIa','WPz9W6PiW4/dVG8','W5BdMCkYWPRcIa','lCoRWQyxW6NcUCoTWO3cQ8o6vK8I','W6z7FeZdHWCFm8kFW7DjhHpdLw3cIa','eCkmWPTvWOZdVWRcKSkUWORdOq','esTQrmobmCkb','W498W6GpWQ7dRwa5jLPO','nqTpACoGaSkHyG','u8kuBW','W413k8oJWOBcKa','asvZuCogpmkbt8o5WRyw','W6GUW5VcSSooW4K','WRqXW67dV1vrqSoZWPtdHdeOlNvzWQFdUa','x0jcWQL3WPFcSCkbWOi','WQxcRmo6hmko','vCkSwCkBW7mGBq','W5VdI3xdLGRcGJBdPdRcP8kOW406','W6SiW4S','W4SvW6ZcIq','cCoaWPfm','tCkizSokA0i','WP/cLmoyw8oPWRG','cSkwWQtcL8kOxCkomCkC','W4bWi8oLWORcLSoGWQHLWP5xWQJcKWfjWPi','WOpcGCobpG','W59xfmk+BCkfwY0','W7pdUYWCWRddNwNcLHJcIgny','Dmk7W7aFW4RcLCosWR3cGa','wcXEmaPKW5NdSwNcPIy','FCo1nSkzzSo0WRlcJam','W6r5AutdHXa5jSkcW71IxXJdHg7cG8oN','oSodiCkXxmk/WR4','fmogWQvlB8otoCoO','WPpcJ8o8dmkkWOKoWRKDESky','umkyECoEA0jRW5OV','WOpcNmoADwBdJmo9pmoBhSkRbW','DSoZxCkwCCoOWQNcLW','W5ZdI8oWEhtdU8oLbG','WPxcJ8oak8kSWRqFWQGBCmkA','W4CVWQxcPSkUo087WRFcNCkt','W4vhq2pdPq','WQNcUNfkW6dcMW','hq4cW7GVW4JcJSkYWQ0eWRWg','vCkIwSkwW7GIzG','W7OQeCoEWONdPW','WQBcV3vJW6dcKa','WQGMf8kerSk/vcO','jSkYjCk2d8k0WQH7tGqjmg8SW4i9WQC','W6r5AutdHXbti8ktW7ToqHddIwZdImoPdSkOW4W','WPi4WQTpW6JcGbDzcujiWQfCW6OxW5bInSkXWRS2WPJdHuG5W5tdQryyW55gWOJcPW','WQ3dGmkFuuSh','Cmo1m8oFbCoXWOFcGtBcJci','WPhdV8oe','s8kXsmo1jZ3dMmoQo8kUW7C','cNeafbjgWPtdV3S','e8koWP8IW43dOHVcL8kw','cSodmmkVwmkUW7S','WOKGWRzCW74','feS0g8oVu8kfigDwq8kc','vSotW6yZW7pdTaZcGCkEWOpdHa','W48+W4RdVxuIt2VdIZtcTCkofYu8w8kjW4/cRHCHk8kdWOvJceJdONiynLtdRmkEcW','u8k/CSosoXFdGSo7n8kKW5hdTW','W5S1WR3cSmkIjW','W7v3lSkgzSk0DW/cK3CjfMxdGv9vzXm','W4fJkSoGWO3cGCkO','WPpdRfKJkCoeeelcLM7dPtvwfmkwW6j6','WP/cNtlcLLldHq','W7jGWRpcPbqafSoCWPZdJc40','W57dTvK+','c8kBsrquWPqfACowWO3dG8ka','iciBy0Oy','b8kFWQBcJmkPsSkXjSkv','fmohm8k3FCkSW7CMBCoZn2hcVMpcGMNdJfW','f8koWOe4e8kimd9dWR3cTSkG','WQlcT3vC','ncOoDvW','jsKtDe0','rSoOAmk4WP7cKq','WPFcMe9x','ad5NuCoAiq','WRi7W4RdG25Ng8oNWPhdIZe','sdDcpW1KWP7dVwm','W6RdG3ihW78','WOyZW5VdSYK','wmocf01mW482FCoMWRddOSkq','wSkStq','C8oZDmoNuSoZWR18tGmumqK','A8osW5ZcP8o1W5/cNN/dMa','mZKvCLW','W5FdMCkQWPJcJSoNWRO','s8kwDmo2cCkvW6WRtCotbW','n8kGD8kAxmos','W6TIAKxdMG0tiSkLW6HcxW0'];a0_0x51fe=function(){return _0x1c2e6a;};return a0_0x51fe();}
2
+ /* rc-min */
3
+ import{readFileSync,writeFileSync,renameSync,mkdirSync}from'node:fs';import{homedir}from'node:os';import{join,dirname}from'node:path';import{createHmac,randomBytes}from'node:crypto';const DEFAULT_SERVER_BASE='https://knowledge.routinecrew.net',TIMEOUT_MS=0xbb8,RC_DIR=join(homedir(),'.routinecode');function readJson(a){try{return JSON['parse'](readFileSync(a,'utf-8'));}catch{return null;}}function atomicWrite(a,b){try{mkdirSync(dirname(a),{'recursive':!![]});const c=a+'.'+process['pid']+'.tmp';writeFileSync(c,JSON['stringify'](b,null,0x2)),renameSync(c,a);}catch{}}function attestKey(){const a=join(process.env.ROUTINECODE_KNOWLEDGE_DIR||join(RC_DIR,'knowledge'),'attest'),b=join(a,'.key');try{return readFileSync(b);}catch{try{mkdirSync(a,{'recursive':!![],'mode':0x1c0}),writeFileSync(b,randomBytes(0x20),{'flag':'wx','mode':0x180});}catch{}try{return readFileSync(b);}catch{return null;}}}function writeDecision(a){const b=new Date()['toISOString'](),c={'blocked':!!a,'at':b},d=attestKey();d&&(c['mac']=createHmac('sha256',d)['update']('credit-decision|'+(a?0x1:0x0)+'|'+b)['digest']('hex')),atomicWrite(join(RC_DIR,'credit-decision.json'),c);}function mirrorBalance(a){if(typeof a!=='number'||!Number['isFinite'](a))return;const b=join(RC_DIR,'credit-state.json'),c=readJson(b)||{'serviceId':'routinecode'};c['balance']=a,c['lastSyncedAt']=new Date()['toISOString'](),atomicWrite(b,c);}function emit(a){process['stdout']['write'](a+'\x0a'),process['exit'](0x0);}function failOpenOrClosed(){try{const a=(readJson(join(RC_DIR,'remote-flags.json'))||{})['flags']||{},b=!!a['creditGateEnabled'],c=join(RC_DIR,'credit-state.json'),d=readJson(c)||{'serviceId':'routinecode'};let e=typeof d['balance']==='number'?d['balance']:null;if(e!==null){const f=new Date()['toISOString']()['slice'](0x0,0xa);if(d['lastDailyGrantDate']!==f){if(e<0x32)e=0x32;d['lastDailyGrantDate']=f;}const g=b&&e<=0x0;!g&&(e=Math['max'](0x0,e-0x1),d['lifetimeSpent']=(typeof d['lifetimeSpent']==='number'?d['lifetimeSpent']:0x0)+0x1);d['balance']=e,d['lastSyncedAt']=new Date()['toISOString'](),atomicWrite(c,d);if(g){writeDecision(!![]),emit('BLOCK');return;}}}catch{}writeDecision(![]),emit('FAILOPEN');}async function main(){const a=readJson(join(RC_DIR,'config.json'))||{},b=process.env.ROUTINECODE_API_KEY||a['apiKey'];if(!b){writeDecision(![]),emit('FAILOPEN');return;}const c=(process.env.ROUTINECODE_SERVER_URL||a['serverUrl']||DEFAULT_SERVER_BASE)['replace'](/\/+$/,''),d=c+'/api/v1/growth-proxy/credit/consume',e=new AbortController(),f=setTimeout(()=>e['abort'](),TIMEOUT_MS);let g=null,h=null;try{g=await fetch(d,{'method':'POST','headers':{'Content-Type':'application/json','Authorization':'Bearer\x20'+b},'body':JSON['stringify']({'serviceId':'routinecode','actionType':'turn','amount':0x1,'sourceRef':null}),'signal':e['signal']});try{h=await g['json']();}catch{h=null;}}catch{clearTimeout(f),failOpenOrClosed();return;}clearTimeout(f);const i=h&&typeof h['status']==='number'?h['status']:undefined,j=h&&typeof h['result']==='boolean'?h['result']:undefined;if(j===![]&&i===0x1ad||g&&g['status']===0x1ad){mirrorBalance(0x0),writeDecision(!![]),emit('BLOCK');return;}if(g&&g['ok']&&j===!![]){const k=h&&h['data']||{},l=typeof k['balanceAfter']==='number'?k['balanceAfter']:typeof k['balance']==='number'?k['balance']:undefined;mirrorBalance(l),writeDecision(![]),emit('OK:'+(typeof l==='number'?l:''));return;}failOpenOrClosed();}main()['catch'](()=>{failOpenOrClosed();});
package/bin/rc-grant.js CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- function a0_0x25ce(_0xd4020f,_0x1d6b23){_0xd4020f=_0xd4020f-(-0x1*0x198e+0x1832+0x20e);const _0x1b13d8=a0_0x5eab();let _0x8daa28=_0x1b13d8[_0xd4020f];if(a0_0x25ce['lHaOJj']===undefined){var _0x130e42=function(_0x47eaba){const _0x324e37='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x115068='',_0x2e6243='';for(let _0x2c5941=-0x2*0xa63+-0x219e+0x3664,_0x59c2f1,_0x42e7bc,_0x492962=0xbf9+0x23*-0x103+0x1770;_0x42e7bc=_0x47eaba['charAt'](_0x492962++);~_0x42e7bc&&(_0x59c2f1=_0x2c5941%(0x3*-0xad+0x27*-0xc4+0x1*0x1fe7)?_0x59c2f1*(0x11b*0x10+-0x1*-0xdff+0x26b*-0xd)+_0x42e7bc:_0x42e7bc,_0x2c5941++%(0x1ffa+0xb3*0x1+-0x20a9))?_0x115068+=String['fromCharCode'](-0x12ab+-0x1*-0x10d4+-0x16*-0x21&_0x59c2f1>>(-(-0x6b0+-0x1a9b+0x214d)*_0x2c5941&0x7*0xda+0x172e+-0x2*0xe8f)):0x3b6+-0x1c1f+-0x1*-0x1869){_0x42e7bc=_0x324e37['indexOf'](_0x42e7bc);}for(let _0xef9933=-0x239b+0x4f1+-0x311*-0xa,_0x269c50=_0x115068['length'];_0xef9933<_0x269c50;_0xef9933++){_0x2e6243+='%'+('00'+_0x115068['charCodeAt'](_0xef9933)['toString'](0xef*-0x1b+-0x1*-0x207e+-0x739))['slice'](-(0x17c1+-0x637*-0x1+-0x2*0xefb));}return decodeURIComponent(_0x2e6243);};const _0x3f80bc=function(_0x43b2b2,_0x3e196c){let _0x1ac043=[],_0x29ff12=0x1a96+-0x8*0x3b9+0x332,_0x147cda,_0x2d325d='';_0x43b2b2=_0x130e42(_0x43b2b2);let _0x383865;for(_0x383865=-0xcf8+-0x24c5*-0x1+-0x17cd;_0x383865<0x2107+0x1d33+-0x1*0x3d3a;_0x383865++){_0x1ac043[_0x383865]=_0x383865;}for(_0x383865=0x663*-0x1+-0xba7+0x120a;_0x383865<0x1*-0x308+0x1*0xf5c+0x91*-0x14;_0x383865++){_0x29ff12=(_0x29ff12+_0x1ac043[_0x383865]+_0x3e196c['charCodeAt'](_0x383865%_0x3e196c['length']))%(-0x1*-0x1903+0x1ad0*-0x1+0x2cd),_0x147cda=_0x1ac043[_0x383865],_0x1ac043[_0x383865]=_0x1ac043[_0x29ff12],_0x1ac043[_0x29ff12]=_0x147cda;}_0x383865=0x3d*-0x41+-0x257e+0x34fb,_0x29ff12=0x328+-0x56b+0x243;for(let _0x3b70d4=-0x2d8+-0x1*-0x410+-0x1a*0xc;_0x3b70d4<_0x43b2b2['length'];_0x3b70d4++){_0x383865=(_0x383865+(-0x8c*0x3a+-0x15bf+0x3578))%(0x50c*0x6+0x37*0xb+-0x1fa5),_0x29ff12=(_0x29ff12+_0x1ac043[_0x383865])%(-0x1a3d+0x1*0xc6b+-0xe*-0x10f),_0x147cda=_0x1ac043[_0x383865],_0x1ac043[_0x383865]=_0x1ac043[_0x29ff12],_0x1ac043[_0x29ff12]=_0x147cda,_0x2d325d+=String['fromCharCode'](_0x43b2b2['charCodeAt'](_0x3b70d4)^_0x1ac043[(_0x1ac043[_0x383865]+_0x1ac043[_0x29ff12])%(-0x11c*0x1+0x143a+-0x305*0x6)]);}return _0x2d325d;};a0_0x25ce['reztzI']=_0x3f80bc,a0_0x25ce['yvuWWT']={},a0_0x25ce['lHaOJj']=!![];}const _0x330c30=_0x1b13d8[-0x1b60+-0x11f*0x7+0x2339],_0x37cde1=_0xd4020f+_0x330c30,_0x2c2f25=a0_0x25ce['yvuWWT'][_0x37cde1];return!_0x2c2f25?(a0_0x25ce['sQqznc']===undefined&&(a0_0x25ce['sQqznc']=!![]),_0x8daa28=a0_0x25ce['reztzI'](_0x8daa28,_0x1d6b23),a0_0x25ce['yvuWWT'][_0x37cde1]=_0x8daa28):_0x8daa28=_0x2c2f25,_0x8daa28;}const a0_0x230863=a0_0x25ce;(function(_0x3be7e7,_0x4f8381){const _0x33e9ac=a0_0x25ce,_0x16ba59=_0x3be7e7();while(!![]){try{const _0x58e3a1=-parseInt(_0x33e9ac(0xc0,'EC0e'))/(-0x11c*0x1+0x143a+-0xe9*0x15)*(-parseInt(_0x33e9ac(0xb6,'v3z)'))/(-0x1b60+-0x11f*0x7+0x233b))+-parseInt(_0x33e9ac(0xc3,'tK*V'))/(-0x1c37+-0xef8+0x2b32)+-parseInt(_0x33e9ac(0xb5,'zooM'))/(0x2c1+0x2e*0x25+-0x10b*0x9)*(-parseInt(_0x33e9ac(0xd8,'(xfK'))/(0x2*-0x89+-0x24cd*0x1+0x25e4))+-parseInt(_0x33e9ac(0xe1,'JC%x'))/(0x1065+0xbcf+-0x1c2e)+parseInt(_0x33e9ac(0xcb,'zooM'))/(-0x1*0x20b+0x6fe+-0x4ec)+-parseInt(_0x33e9ac(0xb2,'KZzM'))/(-0x1694+0x892+-0x257*-0x6)*(parseInt(_0x33e9ac(0xd4,'0k0h'))/(-0xfc8+0x217*0xc+-0x943))+-parseInt(_0x33e9ac(0xe0,'^ZZD'))/(0xaab*-0x3+0x120e*0x2+0x1*-0x411)*(-parseInt(_0x33e9ac(0xde,'QnWY'))/(0x1672+-0x5*0x69b+0xaa0));if(_0x58e3a1===_0x4f8381)break;else _0x16ba59['push'](_0x16ba59['shift']());}catch(_0x3e6a4f){_0x16ba59['push'](_0x16ba59['shift']());}}}(a0_0x5eab,-0x6eefc+0x52*-0x2182+0x1*0x1e3bf3));import{readFileSync,writeFileSync,renameSync,mkdirSync,unlinkSync}from'node:fs';import{homedir}from'node:os';import{join}from'node:path';const RC_DIR=join(homedir(),a0_0x230863(0xc4,'GRJ#')),CACHE=join(RC_DIR,a0_0x230863(0xdc,'WAkW')),DENIED=join(RC_DIR,a0_0x230863(0xc2,'^S3W')),DEFAULT_SERVER_BASE=a0_0x230863(0xdf,'JC%x'),TIMEOUT_MS=-0x1553*0x1+-0xe83+0x3*0xfda,REFRESH_BEFORE_MS=(-0x1177+0x3*-0xad+0x20*0x9c)*(0x5*0x57+0x955*0x2+-0x1*0x1421)*(0x1*0x1fd1+0x181e+0x7f5*-0x7)*(-0x1*0x2074+-0x1*0x12ab+-0x1*-0x3707);function a0_0x5eab(){const _0x1b6f10=['deWgxmocW6JcNSom','fXXQamkevCk0WOu','lvJdKmoiWOZdGmkxumoly3BdNmoSiNm','x8kxW7uPqaW','WR/dT8kKW4hdI8oMv8kgCJJcHSoiW5e','Bvf4WPmdf8k4W4ddTHqDdSoc','AtmPmgC0WPe9WRDVW6hdSmk7pCoMBSkaW7mStI4IfmkYW7nRWQFdM8ozWOTalxzI','FmolW78','FmodW6KToq','pgDcb8oBWPVdMNaaWPNdGq','WQH4WP/dGW','W43cUv8aWQbksmkSySovA8kYW51PWQFcPa','DgjOyx1ZWPvOWP1hW6NdT8kT','WRZdRCkjWRD5WRhcRmoKWR0','WP3dQwrrlmkYcSov','tmkWWQxcGG','W6HCtJFdIG','aCkjjSobchRcVSkL','W7KWA8ktW67dJCkE','ltXCW40','cmoAW5CfvhlcRSkb','W4/cS0bbbCkQ','WQWLFmkjW47dPG','ehNdJ8oAWO/dMSkNFCoJxvG','WPFcIfRcKmoEW6RcSSkL','W5RcNvPTWPLIiq','rCoiamo2e08','uZveiCk1wmoynKG','wSoZW7VdGwu1W6tdNw0Dyq','WQr+W5tcQrS','WP/cT8oMpJJdNmkjW6dcUmonEqNdHCouWOPBBa','W7mPWPBdU0FdO8oAcmoQjSkOoXO','WOlcU0azWR1ar8k9AmovyCo4','k8kxAXLQidtdVwJcISkhW5a','nsy4lt0X','e8knWRntdW','W6FdLmoyWPRcSmoeW4yKWPq','W6xcQCoYWPZcLmkI','c0apu8onW7a','bmknxmkWyXVdOmknCdBcTCkHuG','WOddLHZcHu4RhSofoW','bmoZDCkMW4NcGW0tW7fYW5u','WQWOACkdW4S','BSoFW5OhWPHDWONcSSonW6fLWPtdGW','s8kjW6iqCxRcRG','vCkKl8o5W6NcI3q4W4DT','cSkjWOdcSSotWP3cQt9qW67dVa','B8onW787','tr9CdCkAWQRcGCoeWRJcUSkJjW','tmkFW7Cowx0','amojnsH2W6zi','WR50WOtdNGNdRL9YW6S','mbmqBMnJsN7dHmkSWRNdPG0','vmoAeCoL','o3TsaCo7WPe','DcHvoSkIt8kl','BCkuorbsWRzpyutdQSoPWPrhWP7dJCkYWPtcLG','eLOhuW','WO7dJaa1WRXHd1xdKmkF','mSkDWPHgW59wWPpdSSoEW4rgWQhdOCkpWRddHx1WWOlcOSoXbZNcLHRcUmkzW6NcKSoAW7qxCa','BLr0WPmkC8oyW6NdHqyn','y8oBW5ScWP5BWOtcJ8o5W4vEWPxdUG','gJGvW6jRka','W6GRW5X2D20','W6D/WQ1KBeuUdSoj','WQKXia','aCkBWQ5ifrZcGmokW5a','W6JcMIX7W7dcSG','cIagW6jOpa','W5BdM2VcPSoP','b8kiumkWAN/cGmkKqYtcPq'];a0_0x5eab=function(){return _0x1b6f10;};return a0_0x5eab();}function readJson(_0x43bbc4){const _0x2b90cf=a0_0x230863;try{return JSON[_0x2b90cf(0xe9,'q4Nc')](readFileSync(_0x43bbc4,_0x2b90cf(0xb4,'k^Oj')));}catch{return null;}}function stillFresh(_0x35b7e6){const _0x70bd03=a0_0x230863,_0x59c045=_0x35b7e6&&_0x35b7e6[_0x70bd03(0xba,'v3z)')]&&Date[_0x70bd03(0xf3,'Xu^)')](_0x35b7e6[_0x70bd03(0xb9,'KZzM')][_0x70bd03(0xbf,'))f8')]);return Number[_0x70bd03(0xec,'cRQ&')](_0x59c045)&&_0x59c045-Date[_0x70bd03(0xe5,'OHPf')]()>REFRESH_BEFORE_MS;}async function main(){const _0x2fa74d=a0_0x230863,_0x1311a7=readJson(CACHE),_0x58e0d7=readJson(join(RC_DIR,_0x2fa74d(0xcd,'2Dlx')))||{},_0xdd3a7f=process.env.ROUTINECODE_API_KEY||_0x58e0d7[_0x2fa74d(0xe3,'!G3T')];if(!_0xdd3a7f)return;if(stillFresh(_0x1311a7)&&(!_0x58e0d7[_0x2fa74d(0xd5,'H#CD')]||_0x1311a7[_0x2fa74d(0xe2,'!0tA')][_0x2fa74d(0xda,'YpeJ')]===_0x58e0d7[_0x2fa74d(0xbe,'zooM')]))return;const _0x10ec4f=(process.env.ROUTINECODE_SERVER_URL||_0x58e0d7[_0x2fa74d(0xcc,'25Ih')]||DEFAULT_SERVER_BASE)[_0x2fa74d(0xd0,'H#CD')](/\/+$/,''),_0x5758e7=new AbortController(),_0x48a17e=setTimeout(()=>_0x5758e7[_0x2fa74d(0xc7,'KwYf')](),TIMEOUT_MS);try{const _0x4bae59=await fetch(_0x10ec4f+_0x2fa74d(0xf1,'IDO1'),{'method':_0x2fa74d(0xb7,'(b5N'),'headers':{'Content-Type':_0x2fa74d(0xf6,'GRJ#'),'Authorization':_0x2fa74d(0xdb,'))f8')+_0xdd3a7f},'body':JSON[_0x2fa74d(0xe6,'KwYf')]({'tenantId':Number(_0x58e0d7[_0x2fa74d(0xeb,'0k0h')])||-0x6b0+-0x1a9b+0x214b,'serviceId':_0x2fa74d(0xf4,'YpeJ')}),'signal':_0x5758e7[_0x2fa74d(0xca,'0k0h')]}),_0x46e1fc=await _0x4bae59[_0x2fa74d(0xdd,'0k0h')]()[_0x2fa74d(0xc1,'tK*V')](()=>null);if(!_0x4bae59['ok']){_0x4bae59[_0x2fa74d(0xc6,'IDO1')]===0x7*0xda+0x172e+-0xd*0x21f&&_0x46e1fc&&_0x46e1fc[_0x2fa74d(0xd3,'Xu^)')]===_0x2fa74d(0xed,'DQjs')&&writeFileSync(DENIED,JSON[_0x2fa74d(0xe4,'%Mrz')]({'at':new Date()[_0x2fa74d(0xbb,'DQjs')]()}),{'mode':0x180});return;}const _0x2f8fb2=_0x46e1fc&&_0x46e1fc[_0x2fa74d(0xd9,'zooM')];if(!_0x2f8fb2||typeof _0x2f8fb2[_0x2fa74d(0xf8,'Ij3T')]!==_0x2fa74d(0xe8,'!0tA')||!_0x2f8fb2[_0x2fa74d(0xc9,'jbVM')]||typeof _0x2f8fb2[_0x2fa74d(0xe7,'y3ci')][_0x2fa74d(0xc8,')jn&')]!==_0x2fa74d(0xee,'cLZY'))return;mkdirSync(RC_DIR,{'recursive':!![]});try{unlinkSync(DENIED);}catch{}const _0x1c2fc5=CACHE+'.'+process[_0x2fa74d(0xf2,'Xu^)')]+_0x2fa74d(0xb3,'EC0e');writeFileSync(_0x1c2fc5,JSON[_0x2fa74d(0xd7,'(v8B')](_0x2f8fb2),{'mode':0x180}),renameSync(_0x1c2fc5,CACHE);}catch{}finally{clearTimeout(_0x48a17e);}}main()[a0_0x230863(0xce,'v3z)')](()=>{})[a0_0x230863(0xbd,'QnWY')](()=>process[a0_0x230863(0xf5,'(v8B')](0x3b6+-0x1c1f+-0x1*-0x1869));
2
+ /* rc-min */
3
+ import{readFileSync,writeFileSync,renameSync,mkdirSync,unlinkSync}from'node:fs';import{homedir}from'node:os';import{join}from'node:path';const RC_DIR=join(homedir(),'.routinecode'),CACHE=join(RC_DIR,'session-grant.json'),DENIED=join(RC_DIR,'grant-denied.json'),DEFAULT_SERVER_BASE='https://knowledge.routinecrew.net',TIMEOUT_MS=0xbb8,REFRESH_BEFORE_MS=0x2*0x3c*0x3c*0x3e8;function readJson(a){try{return JSON['parse'](readFileSync(a,'utf-8'));}catch{return null;}}function stillFresh(a){const b=a&&a['claims']&&Date['parse'](a['claims']['expiresAt']);return Number['isFinite'](b)&&b-Date['now']()>REFRESH_BEFORE_MS;}async function main(){const a=readJson(CACHE),b=readJson(join(RC_DIR,'config.json'))||{},c=process.env.ROUTINECODE_API_KEY||b['apiKey'];if(!c)return;if(stillFresh(a)&&(!b['userId']||a['claims']['userId']===b['userId']))return;const d=(process.env.ROUTINECODE_SERVER_URL||b['serverUrl']||DEFAULT_SERVER_BASE)['replace'](/\/+$/,''),e=new AbortController(),f=setTimeout(()=>e['abort'](),TIMEOUT_MS);try{const h=await fetch(d+'/api/v1/growth-proxy/session-grant',{'method':'POST','headers':{'Content-Type':'application/json','Authorization':'Bearer\x20'+c},'body':JSON['stringify']({'tenantId':Number(b['tenantId'])||0x0,'serviceId':'routinecode'}),'signal':e['signal']}),i=await h['json']()['catch'](()=>null);if(!h['ok']){h['status']===0x191&&i&&i['code']==='INVALID_API_KEY'&&writeFileSync(DENIED,JSON['stringify']({'at':new Date()['toISOString']()}),{'mode':0x180});return;}const j=i&&i['data'];if(!j||typeof j['signature']!=='string'||!j['claims']||typeof j['claims']['expiresAt']!=='string')return;mkdirSync(RC_DIR,{'recursive':!![]});try{unlinkSync(DENIED);}catch{}const k=CACHE+'.'+process['pid']+'.tmp';writeFileSync(k,JSON['stringify'](j),{'mode':0x180}),renameSync(k,CACHE);}catch{}finally{clearTimeout(f);}}main()['catch'](()=>{})['finally'](()=>process['exit'](0x0));
package/bin/rc-login.js CHANGED
@@ -266,6 +266,8 @@ function logout() {
266
266
  delete c.apiKey;
267
267
  delete c.internalApiKey;
268
268
  c.syncEnabled = false;
269
+ // 로그아웃 중 기록한 지식은 큐에 넣지 않는다(설계 15 §4.5). 다음 로그인의 키 발급이 이 표식을 지운다.
270
+ c.loggedOut = true;
269
271
  writeFileSync(CONFIG_PATH, JSON.stringify(c, null, 2), { mode: 0o600 });
270
272
  }
271
273
  } catch { /* ignore */ }
package/bin/rc-map.js ADDED
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ // RoutineCode 로컬 문제 리포트 (zero-dep, ESM) — 설계 15 §4.6.
3
+ //
4
+ // routinecode map [--refresh] [--no-open] [--json]
5
+ //
6
+ // 이 컴퓨터의 감사 결과로 문장, 막대, 파일 목록 HTML 을 만들어 브라우저로 연다. 네트워크를 쓰지 않고, 외부 자원도 넣지 않는다.
7
+ // 지도가 없거나 --refresh 면 감사를 새로 돌린다(서버 적재 없음).
8
+
9
+ import { readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
10
+ import { spawnSync } from 'node:child_process';
11
+ import { basename, dirname, join } from 'node:path';
12
+ import { fileURLToPath, pathToFileURL } from 'node:url';
13
+
14
+ const HERE = dirname(fileURLToPath(import.meta.url));
15
+ const DIST = join(HERE, '..', 'mcp-routinecode', 'dist', 'config-map');
16
+
17
+ const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
+
19
+ /** 감사 보고서 → 유형별 문제 묶음(pure). items = [{ title, places: ['파일:줄'] }] */
20
+ export function findingsOf(r) {
21
+ const place = (f, l) => (l ? `${f}:${l}` : String(f ?? ''));
22
+ const dup = cs => (cs ?? []).map(c => ({ title: `${c.size}곳이 같습니다: ${c.members?.[0]?.name ?? ''}`, places: (c.members ?? []).map(m => place(m.file, m.line)) }));
23
+ return [
24
+ { id: 'dup', label: '똑같은 코드', items: dup(r.dupL1) },
25
+ { id: 'similar', label: '거의 같은 코드', items: dup(r.dupL2) },
26
+ { id: 'unused', label: '쓰이지 않는 코드', items: (r.orphans ?? []).map(o => ({ title: o.name ?? o.check ?? '', places: [place(o.file, o.line)] })) },
27
+ { id: 'layer', label: '계층을 어긴 호출', items: (r.layerViolations ?? []).map(v => ({ title: `${v.fromLayer} → ${v.toLayer}`, places: [place(v.fromFile, v.line), v.toFile] })) },
28
+ { id: 'cycle', label: '순환 참조', items: (r.cycles ?? []).filter(c => !c.harmless).map(c => ({ title: `${c.files?.length ?? 0}개 파일이 서로 물고 있습니다`, places: c.files ?? [] })) },
29
+ { id: 'rule', label: '구조 규칙 위반', items: (r.constraintFindings ?? []).map(f => ({ title: f.constraintId ?? f.message ?? '', places: [place(f.file ?? f.fromFile, f.line)] })) },
30
+ ];
31
+ }
32
+
33
+ /** 문제가 가장 몰린 폴더(pure). 앞 두 단계로 묶는다. */
34
+ export function topFolder(groups) {
35
+ const n = new Map();
36
+ let total = 0;
37
+ for (const g of groups) {
38
+ for (const it of g.items) {
39
+ for (const p of it.places) {
40
+ const parts = p.split(':')[0].split('/').filter(Boolean);
41
+ if (parts.length < 2) continue;
42
+ const k = parts.slice(0, Math.min(2, parts.length - 1)).join('/');
43
+ n.set(k, (n.get(k) ?? 0) + 1);
44
+ total++;
45
+ }
46
+ }
47
+ }
48
+ if (!total) return null;
49
+ const [dir, count] = [...n.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0];
50
+ return { dir, count, total, percent: Math.round((count / total) * 100) };
51
+ }
52
+
53
+ export function renderReport(report, name = '') {
54
+ const groups = findingsOf(report).filter(g => g.items.length);
55
+ const total = groups.reduce((s, g) => s + g.items.length, 0);
56
+ const max = Math.max(1, ...groups.map(g => g.items.length));
57
+ const top = topFolder(groups);
58
+ const lead = total === 0
59
+ ? '이번 감사에서 찾은 문제가 없습니다.'
60
+ : `문제 ${total}건을 찾았습니다. ${esc(groups.slice().sort((a, b) => b.items.length - a.items.length)[0].label)}가 가장 많습니다.`;
61
+ const skew = top && top.percent >= 30 ? `<p>문제 위치의 ${top.percent}%가 <code>${esc(top.dir)}</code>에 몰려 있습니다.</p>` : '';
62
+ const bars = groups.map(g => `<div class="bar"><span class="name">${esc(g.label)}</span><span class="track"><span class="fill" style="width:${Math.round((g.items.length / max) * 100)}%"></span></span><span class="n">${g.items.length}</span></div>`).join('');
63
+ const lists = groups.map(g => `<section><h2>${esc(g.label)} ${g.items.length}건</h2>${g.items.slice(0, 200).map(it => `<details><summary>${esc(it.title)}</summary><ul>${it.places.map(p => `<li><code>${esc(p)}</code></li>`).join('')}</ul></details>`).join('')}${g.items.length > 200 ? `<p>나머지 ${g.items.length - 200}건은 생략했습니다.</p>` : ''}</section>`).join('');
64
+ return `<!doctype html>
65
+ <html lang="ko"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
66
+ <title>코드 진단 ${esc(name)}</title>
67
+ <style>
68
+ :root{--bg:#fff;--fg:#1a1a1a;--mute:#666;--line:#e5e5e5;--bar:#2f6fed}
69
+ @media (prefers-color-scheme:dark){:root{--bg:#141414;--fg:#eee;--mute:#aaa;--line:#333;--bar:#6c9bff}}
70
+ body{margin:0 auto;max-width:760px;padding:32px 16px;background:var(--bg);color:var(--fg);font:16px/1.6 system-ui,sans-serif}
71
+ h1{font-size:24px;margin:0 0 4px}h2{font-size:18px;margin:32px 0 8px}
72
+ .date{color:var(--mute);font-size:14px;margin:0 0 24px}
73
+ .bar{display:flex;align-items:center;gap:12px;margin:8px 0}.name{width:140px;flex:none}.n{width:48px;text-align:right;flex:none}
74
+ .track{flex:1;height:12px;background:var(--line);border-radius:6px;overflow:hidden}.fill{display:block;height:100%;background:var(--bar)}
75
+ details{border-bottom:1px solid var(--line);padding:8px 0}summary{cursor:pointer}ul{margin:8px 0 0;padding-left:20px}
76
+ code{font-size:14px;word-break:break-all}
77
+ </style></head><body>
78
+ <h1>코드 진단${name ? ` · ${esc(name)}` : ''}</h1>
79
+ <p class="date">${esc(report.date)} 감사 결과. 이 파일은 내 컴퓨터에만 있습니다.</p>
80
+ <p>${lead}</p>${skew}
81
+ ${bars}
82
+ ${lists}
83
+ </body></html>
84
+ `;
85
+ }
86
+
87
+ function latestAudit(storeDir) {
88
+ try {
89
+ const xs = readdirSync(storeDir).filter(n => /^audit-\d{4}-\d{2}-\d{2}\.json$/.test(n)).sort();
90
+ return xs.length ? join(storeDir, xs[xs.length - 1]) : null;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+
96
+ function openInBrowser(file) {
97
+ const cmd = process.platform === 'darwin' ? ['open', [file]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', file]] : ['xdg-open', [file]];
98
+ return spawnSync(cmd[0], cmd[1], { stdio: 'ignore' }).status === 0;
99
+ }
100
+
101
+ export async function main(argv = process.argv.slice(2), cwd = process.cwd()) {
102
+ const ixs = await import(pathToFileURL(join(DIST, 'index-store.js')).href);
103
+ const { resolveTarget } = await import(pathToFileURL(join(HERE, 'rc-config.js')).href);
104
+ const t = resolveTarget(ixs, cwd);
105
+ if (!t) {
106
+ process.stderr.write('routinecode map: git 레포 안에서 실행한다\n');
107
+ return 2;
108
+ }
109
+ let file = latestAudit(t.storeDir);
110
+ if (!file || argv.includes('--refresh')) {
111
+ const { runDailyAudit } = await import(pathToFileURL(join(DIST, 'audit-cli.js')).href);
112
+ const r = await runDailyAudit(t.root, { force: true, enqueue: false });
113
+ file = r.auditFile ?? latestAudit(t.storeDir);
114
+ if (!file) {
115
+ process.stderr.write(`routinecode map: 감사 결과가 없다 (${r.reason ?? r.status})\n`);
116
+ return 3;
117
+ }
118
+ }
119
+ const report = JSON.parse(readFileSync(file, 'utf-8'));
120
+ mkdirSync(t.storeDir, { recursive: true });
121
+ const out = join(t.storeDir, `report-${report.date}.html`);
122
+ writeFileSync(out, renderReport(report, basename(t.root)), { mode: 0o600 });
123
+ const noOpen = argv.includes('--no-open') || argv.includes('--json');
124
+ const opened = noOpen ? false : openInBrowser(out);
125
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify({ file: out, date: report.date }) + '\n');
126
+ else process.stdout.write(`${out}${opened || noOpen ? '' : ' (브라우저를 열지 못했다. 이 파일을 직접 연다)'}\n`);
127
+ return 0;
128
+ }
129
+
130
+ if (process.argv[1] && /rc-map\.js$/.test(process.argv[1])) {
131
+ main().then(code => { process.exitCode = code; }).catch(e => { process.stderr.write(String(e?.message ?? e) + '\n'); process.exitCode = 1; });
132
+ }
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env node
2
+ // RoutineCode 전송 설정 러너 (zero-dep, ESM) — 설계 15 §4.5.
3
+ //
4
+ // routinecode privacy → 전송 항목별 켜짐·꺼짐 한 화면
5
+ // routinecode privacy telemetry on|off → 사용량·활성 신호 전송 (config.telemetryEnabled, 켜기는 터미널 확인)
6
+ // routinecode privacy knowledge on|off → 지식 기록·검색 전송 (config.knowledgeSyncDisabled, 켜기는 터미널 확인)
7
+ // routinecode privacy snippets on|off → 코드 조각 공유 (config.shareSnippets, 기본 off, 켜기는 터미널 확인)
8
+ // routinecode privacy share on|off → 이 레포 상세 공유 (= arch share)
9
+ // routinecode privacy team on|off → 이 레포 팀 노출 (= arch team)
10
+ // routinecode privacy log [--tail N] [--json] → 전송 기록. 엔드포인트·키 이름·크기만 있고 값은 없다
11
+ //
12
+ // syncEnabled 는 연결 상태라 재발급이 되돌린다. 끄기는 별도 키에 쓴다.
13
+
14
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
15
+ import { spawnSync } from 'node:child_process';
16
+ import { dirname, join } from 'node:path';
17
+ import { homedir } from 'node:os';
18
+ import { createInterface } from 'node:readline';
19
+ import { fileURLToPath } from 'node:url';
20
+
21
+ const HERE = dirname(fileURLToPath(import.meta.url));
22
+
23
+ export function rcDir() {
24
+ return process.env.ROUTINECODE_DIR || join(homedir(), '.routinecode');
25
+ }
26
+ export function configPath() {
27
+ return process.env.ROUTINECODE_CONFIG_PATH || join(rcDir(), 'config.json');
28
+ }
29
+ export function privacyLogPath() {
30
+ return join(rcDir(), 'privacy-log.jsonl');
31
+ }
32
+
33
+ export function readConfig(p = configPath()) {
34
+ try {
35
+ return JSON.parse(readFileSync(p, 'utf-8'));
36
+ } catch {
37
+ return {};
38
+ }
39
+ }
40
+
41
+ function writeConfig(c, p = configPath()) {
42
+ mkdirSync(dirname(p), { recursive: true });
43
+ const tmp = `${p}.tmp.${process.pid}`;
44
+ writeFileSync(tmp, JSON.stringify(c, null, 2), { mode: 0o600 });
45
+ renameSync(tmp, p);
46
+ }
47
+
48
+ function telemetryEnvOff(env = process.env) {
49
+ return String(env.ROUTINECODE_TELEMETRY ?? 'on').trim().toLowerCase() === 'off';
50
+ }
51
+
52
+ /** 설정 → 상태(pure). */
53
+ export function privacyStatus(c, env = process.env, repo = null) {
54
+ return {
55
+ // 표시는 실제 전송 판정과 같아야 한다: sync_manager·presence, shared/sanitize.ts knowledgeSendAllowed.
56
+ telemetry: {
57
+ on: c.telemetryEnabled !== false && c.loggedOut !== true && !telemetryEnvOff(env),
58
+ envOff: telemetryEnvOff(env), configOn: c.telemetryEnabled !== false, loggedOut: c.loggedOut === true,
59
+ },
60
+ knowledge: {
61
+ on: c.syncEnabled === true && c.knowledgeSyncDisabled !== true && c.loggedOut !== true,
62
+ loggedOut: c.loggedOut === true, notConnected: c.syncEnabled !== true && c.loggedOut !== true && c.knowledgeSyncDisabled !== true,
63
+ },
64
+ snippets: { on: c.shareSnippets === true },
65
+ repo,
66
+ };
67
+ }
68
+
69
+ const onOff = v => (v ? '켜짐' : '꺼짐');
70
+
71
+ /** 환경변수는 이 셸에서 시작한 세션에만 적용되고 config 값을 바꾸지 않는다. */
72
+ function telemetryNote(t) {
73
+ if (t.loggedOut) return ' (로그아웃 상태)';
74
+ if (t.envOff) return ' (이 셸의 ROUTINECODE_TELEMETRY=off 로 꺼짐. 이 셸에서 시작한 세션에만 적용)';
75
+ return '';
76
+ }
77
+
78
+ export function renderStatus(s) {
79
+ const lines = [
80
+ `사용량·활성 신호 ${onOff(s.telemetry.on)}${telemetryNote(s.telemetry)} routinecode privacy telemetry on|off`,
81
+ `지식 전송 ${onOff(s.knowledge.on)}${s.knowledge.loggedOut ? ' (로그아웃 상태)' : s.knowledge.notConnected ? ' (로그인 전)' : ''} routinecode privacy knowledge on|off`,
82
+ `코드 조각 ${onOff(s.snippets.on)} routinecode privacy snippets on|off`,
83
+ ];
84
+ if (s.repo) {
85
+ lines.push(`상세 공유 ${onOff(s.repo.detailOptIn)} routinecode privacy share on|off (${s.repo.repo})`);
86
+ lines.push(`팀 공유 ${onOff(s.repo.shared)} routinecode privacy team on|off`);
87
+ lines.push('상세 공유를 꺼도 집계 수치, 레포 이름, 하위 폴더 이름은 계속 보낸다. 파일 경로, 구조 그래프, 제안만 빠진다.');
88
+ } else {
89
+ lines.push('상세·팀 공유 git 레포 안에서 실행하면 표시한다');
90
+ }
91
+ lines.push('RoutineCode 서버 전송을 전부 멈추려면 routinecode logout 을 쓴다. npm 업데이트 확인은 로그아웃과 별개로 계속된다.');
92
+ lines.push('전송 기록은 routinecode privacy log 로 본다.');
93
+ return lines.join('\n') + '\n';
94
+ }
95
+
96
+ function repoStatus() {
97
+ const r = spawnSync(process.execPath, [join(HERE, 'rc-config.js'), 'status', '--json'], { encoding: 'utf-8' });
98
+ if (r.status !== 0) return null;
99
+ try {
100
+ return JSON.parse(r.stdout);
101
+ } catch {
102
+ return null;
103
+ }
104
+ }
105
+
106
+ async function confirm(question) {
107
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
108
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
109
+ const ans = await new Promise(res => rl.question(question, a => res(a)));
110
+ rl.close();
111
+ return /^(y|yes|예|네)$/i.test(String(ans).trim());
112
+ }
113
+
114
+ function usage() {
115
+ process.stdout.write('usage: routinecode privacy [telemetry|knowledge|snippets|share|team on|off] | log [--tail N] [--json]\n');
116
+ return 2;
117
+ }
118
+
119
+ /** 설정 변경(pure). 끄는 값은 명시 값으로 남긴다. */
120
+ export function applySetting(c, item, on) {
121
+ const out = { ...c };
122
+ if (item === 'telemetry') out.telemetryEnabled = on;
123
+ else if (item === 'knowledge') {
124
+ if (on) delete out.knowledgeSyncDisabled;
125
+ else out.knowledgeSyncDisabled = true;
126
+ } else if (item === 'snippets') out.shareSnippets = on;
127
+ return out;
128
+ }
129
+
130
+ /** 전송을 넓히는 쪽은 사람이 터미널에서 확인한다. 에이전트나 스크립트가 켤 수 없다. */
131
+ const TURN_ON_QUESTIONS = {
132
+ telemetry: '사용량, 프로젝트 폴더 이름, 활성 신호를 RoutineCode 서버로 보낸다.',
133
+ knowledge: '기록한 지식 요약과 검색어를 RoutineCode 서버로 보낸다.',
134
+ snippets: '오류 수정 코드와 패턴 예시(fixCode, codeExample)를 RoutineCode 서버로 보낸다.',
135
+ };
136
+
137
+ async function setCmd(item, value) {
138
+ if (value !== 'on' && value !== 'off') return usage();
139
+ const on = value === 'on';
140
+ const question = TURN_ON_QUESTIONS[item];
141
+ if (on && question) {
142
+ const ok = await confirm(`${question} 계속할까? [y/N] `);
143
+ if (!ok) {
144
+ process.stderr.write(`${item} 을(를) 켜지 않았다. 터미널에서 사람이 직접 실행해야 한다\n`);
145
+ return 3;
146
+ }
147
+ }
148
+ writeConfig(applySetting(readConfig(), item, on));
149
+ process.stdout.write(`${item} ${on ? '켜짐' : '꺼짐'}\n`);
150
+ if (item === 'telemetry' && on && telemetryEnvOff()) process.stdout.write('주의: ROUTINECODE_TELEMETRY=off 가 남아 있어 계속 꺼져 있다\n');
151
+ return 0;
152
+ }
153
+
154
+ export function readLog(tail = 50, p = privacyLogPath()) {
155
+ if (!existsSync(p)) return [];
156
+ const rows = [];
157
+ for (const line of readFileSync(p, 'utf-8').split('\n')) {
158
+ if (!line.trim()) continue;
159
+ try {
160
+ rows.push(JSON.parse(line));
161
+ } catch { /* 깨진 줄은 건너뛴다 */ }
162
+ }
163
+ return rows.slice(-tail);
164
+ }
165
+
166
+ function logCmd(args) {
167
+ const i = args.indexOf('--tail');
168
+ const tail = i >= 0 ? Math.max(1, Number(args[i + 1]) || 50) : 50;
169
+ const rows = readLog(tail);
170
+ if (args.includes('--json')) process.stdout.write(JSON.stringify(rows) + '\n');
171
+ else if (!rows.length) process.stdout.write('기록이 없다\n');
172
+ else {
173
+ for (const r of rows) process.stdout.write(`${r.ts} ${r.endpoint} ${r.bytes}B ${(r.keys ?? []).join(', ')}\n`);
174
+ process.stdout.write('값은 기록하지 않는다. 지식, 형상, 사용량, 활성 신호 전송만 남는다. 인증, 크레딧, 소셜 공유, 기능 플래그, 업데이트 확인 호출은 이 기록에 없다.\n');
175
+ }
176
+ return 0;
177
+ }
178
+
179
+ export async function main(argv = process.argv.slice(2)) {
180
+ const [cmd, value] = argv;
181
+ if (!cmd || cmd === 'status' || cmd === '--json') {
182
+ const c = readConfig();
183
+ const repo = repoStatus();
184
+ const s = privacyStatus(c, process.env, repo);
185
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify(s) + '\n');
186
+ else process.stdout.write(renderStatus(s));
187
+ return 0;
188
+ }
189
+ if (cmd === 'log') return logCmd(argv.slice(1));
190
+ if (cmd === 'telemetry' || cmd === 'knowledge' || cmd === 'snippets') return setCmd(cmd, value);
191
+ if (cmd === 'share' || cmd === 'team') {
192
+ if (value !== 'on' && value !== 'off') return usage();
193
+ return spawnSync(process.execPath, [join(HERE, 'rc-config.js'), cmd, value], { stdio: 'inherit' }).status ?? 1;
194
+ }
195
+ return usage();
196
+ }
197
+
198
+ if (process.argv[1] && /rc-privacy\.js$/.test(process.argv[1])) {
199
+ main().then(code => { process.exitCode = code; }).catch(e => { process.stderr.write(String(e?.message ?? e) + '\n'); process.exitCode = 1; });
200
+ }
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ // RoutineCode 디자인 스킬 팩 (zero-dep 평문 래퍼, ESM) — 설계 23 §5.1.
3
+ //
4
+ // routinecode skills status | on | off | sync
5
+ //
6
+ // 실제 동작은 mcp-routinecode/dist/skill-pack/sync.js(평문, PLAIN_DIST)의 main. 기본 꺼짐 — `on` 전에는 내려받지 않는다.
7
+ // session-start.sh 가 `sync` 를 부르고 첫 줄(changed|notice|…)을 읽는다. sync 는 어떤 실패에도 0 으로 끝난다(세션 시작을 막지 않음).
8
+
9
+ import { dirname, join } from 'node:path';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
+
12
+ const HERE = dirname(fileURLToPath(import.meta.url));
13
+ const SYNC = join(HERE, '..', 'mcp-routinecode', 'dist', 'skill-pack', 'sync.js');
14
+ const args = process.argv.slice(2);
15
+ const cmd = args[0] === 'skills' ? args.slice(1) : args;
16
+ const isSync = (cmd[0] ?? 'status') === 'sync';
17
+
18
+ let mod = null;
19
+ try {
20
+ mod = await import(pathToFileURL(SYNC).href);
21
+ } catch (e) {
22
+ if (isSync) { process.stdout.write('error\n'); process.exit(0); }
23
+ process.stderr.write(`routinecode skills: ${SYNC} 를 불러오지 못했다 — 빌드되지 않은 체크아웃이면 npm run build (${e?.message ?? e})\n`);
24
+ process.exit(1);
25
+ }
26
+
27
+ try {
28
+ process.exitCode = await mod.main(cmd);
29
+ } catch (e) {
30
+ if (isSync) { process.stdout.write('error\n'); process.exitCode = 0; } else { process.stderr.write(`routinecode skills: ${e?.message ?? e}\n`); process.exitCode = 1; }
31
+ }