@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
@@ -7,6 +7,7 @@
7
7
  check_bash(cmd) - 형상 지도 데이터 디렉터리에 쓰는 명령(리다이렉트·cp·mv·rm·tee·sed -i …)
8
8
  - rc-config.js / `routinecode arch (approve|reject|defer|share|team|baseline)` 결정·동의 실행
9
9
  (baseline 은 approve·revoke·show 모두 — 서브커맨드 구분 없이 사람 전용)
10
+ - `arch ratchet init`·`--allow` (래칫 기준선은 사람이 정한다, 설계 18 T7)
10
11
  - script/unbuffer/expect/pty 로 `arch` 를 감싸는 TTY 위조 패턴
11
12
  - rc-config 의 테스트 전용 setter(setConfirmForTests) 호출, 폐기된 ROUTINECODE_CONFIG_ASSUME_TTY env
12
13
  - 정비 러너 동의 변경(`arch maintenance enable|disable|mode|push`) · 러너 브리지 쓰기 명령
@@ -77,6 +78,8 @@ _MAINT_CONSENT_RE = re.compile(r'\b(arch|rc-config(\.js)?)\s+maintenance\s+(enab
77
78
  _MAINT_BRIDGE_RE = re.compile(r'\bmaintenance-cli(\.js)?["\']?[^|;&\n]*?\s["\']?(queue-claim|start|finish|recover|cleanup|postcheck|exec|run-set|drop-worktree)["\']?(?=$|[\s|;&])')
78
79
  _REASON_MAINT = ('[config-guard] 정비 러너 동의·착수·결과 기록(arch maintenance enable|disable|mode|push, maintenance-cli 쓰기 명령)은 '
79
80
  '사람·러너 셸 전용이라 AI 가 실행하지 않는다 — 사용자에게 터미널에서 `routinecode arch maintenance …` 를 안내하라.')
81
+ # 래칫 기준선 재설정·허용(설계 18 T7)은 사람 결정. `arch ratchet check` 는 읽기라 허용
82
+ _RATCHET_RE = re.compile(r'\b(arch|rc-config(\.js)?)\s+ratchet\s+init\b|\b(arch|rc-config(\.js)?)\s+ratchet\b[^|;&\n]*--allow\b')
80
83
  _PTY_RE = re.compile(r'\b(script|unbuffer|expect|socat|ptyprocess|pexpect)\b[^\n]*\barch\b|\bpty\.(spawn|fork|openpty)\b[^\n]*\barch\b|\barch\b[^\n]*\bpty\.(spawn|fork|openpty)\b')
81
84
 
82
85
 
@@ -87,7 +90,7 @@ def check_bash(cmd):
87
90
  return _REASON_TTY
88
91
  if _PTY_RE.search(cmd):
89
92
  return _REASON_TTY
90
- if _DECIDE_RE.search(cmd):
93
+ if _DECIDE_RE.search(cmd) or _RATCHET_RE.search(cmd):
91
94
  return _REASON_DECIDE
92
95
  if _MAINT_CONSENT_RE.search(cmd) or _MAINT_BRIDGE_RE.search(cmd):
93
96
  return _REASON_MAINT
@@ -97,7 +100,136 @@ def check_bash(cmd):
97
100
  refs.append(pre + '/' + _CM_REL)
98
101
  refs.append('$ROUTINECODE_CONFIG_MAP_DIR')
99
102
  refs.append('${ROUTINECODE_CONFIG_MAP_DIR')
100
- scrub = re.sub(r'\d*>>?\s*/dev/null|\d*>&\d', ' ', cmd)
101
- if any(r in cmd for r in refs) and _WRITE_OPS.search(scrub):
102
- return _REASON_DIR
103
- return None
103
+ if not any(r in cmd for r in refs):
104
+ return None
105
+ # 설계 30 §6: 지도 경로가 나오면 "쓰기 대상"이 지도 안인지만 본다(읽기 명령의 `=>`·`>=`·scratch 리다이렉트는 허용).
106
+ # 해석할 수 없으면 예전 규칙(명령 전체에 쓰기 기호 + 지도 경로 = deny)으로 돌아간다 — 보수적 기본값.
107
+ try:
108
+ verdict = _write_targets_hit(cmd, refs)
109
+ except Exception:
110
+ verdict = None
111
+ if verdict is None:
112
+ scrub = re.sub(r'\d*>>?\s*/dev/null|\d*>&\d', ' ', cmd)
113
+ return _REASON_DIR if _WRITE_OPS.search(scrub) else None
114
+ return _REASON_DIR if verdict else None
115
+
116
+
117
+ # 코드 안 쓰기 API — 대상 해석 불가라 지도 경로와 같이 나오면 deny(보수적)
118
+ _CODE_WRITE_RE = re.compile(r'\b(writeFile(Sync)?|appendFile(Sync)?|createWriteStream|copyFile(Sync)?|cpSync|renameSync|rename|unlink(Sync)?|rmSync|rmdirSync|mkdirSync|truncateSync|symlinkSync|write_text|write_bytes|shutil\.(copy|copyfile|copy2|copytree|move|rmtree)|os\.(remove|unlink|rename|replace|makedirs|mkdir))\b|\bopen\([^)]*[\'"][wax+]')
119
+ _DEST_LAST = {'cp', 'mv', 'rsync', 'ln', 'install', 'scp'}
120
+ _ANY_ARG = {'rm', 'rmdir', 'truncate', 'touch', 'mkdir', 'chmod', 'chown', 'unlink', 'shred'}
121
+ _UNPARSEABLE = re.compile(r'\beval\b|`|\$\(|<\(|>\(')
122
+
123
+
124
+ def _scan(cmd):
125
+ """따옴표 밖 기준으로 명령 조각(|;& 와 줄바꿈으로 구분)과 리다이렉트 대상을 뽑는다. 반환 (segments, redirect_targets)."""
126
+ segs, targets = [], []
127
+ cur, i, n, q = [], 0, len(cmd), None
128
+ while i < n:
129
+ ch = cmd[i]
130
+ if q:
131
+ cur.append(ch)
132
+ if ch == '\\' and q == '"' and i + 1 < n:
133
+ cur.append(cmd[i + 1]); i += 2; continue
134
+ if ch == q:
135
+ q = None
136
+ i += 1; continue
137
+ if ch in ('"', "'"):
138
+ q = ch; cur.append(ch); i += 1; continue
139
+ if ch == '\\' and i + 1 < n:
140
+ cur.append(ch); cur.append(cmd[i + 1]); i += 2; continue
141
+ if ch in '|;&\n':
142
+ # `>&2` · `2>&1` 은 리다이렉트 처리에서 먹는다 — 여기 오는 & 는 구분자
143
+ segs.append(''.join(cur)); cur = []; i += 1; continue
144
+ if ch == '>':
145
+ j = i + 1
146
+ if j < n and cmd[j] == '>':
147
+ j += 1
148
+ if j < n and cmd[j] == '&': # >&2 · >&- : fd 복제, 파일 대상 아님
149
+ j += 1
150
+ while j < n and (cmd[j].isdigit() or cmd[j] == '-'):
151
+ j += 1
152
+ i = j; continue
153
+ if j < n and cmd[j] == '|':
154
+ j += 1
155
+ while j < n and cmd[j] in ' \t':
156
+ j += 1
157
+ k, tq, word = j, None, []
158
+ while k < n:
159
+ c = cmd[k]
160
+ if tq:
161
+ if c == tq:
162
+ tq = None
163
+ else:
164
+ word.append(c)
165
+ k += 1; continue
166
+ if c in ('"', "'"):
167
+ tq = c; k += 1; continue
168
+ if c in ' \t|;&<>\n':
169
+ break
170
+ word.append(c); k += 1
171
+ targets.append(''.join(word))
172
+ # 리다이렉트 앞 fd 숫자는 cur 에 남아 있어도 무해(인자로만 보임)
173
+ i = k; continue
174
+ cur.append(ch); i += 1
175
+ if q:
176
+ raise ValueError('unbalanced quotes')
177
+ segs.append(''.join(cur))
178
+ return [s for s in segs if s.strip()], targets
179
+
180
+
181
+ def _write_targets_hit(cmd, refs):
182
+ """True = 지도 안 쓰기 / False = 지도 안 쓰기 없음 / None = 해석 불가(예전 규칙으로)"""
183
+ import shlex
184
+ if _UNPARSEABLE.search(cmd):
185
+ return None
186
+ if _CODE_WRITE_RE.search(cmd):
187
+ return True
188
+ segs, redirs = _scan(cmd)
189
+ has_ref = lambda s: any(r in s for r in refs)
190
+ cd_into_map = False
191
+ dests = list(redirs)
192
+ for seg in segs:
193
+ argv = shlex.split(seg)
194
+ while argv and re.match(r'^[A-Za-z_][A-Za-z0-9_]*=', argv[0]): # VAR=… 접두
195
+ if has_ref(argv[0]):
196
+ cd_into_map = True # 변수에 지도 경로를 담으면 뒤의 $VAR 대상은 해석 불가 → 보수적
197
+ argv = argv[1:]
198
+ while argv and argv[0] in ('sudo', 'env', 'command', 'builtin', 'nohup', 'time', 'xargs'):
199
+ argv = argv[1:]
200
+ if not argv:
201
+ continue
202
+ name = os.path.basename(argv[0])
203
+ args = argv[1:]
204
+ if name in ('cd', 'pushd') and args and has_ref(args[0]):
205
+ cd_into_map = True
206
+ elif name in _DEST_LAST:
207
+ t_opt = [args[i + 1] for i, a in enumerate(args[:-1]) if a in ('-t', '--target-directory')]
208
+ pos = [a for a in args if not a.startswith('-')]
209
+ if t_opt:
210
+ dests += t_opt
211
+ elif pos:
212
+ dests.append(pos[-1])
213
+ elif name == 'tee':
214
+ dests += [a for a in args if not a.startswith('-')]
215
+ elif name == 'dd':
216
+ dests += [a[3:] for a in args if a.startswith('of=')]
217
+ elif name in _ANY_ARG:
218
+ dests += [a for a in args if not a.startswith('-')]
219
+ elif name in ('sed', 'perl') and any(re.match(r'^-[a-zA-Z]*i', a) or a.startswith('--in-place') for a in args):
220
+ dests += [a for a in args if not a.startswith('-')]
221
+ elif name == 'git' and has_ref(seg):
222
+ return None # git -C <지도> … 는 쓰기 여부 해석 안 함
223
+ for d in dests:
224
+ if d in ('/dev/null', '/dev/stdout', '/dev/stderr'):
225
+ continue
226
+ if has_ref(d):
227
+ return True
228
+ if '$' in d and cd_into_map:
229
+ return True
230
+ if cd_into_map and not d.startswith('/') and not d.startswith('~'):
231
+ return True
232
+ if '$' in d and not d.startswith('/') and not d.startswith('~'):
233
+ # 변수 경로 — 명령에 지도 경로가 있으니 보수적으로
234
+ return True
235
+ return False
@@ -0,0 +1,182 @@
1
+ # -*- coding: utf-8 -*-
2
+ """edit-tracker.json — 세션별 편집 기록(설계 31 §16).
3
+
4
+ 예전에는 머신의 모든 세션이 한 목록(files·ts·first·heads)을 같이 썼다. 그래서 다른 세션 편집이
5
+ 이 세션의 채점 대상이 되고, 한 세션의 완료 처리가 남의 기록까지 지웠다.
6
+
7
+ 형식(기존 칸 유지 + 두 칸 추가):
8
+ files [경로] 머신 전체(하위 호환)
9
+ ts {경로: ms} 파일별 마지막 편집(어느 세션이든) — 증거 신선도는 코드 상태 기준이라 공용이 맞다
10
+ first {경로: ms} 머신 전체 첫 편집(하위 호환)
11
+ heads {레포: sha} 머신 전체 첫 HEAD(하위 호환)
12
+ by {세션: {경로: ms}} 세션별 편집 파일과 그 세션의 첫 편집 시각
13
+ sheads {세션: {레포: sha}} 세션별 태스크 시작 HEAD
14
+
15
+ 보기(view): by 칸이 없으면(구형 파일) 예전 그대로. 있으면 그 세션 것만 — by 이전에 쌓인 구형 항목은
16
+ 출처를 모르므로 어느 세션 채점에도 넣지 않는다. 세션 ID 를 모르면(None) 예전 그대로(fail-open).
17
+ 쓰기는 update()로 잠금(edit-tracker.json.lock)을 잡는다. 초기화(reset_session): 그 세션 칸만 지우고, 아무 세션도 참조하지 않는 파일은 공용 칸에서도 지운다.
18
+ 세션 ID 는 앞 12자(board.py 와 같다). 표준 라이브러리만, 예외를 올리지 않는다. Python 3.9 호환.
19
+ """
20
+ import json
21
+ import os
22
+ import time
23
+
24
+ SID_LEN = 12
25
+ LOCK_WAIT_S = 2.0 # 잠금 대기 상한 — 넘으면 잠금 없이 진행(편집을 막지 않는다)
26
+ LOCK_STALE_S = 10.0 # 이보다 오래된 잠금 파일은 죽은 프로세스 것으로 보고 지운다
27
+
28
+
29
+ def path():
30
+ return os.path.join(os.environ.get('ROUTINECODE_KNOWLEDGE_DIR') or os.path.expanduser('~/.routinecode/knowledge'),
31
+ 'edit-tracker.json')
32
+
33
+
34
+ def sid_of(session_id):
35
+ s = str(session_id or '')[:SID_LEN]
36
+ return s if s and s != 'unknown'[:SID_LEN] else None
37
+
38
+
39
+ def load(p=None):
40
+ try:
41
+ with open(p or path(), encoding='utf-8') as f:
42
+ t = json.load(f)
43
+ if isinstance(t, dict) and isinstance(t.get('files'), list):
44
+ return t
45
+ except Exception:
46
+ pass
47
+ return {'files': []}
48
+
49
+
50
+ def save(t, p=None):
51
+ p = p or path()
52
+ try:
53
+ os.makedirs(os.path.dirname(p), exist_ok=True)
54
+ tmp = '%s.%d.tmp' % (p, os.getpid())
55
+ with open(tmp, 'w', encoding='utf-8') as f:
56
+ json.dump(t, f)
57
+ os.replace(tmp, p)
58
+ return True
59
+ except Exception:
60
+ return False
61
+
62
+
63
+ def _lock_path(p):
64
+ return p + '.lock'
65
+
66
+
67
+ def _acquire(p):
68
+ lp = _lock_path(p)
69
+ deadline = time.time() + LOCK_WAIT_S
70
+ while True:
71
+ try:
72
+ fd = os.open(lp, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)
73
+ os.write(fd, str(os.getpid()).encode())
74
+ os.close(fd)
75
+ return True
76
+ except FileExistsError:
77
+ try:
78
+ if time.time() - os.path.getmtime(lp) > LOCK_STALE_S:
79
+ os.unlink(lp)
80
+ continue
81
+ except Exception:
82
+ pass
83
+ if time.time() >= deadline:
84
+ return False
85
+ time.sleep(0.02)
86
+ except Exception:
87
+ return False
88
+
89
+
90
+ def update(fn, p=None):
91
+ """잠금을 잡고 읽기 → fn(t) → 쓰기. 동시 편집에서 한쪽 기록이 빠지던 문제(§17.3-5).
92
+ 잠금 파일은 edit-tracker.json.lock(O_EXCL) — TS recordEdits 와 같은 파일. 실패해도 예외 없음."""
93
+ p = p or path()
94
+ got = False
95
+ try:
96
+ os.makedirs(os.path.dirname(p), exist_ok=True)
97
+ got = _acquire(p)
98
+ t = load(p)
99
+ t = fn(t) or t
100
+ return save(t, p)
101
+ except Exception:
102
+ return False
103
+ finally:
104
+ if got:
105
+ try:
106
+ os.unlink(_lock_path(p))
107
+ except Exception:
108
+ pass
109
+
110
+
111
+ def _dict(t, k):
112
+ if not isinstance(t.get(k), dict):
113
+ t[k] = {}
114
+ return t[k]
115
+
116
+
117
+ def record(t, files, sid, now_ms, heads=None):
118
+ """편집 기록. heads = {레포: sha} (그 레포의 첫 기록만 남는다)."""
119
+ ts, first = _dict(t, 'ts'), _dict(t, 'first')
120
+ for f in files:
121
+ if f not in t['files']:
122
+ t['files'].append(f)
123
+ ts[f] = now_ms
124
+ first.setdefault(f, now_ms)
125
+ for top, sha in (heads or {}).items():
126
+ _dict(t, 'heads').setdefault(top, sha)
127
+ if sid:
128
+ mine = _dict(t, 'by').setdefault(sid, {})
129
+ for f in files:
130
+ mine.setdefault(f, now_ms)
131
+ sh = _dict(t, 'sheads').setdefault(sid, {})
132
+ for top, sha in (heads or {}).items():
133
+ sh.setdefault(top, sha)
134
+ return t
135
+
136
+
137
+ def view(t, sid):
138
+ """이 세션의 태스크 보기 → {'files','ts','first','heads'} (형식은 예전 tracker 와 같다)."""
139
+ if not sid or not isinstance(t.get('by'), dict):
140
+ return {'files': [f for f in t.get('files') or [] if isinstance(f, str)],
141
+ 'ts': t.get('ts') if isinstance(t.get('ts'), dict) else {},
142
+ 'first': t.get('first') if isinstance(t.get('first'), dict) else {},
143
+ 'heads': t.get('heads') if isinstance(t.get('heads'), dict) else {}}
144
+ mine = t['by'].get(sid) or {}
145
+ ts = t.get('ts') if isinstance(t.get('ts'), dict) else {}
146
+ files = [f for f in mine if isinstance(f, str)]
147
+ return {'files': files, 'ts': {f: ts[f] for f in files if f in ts}, 'first': dict(mine),
148
+ 'heads': dict((t.get('sheads') or {}).get(sid) or {})}
149
+
150
+
151
+ def reset_session(t, sid):
152
+ """완료 처리 — 이 세션 칸만 비운다. by 칸이 없거나 세션을 모르면 예전처럼 전부 비운다."""
153
+ if not sid or not isinstance(t.get('by'), dict):
154
+ return {'files': []}
155
+ t['by'].pop(sid, None)
156
+ _dict(t, 'sheads').pop(sid, None)
157
+ keep = set()
158
+ for m in t['by'].values():
159
+ if isinstance(m, dict):
160
+ keep.update(m)
161
+ t['files'] = [f for f in t.get('files') or [] if f in keep]
162
+ for k in ('ts', 'first'):
163
+ t[k] = {f: v for f, v in _dict(t, k).items() if f in keep}
164
+ if not t['by']:
165
+ t['heads'] = {}
166
+ return t
167
+
168
+
169
+ def write_view(sid, out_path, p=None):
170
+ """이 세션 보기를 예전 형식 파일로 쓴다(경로를 넘겨받는 기존 판정기용). 성공하면 out_path."""
171
+ v = view(load(p), sid)
172
+ return out_path if save(v, out_path) else None
173
+
174
+
175
+ if __name__ == '__main__':
176
+ import sys
177
+ a = sys.argv[1:]
178
+ if a[:1] == ['view'] and len(a) >= 3: # view <sid> <out>
179
+ print(write_view(sid_of(a[1]), a[2]) or '')
180
+ elif a[:1] == ['reset'] and len(a) >= 2: # reset <sid>
181
+ sid = sid_of(a[1])
182
+ update(lambda t: reset_session(t, sid))
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+ """에러 줄 판정과 종류 키 (docs/지식체계/38 E2·E3).
3
+
4
+ 빌드·테스트·Bash 세 경로가 같이 쓴다.
5
+ error_line(text, fallback=False) → 에러 머리 형식에 맞는 첫 줄(위치 접두 제거) 또는 None.
6
+ 소스 코드 모양의 줄(grep·cat 으로 본 코드)은 버린다. fallback=True 는 실패가 확실한 경로(PostToolUseFailure)에서만
7
+ 쓴다 — 머리 형식이 없으면 'Exit code N' 다음의 첫 비코드 줄을 쓴다(없으면 None: grep 일치 없음 같은 빈 실패).
8
+ family_of(line) → {'familyKey': sha1(뼈대)[:12], 'family': 뼈대(≤120)}. 따옴표 안 식별자·경로·숫자를 * 로 바꿔
9
+ 같은 종류(TS2307 'os' / 'node:path')를 한 키로 묶는다. 에러 코드(TS2307·E404·ECONNREFUSED)는 남긴다.
10
+ 어떤 실패도 None.
11
+ """
12
+ import hashlib
13
+ import re
14
+
15
+ # 위치 접두: grep -n(path:12: / 12-), tsc(path(13,31): ), gcc(path:12:5: )
16
+ _LOC_RE = re.compile(r'^\s*(?:[^\s:()]+(?:\(\d+,\d+\)|:\d+(?::\d+)?)[:-]?\s*|\d+[:-](?!\d))')
17
+ _CODE_START_RE = re.compile(
18
+ r'^\s*(?:import|export|from|const|let|var|function|def|class|return|throw|except|catch|try|if|else|elif|'
19
+ r'async|await|public|private|protected|interface|type|module\.exports|require\(|#|//|/\*|\*|@)\b')
20
+ _CODE_INSIDE_RE = re.compile(r'(?:throw new |new \w*(?:Error|Exception)\(|instanceof \w*(?:Error|Exception)|'
21
+ r'except \w*(?:Error|Exception)|catch\s*\(|\.json\(|=>|\bres\.status\()')
22
+ _ENVELOPE_RE = re.compile(r'^\s*[{\[]\s*"(?:stdout|stderr|content|type)"')
23
+
24
+ _HEADER_RE = re.compile(
25
+ r'(?:\berror TS\d{3,5}\b' # tsc
26
+ r'|^\s*npm (?:ERR!|error)\s' # npm
27
+ r'|^\s*Traceback \(most recent call last\)' # python
28
+ r'|^\s*(?:FAIL|✗|×|✕)\s+\S' # 테스트 실패 줄
29
+ r'|^\s*(?:fatal|panic|error|ERROR|Error|FATAL)(?:\[\w+\])?:\s'
30
+ r'|^\s*\w*(?:Error|Exception)(?:\s*\[[\w-]+\])?:\s' # TypeError: · AssertionError [ERR_X]:
31
+ r'|\b(?:ECONNREFUSED|ENOENT|EACCES|EADDRINUSE|ETIMEDOUT|ERR_[A-Z_]{3,})\b'
32
+ r'|^\s*\d+:\d+\s+error\s' # eslint
33
+ r'|\bcommand not found\b|\bNo such file or directory\b|\bPermission denied\b)')
34
+ _EXIT_RE = re.compile(r'^\s*Exit code \d+\s*$')
35
+
36
+ _QUOTED_RE = re.compile(r"'[^'\n]{0,200}'|\"[^\"\n]{0,200}\"|`[^`\n]{0,200}`")
37
+ _PATH_RE = re.compile(r'(?:[A-Za-z]:)?(?:[\w.@~-]*/)+[\w.@-]+')
38
+ _NUM_RE = re.compile(r'(?<![A-Za-z0-9_.])\d+(?:\.\d+)*(?![A-Za-z_])')
39
+ _HEX_RE = re.compile(r'\b0x[0-9a-fA-F]+\b|\b[0-9a-f]{8,}\b')
40
+ _WS_RE = re.compile(r'\s+')
41
+ FAMILY_MAX = 120
42
+ LINE_MAX = 400
43
+
44
+
45
+ def _strip_loc(line):
46
+ return _LOC_RE.sub('', line, count=1)
47
+
48
+
49
+ def _is_code(line):
50
+ s = _strip_loc(line)
51
+ return bool(_ENVELOPE_RE.search(line) or _CODE_START_RE.match(s) or _CODE_INSIDE_RE.search(s))
52
+
53
+
54
+ def _lines(text):
55
+ t = str(text or '')
56
+ t = t.replace('\\n', '\n') # JSON 직렬화된 출력
57
+ return [ln.rstrip() for ln in t.split('\n') if ln.strip()]
58
+
59
+
60
+ def error_line(text, fallback=False):
61
+ try:
62
+ lines = _lines(text)
63
+ for ln in lines:
64
+ if _EXIT_RE.match(ln) or _is_code(ln):
65
+ continue
66
+ if _HEADER_RE.search(ln) or _HEADER_RE.search(_strip_loc(ln)):
67
+ return _strip_loc(ln).strip()[:LINE_MAX] or ln.strip()[:LINE_MAX]
68
+ if fallback:
69
+ for ln in lines:
70
+ if _EXIT_RE.match(ln) or _is_code(ln):
71
+ continue
72
+ return _strip_loc(ln).strip()[:LINE_MAX] or None
73
+ return None
74
+ except Exception:
75
+ return None
76
+
77
+
78
+ def family_of(line):
79
+ try:
80
+ if not line:
81
+ return None
82
+ s = _strip_loc(str(line))
83
+ s = _QUOTED_RE.sub('*', s)
84
+ s = _HEX_RE.sub('*', s)
85
+ s = _PATH_RE.sub('*', s)
86
+ s = _NUM_RE.sub('*', s)
87
+ s = _WS_RE.sub(' ', s).strip()
88
+ s = re.sub(r'(?:\*\s*){2,}', '* ', s).strip()
89
+ s = s[:FAMILY_MAX]
90
+ if not s or s == '*':
91
+ return None
92
+ return {'familyKey': hashlib.sha1(s.encode('utf-8')).hexdigest()[:12], 'family': s}
93
+ except Exception:
94
+ return None
@@ -0,0 +1,66 @@
1
+ """세션 시작 시 3회 실패 에스컬레이션 복원 — session-start.sh §1 에서 부른다(설계 27 T4 후속).
2
+
3
+ attempts.json 키가 `<서명>@<프로젝트 해시>`(mcp-routinecode/src/failure-tracker.ts)로 바뀐 뒤의 규칙:
4
+ - 이 프로젝트의 기록만 센다(시도의 project 칸 == 현재 프로젝트, project 없는 옛 기록은 어디서나 같다고 본다)
5
+ → 다른 저장소의 3회 실패가 이 저장소 편집을 막지 않는다
6
+ - failure-tracker 와 같은 TTL(7일) 밖 기록은 세지 않는다
7
+ - 안내 문구에는 opaque 키 대신 모델이 쓴 issueId 원문을 보인다
8
+ 사용: python3 escalation_restore.py <attempts.json> <state.json> [project_dir]
9
+ 출력: 복원했으면 한 줄 안내, 아니면 빈 줄. 실패해도 조용히 빈 줄(fail-open).
10
+ """
11
+ import json
12
+ import os
13
+ import sys
14
+ from datetime import datetime, timezone
15
+
16
+ THRESHOLD = 3
17
+ TTL_SEC = 7 * 24 * 3600
18
+
19
+
20
+ def _ts(v):
21
+ try:
22
+ return datetime.fromisoformat(str(v).replace('Z', '+00:00')).timestamp()
23
+ except Exception:
24
+ return None
25
+
26
+
27
+ def find_escalated(attempts, project, now=None):
28
+ """(key, 원문 issueId, 실패 수) 또는 None"""
29
+ now = now if now is not None else datetime.now(timezone.utc).timestamp()
30
+ proj = os.path.abspath(project) if project else None
31
+ for key, history in (attempts or {}).items():
32
+ if not isinstance(history, list):
33
+ continue
34
+ recent = [a for a in history if isinstance(a, dict) and (_ts(a.get('ts')) or 0) >= now - TTL_SEC]
35
+ if proj and any(a.get('project') and os.path.abspath(a['project']) != proj for a in recent):
36
+ continue
37
+ fails = [a for a in recent if a.get('result') == 'fail']
38
+ if len(fails) >= THRESHOLD:
39
+ text = next((a.get('issueId') for a in reversed(fails) if a.get('issueId')), key)
40
+ return key, text, len(fails)
41
+ return None
42
+
43
+
44
+ def main(argv):
45
+ if len(argv) < 3:
46
+ print('')
47
+ return
48
+ attempts_path, state_path = argv[1], argv[2]
49
+ project = argv[3] if len(argv) > 3 and argv[3] else (os.environ.get('CLAUDE_PROJECT_DIR') or os.getcwd())
50
+ try:
51
+ with open(attempts_path, encoding='utf-8') as f:
52
+ attempts = json.load(f)
53
+ hit = find_escalated(attempts, project)
54
+ if not hit:
55
+ print('')
56
+ return
57
+ key, text, n = hit
58
+ with open(state_path, 'w', encoding='utf-8') as f:
59
+ json.dump({'escalated': True, 'issueId': key, 'issue': str(text)[:200], 'restoredFromPersistent': True}, f)
60
+ print(f'Escalation restored: {str(text)[:120]} ({n} failures)')
61
+ except Exception:
62
+ print('')
63
+
64
+
65
+ if __name__ == '__main__':
66
+ main(sys.argv)
package/hooks/lib/i18n.py CHANGED
@@ -484,12 +484,26 @@ STRINGS = {
484
484
  },
485
485
 
486
486
  # ── Escalation (pre-edit-check.sh) ──
487
+ "escalation.observed": {
488
+ "en": "[HOOK] Same error 3 times with edits in between: {label}. These edits did not fix it: {files}. Stop editing and re-derive the root cause (read the error, check the premise). Then call mcp__routinecode__clear_attempts with issueId \"{pk}\" and try a different approach.",
489
+ "ko": "[HOOK] 편집을 사이에 두고 같은 오류가 3번 났습니다: {label}. 원인이 아니었던 수정: {files}. 편집을 멈추고 원인을 다시 분석하세요(오류 원문을 읽고 전제를 확인). 그다음 mcp__routinecode__clear_attempts 를 issueId \"{pk}\" 로 호출하고 다른 접근으로 진행하세요.",
490
+ "ja": "[HOOK] 編集を挟んで同じエラーが3回発生: {label}。原因ではなかった修正: {files}。編集を止めて原因を再分析してください。その後 mcp__routinecode__clear_attempts を issueId \"{pk}\" で呼び、別の方法を試してください。",
491
+ "zh": "[HOOK] 中间有编辑但同一错误出现3次: {label}。不是原因的修改: {files}。请停止编辑并重新分析根因,然后以 issueId \"{pk}\" 调用 mcp__routinecode__clear_attempts 并换用其他方法。",
492
+ "es": "[HOOK] El mismo error 3 veces con ediciones entre medias: {label}. Estas ediciones no lo arreglaron: {files}. Deja de editar y vuelve a analizar la causa raíz. Luego llama a mcp__routinecode__clear_attempts con issueId \"{pk}\" y usa otro enfoque.",
493
+ },
494
+ "board.conflict": {
495
+ "en": "[HOOK] Shared board: {file} is claimed by session {session} for task {task} ({title}). Coordinate through board_view/board_note before editing, or claim a different task.",
496
+ "ko": "[HOOK] 공유 판: {file} 은(는) 세션 {session} 이(가) 과제 {task}({title})로 잡고 있습니다. 편집하기 전에 board_view·board_note로 조율하거나 다른 과제를 잡으세요.",
497
+ "ja": "[HOOK] 共有ボード: {file} はセッション {session} がタスク {task}({title})で確保中です。編集前に board_view・board_note で調整するか、別のタスクを取ってください。",
498
+ "zh": "[HOOK] 共享看板: {file} 已被会话 {session} 以任务 {task}({title})认领。编辑前请通过 board_view/board_note 协调,或认领其他任务。",
499
+ "es": "[HOOK] Tablero compartido: {file} está reclamado por la sesión {session} para la tarea {task} ({title}). Coordina con board_view/board_note antes de editar o toma otra tarea.",
500
+ },
487
501
  "escalation.block": {
488
- "en": "[HOOK] Escalation active: 3+ failed attempts on the same issue. You MUST consult the reviewer agent before making more edits. Call mcp__routinecode__check_escalation to see attempt history, then delegate to reviewer.",
489
- "ko": "[HOOK] 에스컬레이션 활성: 동일 이슈에서 3회 이상 실패. 추가 수정 전 반드시 reviewer 에이전트와 상의하세요. mcp__routinecode__check_escalation으로 시도 이력 확인 후 reviewer에 위임.",
490
- "ja": "[HOOK] エスカレーション発動中: 同一問題で3回以上失敗。追加編集前にreviewerエージェントに相談が必要です。mcp__routinecode__check_escalationで試行履歴を確認し、reviewerに委任してください。",
491
- "zh": "[HOOK] 升级已激活: 同一问题失败3次以上。继续编辑前必须咨询 reviewer 代理。调用 mcp__routinecode__check_escalation 查看尝试历史,然后委托给 reviewer。",
492
- "es": "[HOOK] Escalación activa: 3+ intentos fallidos en el mismo problema. DEBES consultar al agente reviewer antes de hacer más ediciones. Llama a mcp__routinecode__check_escalation para ver el historial, luego delega al reviewer.",
502
+ "en": "[HOOK] Escalation active: 3+ failed attempts on the same issue. Stop and re-derive the root cause before making more edits. Call mcp__routinecode__check_escalation to see attempt history, then call clear_attempts and use a different approach.",
503
+ "ko": "[HOOK] 에스컬레이션 활성: 동일 이슈에서 3회 이상 실패. 추가 수정 전 원인을 다시 분석하세요. mcp__routinecode__check_escalation으로 시도 이력 확인 후 clear_attempts를 호출하고 다른 접근을 쓰세요.",
504
+ "ja": "[HOOK] エスカレーション発動中: 同一問題で3回以上失敗。追加編集の前に原因を再分析してください。mcp__routinecode__check_escalationで試行履歴を確認し、clear_attemptsを呼んで別の方法を試してください。",
505
+ "zh": "[HOOK] 升级已激活: 同一问题失败3次以上。继续编辑前请重新分析根因。调用 mcp__routinecode__check_escalation 查看尝试历史,然后调用 clear_attempts 并换用其他方法。",
506
+ "es": "[HOOK] Escalación activa: 3+ intentos fallidos en el mismo problema. Vuelve a analizar la causa raíz antes de hacer más ediciones. Llama a mcp__routinecode__check_escalation para ver el historial, luego llama a clear_attempts y usa otro enfoque.",
493
507
  },
494
508
 
495
509
  # ── Stop hook v2 (false claim block) ──
@@ -588,11 +602,11 @@ STRINGS = {
588
602
  "es": "[HOOK:design-gate] No se puede extraer taskId del prompt del implementor. Incluye \"taskId: <id>\" en la sección CONTEXT.",
589
603
  },
590
604
  "gate.design_score_low": {
591
- "en": "[HOOK:design-gate] Design phase score {score}/100 < 90 for task {task_id}. Run reviewer cross-validation and re-score the design phase before spawning implementor.",
592
- "ko": "[HOOK:design-gate] 태스크 {task_id}의 설계 점수 {score}/100 < 90. reviewer 교차검증 후 재채점한 뒤 implementor를 위임하세요.",
593
- "ja": "[HOOK:design-gate] タスク {task_id} の設計スコア {score}/100 < 90。reviewerのクロス検証後に再採点してからimplementorを起動してください。",
594
- "zh": "[HOOK:design-gate] 任务 {task_id} 的设计评分 {score}/100 < 90。请先通过 reviewer 交叉验证并重新评分,再派发 implementor。",
595
- "es": "[HOOK:design-gate] Puntuación de diseño {score}/100 < 90 para la tarea {task_id}. Ejecuta la validación cruzada del reviewer y vuelve a puntuar antes de lanzar el implementor.",
605
+ "en": "[HOOK:design-gate] Design phase score {score}/100 < 90 for task {task_id}. Verify the design assumptions by running them and re-score the design phase before spawning implementor.",
606
+ "ko": "[HOOK:design-gate] 태스크 {task_id}의 설계 점수 {score}/100 < 90. 설계 전제를 실행으로 확인하고 재채점한 뒤 implementor를 위임하세요.",
607
+ "ja": "[HOOK:design-gate] タスク {task_id} の設計スコア {score}/100 < 90。設計の前提を実行で確認し、再採点してからimplementorを起動してください。",
608
+ "zh": "[HOOK:design-gate] 任务 {task_id} 的设计评分 {score}/100 < 90。请先通过实际运行验证设计前提并重新评分,再派发 implementor。",
609
+ "es": "[HOOK:design-gate] Puntuación de diseño {score}/100 < 90 para la tarea {task_id}. Verifica las premisas del diseño ejecutándolas y vuelve a puntuar antes de lanzar el implementor.",
596
610
  },
597
611
  "gate.no_design_verify": {
598
612
  "en": "[HOOK:design-gate] No design verification found for task {task_id} (tier={tier}). Complete design phase scoring (>= 90) before spawning implementor.",
@@ -602,11 +616,11 @@ STRINGS = {
602
616
  "es": "[HOOK:design-gate] No se encontró verificación de diseño para la tarea {task_id} (tier={tier}). Completa la puntuación de diseño (>= 90) antes de lanzar el implementor.",
603
617
  },
604
618
  "gate.w5_high_risk": {
605
- "en": "[risk-gate] {count} HIGH-risk file(s) involved (e.g. {file}) — consulting reviewer first is recommended.",
606
- "ko": "[risk-gate] HIGH risk 파일 {count}개 포함(예: {file}) — reviewer 선행을 권장합니다.",
607
- "ja": "[risk-gate] HIGHリスクのファイルが{count}件含まれます(例: {file})— reviewerの事前相談を推奨します。",
608
- "zh": "[risk-gate] 包含 {count} 个高风险文件(如 {file})— 建议先咨询 reviewer。",
609
- "es": "[risk-gate] {count} archivo(s) de alto riesgo (p. ej. {file}) — se recomienda consultar primero al reviewer.",
619
+ "en": "[risk-gate] {count} HIGH-risk file(s) involved (e.g. {file}) — run the code-review skill after the change.",
620
+ "ko": "[risk-gate] HIGH risk 파일 {count}개 포함(예: {file}) — 변경 후 code-review 스킬 실행을 권장합니다.",
621
+ "ja": "[risk-gate] HIGHリスクのファイルが{count}件含まれます(例: {file})— 変更後にcode-reviewスキルの実行を推奨します。",
622
+ "zh": "[risk-gate] 包含 {count} 个高风险文件(如 {file})— 建议变更后运行 code-review 技能。",
623
+ "es": "[risk-gate] {count} archivo(s) de alto riesgo (p. ej. {file}) — se recomienda ejecutar la skill code-review después del cambio.",
610
624
  },
611
625
  "gate.w6_full_tier": {
612
626
  "en": "[tier-gate] full-tier task with planName=none — planner-first is recommended (6+ file scope is safer with wave decomposition).",
@@ -760,4 +774,12 @@ STRINGS = {
760
774
  "zh": "\n[PENDING REGISTERED] {count} 个延迟项已记录到 ~/.routinecode/knowledge/pending-issues.jsonl。下次会话启动时提醒。如可立即处理,请现在处理。",
761
775
  "es": "\n[PENDING REGISTERED] elementos diferidos ({count}) registrados en ~/.routinecode/knowledge/pending-issues.jsonl. Se mostrarán al inicio de la próxima sesión. Si se pueden resolver ahora, manéjalos de inmediato.",
762
776
  },
777
+ # ── 지식 계정 격리 안내 (docs/지식체계/36 §16.2) — 팀 계정 세션 시작 1회 ──
778
+ "knowledge.team_shared_notice": {
779
+ "en": "Work knowledge from this account is shared with the {team} team",
780
+ "ko": "이 계정의 작업 지식은 {team}팀에 공유됩니다",
781
+ "ja": "このアカウントの作業ナレッジは {team} チームに共有されます",
782
+ "zh": "此账户的工作知识将共享给 {team} 团队",
783
+ "es": "El conocimiento de trabajo de esta cuenta se comparte con el equipo {team}",
784
+ },
763
785
  }