@cjhyy/code-shell 0.1.5 → 0.1.7

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 (158) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/anthropic-UBSB5AQH.js +1 -0
  3. package/dist/arena/index.js +1 -104
  4. package/dist/arena-OW55ZCHT.js +3 -0
  5. package/dist/bwrap-PVZMLHZR.js +2 -0
  6. package/dist/chunk-2NS3JMNK.js +1 -0
  7. package/dist/chunk-3QP5BQ3L.js +1 -0
  8. package/dist/chunk-B7K2OWKC.js +2 -0
  9. package/dist/chunk-EWWK56K6.js +2 -0
  10. package/dist/chunk-FU7AHZNN.js +1 -0
  11. package/dist/chunk-HIJ2XXGX.js +1 -0
  12. package/dist/chunk-KCXSARAA.js +1 -0
  13. package/dist/chunk-NFH3UQ3E.js +2 -0
  14. package/dist/chunk-NMBYBGC7.js +250 -0
  15. package/dist/chunk-NVAZJ5XS.js +2 -0
  16. package/dist/chunk-O5HFCH2U.js +1 -0
  17. package/dist/chunk-P6JSTIFM.js +1 -0
  18. package/dist/chunk-PGANL6F2.js +3 -0
  19. package/dist/chunk-Q4O2HGWS.js +251 -0
  20. package/dist/chunk-QTWU7UNA.js +5 -0
  21. package/dist/chunk-RP26WO4R.js +1 -0
  22. package/dist/chunk-SNFAPSLA.js +1 -0
  23. package/dist/chunk-T222K6IV.js +18 -0
  24. package/dist/chunk-TKJA6W36.js +3 -0
  25. package/dist/chunk-UDPUTFQT.js +2 -0
  26. package/dist/chunk-W47Z7MGS.js +33 -0
  27. package/dist/chunk-WI6FSWGU.js +1 -0
  28. package/dist/chunk-WOP6MJKW.js +1 -0
  29. package/dist/chunk-XDOWC7EG.js +4 -0
  30. package/dist/chunk-Y2NS6HPO.js +641 -0
  31. package/dist/cli/main.js +303 -22037
  32. package/dist/cli/updater.d.ts +8 -0
  33. package/dist/client-base-6ZZJJYDY.js +1 -0
  34. package/dist/compaction-ECVQVOCT.js +1 -0
  35. package/dist/devtools-SGDUOOM4.js +1 -0
  36. package/dist/engine/engine.d.ts +15 -0
  37. package/dist/export-md-U72T7NW7.js +22 -0
  38. package/dist/file-history-7FQFEQOL.js +1 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +1 -347
  41. package/dist/llm/token-counter.d.ts +17 -0
  42. package/dist/manager-C3TDN6MS.js +1 -0
  43. package/dist/mcp-manager-OP4XYV53.js +1 -0
  44. package/dist/memory-BNI4WEWL.js +1 -0
  45. package/dist/model-cache-HEDXI7UJ.js +1 -0
  46. package/dist/model-fetcher-BJ64META.js +1 -0
  47. package/dist/off-7SDVMMXW.js +1 -0
  48. package/dist/openai-KEWQ54TM.js +1 -0
  49. package/dist/openrouter-models-AM6M52D6.js +1 -0
  50. package/dist/openrouter-sync-5JNBL3Z6.js +1 -0
  51. package/dist/product/index.js +1 -21
  52. package/dist/run/index.js +1 -48
  53. package/dist/seatbelt-WBYROQT6.js +37 -0
  54. package/dist/session/session-manager.d.ts +2 -0
  55. package/dist/session-manager-AGWS5SMJ.js +1 -0
  56. package/dist/settings/schema.d.ts +72 -6
  57. package/dist/tool-summary-5UE62VU4.js +2 -0
  58. package/dist/tool-system/builtin/bash.d.ts +7 -1
  59. package/dist/tool-system/context.d.ts +7 -0
  60. package/dist/tool-system/investigation-guard.d.ts +9 -0
  61. package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
  62. package/dist/tool-system/sandbox/index.d.ts +71 -0
  63. package/dist/tool-system/sandbox/off.d.ts +2 -0
  64. package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
  65. package/dist/types.d.ts +4 -0
  66. package/dist/ui/components/SessionPicker.d.ts +2 -0
  67. package/dist/ui/components/SpinnerWithVerb.d.ts +2 -2
  68. package/dist/ui/components/StatusLine.d.ts +2 -2
  69. package/dist/updater-OCNU2K2Z.js +1 -0
  70. package/package.json +8 -10
  71. package/skills-builtin/codeshell-help.md +135 -0
  72. package/dist/anthropic-IBTI4WL2.cjs +0 -10
  73. package/dist/anthropic-PRZZKHEZ.js +0 -10
  74. package/dist/arena/index.cjs +0 -104
  75. package/dist/arena-KBQOPLFV.cjs +0 -261
  76. package/dist/arena-O2L4TN6A.js +0 -261
  77. package/dist/chunk-2EP3CLEN.js +0 -44
  78. package/dist/chunk-2YW4FPFG.cjs +0 -101
  79. package/dist/chunk-3OA5G4TM.js +0 -47
  80. package/dist/chunk-52LGZKT3.cjs +0 -47
  81. package/dist/chunk-55XGPMAP.cjs +0 -146
  82. package/dist/chunk-5ECBT4YA.js +0 -450
  83. package/dist/chunk-6QVAYW7C.cjs +0 -438
  84. package/dist/chunk-6S4BJ65N.js +0 -113
  85. package/dist/chunk-76HYEPDM.js +0 -307
  86. package/dist/chunk-76W334S4.js +0 -54
  87. package/dist/chunk-7EG3V4JY.cjs +0 -113
  88. package/dist/chunk-7JVTYEEC.js +0 -340
  89. package/dist/chunk-7K6SDRRF.js +0 -9047
  90. package/dist/chunk-7Y6S3OCX.js +0 -438
  91. package/dist/chunk-A5LCRPDP.cjs +0 -54
  92. package/dist/chunk-BSW22MPA.js +0 -146
  93. package/dist/chunk-BUU5PZK2.cjs +0 -9048
  94. package/dist/chunk-BWTOS5BH.cjs +0 -5128
  95. package/dist/chunk-BXCY2FSE.js +0 -203
  96. package/dist/chunk-C5YQBIRK.js +0 -5128
  97. package/dist/chunk-HEKQCI7B.cjs +0 -224
  98. package/dist/chunk-HS2MFNUC.cjs +0 -44
  99. package/dist/chunk-IK4EWJBP.cjs +0 -203
  100. package/dist/chunk-JMR33QVF.cjs +0 -169
  101. package/dist/chunk-KOVYSDHZ.cjs +0 -340
  102. package/dist/chunk-KS3RYAYL.cjs +0 -45
  103. package/dist/chunk-MD32R22I.js +0 -50
  104. package/dist/chunk-MY5XHADU.cjs +0 -216
  105. package/dist/chunk-NUNC3VFB.cjs +0 -307
  106. package/dist/chunk-QRM7IF2S.cjs +0 -4711
  107. package/dist/chunk-R47ROHGL.cjs +0 -298
  108. package/dist/chunk-RMYKO74M.js +0 -1252
  109. package/dist/chunk-SFXHZSRF.js +0 -101
  110. package/dist/chunk-SIHHIQLO.js +0 -224
  111. package/dist/chunk-SNT563K3.cjs +0 -107
  112. package/dist/chunk-T6VYG46N.js +0 -105
  113. package/dist/chunk-TUY2T5KP.cjs +0 -105
  114. package/dist/chunk-VIAGTYYW.js +0 -169
  115. package/dist/chunk-VYL4EFRC.cjs +0 -1252
  116. package/dist/chunk-W22P377T.js +0 -299
  117. package/dist/chunk-WASS5YWB.js +0 -215
  118. package/dist/chunk-XDIQWQJ4.js +0 -4711
  119. package/dist/chunk-YIQBXAYU.cjs +0 -264
  120. package/dist/chunk-YJ77GQK5.js +0 -107
  121. package/dist/chunk-YUI524OE.cjs +0 -450
  122. package/dist/chunk-ZBPSQCPU.js +0 -264
  123. package/dist/cli/main.cjs +0 -22133
  124. package/dist/client-base-HTF236ZD.cjs +0 -9
  125. package/dist/client-base-QKRKCOWB.js +0 -9
  126. package/dist/compaction-6VU2T643.js +0 -33
  127. package/dist/compaction-OKUNTCA7.cjs +0 -33
  128. package/dist/devtools-T2NIZBJK.cjs +0 -6
  129. package/dist/devtools-YXWHOVKR.js +0 -6
  130. package/dist/export-md-RXDW6F5W.cjs +0 -135
  131. package/dist/export-md-XXKZANW5.js +0 -135
  132. package/dist/file-history-KYPE3ECT.cjs +0 -7
  133. package/dist/file-history-LF4F7X26.js +0 -7
  134. package/dist/index.cjs +0 -347
  135. package/dist/manager-C2IUXKRC.js +0 -7
  136. package/dist/manager-YYKWYTRM.cjs +0 -7
  137. package/dist/mcp-manager-QMKWPBZ4.js +0 -8
  138. package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
  139. package/dist/memory-5LWZ6FI2.cjs +0 -9
  140. package/dist/memory-VIJLBAMQ.js +0 -9
  141. package/dist/model-cache-5KIYL5SL.js +0 -13
  142. package/dist/model-cache-OED3IM4R.cjs +0 -13
  143. package/dist/model-fetcher-HKGICACL.js +0 -8
  144. package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
  145. package/dist/openai-JR2WEKOF.js +0 -10
  146. package/dist/openai-YBTOET4O.cjs +0 -10
  147. package/dist/openrouter-models-OU4GRZQY.cjs +0 -15
  148. package/dist/openrouter-models-TGKDKY52.js +0 -15
  149. package/dist/openrouter-sync-BBHUM3R6.cjs +0 -11
  150. package/dist/openrouter-sync-UXUSJCIR.js +0 -11
  151. package/dist/product/index.cjs +0 -21
  152. package/dist/run/index.cjs +0 -48
  153. package/dist/session-manager-Q22BBMD3.js +0 -8
  154. package/dist/session-manager-XODQVL3C.cjs +0 -8
  155. package/dist/tool-summary-63DPIS7G.cjs +0 -31
  156. package/dist/tool-summary-NP5CDBKG.js +0 -31
  157. package/dist/updater-QW473OF4.cjs +0 -17
  158. package/dist/updater-VFUAHCVY.js +0 -17
