claude-code-superkit 0.0.0-stage → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +374 -2
  3. package/bin/cli.js +153 -0
  4. package/bin/inject-tokens.js +224 -0
  5. package/bin/measure-tokens.js +17 -0
  6. package/bin/superkit-counts-verify.sh +30 -0
  7. package/lib/codex.js +246 -0
  8. package/lib/docs-scaffold.js +147 -0
  9. package/lib/installer.js +499 -0
  10. package/lib/prompts.js +51 -0
  11. package/lib/settings-builder.js +51 -0
  12. package/lib/superpowers.js +99 -0
  13. package/lib/utils.js +117 -0
  14. package/lib/validator.js +84 -0
  15. package/package.json +49 -4
  16. package/packages/codex/AGENTS.md +396 -0
  17. package/packages/codex/INSTALL.md +342 -0
  18. package/packages/codex/config.toml +22 -0
  19. package/packages/codex/hooks/superkit.mjs +203 -0
  20. package/packages/codex/hooks.json +30 -0
  21. package/packages/codex/legacy-baseline.json +88 -0
  22. package/packages/codex/native-skills.txt +65 -0
  23. package/packages/codex/rules/default.rules +565 -0
  24. package/packages/codex/skills/ai-slop-cleaner/SKILL.md +44 -0
  25. package/packages/codex/skills/api-contract-sync/SKILL.md +96 -0
  26. package/packages/codex/skills/architect/SKILL.md +49 -0
  27. package/packages/codex/skills/audit-backend/SKILL.md +80 -0
  28. package/packages/codex/skills/audit-frontend/SKILL.md +82 -0
  29. package/packages/codex/skills/audit-infra/SKILL.md +87 -0
  30. package/packages/codex/skills/audit-orchestrator/SKILL.md +114 -0
  31. package/packages/codex/skills/behavioral-nudge-engine/SKILL.md +110 -0
  32. package/packages/codex/skills/benchmark/SKILL.md +49 -0
  33. package/packages/codex/skills/bot-reviewer/SKILL.md +94 -0
  34. package/packages/codex/skills/code-reviewer/SKILL.md +67 -0
  35. package/packages/codex/skills/codebase-onboarding-engineer/SKILL.md +46 -0
  36. package/packages/codex/skills/comment-rot-analyzer/SKILL.md +75 -0
  37. package/packages/codex/skills/commit-helper/SKILL.md +101 -0
  38. package/packages/codex/skills/critic/SKILL.md +56 -0
  39. package/packages/codex/skills/database-reviewer/SKILL.md +79 -0
  40. package/packages/codex/skills/debug-observer/SKILL.md +107 -0
  41. package/packages/codex/skills/dependency-checker/SKILL.md +69 -0
  42. package/packages/codex/skills/design-system-reviewer/SKILL.md +121 -0
  43. package/packages/codex/skills/dev-orchestrator/SKILL.md +304 -0
  44. package/packages/codex/skills/docs-reviewer/SKILL.md +86 -0
  45. package/packages/codex/skills/drizzle-orm-expert/SKILL.md +246 -0
  46. package/packages/codex/skills/e2e-test-generator/SKILL.md +95 -0
  47. package/packages/codex/skills/evaluator/SKILL.md +63 -0
  48. package/packages/codex/skills/frontend-perf-reviewer/SKILL.md +95 -0
  49. package/packages/codex/skills/frontend-ui-color-reviewer/SKILL.md +68 -0
  50. package/packages/codex/skills/frontend-ui-design-critic/SKILL.md +99 -0
  51. package/packages/codex/skills/frontend-ui-interaction-reviewer/SKILL.md +102 -0
  52. package/packages/codex/skills/frontend-ui-motion-reviewer/SKILL.md +85 -0
  53. package/packages/codex/skills/frontend-ui-reviewer/SKILL.md +81 -0
  54. package/packages/codex/skills/frontend-ui-typography-reviewer/SKILL.md +62 -0
  55. package/packages/codex/skills/gltf-debugging/SKILL.md +128 -0
  56. package/packages/codex/skills/go-benchmark/SKILL.md +217 -0
  57. package/packages/codex/skills/go-concurrency-reviewer/SKILL.md +113 -0
  58. package/packages/codex/skills/go-error-reviewer/SKILL.md +107 -0
  59. package/packages/codex/skills/go-grpc-patterns/SKILL.md +285 -0
  60. package/packages/codex/skills/go-modernizer/SKILL.md +111 -0
  61. package/packages/codex/skills/go-observability-reviewer/SKILL.md +121 -0
  62. package/packages/codex/skills/go-performance-reviewer/SKILL.md +112 -0
  63. package/packages/codex/skills/go-reviewer/SKILL.md +109 -0
  64. package/packages/codex/skills/go-samber-do/SKILL.md +158 -0
  65. package/packages/codex/skills/go-samber-lo/SKILL.md +178 -0
  66. package/packages/codex/skills/go-samber-oops/SKILL.md +174 -0
  67. package/packages/codex/skills/goal-verifier/SKILL.md +53 -0
  68. package/packages/codex/skills/health-checker/SKILL.md +109 -0
  69. package/packages/codex/skills/html-to-3d-texture/SKILL.md +153 -0
  70. package/packages/codex/skills/impeccable-craft/SKILL.md +101 -0
  71. package/packages/codex/skills/lint-runner/SKILL.md +85 -0
  72. package/packages/codex/skills/migrate/SKILL.md +60 -0
  73. package/packages/codex/skills/migration-reviewer/SKILL.md +88 -0
  74. package/packages/codex/skills/minimal-change-engineer/SKILL.md +44 -0
  75. package/packages/codex/skills/new-migration/SKILL.md +59 -0
  76. package/packages/codex/skills/nextjs-supabase-auth/SKILL.md +227 -0
  77. package/packages/codex/skills/output-enforcement/SKILL.md +71 -0
  78. package/packages/codex/skills/plan-checker/SKILL.md +53 -0
  79. package/packages/codex/skills/postgresql-optimization/SKILL.md +159 -0
  80. package/packages/codex/skills/pre-deploy-validator/SKILL.md +111 -0
  81. package/packages/codex/skills/presentation-reviewer/SKILL.md +88 -0
  82. package/packages/codex/skills/product-3d-lighting/SKILL.md +137 -0
  83. package/packages/codex/skills/project-architecture/SKILL.md +52 -0
  84. package/packages/codex/skills/py-reviewer/SKILL.md +100 -0
  85. package/packages/codex/skills/r3f-scene-reviewer/SKILL.md +88 -0
  86. package/packages/codex/skills/r3f-scroll-driven-3d/SKILL.md +162 -0
  87. package/packages/codex/skills/reality-checker/SKILL.md +61 -0
  88. package/packages/codex/skills/redis-patterns/SKILL.md +260 -0
  89. package/packages/codex/skills/review-orchestrator/SKILL.md +151 -0
  90. package/packages/codex/skills/rs-reviewer/SKILL.md +98 -0
  91. package/packages/codex/skills/ru-text/SKILL.md +132 -0
  92. package/packages/codex/skills/scaffold-endpoint/SKILL.md +44 -0
  93. package/packages/codex/skills/security-scanner/SKILL.md +94 -0
  94. package/packages/codex/skills/silent-failure-hunter/SKILL.md +176 -0
  95. package/packages/codex/skills/telegram-bot-builder/SKILL.md +120 -0
  96. package/packages/codex/skills/test-generator/SKILL.md +79 -0
  97. package/packages/codex/skills/test-runner/SKILL.md +101 -0
  98. package/packages/codex/skills/threejs-color-management/SKILL.md +97 -0
  99. package/packages/codex/skills/tree-generator/SKILL.md +63 -0
  100. package/packages/codex/skills/ts-reviewer/SKILL.md +90 -0
  101. package/packages/codex/skills/ui-design-reviewer/SKILL.md +89 -0
  102. package/packages/codex/skills/ui-reviewer/SKILL.md +103 -0
  103. package/packages/codex/skills/visual-reviewer/SKILL.md +85 -0
  104. package/packages/codex/skills/writing-agents/SKILL.md +165 -0
  105. package/packages/codex/skills/writing-commands/SKILL.md +173 -0
  106. package/packages/core/CLAUDE.md +118 -0
  107. package/packages/core/INTERNAL-FILES +16 -0
  108. package/packages/core/agents/ai-slop-cleaner.md +187 -0
  109. package/packages/core/agents/api-contract-sync.md +127 -0
  110. package/packages/core/agents/architect.md +205 -0
  111. package/packages/core/agents/audit-backend.md +137 -0
  112. package/packages/core/agents/audit-frontend.md +129 -0
  113. package/packages/core/agents/audit-infra.md +182 -0
  114. package/packages/core/agents/behavioral-nudge-engine.md +170 -0
  115. package/packages/core/agents/code-reviewer.md +195 -0
  116. package/packages/core/agents/codebase-onboarding-engineer.md +172 -0
  117. package/packages/core/agents/comment-rot-analyzer.md +115 -0
  118. package/packages/core/agents/critic.md +172 -0
  119. package/packages/core/agents/database-reviewer.md +201 -0
  120. package/packages/core/agents/debug-observer.md +261 -0
  121. package/packages/core/agents/dependency-checker.md +199 -0
  122. package/packages/core/agents/docs-reviewer.md +206 -0
  123. package/packages/core/agents/e2e-test-generator.md +261 -0
  124. package/packages/core/agents/evaluator.md +141 -0
  125. package/packages/core/agents/goal-verifier.md +130 -0
  126. package/packages/core/agents/health-checker.md +194 -0
  127. package/packages/core/agents/migration-reviewer.md +161 -0
  128. package/packages/core/agents/minimal-change-engineer.md +219 -0
  129. package/packages/core/agents/plan-checker.md +139 -0
  130. package/packages/core/agents/pre-deploy-validator.md +189 -0
  131. package/packages/core/agents/reality-checker.md +175 -0
  132. package/packages/core/agents/scaffold-endpoint.md +162 -0
  133. package/packages/core/agents/security-scanner.md +236 -0
  134. package/packages/core/agents/silent-failure-hunter.md +276 -0
  135. package/packages/core/agents/test-generator.md +146 -0
  136. package/packages/core/agents/tree-generator.md +141 -0
  137. package/packages/core/agents/ui-reviewer.md +172 -0
  138. package/packages/core/agents/visual-reviewer.md +211 -0
  139. package/packages/core/commands/audit.md +166 -0
  140. package/packages/core/commands/benchmark.md +130 -0
  141. package/packages/core/commands/commit.md +148 -0
  142. package/packages/core/commands/dev.md +302 -0
  143. package/packages/core/commands/docs-init.md +75 -0
  144. package/packages/core/commands/lint.md +137 -0
  145. package/packages/core/commands/migrate.md +146 -0
  146. package/packages/core/commands/new-migration.md +182 -0
  147. package/packages/core/commands/pair.md +209 -0
  148. package/packages/core/commands/review.md +195 -0
  149. package/packages/core/commands/security-scan.md +142 -0
  150. package/packages/core/commands/superkit-evolve.md +231 -0
  151. package/packages/core/commands/superkit-init.md +274 -0
  152. package/packages/core/commands/test.md +108 -0
  153. package/packages/core/commands/workflow.md +150 -0
  154. package/packages/core/docs/guide/01-getting-started.md +41 -0
  155. package/packages/core/docs-templates/README.md +33 -0
  156. package/packages/core/docs-templates/adr-template.md +62 -0
  157. package/packages/core/docs-templates/architecture/api-contracts.md +26 -0
  158. package/packages/core/docs-templates/architecture/api-reference.md +48 -0
  159. package/packages/core/docs-templates/architecture/auth-and-sessions.md +38 -0
  160. package/packages/core/docs-templates/architecture/backend-layers.md +42 -0
  161. package/packages/core/docs-templates/architecture/data-flow.md +26 -0
  162. package/packages/core/docs-templates/architecture/database-schema.md +51 -0
  163. package/packages/core/docs-templates/architecture/deployment.md +41 -0
  164. package/packages/core/docs-templates/architecture/frontend-state.md +46 -0
  165. package/packages/core/helpers/statusline.cjs +370 -0
  166. package/packages/core/hooks/CHAIN-SEMANTICS.md +84 -0
  167. package/packages/core/hooks/audit-settings-source.sh +98 -0
  168. package/packages/core/hooks/audit-trail.sh +120 -0
  169. package/packages/core/hooks/block-dangerous-git.sh +189 -0
  170. package/packages/core/hooks/bundle-import-check.sh +64 -0
  171. package/packages/core/hooks/compact-state-inject.sh +84 -0
  172. package/packages/core/hooks/config-protection.sh +68 -0
  173. package/packages/core/hooks/console-log-warning.sh +28 -0
  174. package/packages/core/hooks/context-monitor.sh +35 -0
  175. package/packages/core/hooks/dev-edit-counter.sh +59 -0
  176. package/packages/core/hooks/dev-marker-set.sh +55 -0
  177. package/packages/core/hooks/dev-required-on-commit.sh +426 -0
  178. package/packages/core/hooks/doc-check-on-commit.sh +396 -0
  179. package/packages/core/hooks/edit-streak-check.sh +63 -0
  180. package/packages/core/hooks/evolve-check.sh +78 -0
  181. package/packages/core/hooks/gateguard-pre-edit.sh +154 -0
  182. package/packages/core/hooks/gateguard-record-facts.sh +37 -0
  183. package/packages/core/hooks/intake-classifier.py +449 -0
  184. package/packages/core/hooks/lib/profile.sh +141 -0
  185. package/packages/core/hooks/loop-guard.sh +75 -0
  186. package/packages/core/hooks/migration-safety.sh +56 -0
  187. package/packages/core/hooks/plan-completion-gate.sh +61 -0
  188. package/packages/core/hooks/pre-compact-save.sh +89 -0
  189. package/packages/core/hooks/security-patterns.sh +119 -0
  190. package/packages/core/hooks/session-context-restore.sh +76 -0
  191. package/packages/core/hooks/subagent-stop-validate.sh +73 -0
  192. package/packages/core/hooks/superkit-counts-verify.sh +346 -0
  193. package/packages/core/hooks/superkit-update.sh +367 -0
  194. package/packages/core/hooks/tests/README.md +42 -0
  195. package/packages/core/hooks/tests/audit-trail-chain_test.sh +62 -0
  196. package/packages/core/hooks/tests/block-dangerous-git_test.sh +144 -0
  197. package/packages/core/hooks/tests/chain-semantics/h1.sh +11 -0
  198. package/packages/core/hooks/tests/chain-semantics/h2.sh +9 -0
  199. package/packages/core/hooks/tests/chain-semantics/h3.sh +11 -0
  200. package/packages/core/hooks/tests/chain-semantics/run-experiment.sh +65 -0
  201. package/packages/core/hooks/tests/chain-semantics/settings-experiment.json +15 -0
  202. package/packages/core/hooks/tests/counts-verify_test.sh +118 -0
  203. package/packages/core/hooks/tests/dev-required-on-commit_test.sh +207 -0
  204. package/packages/core/hooks/tests/dev-required-wip-on-main_test.sh +20 -0
  205. package/packages/core/hooks/tests/doc-check-on-commit_test.sh +122 -0
  206. package/packages/core/hooks/tests/edit-streak-check_test.sh +106 -0
  207. package/packages/core/hooks/tests/internal-manifest_test.sh +130 -0
  208. package/packages/core/hooks/tests/json-path_test.sh +108 -0
  209. package/packages/core/hooks/tests/mirror-invariants_test.sh +139 -0
  210. package/packages/core/hooks/tests/nudge-throttle_test.sh +95 -0
  211. package/packages/core/hooks/tests/profile-helper_test.sh +21 -0
  212. package/packages/core/hooks/tests/run-all.sh +47 -0
  213. package/packages/core/hooks/tests/session-key-helper_test.sh +17 -0
  214. package/packages/core/hooks/tests/superkit-update_test.sh +311 -0
  215. package/packages/core/hooks/tests/warn-visibility_test.sh +59 -0
  216. package/packages/core/hooks/user-intent-detect.sh +44 -0
  217. package/packages/core/hooks/verify-hooks.sh +69 -0
  218. package/packages/core/rules/auto-commands.md +124 -0
  219. package/packages/core/rules/coding-style.md +68 -0
  220. package/packages/core/rules/dev-workflow.md +77 -0
  221. package/packages/core/rules/documentation.md +106 -0
  222. package/packages/core/rules/frontend-aesthetics.md +53 -0
  223. package/packages/core/rules/git-workflow.md +14 -0
  224. package/packages/core/rules/security.md +29 -0
  225. package/packages/core/rules/superkit-integrity.md +114 -0
  226. package/packages/core/settings.json +229 -0
  227. package/packages/core/skills/drizzle-orm-expert/SKILL.md +260 -0
  228. package/packages/core/skills/nextjs-supabase-auth/SKILL.md +259 -0
  229. package/packages/core/skills/postgresql-optimization/SKILL.md +150 -0
  230. package/packages/core/skills/project-architecture/SKILL.md +31 -0
  231. package/packages/core/skills/project-scanner/SKILL.md +132 -0
  232. package/packages/core/skills/redis-patterns/SKILL.md +261 -0
  233. package/packages/core/skills/ru-text/SKILL.md +156 -0
  234. package/packages/core/skills/telegram-bot-builder/SKILL.md +145 -0
  235. package/packages/core/skills/writing-agents/SKILL.md +220 -0
  236. package/packages/core/skills/writing-commands/SKILL.md +176 -0
  237. package/packages/core/skills/writing-hooks/SKILL.md +335 -0
  238. package/packages/extras/bot-reviewer.md +279 -0
  239. package/packages/extras/design-system-reviewer.md +234 -0
  240. package/packages/extras/red-blue-auditor/README.md +117 -0
  241. package/packages/extras/red-blue-auditor/agent.md +128 -0
  242. package/packages/extras/red-blue-auditor/patterns/agent-config.txt +4 -0
  243. package/packages/extras/red-blue-auditor/patterns/hook-injection.txt +8 -0
  244. package/packages/extras/red-blue-auditor/patterns/mcp-risk.txt +5 -0
  245. package/packages/extras/red-blue-auditor/patterns/permission-abuse.txt +6 -0
  246. package/packages/extras/red-blue-auditor/patterns/secrets.txt +17 -0
  247. package/packages/extras/red-blue-auditor/scan.sh +88 -0
  248. package/packages/extras/skillsmp-search/SKILL.md +134 -0
  249. package/packages/frontend-3d/README.md +62 -0
  250. package/packages/frontend-3d/agents/frontend-perf-reviewer.md +164 -0
  251. package/packages/frontend-3d/agents/presentation-reviewer.md +146 -0
  252. package/packages/frontend-3d/agents/r3f-scene-reviewer.md +128 -0
  253. package/packages/frontend-3d/agents/ui-design-reviewer.md +169 -0
  254. package/packages/frontend-3d/commands/capture-screen.md +166 -0
  255. package/packages/frontend-3d/hooks/bundle-size-warn.sh +93 -0
  256. package/packages/frontend-3d/hooks/gsap-pattern-check.sh +74 -0
  257. package/packages/frontend-3d/hooks/r3f-color-check.sh +76 -0
  258. package/packages/frontend-3d/hooks/tailwind-version-guard.sh +98 -0
  259. package/packages/frontend-3d/rules/frontend-aesthetics-3d.md +81 -0
  260. package/packages/frontend-3d/rules/gsap-conventions.md +129 -0
  261. package/packages/frontend-3d/rules/threejs-conventions.md +116 -0
  262. package/packages/frontend-3d/skills/gltf-debugging/SKILL.md +145 -0
  263. package/packages/frontend-3d/skills/html-to-3d-texture/SKILL.md +183 -0
  264. package/packages/frontend-3d/skills/output-enforcement/SKILL.md +79 -0
  265. package/packages/frontend-3d/skills/product-3d-lighting/SKILL.md +166 -0
  266. package/packages/frontend-3d/skills/r3f-scroll-driven-3d/SKILL.md +209 -0
  267. package/packages/frontend-3d/skills/threejs-color-management/SKILL.md +111 -0
  268. package/packages/frontend-ui/NOTICE.md +99 -0
  269. package/packages/frontend-ui/README.md +59 -0
  270. package/packages/frontend-ui/agents/ui-color-reviewer.md +174 -0
  271. package/packages/frontend-ui/agents/ui-design-critic.md +198 -0
  272. package/packages/frontend-ui/agents/ui-interaction-reviewer.md +259 -0
  273. package/packages/frontend-ui/agents/ui-motion-reviewer.md +266 -0
  274. package/packages/frontend-ui/agents/ui-reviewer.md +251 -0
  275. package/packages/frontend-ui/agents/ui-typography-reviewer.md +222 -0
  276. package/packages/frontend-ui/hooks/tests/ui-animation-easing-check_test.sh +78 -0
  277. package/packages/frontend-ui/hooks/tests/ui-banned-fonts-check_test.sh +77 -0
  278. package/packages/frontend-ui/hooks/tests/ui-color-check_test.sh +75 -0
  279. package/packages/frontend-ui/hooks/ui-animation-easing-check.sh +86 -0
  280. package/packages/frontend-ui/hooks/ui-banned-fonts-check.sh +90 -0
  281. package/packages/frontend-ui/hooks/ui-color-check.sh +102 -0
  282. package/packages/frontend-ui/rules/color-and-contrast.md +230 -0
  283. package/packages/frontend-ui/rules/frontend-design-aesthetics.md +124 -0
  284. package/packages/frontend-ui/rules/interaction-polish.md +335 -0
  285. package/packages/frontend-ui/rules/motion-and-animation.md +283 -0
  286. package/packages/frontend-ui/rules/spatial-and-layout.md +212 -0
  287. package/packages/frontend-ui/rules/typography-guidelines.md +185 -0
  288. package/packages/frontend-ui/rules/ui-anti-patterns.md +309 -0
  289. package/packages/frontend-ui/settings.json +24 -0
  290. package/packages/frontend-ui/skills/impeccable-craft/SKILL.md +187 -0
  291. package/packages/gan/README.md +232 -0
  292. package/packages/gan/agents/gan-evaluator.md +214 -0
  293. package/packages/gan/agents/gan-generator.md +171 -0
  294. package/packages/gan/agents/gan-planner.md +206 -0
  295. package/packages/gan/rubrics/functionality.md +66 -0
  296. package/packages/gan/rubrics/ui-quality.md +77 -0
  297. package/packages/gan/skills/gan-evaluator/SKILL.md +91 -0
  298. package/packages/gan/skills/gan-generator/SKILL.md +72 -0
  299. package/packages/gan/skills/gan-planner/SKILL.md +93 -0
  300. package/packages/stack-agents/go/go-concurrency-reviewer.md +210 -0
  301. package/packages/stack-agents/go/go-error-reviewer.md +187 -0
  302. package/packages/stack-agents/go/go-modernizer.md +160 -0
  303. package/packages/stack-agents/go/go-observability-reviewer.md +185 -0
  304. package/packages/stack-agents/go/go-performance-reviewer.md +160 -0
  305. package/packages/stack-agents/go/go-reviewer.md +277 -0
  306. package/packages/stack-agents/go/references/benchmark-methodology.md +280 -0
  307. package/packages/stack-agents/go/references/channel-patterns.md +384 -0
  308. package/packages/stack-agents/go/references/cli-cobra-viper.md +190 -0
  309. package/packages/stack-agents/go/references/code-style.md +262 -0
  310. package/packages/stack-agents/go/references/context-propagation.md +317 -0
  311. package/packages/stack-agents/go/references/data-structures.md +315 -0
  312. package/packages/stack-agents/go/references/database-patterns.md +334 -0
  313. package/packages/stack-agents/go/references/design-patterns.md +411 -0
  314. package/packages/stack-agents/go/references/di-frameworks.md +146 -0
  315. package/packages/stack-agents/go/references/error-creation.md +251 -0
  316. package/packages/stack-agents/go/references/error-inspection.md +348 -0
  317. package/packages/stack-agents/go/references/error-wrapping.md +230 -0
  318. package/packages/stack-agents/go/references/gopls-driving.md +62 -0
  319. package/packages/stack-agents/go/references/goroutine-lifecycle.md +351 -0
  320. package/packages/stack-agents/go/references/graphql-patterns.md +221 -0
  321. package/packages/stack-agents/go/references/grpc-patterns.md +373 -0
  322. package/packages/stack-agents/go/references/modernize-guide.md +522 -0
  323. package/packages/stack-agents/go/references/module-management.md +191 -0
  324. package/packages/stack-agents/go/references/naming-conventions.md +176 -0
  325. package/packages/stack-agents/go/references/observability-pipeline.md +352 -0
  326. package/packages/stack-agents/go/references/performance-profiling.md +250 -0
  327. package/packages/stack-agents/go/references/refactoring-mechanics.md +127 -0
  328. package/packages/stack-agents/go/references/rest-openapi-patterns.md +160 -0
  329. package/packages/stack-agents/go/references/samber-do.md +201 -0
  330. package/packages/stack-agents/go/references/samber-libraries.md +363 -0
  331. package/packages/stack-agents/go/references/samber-lo.md +260 -0
  332. package/packages/stack-agents/go/references/samber-oops.md +200 -0
  333. package/packages/stack-agents/go/references/security-checklist.md +441 -0
  334. package/packages/stack-agents/go/references/standard-stdlib-now.md +181 -0
  335. package/packages/stack-agents/go/references/stay-updated.md +147 -0
  336. package/packages/stack-agents/go/references/structs-interfaces.md +312 -0
  337. package/packages/stack-agents/go/references/sync-primitives.md +395 -0
  338. package/packages/stack-agents/go/references/testing-patterns.md +483 -0
  339. package/packages/stack-agents/go/references/troubleshooting.md +98 -0
  340. package/packages/stack-agents/python/py-reviewer.md +194 -0
  341. package/packages/stack-agents/rust/rs-reviewer.md +188 -0
  342. package/packages/stack-agents/typescript/ts-reviewer.md +135 -0
  343. package/packages/stack-hooks/go/go-context-check-on-edit.sh +56 -0
  344. package/packages/stack-hooks/go/go-error-check-on-edit.sh +54 -0
  345. package/packages/stack-hooks/go/go-format-on-edit.sh +32 -0
  346. package/packages/stack-hooks/go/go-safety-check-on-edit.sh +54 -0
  347. package/packages/stack-hooks/go/go-vet-on-edit.sh +61 -0
  348. package/packages/stack-hooks/go/golangci-lint-on-edit.sh +54 -0
  349. package/packages/stack-hooks/python/ruff-on-edit.sh +67 -0
  350. package/packages/stack-hooks/rust/cargo-check-on-edit.sh +64 -0
  351. package/packages/stack-hooks/typescript/typecheck-on-edit.sh +76 -0
  352. package/packages/stack-rules/go/go-conventions.md +44 -0
  353. package/packages/stack-rules/go/go-safety.md +35 -0
