@dirgha/code 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/LICENSE +101 -0
  2. package/README.md +674 -0
  3. package/dist/dirgha.mjs +2185 -0
  4. package/dist_v2/acp/index.d.ts +1 -0
  5. package/dist_v2/acp/index.js +2 -0
  6. package/dist_v2/acp/server.d.ts +31 -0
  7. package/dist_v2/acp/server.js +137 -0
  8. package/dist_v2/cli/auth-cmd.d.ts +10 -0
  9. package/dist_v2/cli/auth-cmd.js +69 -0
  10. package/dist_v2/cli/config.d.ts +46 -0
  11. package/dist_v2/cli/config.js +70 -0
  12. package/dist_v2/cli/flags.d.ts +10 -0
  13. package/dist_v2/cli/flags.js +49 -0
  14. package/dist_v2/cli/flows/full-cycle.d.ts +30 -0
  15. package/dist_v2/cli/flows/full-cycle.js +39 -0
  16. package/dist_v2/cli/flows/index.d.ts +2 -0
  17. package/dist_v2/cli/flows/index.js +3 -0
  18. package/dist_v2/cli/flows/tarball.d.ts +10 -0
  19. package/dist_v2/cli/flows/tarball.js +47 -0
  20. package/dist_v2/cli/index.d.ts +4 -0
  21. package/dist_v2/cli/index.js +5 -0
  22. package/dist_v2/cli/interactive.d.ts +21 -0
  23. package/dist_v2/cli/interactive.js +207 -0
  24. package/dist_v2/cli/main.d.ts +10 -0
  25. package/dist_v2/cli/main.js +173 -0
  26. package/dist_v2/cli/models-cmd.d.ts +6 -0
  27. package/dist_v2/cli/models-cmd.js +50 -0
  28. package/dist_v2/cli/setup.d.ts +13 -0
  29. package/dist_v2/cli/setup.js +128 -0
  30. package/dist_v2/cli/slash/account.d.ts +10 -0
  31. package/dist_v2/cli/slash/account.js +59 -0
  32. package/dist_v2/cli/slash/clear.d.ts +8 -0
  33. package/dist_v2/cli/slash/clear.js +15 -0
  34. package/dist_v2/cli/slash/compact.d.ts +7 -0
  35. package/dist_v2/cli/slash/compact.js +13 -0
  36. package/dist_v2/cli/slash/config.d.ts +8 -0
  37. package/dist_v2/cli/slash/config.js +49 -0
  38. package/dist_v2/cli/slash/exit.d.ts +7 -0
  39. package/dist_v2/cli/slash/exit.js +16 -0
  40. package/dist_v2/cli/slash/fleet.d.ts +7 -0
  41. package/dist_v2/cli/slash/fleet.js +22 -0
  42. package/dist_v2/cli/slash/help.d.ts +9 -0
  43. package/dist_v2/cli/slash/help.js +31 -0
  44. package/dist_v2/cli/slash/history.d.ts +7 -0
  45. package/dist_v2/cli/slash/history.js +42 -0
  46. package/dist_v2/cli/slash/index.d.ts +30 -0
  47. package/dist_v2/cli/slash/index.js +52 -0
  48. package/dist_v2/cli/slash/init.d.ts +8 -0
  49. package/dist_v2/cli/slash/init.js +57 -0
  50. package/dist_v2/cli/slash/keys.d.ts +8 -0
  51. package/dist_v2/cli/slash/keys.js +101 -0
  52. package/dist_v2/cli/slash/login.d.ts +10 -0
  53. package/dist_v2/cli/slash/login.js +47 -0
  54. package/dist_v2/cli/slash/memory.d.ts +8 -0
  55. package/dist_v2/cli/slash/memory.js +101 -0
  56. package/dist_v2/cli/slash/mode.d.ts +8 -0
  57. package/dist_v2/cli/slash/mode.js +30 -0
  58. package/dist_v2/cli/slash/models.d.ts +8 -0
  59. package/dist_v2/cli/slash/models.js +73 -0
  60. package/dist_v2/cli/slash/resume.d.ts +8 -0
  61. package/dist_v2/cli/slash/resume.js +24 -0
  62. package/dist_v2/cli/slash/session.d.ts +8 -0
  63. package/dist_v2/cli/slash/session.js +74 -0
  64. package/dist_v2/cli/slash/setup.d.ts +8 -0
  65. package/dist_v2/cli/slash/setup.js +50 -0
  66. package/dist_v2/cli/slash/status.d.ts +7 -0
  67. package/dist_v2/cli/slash/status.js +37 -0
  68. package/dist_v2/cli/slash/theme.d.ts +9 -0
  69. package/dist_v2/cli/slash/theme.js +53 -0
  70. package/dist_v2/cli/slash/types.d.ts +14 -0
  71. package/dist_v2/cli/slash/types.js +9 -0
  72. package/dist_v2/cli/slash/upgrade.d.ts +9 -0
  73. package/dist_v2/cli/slash/upgrade.js +66 -0
  74. package/dist_v2/cli/slash.d.ts +72 -0
  75. package/dist_v2/cli/slash.js +77 -0
  76. package/dist_v2/cli/subcommands/ask.d.ts +17 -0
  77. package/dist_v2/cli/subcommands/ask.js +76 -0
  78. package/dist_v2/cli/subcommands/audit.d.ts +15 -0
  79. package/dist_v2/cli/subcommands/audit.js +128 -0
  80. package/dist_v2/cli/subcommands/chat.d.ts +13 -0
  81. package/dist_v2/cli/subcommands/chat.js +72 -0
  82. package/dist_v2/cli/subcommands/compact.d.ts +14 -0
  83. package/dist_v2/cli/subcommands/compact.js +114 -0
  84. package/dist_v2/cli/subcommands/doctor.d.ts +11 -0
  85. package/dist_v2/cli/subcommands/doctor.js +103 -0
  86. package/dist_v2/cli/subcommands/export-session.d.ts +10 -0
  87. package/dist_v2/cli/subcommands/export-session.js +60 -0
  88. package/dist_v2/cli/subcommands/import-session.d.ts +11 -0
  89. package/dist_v2/cli/subcommands/import-session.js +77 -0
  90. package/dist_v2/cli/subcommands/index.d.ts +40 -0
  91. package/dist_v2/cli/subcommands/index.js +38 -0
  92. package/dist_v2/cli/subcommands/init.d.ts +10 -0
  93. package/dist_v2/cli/subcommands/init.js +74 -0
  94. package/dist_v2/cli/subcommands/keys.d.ts +12 -0
  95. package/dist_v2/cli/subcommands/keys.js +136 -0
  96. package/dist_v2/cli/subcommands/login.d.ts +10 -0
  97. package/dist_v2/cli/subcommands/login.js +60 -0
  98. package/dist_v2/cli/subcommands/logout.d.ts +10 -0
  99. package/dist_v2/cli/subcommands/logout.js +21 -0
  100. package/dist_v2/cli/subcommands/models.d.ts +14 -0
  101. package/dist_v2/cli/subcommands/models.js +144 -0
  102. package/dist_v2/cli/subcommands/setup.d.ts +11 -0
  103. package/dist_v2/cli/subcommands/setup.js +107 -0
  104. package/dist_v2/cli/subcommands/stats.d.ts +13 -0
  105. package/dist_v2/cli/subcommands/stats.js +148 -0
  106. package/dist_v2/cli/subcommands/status.d.ts +14 -0
  107. package/dist_v2/cli/subcommands/status.js +91 -0
  108. package/dist_v2/cli/submit-paper.d.ts +15 -0
  109. package/dist_v2/cli/submit-paper.js +68 -0
  110. package/dist_v2/context/_fts.d.ts +62 -0
  111. package/dist_v2/context/_fts.js +195 -0
  112. package/dist_v2/context/branch.d.ts +18 -0
  113. package/dist_v2/context/branch.js +66 -0
  114. package/dist_v2/context/compaction.d.ts +26 -0
  115. package/dist_v2/context/compaction.js +120 -0
  116. package/dist_v2/context/index.d.ts +5 -0
  117. package/dist_v2/context/index.js +6 -0
  118. package/dist_v2/context/knowledge.d.ts +38 -0
  119. package/dist_v2/context/knowledge.js +146 -0
  120. package/dist_v2/context/memory.d.ts +80 -0
  121. package/dist_v2/context/memory.js +276 -0
  122. package/dist_v2/context/mode.d.ts +25 -0
  123. package/dist_v2/context/mode.js +81 -0
  124. package/dist_v2/context/session.d.ts +56 -0
  125. package/dist_v2/context/session.js +108 -0
  126. package/dist_v2/daemon/index.d.ts +2 -0
  127. package/dist_v2/daemon/index.js +3 -0
  128. package/dist_v2/daemon/protocol.d.ts +73 -0
  129. package/dist_v2/daemon/protocol.js +6 -0
  130. package/dist_v2/daemon/server.d.ts +35 -0
  131. package/dist_v2/daemon/server.js +191 -0
  132. package/dist_v2/eval/index.d.ts +5 -0
  133. package/dist_v2/eval/index.js +6 -0
  134. package/dist_v2/eval/regression.d.ts +14 -0
  135. package/dist_v2/eval/regression.js +106 -0
  136. package/dist_v2/eval/reporter.d.ts +7 -0
  137. package/dist_v2/eval/reporter.js +34 -0
  138. package/dist_v2/eval/swe-bench.d.ts +18 -0
  139. package/dist_v2/eval/swe-bench.js +23 -0
  140. package/dist_v2/eval/terminal-bench.d.ts +13 -0
  141. package/dist_v2/eval/terminal-bench.js +19 -0
  142. package/dist_v2/eval/types.d.ts +36 -0
  143. package/dist_v2/eval/types.js +5 -0
  144. package/dist_v2/fleet/apply-back.d.ts +27 -0
  145. package/dist_v2/fleet/apply-back.js +191 -0
  146. package/dist_v2/fleet/cli-command.d.ts +61 -0
  147. package/dist_v2/fleet/cli-command.js +329 -0
  148. package/dist_v2/fleet/index.d.ts +21 -0
  149. package/dist_v2/fleet/index.js +21 -0
  150. package/dist_v2/fleet/runner.d.ts +28 -0
  151. package/dist_v2/fleet/runner.js +347 -0
  152. package/dist_v2/fleet/tripleshot.d.ts +21 -0
  153. package/dist_v2/fleet/tripleshot.js +222 -0
  154. package/dist_v2/fleet/types.d.ts +193 -0
  155. package/dist_v2/fleet/types.js +24 -0
  156. package/dist_v2/fleet/worktree.d.ts +51 -0
  157. package/dist_v2/fleet/worktree.js +176 -0
  158. package/dist_v2/hooks/index.d.ts +1 -0
  159. package/dist_v2/hooks/index.js +2 -0
  160. package/dist_v2/hooks/registry.d.ts +21 -0
  161. package/dist_v2/hooks/registry.js +40 -0
  162. package/dist_v2/index.d.ts +12 -0
  163. package/dist_v2/index.js +11 -0
  164. package/dist_v2/integrations/arniko-client.d.ts +42 -0
  165. package/dist_v2/integrations/arniko-client.js +86 -0
  166. package/dist_v2/integrations/auth.d.ts +45 -0
  167. package/dist_v2/integrations/auth.js +54 -0
  168. package/dist_v2/integrations/billing.d.ts +71 -0
  169. package/dist_v2/integrations/billing.js +107 -0
  170. package/dist_v2/integrations/bucky-client.d.ts +105 -0
  171. package/dist_v2/integrations/bucky-client.js +76 -0
  172. package/dist_v2/integrations/deploy-client.d.ts +60 -0
  173. package/dist_v2/integrations/deploy-client.js +87 -0
  174. package/dist_v2/integrations/device-auth.d.ts +48 -0
  175. package/dist_v2/integrations/device-auth.js +192 -0
  176. package/dist_v2/integrations/entitlements.d.ts +34 -0
  177. package/dist_v2/integrations/entitlements.js +43 -0
  178. package/dist_v2/integrations/http.d.ts +22 -0
  179. package/dist_v2/integrations/http.js +114 -0
  180. package/dist_v2/integrations/index.d.ts +8 -0
  181. package/dist_v2/integrations/index.js +15 -0
  182. package/dist_v2/intelligence/cost.d.ts +28 -0
  183. package/dist_v2/intelligence/cost.js +58 -0
  184. package/dist_v2/intelligence/error-classifier.d.ts +8 -0
  185. package/dist_v2/intelligence/error-classifier.js +71 -0
  186. package/dist_v2/intelligence/index.d.ts +5 -0
  187. package/dist_v2/intelligence/index.js +6 -0
  188. package/dist_v2/intelligence/prices.d.ts +13 -0
  189. package/dist_v2/intelligence/prices.js +26 -0
  190. package/dist_v2/intelligence/smart-router.d.ts +21 -0
  191. package/dist_v2/intelligence/smart-router.js +59 -0
  192. package/dist_v2/intelligence/telemetry.d.ts +22 -0
  193. package/dist_v2/intelligence/telemetry.js +31 -0
  194. package/dist_v2/kernel/agent-loop.d.ts +32 -0
  195. package/dist_v2/kernel/agent-loop.js +151 -0
  196. package/dist_v2/kernel/event-stream.d.ts +18 -0
  197. package/dist_v2/kernel/event-stream.js +102 -0
  198. package/dist_v2/kernel/index.d.ts +4 -0
  199. package/dist_v2/kernel/index.js +5 -0
  200. package/dist_v2/kernel/message.d.ts +29 -0
  201. package/dist_v2/kernel/message.js +118 -0
  202. package/dist_v2/kernel/types.d.ts +206 -0
  203. package/dist_v2/kernel/types.js +9 -0
  204. package/dist_v2/mcp/client.d.ts +44 -0
  205. package/dist_v2/mcp/client.js +63 -0
  206. package/dist_v2/mcp/index.d.ts +3 -0
  207. package/dist_v2/mcp/index.js +4 -0
  208. package/dist_v2/mcp/tool-bridge.d.ts +11 -0
  209. package/dist_v2/mcp/tool-bridge.js +33 -0
  210. package/dist_v2/mcp/transport.d.ts +29 -0
  211. package/dist_v2/mcp/transport.js +73 -0
  212. package/dist_v2/parity/index.d.ts +3 -0
  213. package/dist_v2/parity/index.js +4 -0
  214. package/dist_v2/parity/mock-openai-compat.d.ts +15 -0
  215. package/dist_v2/parity/mock-openai-compat.js +35 -0
  216. package/dist_v2/parity/runner.d.ts +21 -0
  217. package/dist_v2/parity/runner.js +76 -0
  218. package/dist_v2/parity/scenarios.d.ts +20 -0
  219. package/dist_v2/parity/scenarios.js +70 -0
  220. package/dist_v2/providers/anthropic.d.ts +21 -0
  221. package/dist_v2/providers/anthropic.js +191 -0
  222. package/dist_v2/providers/dispatch.d.ts +11 -0
  223. package/dist_v2/providers/dispatch.js +45 -0
  224. package/dist_v2/providers/fireworks.d.ts +18 -0
  225. package/dist_v2/providers/fireworks.js +44 -0
  226. package/dist_v2/providers/gemini.d.ts +19 -0
  227. package/dist_v2/providers/gemini.js +188 -0
  228. package/dist_v2/providers/http.d.ts +41 -0
  229. package/dist_v2/providers/http.js +188 -0
  230. package/dist_v2/providers/iface.d.ts +18 -0
  231. package/dist_v2/providers/iface.js +18 -0
  232. package/dist_v2/providers/index.d.ts +39 -0
  233. package/dist_v2/providers/index.js +51 -0
  234. package/dist_v2/providers/nvidia.d.ts +27 -0
  235. package/dist_v2/providers/nvidia.js +142 -0
  236. package/dist_v2/providers/ollama.d.ts +15 -0
  237. package/dist_v2/providers/ollama.js +37 -0
  238. package/dist_v2/providers/openai-compat.d.ts +29 -0
  239. package/dist_v2/providers/openai-compat.js +239 -0
  240. package/dist_v2/providers/openai.d.ts +20 -0
  241. package/dist_v2/providers/openai.js +107 -0
  242. package/dist_v2/providers/openrouter.d.ts +24 -0
  243. package/dist_v2/providers/openrouter.js +69 -0
  244. package/dist_v2/safety/approval-bus.d.ts +26 -0
  245. package/dist_v2/safety/approval-bus.js +48 -0
  246. package/dist_v2/safety/audit-log.d.ts +27 -0
  247. package/dist_v2/safety/audit-log.js +71 -0
  248. package/dist_v2/safety/index.d.ts +4 -0
  249. package/dist_v2/safety/index.js +5 -0
  250. package/dist_v2/safety/policy.d.ts +32 -0
  251. package/dist_v2/safety/policy.js +131 -0
  252. package/dist_v2/safety/sandbox/bwrap.d.ts +11 -0
  253. package/dist_v2/safety/sandbox/bwrap.js +52 -0
  254. package/dist_v2/safety/sandbox/iface.d.ts +29 -0
  255. package/dist_v2/safety/sandbox/iface.js +8 -0
  256. package/dist_v2/safety/sandbox/index.d.ts +7 -0
  257. package/dist_v2/safety/sandbox/index.js +8 -0
  258. package/dist_v2/safety/sandbox/landlock.d.ts +17 -0
  259. package/dist_v2/safety/sandbox/landlock.js +26 -0
  260. package/dist_v2/safety/sandbox/noop.d.ts +12 -0
  261. package/dist_v2/safety/sandbox/noop.js +52 -0
  262. package/dist_v2/safety/sandbox/seatbelt.d.ts +11 -0
  263. package/dist_v2/safety/sandbox/seatbelt.js +49 -0
  264. package/dist_v2/safety/sandbox/select.d.ts +6 -0
  265. package/dist_v2/safety/sandbox/select.js +42 -0
  266. package/dist_v2/safety/sandbox/windows.d.ts +13 -0
  267. package/dist_v2/safety/sandbox/windows.js +22 -0
  268. package/dist_v2/skills/index.d.ts +3 -0
  269. package/dist_v2/skills/index.js +4 -0
  270. package/dist_v2/skills/loader.d.ts +38 -0
  271. package/dist_v2/skills/loader.js +102 -0
  272. package/dist_v2/skills/matcher.d.ts +14 -0
  273. package/dist_v2/skills/matcher.js +72 -0
  274. package/dist_v2/skills/runtime.d.ts +13 -0
  275. package/dist_v2/skills/runtime.js +40 -0
  276. package/dist_v2/subagents/delegator.d.ts +36 -0
  277. package/dist_v2/subagents/delegator.js +82 -0
  278. package/dist_v2/subagents/index.d.ts +2 -0
  279. package/dist_v2/subagents/index.js +3 -0
  280. package/dist_v2/subagents/pool.d.ts +18 -0
  281. package/dist_v2/subagents/pool.js +31 -0
  282. package/dist_v2/tools/browser.d.ts +27 -0
  283. package/dist_v2/tools/browser.js +179 -0
  284. package/dist_v2/tools/checkpoint.d.ts +25 -0
  285. package/dist_v2/tools/checkpoint.js +222 -0
  286. package/dist_v2/tools/cron.d.ts +32 -0
  287. package/dist_v2/tools/cron.js +160 -0
  288. package/dist_v2/tools/diff.d.ts +18 -0
  289. package/dist_v2/tools/diff.js +117 -0
  290. package/dist_v2/tools/exec.d.ts +19 -0
  291. package/dist_v2/tools/exec.js +49 -0
  292. package/dist_v2/tools/fs-edit.d.ts +11 -0
  293. package/dist_v2/tools/fs-edit.js +81 -0
  294. package/dist_v2/tools/fs-ls.d.ts +7 -0
  295. package/dist_v2/tools/fs-ls.js +57 -0
  296. package/dist_v2/tools/fs-read.d.ts +7 -0
  297. package/dist_v2/tools/fs-read.js +60 -0
  298. package/dist_v2/tools/fs-write.d.ts +8 -0
  299. package/dist_v2/tools/fs-write.js +46 -0
  300. package/dist_v2/tools/git.d.ts +8 -0
  301. package/dist_v2/tools/git.js +57 -0
  302. package/dist_v2/tools/index.d.ts +25 -0
  303. package/dist_v2/tools/index.js +39 -0
  304. package/dist_v2/tools/multimodal.d.ts +41 -0
  305. package/dist_v2/tools/multimodal.js +381 -0
  306. package/dist_v2/tools/permission.d.ts +27 -0
  307. package/dist_v2/tools/permission.js +43 -0
  308. package/dist_v2/tools/registry.d.ts +44 -0
  309. package/dist_v2/tools/registry.js +62 -0
  310. package/dist_v2/tools/search-glob.d.ts +7 -0
  311. package/dist_v2/tools/search-glob.js +98 -0
  312. package/dist_v2/tools/search-grep.d.ts +7 -0
  313. package/dist_v2/tools/search-grep.js +109 -0
  314. package/dist_v2/tools/shell.d.ts +10 -0
  315. package/dist_v2/tools/shell.js +76 -0
  316. package/dist_v2/tools/task.d.ts +8 -0
  317. package/dist_v2/tools/task.js +37 -0
  318. package/dist_v2/tui/approval.d.ts +7 -0
  319. package/dist_v2/tui/approval.js +55 -0
  320. package/dist_v2/tui/index.d.ts +4 -0
  321. package/dist_v2/tui/index.js +5 -0
  322. package/dist_v2/tui/ink/App.d.ts +39 -0
  323. package/dist_v2/tui/ink/App.js +206 -0
  324. package/dist_v2/tui/ink/components/AtFileComplete.d.ts +25 -0
  325. package/dist_v2/tui/ink/components/AtFileComplete.js +158 -0
  326. package/dist_v2/tui/ink/components/HelpOverlay.d.ts +24 -0
  327. package/dist_v2/tui/ink/components/HelpOverlay.js +130 -0
  328. package/dist_v2/tui/ink/components/InputBox.d.ts +35 -0
  329. package/dist_v2/tui/ink/components/InputBox.js +153 -0
  330. package/dist_v2/tui/ink/components/Logo.d.ts +12 -0
  331. package/dist_v2/tui/ink/components/Logo.js +27 -0
  332. package/dist_v2/tui/ink/components/ModelPicker.d.ts +26 -0
  333. package/dist_v2/tui/ink/components/ModelPicker.js +80 -0
  334. package/dist_v2/tui/ink/components/PasteCollapse.d.ts +36 -0
  335. package/dist_v2/tui/ink/components/PasteCollapse.js +59 -0
  336. package/dist_v2/tui/ink/components/StatusBar.d.ts +18 -0
  337. package/dist_v2/tui/ink/components/StatusBar.js +41 -0
  338. package/dist_v2/tui/ink/components/StreamingText.d.ts +14 -0
  339. package/dist_v2/tui/ink/components/StreamingText.js +11 -0
  340. package/dist_v2/tui/ink/components/ThinkingBlock.d.ts +13 -0
  341. package/dist_v2/tui/ink/components/ThinkingBlock.js +13 -0
  342. package/dist_v2/tui/ink/components/ToolBox.d.ts +20 -0
  343. package/dist_v2/tui/ink/components/ToolBox.js +63 -0
  344. package/dist_v2/tui/ink/components/vim-bindings.d.ts +43 -0
  345. package/dist_v2/tui/ink/components/vim-bindings.js +135 -0
  346. package/dist_v2/tui/ink/index.d.ts +39 -0
  347. package/dist_v2/tui/ink/index.js +47 -0
  348. package/dist_v2/tui/ink/use-event-projection.d.ts +51 -0
  349. package/dist_v2/tui/ink/use-event-projection.js +126 -0
  350. package/dist_v2/tui/ink/use-overlays.d.ts +24 -0
  351. package/dist_v2/tui/ink/use-overlays.js +50 -0
  352. package/dist_v2/tui/renderer.d.ts +19 -0
  353. package/dist_v2/tui/renderer.js +64 -0
  354. package/dist_v2/tui/status-bar.d.ts +12 -0
  355. package/dist_v2/tui/status-bar.js +16 -0
  356. package/dist_v2/tui/theme.d.ts +27 -0
  357. package/dist_v2/tui/theme.js +56 -0
  358. package/dist_v2/utils/json-repair.d.ts +7 -0
  359. package/dist_v2/utils/json-repair.js +45 -0
  360. package/package.json +113 -0