@@ -219,16 +219,16 @@ export declare const SettingsSchema: z.ZodObject<{
219
219
  args?: string[] | undefined;
220
220
  headers?: Record<string, string> | undefined;
221
221
  command?: string | undefined;
222
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
223
222
  env?: Record<string, string> | undefined;
223
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
224
224
  }, {
225
225
  name: string;
226
226
  url?: string | undefined;
227
227
  args?: string[] | undefined;
228
228
  headers?: Record<string, string> | undefined;
229
229
  command?: string | undefined;
230
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
231
230
  env?: Record<string, string> | undefined;
231
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
232
232
  }>>>;
233
233
  instructions: z.ZodDefault<z.ZodObject<{
234
234
  fileName: z.ZodDefault<z.ZodString>;
@@ -303,6 +303,28 @@ export declare const SettingsSchema: z.ZodObject<{
303
303
  }, {
304
304
  format?: "text" | "json" | "jsonl" | "stream-json" | undefined;
305
305
  }>>;
306
+ /**
307
+ * OS-level sandbox for shell-tool execution. "auto" picks per platform:
308
+ * Seatbelt on macOS, bubblewrap on Linux when installed, otherwise off.
309
+ * Defaults are applied per Engine run depending on headless vs REPL —
310
+ * see Engine.run() and run.ts.
311
+ */
312
+ sandbox: z.ZodOptional<z.ZodObject<{
313
+ mode: z.ZodOptional<z.ZodEnum<["off", "auto", "seatbelt", "bwrap"]>>;
314
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
315
+ deniedReads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
316
+ network: z.ZodOptional<z.ZodEnum<["allow", "deny"]>>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
319
+ writableRoots?: string[] | undefined;
320
+ deniedReads?: string[] | undefined;
321
+ network?: "allow" | "deny" | undefined;
322
+ }, {
323
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
324
+ writableRoots?: string[] | undefined;
325
+ deniedReads?: string[] | undefined;
326
+ network?: "allow" | "deny" | undefined;
327
+ }>>;
306
328
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
307
329
  agent: z.ZodDefault<z.ZodObject<{
308
330
  preset: z.ZodDefault<z.ZodString>;
@@ -520,16 +542,16 @@ export declare const SettingsSchema: z.ZodObject<{
520
542
  args?: string[] | undefined;
521
543
  headers?: Record<string, string> | undefined;
522
544
  command?: string | undefined;
523
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
524
545
  env?: Record<string, string> | undefined;
546
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
525
547
  }, {
526
548
  name: string;
527
549
  url?: string | undefined;
528
550
  args?: string[] | undefined;
529
551
  headers?: Record<string, string> | undefined;
530
552
  command?: string | undefined;
531
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
532
553
  env?: Record<string, string> | undefined;
554
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
533
555
  }>>>;
534
556
  instructions: z.ZodDefault<z.ZodObject<{
535
557
  fileName: z.ZodDefault<z.ZodString>;
@@ -604,6 +626,28 @@ export declare const SettingsSchema: z.ZodObject<{
604
626
  }, {
605
627
  format?: "text" | "json" | "jsonl" | "stream-json" | undefined;
606
628
  }>>;
629
+ /**
630
+ * OS-level sandbox for shell-tool execution. "auto" picks per platform:
631
+ * Seatbelt on macOS, bubblewrap on Linux when installed, otherwise off.
632
+ * Defaults are applied per Engine run depending on headless vs REPL —
633
+ * see Engine.run() and run.ts.
634
+ */
635
+ sandbox: z.ZodOptional<z.ZodObject<{
636
+ mode: z.ZodOptional<z.ZodEnum<["off", "auto", "seatbelt", "bwrap"]>>;
637
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
638
+ deniedReads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
639
+ network: z.ZodOptional<z.ZodEnum<["allow", "deny"]>>;
640
+ }, "strip", z.ZodTypeAny, {
641
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
642
+ writableRoots?: string[] | undefined;
643
+ deniedReads?: string[] | undefined;
644
+ network?: "allow" | "deny" | undefined;
645
+ }, {
646
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
647
+ writableRoots?: string[] | undefined;
648
+ deniedReads?: string[] | undefined;
649
+ network?: "allow" | "deny" | undefined;
650
+ }>>;
607
651
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
608
652
  agent: z.ZodDefault<z.ZodObject<{
609
653
  preset: z.ZodDefault<z.ZodString>;
@@ -821,16 +865,16 @@ export declare const SettingsSchema: z.ZodObject<{
821
865
  args?: string[] | undefined;
822
866
  headers?: Record<string, string> | undefined;
823
867
  command?: string | undefined;
824
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
825
868
  env?: Record<string, string> | undefined;
869
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
826
870
  }, {
827
871
  name: string;
828
872
  url?: string | undefined;
829
873
  args?: string[] | undefined;
830
874
  headers?: Record<string, string> | undefined;
831
875
  command?: string | undefined;
832
- transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
833
876
  env?: Record<string, string> | undefined;
877
+ transport?: "stdio" | "sse" | "streamable-http" | "inprocess" | undefined;
834
878
  }>>>;
835
879
  instructions: z.ZodDefault<z.ZodObject<{
836
880
  fileName: z.ZodDefault<z.ZodString>;
@@ -905,6 +949,28 @@ export declare const SettingsSchema: z.ZodObject<{
905
949
  }, {
906
950
  format?: "text" | "json" | "jsonl" | "stream-json" | undefined;
907
951
  }>>;
952
+ /**
953
+ * OS-level sandbox for shell-tool execution. "auto" picks per platform:
954
+ * Seatbelt on macOS, bubblewrap on Linux when installed, otherwise off.
955
+ * Defaults are applied per Engine run depending on headless vs REPL —
956
+ * see Engine.run() and run.ts.
957
+ */
958
+ sandbox: z.ZodOptional<z.ZodObject<{
959
+ mode: z.ZodOptional<z.ZodEnum<["off", "auto", "seatbelt", "bwrap"]>>;
960
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
961
+ deniedReads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
962
+ network: z.ZodOptional<z.ZodEnum<["allow", "deny"]>>;
963
+ }, "strip", z.ZodTypeAny, {
964
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
965
+ writableRoots?: string[] | undefined;
966
+ deniedReads?: string[] | undefined;
967
+ network?: "allow" | "deny" | undefined;
968
+ }, {
969
+ mode?: "auto" | "off" | "seatbelt" | "bwrap" | undefined;
970
+ writableRoots?: string[] | undefined;
971
+ deniedReads?: string[] | undefined;
972
+ network?: "allow" | "deny" | undefined;
973
+ }>>;
908
974
  }, z.ZodTypeAny, "passthrough">>;
909
975
  export type ValidatedSettings = z.infer<typeof SettingsSchema>;
910
976
  export declare function validateSettings(raw: unknown): ValidatedSettings;
@@ -0,0 +1,2 @@
1
+ import {b}from'./chunk-B7K2OWKC.js';import {h,a}from'./chunk-3QP5BQ3L.js';h();var p='Generate a very brief (under 40 chars) summary of what these tools did. Use past tense, commit-subject style. Examples: "Read 3 config files", "Fixed import in auth.ts", "Searched for API endpoints". Respond with ONLY the summary text, nothing else.';async function d(r,a,l){if(r.length===0)return null;try{let e=[];for(let t=0;t<r.length;t++){let s=r[t],o=a[t],u=JSON.stringify(s.args).slice(0,200),c=(o?.result??o?.error??"").slice(0,300);e.push(`Tool: ${s.toolName}(${u}) \u2192 ${c}`);}return (await l(p,e.join(`
2
+ `)))?.trim()||null}catch(e){return b.warn("tool_summary.failed",{error:e.message}),null}}a(d,"generateToolUseSummary");export{d as generateToolUseSummary};
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Built-in Bash shell command execution tool.
3
+ *
4
+ * Spawns commands under an optional OS-level sandbox (Seatbelt on macOS,
5
+ * bubblewrap on Linux). The sandbox is selected by the Engine and handed
6
+ * down via ToolContext.sandbox. Without a sandbox we fall back to the
7
+ * historical behavior — plain shell spawn in the user's environment.
3
8
  */
9
+ import type { ToolContext } from "../context.js";
4
10
  import type { ToolDefinition } from "../../types.js";
5
11
  export declare const bashToolDef: ToolDefinition;
6
- export declare function bashTool(args: Record<string, unknown>): Promise<string>;
12
+ export declare function bashTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
@@ -16,6 +16,7 @@ import type { LLMConfig, StreamCallback } from "../types.js";
16
16
  import type { ModelPool } from "../llm/model-pool.js";
17
17
  import type { ToolRegistry } from "./registry.js";
18
18
  import type { AgentPresetName } from "../preset/index.js";
19
+ import type { SandboxBackend } from "./sandbox/index.js";
19
20
  /** One choice in a multiple-choice AskUserQuestion. */
20
21
  export interface AskUserChoice {
21
22
  label: string;
@@ -86,6 +87,12 @@ export interface ToolContext {
86
87
  askUser?: AskUserFn;
87
88
  /** Sub-agent spawner (Agent tool). Undefined → Agent tool unavailable. */
88
89
  subAgentSpawner?: SubAgentSpawner;
90
+ /**
91
+ * Active sandbox backend for the Bash tool. Undefined falls back to "off"
92
+ * (plain spawn). Headless runs default to an OS-level sandbox; the REPL
93
+ * defaults to off because a human is in the loop to approve commands.
94
+ */
95
+ sandbox?: SandboxBackend;
89
96
  /** Optional cancellation signal for the whole turn. */
90
97
  signal?: AbortSignal;
91
98
  }
@@ -28,6 +28,15 @@ export declare class InvestigationGuard {
28
28
  private turnHasText;
29
29
  private turnHasSideEffect;
30
30
  private lastReminderSilent;
31
+ /**
32
+ * Soft mode replaces hard blocks (3rd-read dedupe) with a stronger
33
+ * reminder. Used in headless runs (`code-shell run …`) where there is
34
+ * no human to retry the task, so an unattended automation should not
35
+ * be killed by the guard — it should still get the signal to change
36
+ * strategy, but the tool call goes through.
37
+ */
38
+ private softMode;
39
+ setSoftMode(soft: boolean): void;
31
40
  preToolCheck(call: ToolCall): GuardDecision | undefined;
32
41
  noteText(text: string | undefined): void;
33
42
  noteToolResult(_call: ToolCall, _result: ToolResult): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Linux bubblewrap backend.
3
+ *
4
+ * bwrap creates a fresh mount namespace, then bind-mounts only what we tell
5
+ * it. We bind / read-only and overlay writableRoots as read-write. PID,
6
+ * IPC, UTS, cgroup namespaces are unshared. Network is shared unless
7
+ * config.network === "deny".
8
+ *
9
+ * Sensitive directories listed in deniedReads are shadowed with a tmpfs so
10
+ * the inner process literally cannot see them even though `/` is mounted.
11
+ */
12
+ import type { SandboxBackend, SandboxConfig } from "./index.js";
13
+ export declare function createBwrapBackend(config: SandboxConfig): SandboxBackend;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Sandbox backends for shell command execution.
3
+ *
4
+ * We wrap Bash-tool commands in an OS-level sandbox so a misbehaving (or
5
+ * prompt-injected) model can't reach beyond the workspace. The sandbox runs
6
+ * the user's command inside an isolated process tree with restricted file
7
+ * and (optionally) network access. The Engine itself is NOT sandboxed; only
8
+ * the spawned shell is. File-editing tools (Edit/Write) keep going through
9
+ * the application-layer permission gate.
10
+ *
11
+ * Backends are platform-specific:
12
+ * - "seatbelt" macOS sandbox-exec, built into macOS, zero install
13
+ * - "bwrap" Linux bubblewrap, requires `apt install bubblewrap`
14
+ * - "off" passthrough, no sandboxing (current behavior)
15
+ *
16
+ * "auto" picks per platform at startup; falls back to "off" with a warning
17
+ * when no sandbox is available.
18
+ */
19
+ export type SandboxMode = "off" | "auto" | "seatbelt" | "bwrap";
20
+ export type SandboxNetworkPolicy = "allow" | "deny";
21
+ export interface SandboxConfig {
22
+ mode: SandboxMode;
23
+ writableRoots: string[];
24
+ deniedReads: string[];
25
+ network: SandboxNetworkPolicy;
26
+ }
27
+ export interface SandboxBackend {
28
+ /** Resolved backend name — "off" means no sandboxing. */
29
+ name: "off" | "seatbelt" | "bwrap";
30
+ /**
31
+ * Decide the binary + argv that should actually be spawned to run `command`
32
+ * under this sandbox. The shell still interprets `command`; we only swap
33
+ * the outer process.
34
+ */
35
+ wrap(command: string, opts: {
36
+ cwd: string;
37
+ shell: string;
38
+ }): {
39
+ file: string;
40
+ args: string[];
41
+ };
42
+ /**
43
+ * If `stderr` looks like a sandbox denial, return a short hint string that
44
+ * the Bash tool will append to its result so the model understands why.
45
+ */
46
+ hintForBlockedOutput?(stderr: string): string | undefined;
47
+ }
48
+ /**
49
+ * Detect which sandbox mechanisms are available on the current host. Used by
50
+ * "auto" mode and surfaced to the user via /sandbox status if desired.
51
+ */
52
+ export declare function detectSandboxCapabilities(): {
53
+ seatbelt: boolean;
54
+ bwrap: boolean;
55
+ };
56
+ /**
57
+ * Expand `~` and `${workspace}` placeholders against the live cwd and home.
58
+ */
59
+ export declare function expandPath(p: string, cwd: string): string;
60
+ export declare function expandConfig(config: SandboxConfig, cwd: string): SandboxConfig;
61
+ export declare function defaultSandboxConfig(mode?: SandboxMode): SandboxConfig;
62
+ /**
63
+ * Resolve the active backend given user config + the current host.
64
+ *
65
+ * "off" → off backend
66
+ * "seatbelt" → seatbelt if available, else throws (explicit choice)
67
+ * "bwrap" → bwrap if available, else throws
68
+ * "auto" → seatbelt on macOS, bwrap on Linux with bwrap installed,
69
+ * else off + console warning
70
+ */
71
+ export declare function resolveSandboxBackend(config: SandboxConfig, cwd: string): Promise<SandboxBackend>;
@@ -0,0 +1,2 @@
1
+ import type { SandboxBackend } from "./index.js";
2
+ export declare function createOffBackend(): SandboxBackend;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * macOS Seatbelt backend.
3
+ *
4
+ * Builds a sandbox-exec profile that:
5
+ * - Allows reading most of the filesystem (denying everything breaks tooling)
6
+ * - Denies reads of sensitive credential directories
7
+ * - Restricts writes to the workspace + writableRoots
8
+ * - Optionally denies outbound network
9
+ *
10
+ * The profile is written to a fresh temp file per command (cheap; users can
11
+ * have arbitrary writableRoots so we can't cache). The spawned process and
12
+ * its entire subprocess tree inherit the profile via XNU's sandbox framework.
13
+ *
14
+ * sandbox-exec is technically deprecated by Apple but remains the only
15
+ * working OS-level sandbox on macOS and is what Codex CLI / Cursor use today.
16
+ */
17
+ import type { SandboxBackend, SandboxConfig } from "./index.js";
18
+ export declare function createSeatbeltBackend(config: SandboxConfig): SandboxBackend;
package/dist/types.d.ts CHANGED
@@ -169,6 +169,7 @@ export interface TaskInfo {
169
169
  export type StreamEvent = {
170
170
  type: "session_started";
171
171
  sessionId: string;
172
+ promptTokens: number;
172
173
  } | {
173
174
  type: "stream_request_start";
174
175
  turnNumber: number;
@@ -176,6 +177,7 @@ export type StreamEvent = {
176
177
  } | {
177
178
  type: "text_delta";
178
179
  text: string;
180
+ tokens?: number;
179
181
  agentId?: string;
180
182
  } | {
181
183
  type: "tool_use_start";
@@ -258,6 +260,8 @@ export interface LLMResponse {
258
260
  export interface LLMStreamChunk {
259
261
  type: "text" | "tool_use_start" | "tool_use_delta" | "tool_use_end" | "stop";
260
262
  text?: string;
263
+ /** Token count for this text delta, when provider can compute it. */
264
+ tokens?: number;
261
265
  toolCall?: Partial<ToolCall>;
262
266
  stopReason?: string;
263
267
  }
@@ -1,6 +1,8 @@
1
1
  export interface SessionPickerEntry {
2
2
  sessionId: string;
3
3
  startedAt: number;
4
+ /** Last activity time — used to sort and display the row. */
5
+ lastActiveAt?: number;
4
6
  turnCount: number;
5
7
  preview?: string;
6
8
  cwd?: string;
@@ -5,9 +5,9 @@ import { type MutableRefObject } from "react";
5
5
  export type SpinnerMode = "responding" | "tool-use" | "thinking";
6
6
  interface SpinnerWithVerbProps {
7
7
  mode: SpinnerMode;
8
- streamingCharsRef?: MutableRefObject<number>;
8
+ streamingTokensRef?: MutableRefObject<number>;
9
9
  runStartRef?: MutableRefObject<number>;
10
10
  thinkingContent?: string;
11
11
  }
12
- export declare function SpinnerWithVerb({ mode, streamingCharsRef, runStartRef, thinkingContent, }: SpinnerWithVerbProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function SpinnerWithVerb({ mode, streamingTokensRef, runStartRef, thinkingContent, }: SpinnerWithVerbProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -17,8 +17,8 @@ interface StatusLineProps {
17
17
  maxContextTokens?: number;
18
18
  gitBranch?: string;
19
19
  isRunning?: boolean;
20
- streamingCharsRef?: MutableRefObject<number>;
20
+ streamingTokensRef?: MutableRefObject<number>;
21
21
  runStartRef?: MutableRefObject<number>;
22
22
  }
23
- export declare function StatusLine({ model, effort, tokens, cost, sessionId, baseContextTokens, maxContextTokens, gitBranch, isRunning, streamingCharsRef, runStartRef, }: StatusLineProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function StatusLine({ model, effort, tokens, cost, sessionId, baseContextTokens, maxContextTokens, gitBranch, isRunning, streamingTokensRef, runStartRef, }: StatusLineProps): import("react/jsx-runtime").JSX.Element;
24
24
  export {};
@@ -0,0 +1 @@
1
+ export{f as __internal,a as checkForUpdate,c as getAutoUpdateDisabledReason,e as getCurrentVersion,b as getUpdateAvailable,d as scheduleAutoInstallOnExit}from'./chunk-TKJA6W36.js';import'./chunk-3QP5BQ3L.js';
package/package.json CHANGED
@@ -1,31 +1,27 @@
1
1
  {
2
2
  "name": "@cjhyy/code-shell",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Code Shell — general-purpose agent orchestration framework with a terminal coding preset",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
6
+ "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
12
+ "import": "./dist/index.js"
14
13
  },
15
14
  "./run": {
16
15
  "types": "./dist/run/index.d.ts",
17
- "import": "./dist/run/index.js",
18
- "require": "./dist/run/index.cjs"
16
+ "import": "./dist/run/index.js"
19
17
  },
20
18
  "./arena": {
21
19
  "types": "./dist/arena/index.d.ts",
22
- "import": "./dist/arena/index.js",
23
- "require": "./dist/arena/index.cjs"
20
+ "import": "./dist/arena/index.js"
24
21
  },
25
22
  "./product": {
26
23
  "types": "./dist/product/index.d.ts",
27
- "import": "./dist/product/index.js",
28
- "require": "./dist/product/index.cjs"
24
+ "import": "./dist/product/index.js"
29
25
  },
30
26
  "./package.json": "./package.json"
31
27
  },
@@ -62,6 +58,7 @@
62
58
  "files": [
63
59
  "dist",
64
60
  "scripts/check-node.cjs",
61
+ "skills-builtin",
65
62
  "README.md",
66
63
  "LICENSE",
67
64
  "CHANGELOG.md"
@@ -94,6 +91,7 @@
94
91
  "emoji-regex": "^10.6.0",
95
92
  "get-east-asian-width": "^1.5.0",
96
93
  "glob": "^11.0.0",
94
+ "gpt-tokenizer": "^3.4.0",
97
95
  "indent-string": "^5.0.0",
98
96
  "lodash-es": "^4.17.23",
99
97
  "marked": "^17.0.5",
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: codeshell-help
3
+ description: Use when the user asks how to use code-shell itself — slash commands, login/model setup, settings.json keys, hooks, MCP servers, debugging flags, or "how do I X in code-shell". Skip for general programming questions.
4
+ when_to_use: User asks about code-shell features, configuration, slash commands, or runtime behavior. Not for code questions in the user's own project.
5
+ ---
6
+
7
+ # Using code-shell
8
+
9
+ You are running inside **code-shell**, a terminal coding agent. This skill answers user questions about code-shell itself. Quote sections directly where helpful. If a topic isn't covered, say so — don't invent commands.
10
+
11
+ ## Getting started
12
+
13
+ - `code-shell` — start an interactive REPL in the current directory.
14
+ - `code-shell run "<prompt>"` — one-shot non-interactive run, prints final answer and exits.
15
+ - `code-shell runs <sid>` — resume a saved session by id.
16
+ - First launch shows an onboarding flow that walks through provider + model setup.
17
+
18
+ ## Slash commands (run inside the REPL)
19
+
20
+ Type `/` and the menu appears. The full list:
21
+
22
+ ### Core
23
+ - `/help` — show the slash menu.
24
+ - `/exit` — quit the REPL.
25
+ - `/clear` — clear the conversation (keeps session id).
26
+ - `/compact` — manually trigger context compaction.
27
+ - `/status` — current model, effort, token usage, working dir.
28
+ - `/version` — code-shell version.
29
+ - `/cost` — token cost summary for the session.
30
+ - `/sid` — print the current session id.
31
+ - `/session` — open the session picker.
32
+ - `/resume` — resume the most recent session.
33
+ - `/diff` — show working-tree diff.
34
+ - `/tasks` — current task list (TaskCreate/TaskUpdate state).
35
+ - `/tools` — list available tools.
36
+ - `/memory` — open the per-project memory file.
37
+ - `/export markdown` — export the current conversation to a markdown file.
38
+
39
+ ### Models / providers
40
+ - `/login` — add a new provider + model via the unified ProviderModelFlow.
41
+ - `/logout` — remove a provider's stored credentials.
42
+ - `/model` — quick-switch the active model.
43
+ - `/models` — open the ModelManager (add, refresh, delete providers and models).
44
+
45
+ ### Configuration
46
+ - `/config` — open `settings.json` for the active scope.
47
+ - `/permissions` — manage tool permission rules.
48
+ - `/hooks` — list hooks configured in settings.
49
+ - `/mcp` — list and manage MCP servers.
50
+ - `/skills` — list discovered skills.
51
+ - `/effort` — set reasoning effort (low / medium / high) for reasoning models.
52
+
53
+ ### Git / review
54
+ - `/commit` — agent drafts a commit from staged changes.
55
+ - `/branch` — branch operations.
56
+ - `/review` — review pending changes.
57
+ - `/pr-comments` — fetch GitHub PR comments.
58
+ - `/autofix-pr` — apply review suggestions.
59
+ - `/security-review` — run a security-focused review of pending changes.
60
+
61
+ ### Misc
62
+ - `/init` — scaffold or refresh `CODESHELL.md` / project rules based on repo state.
63
+ - `/copy` — copy last response to clipboard.
64
+ - `/undo` — undo the most recent file edit done by the agent.
65
+ - `/update` — check for and install code-shell updates (auto-installs on exit when npm prefix is writable).
66
+ - `/log` — open the session log file.
67
+ - `/files` — list files the agent has touched this session.
68
+ - `/release-notes` — show CHANGELOG for the running version.
69
+ - `/feedback` — open the feedback URL.
70
+ - `/voice` — voice input (if enabled).
71
+
72
+ ## Provider + model setup
73
+
74
+ code-shell uses a **two-layer config**: `providers[]` holds credentials and base URLs; `models[]` references a provider by key.
75
+
76
+ - New users: `/login` runs the full wizard — pick provider kind (anthropic / openai / openrouter / deepseek / custom), enter API key, optional base URL, then pick a model from the fetched list.
77
+ - Existing users with the legacy flat `models[]` shape: auto-migrated on startup with a `.bak` snapshot written next to `settings.json`.
78
+ - Refresh a provider's model list: `/models` → select provider → Refresh. Cached for 7 days under `~/.code-shell/cache/`.
79
+
80
+ ## settings.json — key fields
81
+
82
+ Located at `~/.code-shell/settings.json` (user scope) or `.code-shell/settings.json` (project scope, takes precedence).
83
+
84
+ - `providers[]` — `[{ key, kind, baseUrl, apiKey }]`. Source of credentials.
85
+ - `models[]` — `[{ id, providerKey, displayName, contextLength, ... }]`.
86
+ - `model` — the default active model id.
87
+ - `autoUpdates` — `false` disables the background updater.
88
+ - `permissions` — allow/deny rules for the Bash tool and others.
89
+ - `hooks` — shell commands to run on events (SessionStart, PreToolUse, etc.).
90
+ - `mcpServers` — `{ name: { command, args, env } }` map of MCP servers.
91
+
92
+ ## Hooks
93
+
94
+ Hooks are shell commands the harness runs on events. Configured in `settings.json` under `hooks`. Common events: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`. Use them for automated behaviors ("each time X happens, run Y") — memory or preferences can't do this because the model doesn't fire actions on schedule, the harness does.
95
+
96
+ ## MCP servers
97
+
98
+ `code-shell` speaks the Model Context Protocol. Add servers in `settings.json` under `mcpServers`. Each entry is a stdio command code-shell spawns; its tools/resources become available to the agent automatically. List with `/mcp`.
99
+
100
+ ## Debugging
101
+
102
+ - `CODE_SHELL_DEV=1 code-shell` — dev mode: enables the per-session verbose recorder (JSONL traces under `log/<date>/session-<sid>.jsonl`, 7-day retention), disables auto-update, shows extra UI.
103
+ - `--debug` flag has the same effect as `CODE_SHELL_DEV=1`.
104
+ - Logs: `~/.code-shell/log/` for general logs; per-session JSONL traces appear there when dev mode is on.
105
+ - Investigation guard: re-reading the same file 3× is hard-blocked. 4+ consecutive read-only tool calls inject a "change strategy" reminder. This is intentional — break the loop, don't fight it.
106
+ - Update install log: `~/.code-shell/update.log`.
107
+
108
+ ## Memory
109
+
110
+ code-shell has a per-project memory system at `.code-shell/memory/` (relative to project root) and a global one at `~/.code-shell/memory/`. The `MEMORY.md` index is auto-loaded into context every session. Individual memory files are loaded on demand. Edit with `/memory` or directly.
111
+
112
+ ## Skills
113
+
114
+ Skills are markdown files with frontmatter that get discovered automatically. Locations scanned:
115
+ - `<cwd>/.code-shell/skills/` — project-level
116
+ - `<cwd>/.claude/skills/` — project-level (Claude Code compat)
117
+ - `~/.code-shell/skills/` — user-level
118
+ - `~/.claude/skills/` — user-level (Claude Code compat)
119
+ - Built-in skills shipped with the package (e.g. this one).
120
+
121
+ List discovered skills with `/skills`. Invoke a skill with the `Skill` tool by name. Frontmatter `description` tells the model when to use it.
122
+
123
+ ## Common questions
124
+
125
+ **"How do I switch models?"** — `/model <id>` or pick from `/models`.
126
+
127
+ **"How do I add a new provider?"** — `/login`, then follow the wizard. Or edit `settings.json` `providers[]` directly.
128
+
129
+ **"Why is auto-update not working?"** — `/update` shows the disabled reason. Common: dev build, `DISABLE_AUTOUPDATER=1`, `settings.autoUpdates: false`, or the npm global prefix isn't writable (use the shown `sudo` command).
130
+
131
+ **"Where's my session saved?"** — `~/.code-shell/sessions/<sid>/`. State, messages, and tool results all there.
132
+
133
+ **"How do I see what tools an agent has?"** — `/tools`.
134
+
135
+ **"How do I limit what Bash commands the agent can run?"** — `/permissions` or edit `settings.permissions` directly.
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkYIQBXAYUcjs = require('./chunk-YIQBXAYU.cjs');
4
- require('./chunk-7EG3V4JY.cjs');
5
- require('./chunk-2YW4FPFG.cjs');
6
- require('./chunk-IK4EWJBP.cjs');
7
- require('./chunk-KS3RYAYL.cjs');
8
-
9
-
10
- exports.AnthropicClient = _chunkYIQBXAYUcjs.AnthropicClient;
@@ -1,10 +0,0 @@
1
- import {
2
- AnthropicClient
3
- } from "./chunk-ZBPSQCPU.js";
4
- import "./chunk-6S4BJ65N.js";
5
- import "./chunk-SFXHZSRF.js";
6
- import "./chunk-BXCY2FSE.js";
7
- import "./chunk-MD32R22I.js";
8
- export {
9
- AnthropicClient
10
- };