@@ -0,0 +1,26 @@
1
+ # External API Contracts
2
+
3
+ > Update when adding or changing external API integrations.
4
+
5
+ ## Integrations
6
+
7
+ | Service | Purpose | Auth | Docs |
8
+ |---------|---------|------|------|
9
+ | TODO | TODO | TODO | TODO |
10
+
11
+ ## Request/Response Patterns
12
+
13
+ <!-- For each external API, document: endpoint, auth, rate limits, error handling -->
14
+
15
+ ### TODO: Service Name
16
+
17
+ - **Base URL:** TODO
18
+ - **Auth:** TODO (API key, OAuth, etc.)
19
+ - **Rate Limits:** TODO
20
+ - **Error Handling:** TODO (retry? circuit breaker? fallback?)
21
+
22
+ ## Webhook Handling
23
+
24
+ <!-- If you receive webhooks from external services -->
25
+
26
+ TODO: Describe webhook endpoints and validation.
@@ -0,0 +1,48 @@
1
+ # API Reference
2
+
3
+ > Maintain this file when handlers or routes change. This is the source of truth for all endpoints.
4
+
5
+ ## Authentication
6
+
7
+ <!-- Auth mechanism: JWT, API key, OAuth, session cookies?
8
+ Where is the token sent? (Authorization header, cookie, query param?) -->
9
+
10
+ TODO: Describe auth mechanism.
11
+
12
+ ## Base URL
13
+
14
+ TODO: e.g., `http://localhost:8080/api/v1`
15
+
16
+ ## Endpoints
17
+
18
+ ### Public (no auth required)
19
+
20
+ | Method | Path | Description |
21
+ |--------|------|-------------|
22
+ | TODO | TODO | TODO |
23
+
24
+ ### Protected (auth required)
25
+
26
+ | Method | Path | Auth | Description |
27
+ |--------|------|------|-------------|
28
+ | TODO | TODO | TODO | TODO |
29
+
30
+ ### Admin
31
+
32
+ | Method | Path | Auth | Description |
33
+ |--------|------|------|-------------|
34
+ | TODO | TODO | TODO | TODO |
35
+
36
+ ## Error Response Format
37
+
38
+ <!-- Standard error shape returned by all endpoints -->
39
+
40
+ ```json
41
+ TODO: { "error": { "code": "...", "message": "..." } }
42
+ ```
43
+
44
+ ## Pagination
45
+
46
+ <!-- How are list endpoints paginated? Cursor-based? Offset? -->
47
+
48
+ TODO: Describe pagination pattern.
@@ -0,0 +1,38 @@
1
+ # Authentication & Sessions
2
+
3
+ > Update when auth flow, token format, or session management changes.
4
+
5
+ ## Auth Flow
6
+
7
+ <!-- Describe the authentication flow step by step -->
8
+
9
+ 1. TODO: Client sends credentials (login form, OAuth, Telegram initData, etc.)
10
+ 2. TODO: Server validates → issues token (JWT, session cookie, API key)
11
+ 3. TODO: Client stores token (localStorage, cookie, memory)
12
+ 4. TODO: Client sends token with requests (Authorization header, cookie)
13
+ 5. TODO: Server validates token on each request (middleware)
14
+
15
+ ## Token Format
16
+
17
+ <!-- JWT claims, expiration, refresh mechanism -->
18
+
19
+ TODO: Describe token format and lifecycle.
20
+
21
+ ## Session Management
22
+
23
+ <!-- How are sessions stored? Redis? DB? Memory?
24
+ Single-device enforcement? Session invalidation? -->
25
+
26
+ TODO: Describe session storage and management.
27
+
28
+ ## Refresh Flow
29
+
30
+ <!-- How are expired tokens refreshed? -->
31
+
32
+ TODO: Describe refresh mechanism.
33
+
34
+ ## Permissions / RBAC
35
+
36
+ <!-- Role-based access control, if any -->
37
+
38
+ TODO: Describe roles and permissions.
@@ -0,0 +1,42 @@
1
+ # Backend Architecture — Layers
2
+
3
+ > Fill in your backend's layered architecture. Update when adding new layers or changing DI patterns.
4
+
5
+ ## Layers
6
+
7
+ <!-- Describe your layer hierarchy, e.g.:
8
+ Transport (HTTP handlers) → Services (business logic) → Repositories (data access)
9
+ State which layers can import which. -->
10
+
11
+ TODO: Define your layers and their dependency rules.
12
+
13
+ ## Dependency Injection
14
+
15
+ <!-- How are dependencies wired? Constructor injection? DI container? Service locator?
16
+ Show a typical constructor signature. -->
17
+
18
+ TODO: Describe your DI pattern with example.
19
+
20
+ ## Error Handling
21
+
22
+ <!-- How do errors propagate across layers?
23
+ Domain errors in services? Error wrapping with context? HTTP status mapping in handlers? -->
24
+
25
+ TODO: Define error propagation strategy.
26
+
27
+ ## Middleware
28
+
29
+ <!-- List middleware applied to routes: auth, CORS, logging, rate limiting, etc.
30
+ Which route groups get which middleware? -->
31
+
32
+ TODO: List middleware stack.
33
+
34
+ ## Adding a New Endpoint (Checklist)
35
+
36
+ <!-- Step-by-step for adding a new API endpoint in this architecture. -->
37
+
38
+ 1. TODO: Create handler in transport layer
39
+ 2. TODO: Create/update service with business logic
40
+ 3. TODO: Create/update repository if data access needed
41
+ 4. TODO: Register route with appropriate middleware
42
+ 5. TODO: Add tests
@@ -0,0 +1,26 @@
1
+ # Key Data Flows
2
+
3
+ > Update when major features change their data flow through the system.
4
+
5
+ ## Flow Template
6
+
7
+ For each major feature, document the data flow:
8
+
9
+ ```
10
+ [Trigger] → [Step 1] → [Step 2] → ... → [Result]
11
+ ```
12
+
13
+ ## TODO: Feature 1 Flow
14
+
15
+ ```
16
+ TODO: User action → Handler → Service → Repo → DB → Response
17
+ ```
18
+
19
+ **Key decisions:**
20
+ - TODO: Why this flow? What alternatives were considered?
21
+
22
+ ## TODO: Feature 2 Flow
23
+
24
+ ```
25
+ TODO: Describe another key data flow
26
+ ```
@@ -0,0 +1,51 @@
1
+ # Database Schema
2
+
3
+ > Update when migrations add/change tables, columns, indexes, or constraints.
4
+
5
+ ## Database
6
+
7
+ - **Engine:** TODO (PostgreSQL 16, MySQL 8, SQLite, etc.)
8
+ - **Driver:** TODO (pgx, prisma, sqlalchemy, diesel, etc.)
9
+ - **ORM:** TODO (none/raw SQL, Prisma, GORM, SQLAlchemy, Diesel)
10
+
11
+ ## Tables
12
+
13
+ <!-- List key tables with their purpose. Don't duplicate the migration files —
14
+ focus on relationships, constraints, and design decisions. -->
15
+
16
+ | Table | Purpose | Key Columns |
17
+ |-------|---------|-------------|
18
+ | TODO | TODO | TODO |
19
+
20
+ ## Relationships
21
+
22
+ <!-- Describe key FK relationships and ON DELETE behavior -->
23
+
24
+ TODO: e.g., `orders.user_id → users.id ON DELETE CASCADE`
25
+
26
+ ## Indexes
27
+
28
+ <!-- List important indexes and why they exist -->
29
+
30
+ | Index | Table | Columns | Purpose |
31
+ |-------|-------|---------|---------|
32
+ | TODO | TODO | TODO | TODO |
33
+
34
+ ## Migrations
35
+
36
+ - **Format:** TODO (e.g., `000NNN_description.up.sql` / `.down.sql`)
37
+ - **Tool:** TODO (golang-migrate, dbmate, alembic, prisma, knex)
38
+ - **Directory:** TODO (e.g., `backend/migrations/`)
39
+ - **Current range:** TODO (e.g., 000001..000048)
40
+
41
+ ## Views
42
+
43
+ <!-- SQL views used for reporting, dashboards, aggregations -->
44
+
45
+ TODO: List views if any.
46
+
47
+ ## Conventions
48
+
49
+ - TODO: Timestamps use TIMESTAMPTZ (not TIMESTAMP)
50
+ - TODO: All tables have `created_at`, `updated_at`
51
+ - TODO: Soft delete via `deleted_at` column (or hard delete)
@@ -0,0 +1,41 @@
1
+ # Deployment
2
+
3
+ > Update when deploy process, environments, or infrastructure changes.
4
+
5
+ ## Environments
6
+
7
+ | Environment | URL | Purpose |
8
+ |------------|-----|---------|
9
+ | TODO: local | localhost | Development |
10
+ | TODO: staging | staging.example.com | Pre-production testing |
11
+ | TODO: production | example.com | Live |
12
+
13
+ ## Infrastructure
14
+
15
+ <!-- Docker, Kubernetes, VPS, serverless, PaaS? -->
16
+
17
+ TODO: Describe infrastructure.
18
+
19
+ ## Deploy Process
20
+
21
+ <!-- Step by step: how code goes from main branch to production -->
22
+
23
+ 1. TODO: Tests pass in CI
24
+ 2. TODO: Build artifacts
25
+ 3. TODO: Deploy to staging
26
+ 4. TODO: Smoke test
27
+ 5. TODO: Deploy to production
28
+
29
+ ## Environment Variables
30
+
31
+ <!-- Key env vars needed per service -->
32
+
33
+ | Variable | Service | Description |
34
+ |----------|---------|-------------|
35
+ | TODO | TODO | TODO |
36
+
37
+ ## Rollback
38
+
39
+ <!-- How to rollback a bad deploy -->
40
+
41
+ TODO: Describe rollback procedure.
@@ -0,0 +1,46 @@
1
+ # Frontend Architecture — State & Navigation
2
+
3
+ > Update when state management, routing, or data fetching patterns change.
4
+
5
+ ## Tech Stack
6
+
7
+ - **Framework:** TODO (React 19, Vue 3, Svelte 5, Next.js 15, etc.)
8
+ - **State Management:** TODO (Zustand, Redux, Pinia, TanStack Query, etc.)
9
+ - **Routing:** TODO (React Router, file-based, state-based, etc.)
10
+ - **Styling:** TODO (Tailwind, CSS Modules, styled-components, etc.)
11
+ - **Animations:** TODO (motion/react, GSAP, CSS transitions, etc.)
12
+
13
+ ## State Management
14
+
15
+ <!-- Server state vs client state separation.
16
+ Which library handles which? -->
17
+
18
+ TODO: Describe state management approach.
19
+
20
+ ## Data Fetching
21
+
22
+ <!-- How is server data fetched and cached?
23
+ Stale times, cache invalidation, persistence? -->
24
+
25
+ TODO: Describe data fetching patterns.
26
+
27
+ ## Navigation / Routing
28
+
29
+ <!-- How do users navigate between screens?
30
+ URL-based? State-based? How is browser back handled? -->
31
+
32
+ TODO: Describe routing approach.
33
+
34
+ ## Screen Map
35
+
36
+ <!-- List all screens/pages with their routes/states -->
37
+
38
+ | Screen | Route/State | Description |
39
+ |--------|------------|-------------|
40
+ | TODO | TODO | TODO |
41
+
42
+ ## Component Patterns
43
+
44
+ <!-- Shared component conventions: naming, file structure, props patterns -->
45
+
46
+ TODO: Describe component conventions.
@@ -0,0 +1,370 @@
1
+ #!/usr/bin/env node
2
+ // statusline.cjs — Claude Code status bar for superkit
3
+ // Shows: superkit version, git branch, model + effort (+ ⟁ULTRA badge),
4
+ // context bar, and real 5h/weekly rate-limit bars. Every segment fail-open.
5
+ // Pure Node.js, no external dependencies, 2s timeout on all execSync calls
6
+
7
+ 'use strict';
8
+
9
+ const { execSync } = require('child_process');
10
+ const { existsSync, readFileSync, readdirSync, openSync, fstatSync, readSync, closeSync } = require('fs');
11
+ const { join } = require('path');
12
+
13
+ // ── Read optional JSON payload from stdin (non-blocking, 50ms window) ─────────
14
+ // Claude Code 2.1.x may pass a richer status payload via stdin.
15
+ // Older CLIs pass nothing — we must never block or throw on empty/TTY stdin.
16
+ function readStdinPayload() {
17
+ try {
18
+ if (process.stdin.isTTY) return null; // interactive terminal — skip
19
+ const buf = [];
20
+ // Read synchronously with a hard limit: if no data in fd, readSync throws
21
+ const fd = process.stdin.fd;
22
+ const chunk = Buffer.alloc(4096);
23
+ let total = Buffer.alloc(0);
24
+ let n;
25
+ // eslint-disable-next-line no-constant-condition
26
+ while (true) {
27
+ try {
28
+ n = require('fs').readSync(fd, chunk, 0, chunk.length, null);
29
+ } catch { break; }
30
+ if (n === 0) break;
31
+ total = Buffer.concat([total, chunk.slice(0, n)]);
32
+ if (total.length > 65536) break; // guard against runaway
33
+ }
34
+ const text = total.toString('utf8').trim();
35
+ if (!text) return null;
36
+ return JSON.parse(text);
37
+ } catch { return null; }
38
+ }
39
+
40
+ const TIMEOUT = 2000;
41
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
42
+
43
+ function exec(cmd) {
44
+ try {
45
+ return execSync(cmd, { cwd: projectDir, timeout: TIMEOUT, encoding: 'utf8' }).trim();
46
+ } catch { return ''; }
47
+ }
48
+
49
+ function getProfile() {
50
+ return process.env.CLAUDE_HOOK_PROFILE || 'standard';
51
+ }
52
+
53
+ const STACK_SKIP_DIRS = new Set([
54
+ 'node_modules', 'dist', 'build', '.git', '.next', '.turbo',
55
+ 'vendor', 'target', 'bin', '__pycache__', '.venv', 'venv',
56
+ 'coverage', 'tmp', 'temp',
57
+ ]);
58
+
59
+ function detectStacksIn(dir) {
60
+ const found = [];
61
+ const markers = {
62
+ 'go.mod': 'Go',
63
+ 'Cargo.toml': 'Rust',
64
+ 'pyproject.toml': 'Py',
65
+ 'requirements.txt': 'Py',
66
+ };
67
+ for (const [file, label] of Object.entries(markers)) {
68
+ if (existsSync(join(dir, file))) found.push(label);
69
+ }
70
+ // TypeScript: need both package.json and tsconfig
71
+ if (existsSync(join(dir, 'package.json')) && existsSync(join(dir, 'tsconfig.json'))) {
72
+ found.push('TS');
73
+ } else if (existsSync(join(dir, 'package.json'))) {
74
+ found.push('JS');
75
+ }
76
+ return found;
77
+ }
78
+
79
+ function getStacks() {
80
+ const stacks = detectStacksIn(projectDir);
81
+ // Monorepo fallback: if root didn't yield a clear stack set, scan 1-level subdirs
82
+ if (stacks.length < 2) {
83
+ try {
84
+ for (const entry of readdirSync(projectDir, { withFileTypes: true })) {
85
+ if (!entry.isDirectory()) continue;
86
+ if (entry.name.startsWith('.')) continue;
87
+ if (STACK_SKIP_DIRS.has(entry.name)) continue;
88
+ stacks.push(...detectStacksIn(join(projectDir, entry.name)));
89
+ }
90
+ } catch { /* skip */ }
91
+ }
92
+ return [...new Set(stacks)].sort();
93
+ }
94
+
95
+ function getGitInfo() {
96
+ const combined = exec('git branch --show-current 2>/dev/null && echo "---SEP---" && git diff --shortstat 2>/dev/null && echo "---SEP---" && git diff --cached --shortstat 2>/dev/null');
97
+ if (!combined) return { branch: '', dirty: false, staged: false };
98
+
99
+ const parts = combined.split('---SEP---').map(s => s.trim());
100
+ return {
101
+ branch: parts[0] || '',
102
+ dirty: !!parts[1],
103
+ staged: !!parts[2],
104
+ };
105
+ }
106
+
107
+ function getMigrationCount() {
108
+ const migDirs = ['migrations', 'db/migrations', 'db/migrate', 'prisma/migrations'];
109
+ for (const dir of migDirs) {
110
+ const full = join(projectDir, dir);
111
+ if (!existsSync(full)) continue;
112
+ try {
113
+ const entries = readdirSync(full).filter(f => !f.startsWith('.'));
114
+ if (entries.length > 0) return entries.length;
115
+ } catch { /* skip */ }
116
+ }
117
+ return 0;
118
+ }
119
+
120
+ function getHookCount() {
121
+ const hooksDir = join(projectDir, '.claude', 'scripts', 'hooks');
122
+ if (!existsSync(hooksDir)) return 0;
123
+ try {
124
+ return readdirSync(hooksDir).filter(f => f.endsWith('.sh')).length;
125
+ } catch { return 0; }
126
+ }
127
+
128
+ function getAgentCount() {
129
+ const agentsDir = join(projectDir, '.claude', 'agents');
130
+ if (!existsSync(agentsDir)) return 0;
131
+ try {
132
+ return readdirSync(agentsDir).filter(f => f.endsWith('.md')).length;
133
+ } catch { return 0; }
134
+ }
135
+
136
+ function getSuperkit() {
137
+ const metaFile = join(projectDir, '.claude', '.superkit-meta');
138
+ if (!existsSync(metaFile)) return '';
139
+ try {
140
+ const content = readFileSync(metaFile, 'utf8');
141
+ const match = content.match(/SUPERKIT_VERSION="([^"]+)"/);
142
+ return match ? match[1] : '';
143
+ } catch { return ''; }
144
+ }
145
+
146
+ // ── Parse effort level from payload ───────────────────
147
+ // Claude Code 2.1.x may send { effort: "xhigh" } or { effort: { level: "xhigh" } }
148
+ // or the env var CLAUDE_EFFORT (for hook contexts). Absent → return ''.
149
+ function getEffortLevel(payload) {
150
+ // Live payload effort takes precedence — the CLI sends the real per-turn
151
+ // effort here, so a stale CLAUDE_EFFORT env var must not mask it.
152
+ // Payload shape: { effort: "xhigh" } or { effort: { level: "xhigh" } }
153
+ if (payload != null) {
154
+ const e = payload.effort;
155
+ if (typeof e === 'string' && e) return e;
156
+ if (e != null && typeof e === 'object' && e.level != null) return String(e.level);
157
+ }
158
+ // Fall back to the env var (available in hook runs / older CLIs).
159
+ return process.env.CLAUDE_EFFORT || '';
160
+ }
161
+
162
+ // ── Transcript tail scan (context fallback + ultracode marker) ────────────
163
+ // Reads only the trailing ~256KB of the JSONL transcript (respects the 2s
164
+ // render budget on huge transcripts), then scans BACKWARDS for the latest
165
+ // usage record, and — in the same pass — tracks the last `/effort` echo
166
+ // (`Set effort level to <value>`) so an ultracode session can show a badge.
167
+ // Caveat: a marker older than the trailing window is missed (badge silently
168
+ // off — fail-safe). Fully fail-open: any error → { used: null, ultra: false }.
169
+ function scanTranscriptTail(transcriptPath) {
170
+ const empty = { used: null, ultra: false };
171
+ try {
172
+ if (typeof transcriptPath !== 'string' || !transcriptPath) return empty;
173
+ const fd = openSync(transcriptPath, 'r');
174
+ try {
175
+ const size = fstatSync(fd).size;
176
+ const readLen = Math.min(size, 262144); // last ~256KB only
177
+ const buf = Buffer.alloc(readLen);
178
+ readSync(fd, buf, 0, readLen, size - readLen);
179
+ const lines = buf.toString('utf8').split('\n');
180
+ let used = null;
181
+ let lastEffortCmd = null;
182
+ for (const line of lines) {
183
+ const m = line.match(/Set effort level to (\w+)/);
184
+ if (m) lastEffortCmd = m[1];
185
+ }
186
+ for (let i = lines.length - 1; i >= 0; i--) { // newest → oldest
187
+ const line = lines[i].trim();
188
+ if (!line || line[0] !== '{') continue;
189
+ let obj;
190
+ try { obj = JSON.parse(line); } catch { continue; } // skip bad/truncated line
191
+ const usage = (obj && obj.message && obj.message.usage) || (obj && obj.usage);
192
+ if (usage && typeof usage === 'object'
193
+ && ('input_tokens' in usage || 'cache_read_input_tokens' in usage
194
+ || 'cache_creation_input_tokens' in usage)) {
195
+ used = (usage.input_tokens || 0)
196
+ + (usage.cache_read_input_tokens || 0)
197
+ + (usage.cache_creation_input_tokens || 0);
198
+ break;
199
+ }
200
+ }
201
+ return { used, ultra: lastEffortCmd === 'ultracode' };
202
+ } finally { closeSync(fd); }
203
+ } catch { return empty; }
204
+ }
205
+
206
+ // Resolve the context window size for the transcript fallback path.
207
+ // Precedence: env override → model '[1m]' marker → >200k heuristic → 200k default.
208
+ function resolveContextWindowTokens(usedTokens, modelString) {
209
+ const env = process.env.CLAUDE_CONTEXT_TOKENS_MAX;
210
+ if (typeof env === 'string' && env.trim()) {
211
+ const n = parseInt(env, 10);
212
+ if (Number.isFinite(n) && n > 0) return n;
213
+ }
214
+ if (typeof modelString === 'string' && /\[1m\]/i.test(modelString)) return 1000000;
215
+ if (typeof usedTokens === 'number' && usedTokens > 200000) return 1000000;
216
+ return 200000;
217
+ }
218
+
219
+ // ── Shared bar rendering (ctx + rate limits speak one visual language) ─────
220
+ function bar10(pct) {
221
+ const filled = Math.max(0, Math.min(10, Math.round((pct / 100) * 10)));
222
+ return '█'.repeat(filled) + '░'.repeat(10 - filled);
223
+ }
224
+ function heatColour(pct) {
225
+ return pct >= 80 ? '\x1b[31m' : pct >= 50 ? '\x1b[33m' : '\x1b[32m';
226
+ }
227
+
228
+ function renderCtxPct(pct) {
229
+ const p = Math.max(0, Math.min(100, Math.round(pct)));
230
+ return `ctx ${heatColour(p)}${bar10(p)}\x1b[0m ${p}%`;
231
+ }
232
+ function renderCtx(used, max) {
233
+ return renderCtxPct((used / max) * 100);
234
+ }
235
+
236
+ // ── Parse context budget from payload ─────────────────
237
+ // Claude Code 2.1.x sends context_window as an OBJECT:
238
+ // { total_input_tokens, context_window_size, used_percentage, … }
239
+ // Older CLIs sent a bare token count there; the oldest sent nothing at all,
240
+ // in which case usage is measured from the transcript instead.
241
+ function getContextBudget(payload, scanned) {
242
+ if (payload == null) return '';
243
+
244
+ const cw = payload.context_window;
245
+
246
+ if (cw && typeof cw === 'object') {
247
+ // used_percentage is the number the CLI itself reports in /context — prefer
248
+ // it, so the bar and /context can never disagree.
249
+ if (typeof cw.used_percentage === 'number') return renderCtxPct(cw.used_percentage);
250
+ if (typeof cw.total_input_tokens === 'number' && cw.context_window_size > 0) {
251
+ return renderCtx(cw.total_input_tokens, cw.context_window_size);
252
+ }
253
+ // Object present but carries no usable numbers → fall through to the transcript.
254
+ } else {
255
+ const used = cw ?? payload.context_tokens_used ?? null;
256
+ if (typeof used === 'number') {
257
+ const max = payload.context_window_max ?? payload.context_tokens_max
258
+ ?? (typeof process.env.CLAUDE_CONTEXT_TOKENS_MAX === 'string'
259
+ ? parseInt(process.env.CLAUDE_CONTEXT_TOKENS_MAX, 10) || null
260
+ : null)
261
+ ?? 1000000; // default: Opus 4.8 1M
262
+ return renderCtx(used, max);
263
+ }
264
+ }
265
+
266
+ // Fallback path: no usable native field → measured from the transcript.
267
+ if (scanned && scanned.used != null) {
268
+ // Model string: the '[1m]' marker rides on model.id (e.g. claude-opus-4-8[1m]);
269
+ // combine id + display_name so either field can carry it.
270
+ const m = payload.model;
271
+ const modelString = typeof m === 'string'
272
+ ? m
273
+ : (m && typeof m === 'object' ? `${m.id || ''} ${m.display_name || ''}` : '');
274
+ const max = resolveContextWindowTokens(scanned.used, modelString);
275
+ return renderCtx(scanned.used, max);
276
+ }
277
+ return '';
278
+ }
279
+
280
+ // ── REAL 5h / weekly rate-limit bars ───────────────────────────────────────
281
+ // Claude Code pipes rate_limits.{five_hour,seven_day}.{used_percentage,
282
+ // resets_at} for Claude subscribers (same data as /usage). Absent (API-key
283
+ // billing, session start) → segments silently skipped.
284
+ function rateLimitSegments(payload) {
285
+ const out = [];
286
+ const rls = payload && payload.rate_limits;
287
+ if (!rls || typeof rls !== 'object') return out;
288
+ const seg = (label, rl) => {
289
+ if (!rl || typeof rl !== 'object') return null;
290
+ const pct = rl.used_percentage;
291
+ if (typeof pct !== 'number' || !Number.isFinite(pct)) return null;
292
+ const p = Math.max(0, Math.min(100, pct));
293
+ // resets_at arrives as epoch seconds OR an ISO string depending on CLI build
294
+ let resetSec = null;
295
+ const r = rl.resets_at;
296
+ if (typeof r === 'number' && r > 0) resetSec = r > 1e12 ? r / 1000 : r;
297
+ else if (typeof r === 'string' && r) {
298
+ const t = Date.parse(r);
299
+ if (Number.isFinite(t)) resetSec = t / 1000;
300
+ }
301
+ let eta = '';
302
+ if (resetSec) {
303
+ let sLeft = Math.max(0, Math.round(resetSec - Date.now() / 1000));
304
+ const d = Math.floor(sLeft / 86400);
305
+ const h = Math.floor((sLeft % 86400) / 3600);
306
+ const mm = Math.floor((sLeft % 3600) / 60);
307
+ eta = d > 0 ? ` ${d}d${h}h` : h > 0 ? ` ${h}h${mm}m` : ` ${mm}m`;
308
+ }
309
+ return `${label} ${heatColour(p)}${bar10(p)}\x1b[0m ${Math.round(p)}%${eta}`;
310
+ };
311
+ const s5 = seg('5h', rls.five_hour);
312
+ const sw = seg('W', rls.seven_day);
313
+ if (s5) out.push(s5);
314
+ if (sw) out.push(sw);
315
+ return out;
316
+ }
317
+
318
+ // ── Build status line ──────────────────────────────────
319
+ const stdinPayload = readStdinPayload();
320
+
321
+ const git = getGitInfo();
322
+ const skVersion = getSuperkit();
323
+ const effortLevel = getEffortLevel(stdinPayload);
324
+ const tp = stdinPayload && typeof stdinPayload.transcript_path === 'string'
325
+ ? stdinPayload.transcript_path : '';
326
+ const scanned = (tp && existsSync(tp)) ? scanTranscriptTail(tp) : { used: null, ultra: false };
327
+ const contextBudget = getContextBudget(stdinPayload, scanned);
328
+
329
+ const parts = [];
330
+
331
+ // Claude Code paints uncoloured statusline text muted gray → the git branch
332
+ // carries an explicit bright colour; CLAUDE_STATUSLINE_THEME=light flips it
333
+ // to black for light terminals.
334
+ const BRIGHT_FG = (process.env.CLAUDE_STATUSLINE_THEME || '').toLowerCase() === 'light' ? '\x1b[30m' : '\x1b[97m';
335
+
336
+ // Superkit version — bold magenta, leads the line.
337
+ if (skVersion) parts.push(`\x1b[1;35mv${skVersion}\x1b[0m`);
338
+
339
+ // Git branch + status (bright fg)
340
+ if (git.branch) {
341
+ let branchStr = git.branch;
342
+ if (git.staged) branchStr += '+';
343
+ if (git.dirty) branchStr += '*';
344
+ parts.push(`${BRIGHT_FG}${branchStr}\x1b[0m`);
345
+ }
346
+
347
+ // Model + effort (heat-graded) + ultracode badge.
348
+ // Model in cyan; effort BOLD, coloured by intensity (high=green, xhigh=yellow,
349
+ // max=red); ⟁ULTRA in bright magenta while the session's /effort is ultracode.
350
+ {
351
+ const m = stdinPayload && stdinPayload.model;
352
+ const modelName = m && typeof m === 'object' ? (m.display_name || m.id) : (typeof m === 'string' ? m : '');
353
+ const effortColour = {
354
+ low: '\x1b[1;94m', medium: '\x1b[1;96m', high: '\x1b[1;92m',
355
+ xhigh: '\x1b[1;93m', max: '\x1b[1;91m',
356
+ }[effortLevel] || '\x1b[1;96m';
357
+ const effortStr = effortLevel ? `${effortColour}⚙${effortLevel}\x1b[0m` : '';
358
+ const ultraStr = scanned.ultra ? '\x1b[1;95m⟁ULTRA\x1b[0m' : '';
359
+ const segment = [modelName ? `\x1b[36m${modelName}\x1b[0m` : '', effortStr, ultraStr]
360
+ .filter(Boolean).join(' ');
361
+ if (segment) parts.push(segment);
362
+ }
363
+
364
+ // Context bar (native or transcript-derived) — absent on older CLIs w/o transcript
365
+ if (contextBudget) parts.push(contextBudget);
366
+
367
+ // Real 5h / weekly rate-limit bars (subscription sessions only)
368
+ for (const seg of rateLimitSegments(stdinPayload)) parts.push(seg);
369
+
370
+ process.stdout.write(parts.join(' | '));