package/README.md ADDED
@@ -0,0 +1,674 @@
1
+ # Dirgha Code
2
+
3
+ **A terminal-native AI coding agent. Sovereign by default. Parallel by design. Bring-your-own-key.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/@dirgha/code?style=flat-square&color=000)](https://www.npmjs.com/package/@dirgha/code)
6
+ [![License: FSL-1.1-MIT](https://img.shields.io/badge/license-FSL--1.1--MIT-blue?style=flat-square)](./LICENSE)
7
+ [![CLI-Anything compliant](https://img.shields.io/badge/CLI--Anything-compliant-10b981?style=flat-square)](https://github.com/HKUDS/CLI-Anything)
8
+ [![Sponsor](https://img.shields.io/badge/sponsor-%E2%99%A1-ec4899?style=flat-square)](https://dirgha.ai/contribute)
9
+
10
+ ---
11
+
12
+ ```
13
+ ◈ Dirgha Code · dirgha.ai · 0.1.0 · nvidia/minimax-m2.7
14
+ ──────────────────────────────────────────────────────────
15
+ ❯ dirgha fleet launch "migrate auth to JWT + add rate limiter"
16
+ ∇ decomposing goal into parallel streams…
17
+
18
+ fleet × 3
19
+ ⠙ auth-middleware fleet/auth-middleware 12s
20
+ ⠹ jwt-service fleet/jwt-service 9s
21
+ · rate-limiter fleet/rate-limiter 5s — done
22
+
23
+ ✓ 3/3 agents completed in 47s · review with `git diff`
24
+ ```
25
+
26
+ Dirgha Code writes, edits, runs, and verifies code from your terminal —
27
+ alone or as a **fleet of parallel agents** working in isolated git
28
+ worktrees. It ships with 43 built-in tools, a dispatcher that speaks to
29
+ 16 LLM providers with automatic failover, a multi-tier memory system,
30
+ persistent sessions, a sandboxed runtime for user code, and a plugin
31
+ registry. It is entirely one binary you install from npm. No Electron,
32
+ no cloud dependency if you BYOK, no telemetry, full CLI-Anything
33
+ compliance (`--json` on every command).
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ npm install -g @dirgha/code # or: pnpm add -g @dirgha/code
39
+ ```
40
+
41
+ Requires Node 20+. Binary installs as both `dirgha` and `d`.
42
+
43
+ ## Start in 30 seconds
44
+
45
+ Pick one of three on-ramps. You can change your mind later without
46
+ reinstalling.
47
+
48
+ ### 1. Hosted (recommended for trial)
49
+
50
+ ```bash
51
+ dirgha login # device-flow browser handshake
52
+ dirgha # launch the TUI
53
+ ```
54
+
55
+ Signs you in to the Dirgha Gateway — cross-provider failover, managed
56
+ quotas, zero key management.
57
+
58
+ ### 2. BYOK (sovereign — recommended for serious work)
59
+
60
+ Bring any one provider key:
61
+
62
+ ```bash
63
+ dirgha keys set NVIDIA_API_KEY nvapi-… # MiniMax M2.7, Kimi K2, Llama 4
64
+ dirgha keys set ANTHROPIC_API_KEY sk-ant-… # Claude
65
+ dirgha keys set OPENROUTER_API_KEY sk-or-… # 300+ models
66
+ # …or 11 others — see "Providers" below
67
+
68
+ dirgha
69
+ ```
70
+
71
+ Keys are stored at `~/.dirgha/keys.json` (mode 0600), auto-loaded into
72
+ env at boot. No telemetry, no gateway round-trip.
73
+
74
+ ### 3. Headless (CI / scripting)
75
+
76
+ ```bash
77
+ # Single-turn
78
+ dirgha ask "summarise the failing tests" --json
79
+
80
+ # Parallel fleet in git worktrees
81
+ dirgha fleet launch "refactor auth + add tests" --concurrency 3
82
+
83
+ # Generate a signup link for new accounts
84
+ dirgha signup
85
+ ```
86
+
87
+ Every command supports `--json` — parseable envelope with `data`, `text`,
88
+ `exitCode`, `timestamp`, and `meta.durationMs` (CLI-Anything spec).
89
+
90
+ ---
91
+
92
+ ## What's new in 0.1.0 — `fleet`
93
+
94
+ The headline feature of 0.1.0 is **parallel multi-agent execution in git
95
+ worktrees**. One command decomposes a goal into independent streams,
96
+ spawns N agents concurrently, and lets you review their diffs before
97
+ anything touches your working tree.
98
+
99
+ ```bash
100
+ dirgha fleet launch "add rate limiting" # 2-5 subtasks in parallel worktrees
101
+ dirgha fleet triple "refactor the auth loop" # 3 variants + judge picks winner
102
+ dirgha fleet list # show all active worktrees
103
+ dirgha fleet merge <agent-id> # 3-way apply-back to your branch
104
+ dirgha fleet cleanup # tear down worktrees + branches
105
+ ```
106
+
107
+ Full guide: [`docs/FLEET.md`](./docs/FLEET.md).
108
+
109
+ ## Why this exists
110
+
111
+ Frontier coding assistants are closed SaaS on someone else's cluster, charging
112
+ per-seat, piping your repository through their telemetry. The assumption is
113
+ that the intelligence must live at the vendor.
114
+
115
+ Dirgha Code is built from the opposite assumption. Your laptop is the unit of
116
+ sovereignty. Your keys, your wallet, your session database, your tool
117
+ executions all live on your machine until you explicitly choose to hit a
118
+ network. Providers are swappable, not sacred. The agent loop itself is open
119
+ source and forkable.
120
+
121
+ You get the frontier tooling without the surrender.
122
+
123
+ ## Architecture
124
+
125
+ ```
126
+ ┌──────────────────────────────────────────────────────────────────────┐
127
+ │ Ink/React TUI │
128
+ │ InputBox · LiveView · StatusBar · ModelPicker · SlashHint │
129
+ │ ─── useInput (raw mode) · bracketed paste · cursor blink ── │
130
+ └────────────────────────┬─────────────────────────────────────────────┘
131
+ │ user turn
132
+ ┌────────────────────────▼─────────────────────────────────────────────┐
133
+ │ Agent Loop │
134
+ │ ┌──────────────┐ ┌─────────────┐ ┌───────────────┐ │
135
+ │ │ context/JIT │ │ compaction │ │ loop-detector │ │
136
+ │ │ system-prompt│→ │ tiered │→ │ 60k-tok ceil. │ │
137
+ │ └──────────────┘ └─────────────┘ └───────────────┘ │
138
+ │ │ │ │
139
+ │ ▼ ▼ │
140
+ │ ┌──────────────┐ pending-messages ┌───────────────┐ │
141
+ │ │ providers/ │◀ ─ mid-turn inject ─ │ tool exec │ │
142
+ │ │ dispatch │ │ 43 tools │ │
143
+ │ └──────┬───────┘ └───────┬──────┘ │
144
+ │ │ │ │
145
+ │ ▼ 429/502/timeout → next hop ▼ │
146
+ │ ┌──────────────┐ ┌────────────┐ │
147
+ │ │ 14 providers│ │ tool runtime│ │
148
+ │ └──────────────┘ │ · host │ │
149
+ │ │ · sandbox │ │
150
+ │ │ · MCP │ │
151
+ │ │ · hub │ │
152
+ │ └────────────┘ │
153
+ └──────────────────────────────────────────────────────────────────────┘
154
+ │ │ │
155
+ ▼ ▼ ▼
156
+ ┌──────────┐ ┌──────────────────┐ ┌─────────────────┐
157
+ │ sessions │ │ memory system │ │ filesystem │
158
+ │ SQLite │ │ · builtin │ │ edit/diff/patch│
159
+ │ ~/.dirgha│ │ · holographic │ │ repo-rooted │
160
+ │ │ │ · gepa (LLM-opt)│ │ │
161
+ │ │ │ · memory-graph │ │ │
162
+ └──────────┘ └──────────────────┘ └─────────────────┘
163
+ ```
164
+
165
+ Every box is a separate module you can read. Total source: **51 subsystems
166
+ across ~50,000 lines of TypeScript**, 59 test files, one bundled distribution.
167
+
168
+ ## Memory system
169
+
170
+ Dirgha Code has four layers of memory, each with a different persistence
171
+ model and retrieval pattern. They compose — a single `save_memory` call can
172
+ write through all four. Retrieval picks the lightest tier that answers the
173
+ query.
174
+
175
+ ### 1. Built-in memory (`memory/builtin.ts`)
176
+
177
+ - **Where:** `~/.dirgha/sessions.db` (SQLite), `memories` table
178
+ - **Shape:** key → content, key is caller-chosen
179
+ - **Retrieval:** exact key match via `read_memory`, full-text scan via
180
+ `search_knowledge`
181
+ - **Use:** the classic "persist this across sessions" slot. Reliable,
182
+ synchronous, local-only.
183
+
184
+ ### 2. Holographic memory (`memory/holographic.ts`)
185
+
186
+ - **Where:** SQLite FTS5 virtual table, same DB
187
+ - **Shape:** text + trust score + timestamp + source
188
+ - **Retrieval:** BM25-ranked full-text, weighted by freshness and trust
189
+ - **Use:** "show me everything the agent learned about the auth module last
190
+ week" — dense, forgettable, repo-aware. Trust score decays; stale entries
191
+ get pruned by the maintenance job.
192
+
193
+ ### 3. GEPA integration (`memory/gepa-integration.ts`)
194
+
195
+ - **Where:** model-specific prompt compilation, cached on disk
196
+ - **Shape:** optimised few-shot prompts produced by GEPA
197
+ (Gradient-free Evolutionary Prompt Adaptation)
198
+ - **Retrieval:** loaded into the system prompt when a matching task is
199
+ detected
200
+ - **Use:** the agent gets better at recurring tasks (test writing, refactor
201
+ patterns, PR reviews) because each round's success/failure retrains the
202
+ prompt library. Opt-in; does not block the basic loop.
203
+
204
+ ### 4. Memory graph (`tools/memory-graph.ts`, Qdrant-backed)
205
+
206
+ - **Where:** a running Qdrant instance (local or hosted) + local cache
207
+ - **Shape:** nodes with embeddings + directed edges with types
208
+ - **Retrieval:** semantic search + graph walk via `memory_graph_query`
209
+ - **Use:** "show me everything related to `OrderBuilder` across all my
210
+ projects and sessions." Cross-repo, cross-temporal, knowledge-graph style.
211
+ Heavy — optional infrastructure.
212
+
213
+ All four are addressable from tools the model actually uses:
214
+ `save_memory`, `read_memory`, `search_knowledge`, `memory_graph_add`,
215
+ `memory_graph_query`, `memory_graph_link`.
216
+
217
+ ## The agent loop
218
+
219
+ `agent/loop.ts` (~560 lines) is the heart. Each turn:
220
+
221
+ 1. **Build system prompt** — `agent/context.ts` parallelises four contributors:
222
+ JIT-discovered repo context, the wiki index, the active skills prompt, and
223
+ installed extensions. All wrapped in try/catch so no single source blocks
224
+ the turn.
225
+ 2. **Classify the query** — `agent/routing.ts` picks a tier (fast / full)
226
+ from trigger heuristics (length, verb, language markers). Tier maps to a
227
+ model ID per provider.
228
+ 3. **Compact if needed** — `agent/compaction.ts` runs tiered summarization
229
+ when history crosses 40 messages / 60k tokens. Earlier messages become a
230
+ terse summary the agent references as "[turns 1-28 summary: …]".
231
+ 4. **Dispatch** — `providers/dispatch.ts` picks the right provider, walks the
232
+ fallback chain on 429 / 5xx / timeout, resumes interrupted streams.
233
+ 5. **Execute tools** — as the model emits tool calls, `agent/tool-execution.ts`
234
+ sanitises frame markers, enforces per-call output caps, and records results.
235
+ 6. **Drain pending messages** — `agent/pending-messages.ts` picks up anything
236
+ you typed mid-turn and appends it as a fresh user message for the next turn.
237
+ 7. **Emit events** — `agent/event-emit.ts` pushes live updates (with a
238
+ circuit breaker on 5 consecutive send failures) to the TUI so you see what
239
+ the agent is doing in real time.
240
+ 8. **Self-reflect** — `agent/reflection.ts` checks for loop-detection
241
+ signals (same tool called 3× with identical args) and forces a correction
242
+ prompt before the next iteration.
243
+
244
+ The loop terminates when the model emits `stop_reason: end_turn` or the user
245
+ presses Esc. Every step is individually failure-isolated; a broken wiki
246
+ index, a flaky provider, or a tool that times out don't cascade.
247
+
248
+ ## Tools (43 built-in, plus MCP and hub)
249
+
250
+ All 43 ship as first-class tool definitions the model sees in its schema.
251
+ Catalogued in `src/tools/defs.ts`:
252
+
253
+ | Category | Tools |
254
+ |---|---|
255
+ | **Filesystem** | `read_file`, `write_file`, `edit_file`, `edit_file_all`, `apply_patch`, `make_dir`, `delete_file` |
256
+ | **Shell** | `run_command`, `bash` (alias) — 8k-char output cap, 60s default timeout, auto-extends to 300s for `npm install` / `bun test` / builds, dangerous-pattern blocklist, cwd-tracking across calls |
257
+ | **Search** | `search_files` (ripgrep), `list_files`, `glob`, `repo_map` (symbol-aware), `web_fetch`, `web_search` (DuckDuckGo), `qmd_search` (semantic docs), `search_knowledge` (local FTS5), `index_files` |
258
+ | **Git** | `git_status`, `git_diff`, `git_log`, `git_commit`, `checkpoint` (stash-based), `git_branch`, `git_push`, `git_stash`, `git_patch`, `git_auto_message` (AI-generated conventional commits) |
259
+ | **Memory** | `save_memory`, `read_memory`, `search_knowledge`, `session_search` (cross-session history), `write_todos`, `ask_user`, `memory_graph_add`, `memory_graph_query`, `memory_graph_link`, `memory_graph_prune` |
260
+ | **Sandbox** | `execute_code` — runs Python or JS in an isolated VM with network-deny, CPU/memory caps, transcript logging |
261
+ | **Browser** | `browser` — navigate, snapshot, click, type, fill, screenshot, find, get, batch, eval, extract, search (Playwright-backed when available) |
262
+ | **Agent orchestration** | `spawn_agent` (depth-limited sub-agents), `orchestrate` (plan → code → verify three-agent chain) |
263
+ | **Deployment** | `deploy_trigger`, `deploy_status` (wired to CI systems via webhooks) |
264
+
265
+ **MCP (Model Context Protocol):** Dirgha Code is an MCP **client**. `mcp/` has
266
+ stdio, SSE, and HTTP transports; `mcp/manager.ts` starts and supervises
267
+ servers you configure in `~/.dirgha/mcp.json`. MCP tools show up in the
268
+ model's tool list alongside built-ins, namespaced by server.
269
+
270
+ **Hub:** `dirgha hub install <plugin>` installs a package from the Dirgha
271
+ plugin registry. Each plugin can contribute new tools, slash commands, or
272
+ output renderers. The registry ships bundled so `hub list` / `hub search`
273
+ work offline.
274
+
275
+ ## Provider dispatch (14 providers, automatic failover)
276
+
277
+ `providers/dispatch.ts` has three primitives:
278
+
279
+ - **`providerFromModelId()`** — infers the provider from the model ID prefix
280
+ (`claude-*` → Anthropic, `accounts/fireworks/*` → Fireworks,
281
+ `minimaxai/*` → NVIDIA, `gpt-*` → OpenAI, …).
282
+ - **`buildFallbackChain()`** — family-aware chain builder. A request for
283
+ a MiniMax model walks: `NVIDIA MiniMax M2.7` → `NVIDIA Kimi K2` →
284
+ `NVIDIA MiniMax M2.5` → `OpenRouter Kimi K2.5` → `Anthropic Claude Sonnet`.
285
+ Each hop is a different billing account with independent quotas, so 429
286
+ on one doesn't throttle the rest.
287
+ - **`withNetworkResume()`** — catches pure network errors (ECONNRESET,
288
+ socket hangup, 502, 503) and retries on the same provider with stream
289
+ resume. 429 is NOT retried here — it jumps to the next provider.
290
+
291
+ | Provider | Env var | Notes |
292
+ |---|---|---|
293
+ | **NVIDIA NIM** | `NVIDIA_API_KEY` | MiniMax M2.7, Kimi K2, Llama 4, Mistral Nemotron — 60s per-call timeout guard |
294
+ | **Anthropic** | `ANTHROPIC_API_KEY` | Claude Opus 4.7, Sonnet 4.6, Haiku 4.5 — extended thinking supported |
295
+ | **OpenAI** | `OPENAI_API_KEY` | GPT-5.4 family, o-series reasoning models |
296
+ | **OpenRouter** | `OPENROUTER_API_KEY` | 300+ models, unified billing, global routing |
297
+ | **Google Gemini** | `GEMINI_API_KEY` | 3.1 Pro, 3.1 Flash — 2M-token context |
298
+ | **Groq** | `GROQ_API_KEY` | Llama, Qwen at extreme TPS |
299
+ | **xAI** | `XAI_API_KEY` | Grok 4 family |
300
+ | **Mistral** | `MISTRAL_API_KEY` | Mistral Large, Codestral |
301
+ | **Cohere** | `COHERE_API_KEY` | Command R / R+ |
302
+ | **Fireworks** | `FIREWORKS_API_KEY` | Self-hosted open models |
303
+ | **DeepInfra** | `DEEPINFRA_API_KEY` | Alt hosting |
304
+ | **Perplexity** | `PERPLEXITY_API_KEY` | Sonar, web-grounded |
305
+ | **Together AI** | `TOGETHER_API_KEY` | Llama, Qwen, DeepSeek |
306
+ | **Ollama** | (none) | Any model running on `localhost:11434` |
307
+ | **Dirgha Gateway** | `dirgha login` | Managed cross-provider routing |
308
+
309
+ Each provider module is a thin adapter (average ~120 lines). New providers
310
+ are a half-day's work: implement `call<Name>(messages, systemPrompt, model, onStream)`
311
+ in `providers/<name>.ts`, add it to the switch in `dispatch.ts`.
312
+
313
+ A **circuit breaker** (`providers/circuit-breaker.ts`) tracks per-provider
314
+ health. Three consecutive failures open the breaker for 30 seconds — the
315
+ dispatcher skips that provider entirely until it heals.
316
+
317
+ ## Sessions & persistence
318
+
319
+ Everything runs on one SQLite database at `~/.dirgha/sessions.db` (via
320
+ `better-sqlite3`, synchronous writes, WAL mode).
321
+
322
+ **Tables:**
323
+ - `sessions(id, title, model, tokens, created_at, updated_at)`
324
+ - `messages(id, session_id, role, content, ...)` with ON DELETE CASCADE
325
+ - `memories(id, key, content, created_at, updated_at)`
326
+ - `file_index(id, filepath, project, content, symbols, indexed_at)` — FTS5
327
+ virtual table for local semantic search
328
+
329
+ `dirgha --resume` picks up the last session. `dirgha --resume <id>` picks up a
330
+ specific one. `session_search` lets the agent itself pull relevant prior turns
331
+ into the current context.
332
+
333
+ Crash recovery is automatic: `dirgha` catches `uncaughtException` and
334
+ `unhandledRejection`, writes to `~/.dirgha/crash.log`, and calls
335
+ `restoreTerminal()` so your shell doesn't end up in bracketed-paste mode
336
+ or with the cursor hidden.
337
+
338
+ ## Safety model
339
+
340
+ ### Secrets in transit
341
+ `agent/secrets.ts` runs every user message through `redactSecrets()` before
342
+ it's saved to history or sent to the model. Detects and masks: Anthropic
343
+ keys, OpenAI keys, Fireworks keys, GitHub PATs, AWS credentials, JWT tokens,
344
+ SSH keys, and 33 other common patterns.
345
+
346
+ ### Shell execution
347
+ `tools/shell.ts` enforces:
348
+ - **Output caps** — 8k chars default, 50k hard ceiling. Model can request
349
+ more via `max_output`. Prevents single tool results from eating the entire
350
+ context window.
351
+ - **Dangerous patterns blocked** — `rm -rf /`, `find -delete` with no scope,
352
+ `git clean -fdx`, `curl | sh`, process substitution `<(...)`,
353
+ `eval $(...)`, and a dozen others. List in `DANGEROUS_PATTERNS`.
354
+ - **Timeout bands** — 60s default, 300s for `npm install` / `bun test` /
355
+ build commands (pattern-matched), max 600s. Timeout errors suggest the
356
+ exact `timeout_ms` to retry with.
357
+
358
+ ### Agent spawning
359
+ `agent/spawn-agent.ts`:
360
+ - `MAX_SPAWN_DEPTH = 3` — a sub-agent can spawn a sub-sub-agent, but no
361
+ further. Prevents recursive fork bombs.
362
+ - `MAX_CONCURRENT_AGENTS = 4` — total active spawns across the session.
363
+ - `spawn_agent` itself is filtered out of sub-agent tool lists so only the
364
+ root can spawn.
365
+
366
+ ### Gateway URL integrity
367
+ `providers/gateway.ts` — `assertSafeGatewayUrl()` rejects any
368
+ `DIRGHA_GATEWAY_URL` that isn't HTTPS (localhost allowed). Prevents a
369
+ shell-rc injection from exfiltrating your bearer token to an attacker host.
370
+
371
+ ### Tool output sanitisation
372
+ `agent/tool-execution.ts` — `sanitizeToolFrameMarkers()` strips `<system>`,
373
+ `<|im_start|>`, Llama 3 chat headers, and Mistral `[INST]` markers from tool
374
+ outputs before they re-enter the context. Blocks prompt-injection via file
375
+ contents.
376
+
377
+ ### Permissions
378
+ `permission/` module — every tool tagged with a capability level
379
+ (`WorkspaceRead`, `WorkspaceWrite`, `SystemWrite`, `Network`). User can pin
380
+ the session to a capability level via `/security`. YOLO mode
381
+ (`--dangerously-skip-permissions` or `DIRGHA_YOLO=1`) disables checks for
382
+ trusted environments.
383
+
384
+ ### Capability tokens
385
+ `security/capabilityTokens.ts` — short-lived HMAC-signed tokens for
386
+ delegating tool access to sub-agents, scoped to specific paths / capabilities.
387
+
388
+ ## Headless & machine-readable — `--json` on every command
389
+
390
+ Every Dirgha command emits machine-readable JSON when `--json` is passed
391
+ (either at the root — `dirgha --json <cmd>` — or at the subcommand —
392
+ `dirgha <cmd> --json`). This is the CLI-Anything contract. Two-tier
393
+ implementation:
394
+
395
+ 1. **Universal capture** — stdout is intercepted for any command and
396
+ wrapped in the standard envelope on exit. Zero per-command changes.
397
+ 2. **Native emit** — commands that want to expose structured `data`
398
+ fields (like `dirgha hub list`, `dirgha fleet launch`) use the
399
+ `emit()` helper and set the natively-emitted flag so the wrapper
400
+ skips.
401
+
402
+ ```bash
403
+ dirgha status --json # account, quota, sessions
404
+ dirgha fleet list --json # all active worktrees + branches
405
+ dirgha hub search ollama --json
406
+ dirgha ask "explain this repo" --json
407
+ ```
408
+
409
+ The envelope shape:
410
+
411
+ ```json
412
+ {
413
+ "data": { "…": "command-specific structured payload" },
414
+ "text": "human-readable output (ANSI-stripped)",
415
+ "exitCode": 0,
416
+ "command": "fleet launch",
417
+ "timestamp": "2026-04-20T07:45:22.118Z",
418
+ "meta": { "durationMs": 27 }
419
+ }
420
+ ```
421
+
422
+ This is how you drive Dirgha from CI, other agents, IDE extensions, or
423
+ shell scripts. `dirgha __dump_spec` returns the full commander tree as
424
+ JSON for tooling/automation.
425
+
426
+ ## Slash commands (80+ in the TUI)
427
+
428
+ Available inside the interactive TUI. Open the modal help (`/help` —
429
+ type to filter, ↑↓ to scroll, `Esc` to close) or see
430
+ [`docs/COMMANDS.md`](./docs/COMMANDS.md) for the full reference. Grouped:
431
+
432
+ - **Session** — `/help`, `/status`, `/clear`, `/compact`, `/save`,
433
+ `/resume`, `/export`, `/summary`, `/cost`, `/tokens`, `/usage`
434
+ - **Auth & config** — `/login`, `/logout`, `/setup`, `/model`, `/keys`,
435
+ `/config`, `/theme`, `/soul`
436
+ - **Dev workflow** — `/spec`, `/plan`, `/review`, `/qa`, `/fix`,
437
+ `/refactor`, `/scaffold`, `/changes`, `/fast`, `/verbose`
438
+ - **Git** — `/diff`, `/commit`, `/stash`, `/push`, `/branch`, `/checkout`
439
+ - **Memory & knowledge** — `/memory`, `/remember`, `/recall`, `/curate`
440
+ - **Safety** — `/checkpoint`, `/rollback`, `/permissions`, `/yolo`,
441
+ `/approvals`, `/btw`
442
+ - **Skills & tools** — `/skills`, `/init`, `/scan`, `/secrets`
443
+ - **System** — `/verify`, `/doctor`
444
+ - **Integrations** — `/mcp`, `/voice`, `/cron`, `/net`, `/fs`, `/team`,
445
+ `/consensus`, `/screen`, `/drop`, `/undo`
446
+ - **Sprint engine** — `/sprint`, `/run`
447
+ - **Multi-agent** — `/side` (ephemeral sub-agent fork), `/orchestrate`
448
+
449
+ Auto-complete on partial entry — `/hel` expands to `/help`, `/sta` to
450
+ `/status`. `/side <prompt>` runs an isolated sub-agent that does NOT
451
+ pollute the main conversation history (Codex pattern, useful for quick
452
+ tangents).
453
+
454
+ ## Configuration surface
455
+
456
+ Everything lives in `~/.dirgha/`:
457
+
458
+ ```
459
+ ~/.dirgha/
460
+ ├── keys.json # BYOK keys (mode 0600), auto-loaded into env at boot
461
+ ├── credentials.json # Gateway login token (if signed in)
462
+ ├── config.json # Theme, defaults, feature flags
463
+ ├── sessions.db # SQLite — sessions, messages, memory, file index
464
+ ├── mcp.json # MCP server configurations
465
+ ├── hub/ # Installed plugins + cached registry
466
+ │ ├── plugins/
467
+ │ └── registry.json
468
+ ├── soul.md # Persistent context you want in every turn
469
+ ├── MEMORY.md # Legacy memory file (still read)
470
+ ├── crash.log # Last unclean exit transcript
471
+ └── transcripts/ # Full tool-execution transcripts for audit
472
+ ```
473
+
474
+ **Environment overrides (commonly useful):**
475
+
476
+ | Var | Effect |
477
+ |---|---|
478
+ | `DIRGHA_PROVIDER` | Pin provider (`nvidia`, `anthropic`, `openrouter`, …) |
479
+ | `DIRGHA_LOCAL_MODEL` | Pin model ID |
480
+ | `DIRGHA_GATEWAY_URL` | Override hosted gateway (HTTPS enforced) |
481
+ | `DIRGHA_ADMIN=1` | Admin mode — BYOK only, long retry budget, no cross-provider failover |
482
+ | `DIRGHA_YOLO=1` | Skip permission prompts (use in trusted shells only) |
483
+ | `DIRGHA_DEBUG=1` | Verbose dispatch + tool logs to stderr |
484
+ | `DIRGHA_PROFILE=1` | Per-turn timing breakdown |
485
+
486
+ ## Runtime & sandbox
487
+
488
+ `runtime/` implements the isolated execution environment for the
489
+ `execute_code` tool. It uses Node's VM module with:
490
+ - Network deny by default (`runtime/network-control.ts`)
491
+ - Filesystem mount scoping (`runtime/mount.ts`) — the sandbox only sees
492
+ directories explicitly mounted
493
+ - CPU + memory caps
494
+ - Transcript logging (`runtime/transcript.ts`) — everything executed is
495
+ recorded and can be replayed
496
+ - Multiplayer mode (`runtime/multiplayer.ts`) — shared sandbox sessions for
497
+ agent collaboration
498
+
499
+ ## Agent orchestration
500
+
501
+ `agent/orchestration/` provides the primitives behind `orchestrate` and
502
+ `spawn_agent`:
503
+
504
+ - **Agent pool** — pre-warmed workers, queue, auto-scaler, idle cleanup
505
+ - **DAG runner** — directed-acyclic-graph task execution with dependencies
506
+ - **Decomposer** — splits high-level goals into sub-tasks
507
+ - **Circuit breaker** — per-agent-type failure tracking
508
+ - **Structured results** — every agent returns a typed result shape
509
+ - **Scheduler** — priority queue, retries, back-off
510
+
511
+ The `swarm/` subsystem (14 files) is a higher-level orchestration primitive
512
+ for multi-agent collaboration patterns: `governance`, `templates`,
513
+ `collaboration`, `runtime` — used by `/team` and `/consensus` slash commands.
514
+
515
+ ## Voice
516
+
517
+ `voice/` (12 files) — optional voice-first mode. Desktop capture via system
518
+ audio, mobile bridge for remote dictation, Whisper-compatible transcription,
519
+ TTS playback via system voices or remote endpoints. `dirgha voice` starts
520
+ the voice loop; `dirgha voice-config` manages shortcuts and hotwords.
521
+
522
+ ## Knowledge engine
523
+
524
+ `knowledge/` (5 files) — Dirgha's local wiki. `dirgha knowledge sync --from
525
+ articles.jsonl` bulk-imports; `dirgha k search "<query>"` does FTS5 search
526
+ over the corpus; `dirgha k wiki` rebuilds the index. Backed by
527
+ `knowledge/compiler.ts` (markdown → searchable), `knowledge/linter.ts`
528
+ (link validation), `knowledge/git-sync.ts` (syncs knowledge files to a git
529
+ remote).
530
+
531
+ ## Source tree overview
532
+
533
+ ```
534
+ src/
535
+ ├── agent/ # Loop, context, compaction, dispatch glue, spawning
536
+ ├── commands/ # 80 commander.js subcommand handlers
537
+ ├── repl/ # TUI REPL shell, slash commands (30 files)
538
+ ├── tui/ # Ink/React 19 components (58 files)
539
+ ├── providers/ # 16 LLM adapters + dispatcher + circuit breaker
540
+ ├── tools/ # 43 built-in tool implementations
541
+ ├── runtime/ # Sandbox: VM, mounts, network control, transcripts
542
+ ├── memory/ # 4-tier memory: builtin, holographic, GEPA, graph
543
+ ├── swarm/ # Multi-agent collaboration patterns
544
+ ├── mcp/ # MCP client: stdio, SSE, HTTP transports
545
+ ├── hub/ # Plugin registry + installer + commands
546
+ ├── knowledge/ # Wiki, compiler, linter, git sync
547
+ ├── security/ # Capability tokens, safe shell, CSRF, scanner
548
+ ├── permission/ # Per-tool capability model
549
+ ├── billing/ # Client-side usage tracking
550
+ ├── session/ # SQLite persistence layer
551
+ ├── voice/ # Whisper + TTS + hotword
552
+ ├── browser/ # Browser automation helpers
553
+ ├── sprint/ # Sprint/recipe orchestration (critic, verifier, watchdog)
554
+ ├── checkpoint/ # Checkpoint/rollback primitives
555
+ ├── skills/ # Built-in skill prompts (plan, debug, review, …)
556
+ ├── extensions/ # Extension host + RPC
557
+ ├── evals/ # Built-in eval suite
558
+ └── utils/ # Credentials, keys, logger, health monitor, security boundary
559
+ ```
560
+
561
+ 59 test files ship alongside the source. Build is `esbuild`, single-file
562
+ output to `dist/dirgha.mjs` (~7.3 MB minified).
563
+
564
+ ## Sister projects in the Dirgha OS
565
+
566
+ This repo is one of five that make up the open-source surface of the Dirgha OS. Each repo stands on its own; together they compose a full stack for builders.
567
+
568
+ | Repo | What it does | License |
569
+ |---|---|---|
570
+ | [`creator-studio`](https://github.com/dirghaai/creator-studio) | Backend API for the creator economy. Monetization, campaigns, memberships, social integrations. | Apache-2.0 |
571
+ | [`writer-studio`](https://github.com/dirghaai/writer-studio) | Backend API for writing — science, fiction, screenplays, research. Binder + AI research + RAG. | Apache-2.0 |
572
+ | [`abundance-protocol`](https://github.com/dirghaai/abundance-protocol) | DePIN for distributed AI inference. Peer-to-peer compute, Lightning settlement, on-chain governance. | Apache-2.0 |
573
+ | [`arniko`](https://github.com/dirghaai/arniko) | AI security scanning. 36 scanner adapters unified into one stream of typed findings. | Apache-2.0 |
574
+
575
+ Visit the umbrella org at [github.com/dirghaai](https://github.com/dirghaai) or the product site at [dirgha.ai](https://dirgha.ai).
576
+
577
+ ## License
578
+
579
+ The Dirgha Code CLI is source-available under **FSL-1.1-MIT** and converts to **MIT** two years after each release. In practice: you can install, use, fork, modify, redistribute, and package it for your team or company today. The one restriction — no competing hosted service — expires automatically. Full rationale in [`LICENSING.md`](./LICENSING.md); quick summary at [dirgha.ai/license](https://dirgha.ai/license).
580
+
581
+ **Dirgha LLC owns the “Dirgha” name, logo, and product family** as registered trademarks. The code is open — the brand isn't. Forks of this repository must rename the product and remove Dirgha branding before distribution. Reasonable nominative use (“a fork of Dirgha Code”) is fine.
582
+
583
+ See [`LICENSE`](./LICENSE) and [`NOTICE.md`](./NOTICE.md) for the full legal text. Related documents:
584
+
585
+ - [`SECURITY.md`](./SECURITY.md) — vulnerability disclosure policy.
586
+ - [`CODE_OF_CONDUCT.md`](./CODE_OF_CONDUCT.md) — Contributor Covenant 2.1.
587
+ - [`SUPPORT.md`](./SUPPORT.md) — where to ask for help.
588
+ - [`CONTRIBUTING.md`](./CONTRIBUTING.md) — how to send a PR.
589
+ - [`LICENSING.md`](./LICENSING.md) — honest rationale for the FSL choice (why not pure MIT? bootstrapped, not VC-funded).
590
+
591
+ ## Troubleshooting
592
+
593
+ **`npm install` fails with peer-dep errors.** We align `marked` to the
594
+ major version `marked-terminal` accepts on every release — if you see
595
+ a conflict, you're probably on an older release. Either upgrade or
596
+ pass `--legacy-peer-deps` as a one-off.
597
+
598
+ **`dirgha` command not found after `npm install -g`.** Your npm global
599
+ `bin` path isn't on `PATH`. Check `npm bin -g` and either add that
600
+ directory to `PATH` or install with pnpm (`pnpm add -g @dirgha/code`).
601
+
602
+ **`better-sqlite3` build fails on Apple Silicon or Linux ARM.** You
603
+ need Xcode Command Line Tools (macOS) or `build-essential` + `python3`
604
+ (Linux). Then `npm rebuild better-sqlite3`.
605
+
606
+ **`dirgha` crashes with `Cannot find package 'libp2p'`.** libp2p is an
607
+ optional dep that only the experimental `mesh` command needs. Run
608
+ `npm install libp2p @libp2p/{tcp,noise,mplex,gossipsub}` if you're on
609
+ the experimental track; otherwise ignore.
610
+
611
+ **Node version warnings.** Minimum is Node 20. We run CI against 20
612
+ and 22. Earlier versions will not work.
613
+
614
+ **Commands like `dao`, `make`, `mesh` aren't in `--help`.** These are
615
+ experimental — run with `DIRGHA_EXPERIMENTAL=1` set.
616
+
617
+ **Seeing "models health" errors about unreachable gateway.** The
618
+ public gateway is at `https://api.dirgha.ai`. If you're offline or
619
+ behind a proxy, set `DIRGHA_API_URL` to a reachable endpoint or run
620
+ entirely in BYOK mode.
621
+
622
+ ## Contribute
623
+
624
+ - **Code** — fork, branch, PR against `main`. Recipes in [`CONTRIBUTING.md`](./CONTRIBUTING.md).
625
+ - **Bugs** — file an issue using the [bug template](https://github.com/dirghaai/dirgha-code/issues/new?template=bug.md).
626
+ - **Features** — file an issue using the [feature template](https://github.com/dirghaai/dirgha-code/issues/new?template=feature.md).
627
+ - **Questions** — open a [Discussion](https://github.com/dirghaai/dirgha-code/discussions) rather than an issue.
628
+ - **Security** — email `security@dirgha.ai`. Do NOT file a public issue for vulnerabilities.
629
+ - **Sponsor** — [dirgha.ai/contribute](https://dirgha.ai/contribute) · Lightning, GitHub Sponsors, OpenCollective.
630
+
631
+
632
+ ## Links
633
+
634
+ | | |
635
+ |---|---|
636
+ | Website | [https://dirgha.ai](https://dirgha.ai) |
637
+ | Repository | [github.com/dirghaai/dirgha-code](https://github.com/dirghaai/dirgha-code) |
638
+ | Issues | [github.com/dirghaai/dirgha-code/issues](https://github.com/dirghaai/dirgha-code/issues) |
639
+ | Discussions | [github.com/dirghaai/dirgha-code/discussions](https://github.com/dirghaai/dirgha-code/discussions) |
640
+ | Security | `security@dirgha.ai` |
641
+ | Enterprise | `enterprise@dirgha.ai` |
642
+ | Press / general | `hello@dirgha.ai` |
643
+
644
+ ---
645
+
646
+ **Dirgha Code** is part of the Dirgha OS — open-source infrastructure for builders, shipped by a small bootstrapped team.
647
+
648
+ Named for the Sanskrit *dīrgha* — “long-horizon.” The agent is built for work that spans hours, not turns.
649
+
650
+ Built by [Dirgha LLC](https://dirgha.ai) in India. Open to the world.
651
+
652
+ Released under **FSL-1.1-MIT** · Copyright © 2026 Dirgha LLC · All third-party trademarks are property of their owners.
653
+
654
+ ---
655
+
656
+ ## 🌐 The Dirgha Ecosystem
657
+
658
+ **[Dirgha AI OS](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS)** — the agentic operating system. *Accelerate Abundance.*
659
+
660
+ | Repo | What it does |
661
+ |---|---|
662
+ | [Rama-I-Dirgha-AI-OS](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS) | Vision, architecture, and the Rama I sovereign compute challenge |
663
+ | [abundance-protocol](https://github.com/Dirgha-AI/abundance-protocol) | P2P compute mesh for distributed AI inference |
664
+ | [arniko](https://github.com/Dirgha-AI/arniko) | Security scanner and red-teaming agent |
665
+ | [dirgha-code](https://github.com/Dirgha-AI/dirgha-code) | Autonomous software engineering CLI (`@dirgha/cli`) |
666
+ | [creator-studio](https://github.com/Dirgha-AI/creator-studio) | AI-native media production workspace |
667
+ | [writer-studio](https://github.com/Dirgha-AI/writer-studio) | AI-native document workspace |
668
+ | [.github](https://github.com/Dirgha-AI/.github) | Org profile and community configuration |
669
+
670
+ - **Live platform:** [dirgha.ai](https://dirgha.ai) — chat, IDE, writer, research, library, marketplace, creator, education, manufacturing
671
+ - **Organization:** [github.com/Dirgha-AI](https://github.com/Dirgha-AI)
672
+ - **Partnerships:** [partner@dirgha.ai](mailto:partner@dirgha.ai)
673
+
674
+ *Dirgha — Accelerate Abundance. Built in India, for the world.*