@cjhyy/code-shell 0.1.0-alpha.3 → 0.1.6

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 (157) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/dist/anthropic-IBTI4WL2.cjs +10 -0
  3. package/dist/anthropic-PRZZKHEZ.js +10 -0
  4. package/dist/arena/index.cjs +7 -6
  5. package/dist/arena/index.js +6 -5
  6. package/dist/arena/model-presets.d.ts +10 -1
  7. package/dist/{arena-ENHBHB2W.js → arena-2LTLIXOL.js} +9 -7
  8. package/dist/{arena-HHDYYVHJ.cjs → arena-ADB7DRFI.cjs} +25 -23
  9. package/dist/{chunk-EL2RL5DG.cjs → chunk-2YW4FPFG.cjs} +2 -2
  10. package/dist/chunk-3OA5G4TM.js +47 -0
  11. package/dist/{chunk-FPFTIKEJ.js → chunk-3QO25N6E.js} +131 -173
  12. package/dist/chunk-3SBSUOWZ.js +447 -0
  13. package/dist/chunk-52LGZKT3.cjs +47 -0
  14. package/dist/{chunk-KOGV6PDQ.cjs → chunk-55XGPMAP.cjs} +44 -9
  15. package/dist/{chunk-YD7XTI7T.cjs → chunk-6QVAYW7C.cjs} +116 -28
  16. package/dist/{chunk-SCDKLTN3.js → chunk-6S4BJ65N.js} +5 -4
  17. package/dist/{chunk-ZLPJJZUW.js → chunk-76HYEPDM.js} +2 -2
  18. package/dist/chunk-7BI3V74Y.cjs +447 -0
  19. package/dist/{chunk-GZBD6QRS.cjs → chunk-7EG3V4JY.cjs} +13 -12
  20. package/dist/{chunk-LMEKCQX4.js → chunk-7JVTYEEC.js} +6 -6
  21. package/dist/{chunk-SW3L7HIM.js → chunk-7QIM3BKD.js} +2 -2
  22. package/dist/{chunk-5C5HIOML.js → chunk-7Y6S3OCX.js} +109 -21
  23. package/dist/{chunk-REFCCVDM.js → chunk-ABRRONJ7.js} +2 -2
  24. package/dist/{chunk-F5BS3GUC.js → chunk-BSW22MPA.js} +39 -4
  25. package/dist/{chunk-ZRVPCXI7.js → chunk-BXCY2FSE.js} +2 -1
  26. package/dist/{chunk-Y7TSCDF6.js → chunk-BZ5TNE7L.js} +347 -6
  27. package/dist/{chunk-X2DNIMPC.cjs → chunk-DDB6QOKJ.cjs} +32 -32
  28. package/dist/{chunk-C7C7ZZY4.cjs → chunk-HEKQCI7B.cjs} +10 -10
  29. package/dist/{chunk-JHNCK7JP.cjs → chunk-IK4EWJBP.cjs} +4 -3
  30. package/dist/{chunk-3CAZIWUA.cjs → chunk-ILHE7XLT.cjs} +9 -9
  31. package/dist/{chunk-M2QI5X3X.cjs → chunk-JMR33QVF.cjs} +2 -2
  32. package/dist/{chunk-TDXBHD24.js → chunk-KAQHULYN.js} +2 -2
  33. package/dist/chunk-KE4EQOWA.js +294 -0
  34. package/dist/{chunk-YAFCN7ZW.cjs → chunk-KOVYSDHZ.cjs} +15 -15
  35. package/dist/{chunk-IJSHQGMP.cjs → chunk-KS3RYAYL.cjs} +4 -4
  36. package/dist/{chunk-DI7RDLOS.js → chunk-MD32R22I.js} +7 -4
  37. package/dist/chunk-MV7YI4WO.cjs +293 -0
  38. package/dist/chunk-MY5XHADU.cjs +216 -0
  39. package/dist/{chunk-OP57WUWQ.cjs → chunk-NUNC3VFB.cjs} +6 -6
  40. package/dist/{chunk-ID6EJUHP.js → chunk-PKGRTCCY.js} +1307 -212
  41. package/dist/{chunk-OUC2DFA7.js → chunk-QARL3IDQ.js} +3 -3
  42. package/dist/{chunk-VIPLU4RY.cjs → chunk-S754JHLR.cjs} +4 -4
  43. package/dist/{chunk-FUOKLKR2.js → chunk-SFXHZSRF.js} +1 -1
  44. package/dist/{chunk-2EUAE7AY.js → chunk-SIHHIQLO.js} +2 -2
  45. package/dist/{chunk-SK62UVS6.js → chunk-T6VYG46N.js} +1 -1
  46. package/dist/{chunk-JHXNOB5G.cjs → chunk-TNLGBJYS.cjs} +6 -6
  47. package/dist/{chunk-3QR52LL5.cjs → chunk-TUY2T5KP.cjs} +2 -2
  48. package/dist/{chunk-VWFET3MG.cjs → chunk-UXOCVJJ6.cjs} +1519 -424
  49. package/dist/{chunk-I57ZD5IQ.js → chunk-VIAGTYYW.js} +1 -1
  50. package/dist/chunk-WASS5YWB.js +215 -0
  51. package/dist/{chunk-HOXQLX5R.cjs → chunk-WZJV6DJC.cjs} +444 -103
  52. package/dist/{chunk-BUJ5KYCI.cjs → chunk-YIQBXAYU.cjs} +13 -13
  53. package/dist/{chunk-BF4LXLQV.cjs → chunk-YKIAELDZ.cjs} +132 -174
  54. package/dist/{chunk-M2SVOKC6.js → chunk-ZBPSQCPU.js} +6 -6
  55. package/dist/cli/commands/builtin/export-md.d.ts +19 -0
  56. package/dist/cli/commands/builtin/init/detect.d.ts +25 -0
  57. package/dist/cli/commands/builtin/init/index.d.ts +19 -0
  58. package/dist/cli/main.cjs +2372 -1453
  59. package/dist/cli/main.js +2502 -1583
  60. package/dist/cli/migrate-models.d.ts +45 -0
  61. package/dist/cli/onboarding.d.ts +110 -5
  62. package/dist/cli/updater.d.ts +59 -4
  63. package/dist/client-base-HTF236ZD.cjs +9 -0
  64. package/dist/client-base-QKRKCOWB.js +9 -0
  65. package/dist/{compaction-YNWCEF7B.js → compaction-6VU2T643.js} +4 -2
  66. package/dist/compaction-OKUNTCA7.cjs +33 -0
  67. package/dist/context/compaction.d.ts +35 -3
  68. package/dist/context/manager.d.ts +40 -3
  69. package/dist/context/tool-result-storage.d.ts +96 -0
  70. package/dist/devtools-T2NIZBJK.cjs +6 -0
  71. package/dist/{devtools-IRQQPIRY.js → devtools-YXWHOVKR.js} +1 -1
  72. package/dist/engine/engine.d.ts +47 -0
  73. package/dist/engine/turn-loop.d.ts +6 -0
  74. package/dist/export-md-RXDW6F5W.cjs +135 -0
  75. package/dist/export-md-XXKZANW5.js +135 -0
  76. package/dist/file-history-KYPE3ECT.cjs +7 -0
  77. package/dist/file-history-LF4F7X26.js +7 -0
  78. package/dist/index.cjs +42 -22
  79. package/dist/index.d.ts +5 -2
  80. package/dist/index.js +38 -18
  81. package/dist/llm/client-base.d.ts +1 -1
  82. package/dist/llm/model-cache.d.ts +21 -0
  83. package/dist/llm/model-fetcher.d.ts +29 -0
  84. package/dist/llm/model-pool.d.ts +13 -0
  85. package/dist/llm/provider-catalog.d.ts +30 -0
  86. package/dist/llm/provider-kinds.d.ts +21 -0
  87. package/dist/llm/types.d.ts +8 -0
  88. package/dist/logging/session-recorder.d.ts +77 -0
  89. package/dist/manager-D65VFAPX.js +7 -0
  90. package/dist/manager-TTF5VHJC.cjs +7 -0
  91. package/dist/mcp-manager-QMKWPBZ4.js +8 -0
  92. package/dist/mcp-manager-Z3OKI74O.cjs +8 -0
  93. package/dist/memory-5LWZ6FI2.cjs +9 -0
  94. package/dist/{memory-EPFDBPII.js → memory-VIJLBAMQ.js} +2 -2
  95. package/dist/model-cache-5KIYL5SL.js +13 -0
  96. package/dist/model-cache-OED3IM4R.cjs +13 -0
  97. package/dist/model-fetcher-HKGICACL.js +8 -0
  98. package/dist/model-fetcher-UR6WJOQP.cjs +8 -0
  99. package/dist/openai-JR2WEKOF.js +10 -0
  100. package/dist/openai-YBTOET4O.cjs +10 -0
  101. package/dist/{openrouter-models-2FM3H4SQ.js → openrouter-models-H56GHBHN.js} +2 -2
  102. package/dist/openrouter-models-TWUFWZ5T.cjs +15 -0
  103. package/dist/openrouter-sync-5VMGN6C2.cjs +11 -0
  104. package/dist/{openrouter-sync-SO3AWEAM.js → openrouter-sync-ALEMF5IU.js} +3 -3
  105. package/dist/product/index.cjs +17 -15
  106. package/dist/product/index.js +16 -14
  107. package/dist/protocol/server.d.ts +3 -1
  108. package/dist/protocol/types.d.ts +36 -2
  109. package/dist/run/index.cjs +17 -15
  110. package/dist/run/index.js +16 -14
  111. package/dist/services/index.d.ts +0 -1
  112. package/dist/session-manager-Q22BBMD3.js +8 -0
  113. package/dist/session-manager-XODQVL3C.cjs +8 -0
  114. package/dist/settings/schema.d.ts +267 -42
  115. package/dist/{tool-summary-RYNR4DDB.cjs → tool-summary-63DPIS7G.cjs} +4 -4
  116. package/dist/{tool-summary-2RUFL5QK.js → tool-summary-NP5CDBKG.js} +2 -2
  117. package/dist/tool-system/builtin/ask-user.d.ts +9 -1
  118. package/dist/tool-system/context.d.ts +31 -2
  119. package/dist/tool-system/executor.d.ts +4 -0
  120. package/dist/tool-system/investigation-guard.d.ts +46 -0
  121. package/dist/types.d.ts +13 -2
  122. package/dist/ui/components/AskUserPrompt.d.ts +8 -1
  123. package/dist/ui/components/DiffLine.d.ts +33 -0
  124. package/dist/ui/components/ModelManager.d.ts +34 -1
  125. package/dist/ui/components/OnboardingPrompt.d.ts +10 -1
  126. package/dist/ui/components/ProviderModelFlow.d.ts +58 -0
  127. package/dist/ui/components/UpdateBanner.d.ts +1 -0
  128. package/dist/updater-I7QBW4DP.cjs +17 -0
  129. package/dist/updater-NVME5S3Z.js +17 -0
  130. package/dist/utils/semver.d.ts +1 -0
  131. package/dist/utils/task-sanitizer.d.ts +6 -0
  132. package/package.json +2 -1
  133. package/skills-builtin/codeshell-help.md +135 -0
  134. package/dist/anthropic-P5VETAFI.cjs +0 -10
  135. package/dist/anthropic-W2GU3D76.js +0 -10
  136. package/dist/chunk-75E4BBFC.js +0 -224
  137. package/dist/chunk-FV2ARONZ.cjs +0 -224
  138. package/dist/client-base-TOVE25FA.js +0 -9
  139. package/dist/client-base-VDDIADAC.cjs +0 -9
  140. package/dist/compaction-D3KV2NWY.cjs +0 -31
  141. package/dist/devtools-WTC3NFNE.cjs +0 -6
  142. package/dist/file-history-HZWO2WQ5.js +0 -7
  143. package/dist/file-history-UQQILIY7.cjs +0 -7
  144. package/dist/manager-FWLOVEEK.cjs +0 -7
  145. package/dist/manager-GEXJLOIS.js +0 -7
  146. package/dist/mcp-manager-37GQLFGX.js +0 -8
  147. package/dist/mcp-manager-U77NEXBY.cjs +0 -8
  148. package/dist/memory-ADGOWADP.cjs +0 -9
  149. package/dist/openai-RXU5URYI.js +0 -10
  150. package/dist/openai-SQW4H2K4.cjs +0 -10
  151. package/dist/openrouter-models-PLCWZZYE.cjs +0 -15
  152. package/dist/openrouter-sync-K2WK3A2A.cjs +0 -11
  153. package/dist/services/compact.d.ts +0 -56
  154. package/dist/session-manager-HRSKENKB.cjs +0 -8
  155. package/dist/session-manager-NEKFEHF3.js +0 -8
  156. package/dist/updater-J7L7R6BY.cjs +0 -185
  157. package/dist/updater-LDBNYCAO.js +0 -185
@@ -16,8 +16,37 @@ 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
- /** Function the host UI / server uses to ask the user a question. */
20
- export type AskUserFn = (question: string) => Promise<string>;
19
+ /** One choice in a multiple-choice AskUserQuestion. */
20
+ export interface AskUserChoice {
21
+ label: string;
22
+ description: string;
23
+ }
24
+ /**
25
+ * Optional rendering hints / multiple-choice options carried alongside the
26
+ * question. Implementations may ignore unknown fields — they're additive.
27
+ */
28
+ export interface AskUserOptions {
29
+ /** Short chip-style label (≤12 chars) shown above the question. */
30
+ header?: string;
31
+ /** Multiple-choice options. When omitted, the UI falls back to free-text. */
32
+ options?: AskUserChoice[];
33
+ /** Allow the user to pick more than one option. Defaults to false. */
34
+ multiSelect?: boolean;
35
+ }
36
+ /**
37
+ * Function the host UI / server uses to ask the user a question.
38
+ *
39
+ * Second argument is optional for backwards compatibility — callers that
40
+ * only need free text can omit it; backends that don't support options
41
+ * should ignore the field and prompt for free text.
42
+ *
43
+ * Return value:
44
+ * - Free-text mode: the user's typed answer (or "(user declined to answer)").
45
+ * - Multiple-choice mode: the selected label, or comma-separated labels for
46
+ * multiSelect, or "Other: <typed>" when the user picks the implicit
47
+ * Other... entry.
48
+ */
49
+ export type AskUserFn = (question: string, opts?: AskUserOptions) => Promise<string>;
21
50
  /** Spawn a sub-agent. Returns the produced text or throws. */
22
51
  export interface SubAgentSpawnRequest {
23
52
  agentId: string;
@@ -7,6 +7,7 @@ import { ToolRegistry } from "./registry.js";
7
7
  import { PermissionClassifier } from "./permission.js";
8
8
  import { logger as rootLogger } from "../logging/logger.js";
9
9
  import type { ToolContext } from "./context.js";
10
+ import type { InvestigationGuard } from "./investigation-guard.js";
10
11
  type Logger = typeof rootLogger;
11
12
  export declare class ToolExecutor {
12
13
  private readonly registry;
@@ -21,7 +22,10 @@ export declare class ToolExecutor {
21
22
  * (tests, ad-hoc tool runs) still write log lines, just without turn tags.
22
23
  */
23
24
  private log;
25
+ private guard?;
24
26
  constructor(registry: ToolRegistry, permission: PermissionClassifier, hooks: HookRegistry);
27
+ setInvestigationGuard(guard: InvestigationGuard | undefined): void;
28
+ getInvestigationGuard(): InvestigationGuard | undefined;
25
29
  /** Set the abort signal for cascading cancellation. */
26
30
  setSignal(signal?: AbortSignal): void;
27
31
  /** Set the per-Engine ToolContext (askUser, llmConfig, modelPool, etc.). */
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Investigation Guard — runtime enforcement of read budgets.
3
+ *
4
+ * Background: prompt rules in coding.md ("never re-read the same file",
5
+ * "after ~3 read-only calls, change strategy") describe a behavior the model
6
+ * frequently violates under context pressure. This module turns those soft
7
+ * rules into in-loop reminders/blocks delivered through tool results.
8
+ *
9
+ * Three independent counters share one guard instance per Engine:
10
+ * A) dedupe — same Read offset hit ≥2 times → reminder; ≥3 times → block
11
+ * B) read-budget — N consecutive read-only tools with no side-effecting
12
+ * tool in between → reminder on the next read
13
+ * C) silent turns — N consecutive turns of only read-only tools with no
14
+ * text output → injected into the *next* turn's user
15
+ * message by turn-loop (the guard just tracks state).
16
+ *
17
+ * Everything decays naturally on any write/Bash/AskUser tool (state reset).
18
+ */
19
+ import type { ToolCall, ToolResult } from "../types.js";
20
+ export interface GuardDecision {
21
+ block?: string;
22
+ prepend?: string;
23
+ }
24
+ export declare class InvestigationGuard {
25
+ private readHistory;
26
+ private consecutiveReads;
27
+ private silentTurns;
28
+ private turnHasText;
29
+ private turnHasSideEffect;
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;
40
+ preToolCheck(call: ToolCall): GuardDecision | undefined;
41
+ noteText(text: string | undefined): void;
42
+ noteToolResult(_call: ToolCall, _result: ToolResult): void;
43
+ turnEnded(turnNumber: number): string | undefined;
44
+ private isMutatingTool;
45
+ private buildKey;
46
+ }
package/dist/types.d.ts CHANGED
@@ -65,7 +65,14 @@ export interface TranscriptEvent {
65
65
  turnNumber: number;
66
66
  data: Record<string, unknown>;
67
67
  }
68
- export type SessionStatus = "active" | "paused" | "completed" | "errored";
68
+ /**
69
+ * Session lifecycle state persisted in state.json. `"active"` means a run is
70
+ * currently in flight (or was, at the moment of the last heartbeat). All other
71
+ * values match the {@link TerminalReason} the last run returned, so callers
72
+ * can distinguish a user-cancelled session (`"aborted_streaming"`) from an
73
+ * actual error (`"model_error"`, `"prompt_too_long"`, ...).
74
+ */
75
+ export type SessionStatus = "active" | "paused" | TerminalReason;
69
76
  export interface SessionState {
70
77
  sessionId: string;
71
78
  cwd: string;
@@ -219,10 +226,14 @@ export type StreamEvent = {
219
226
  summary: string;
220
227
  } | {
221
228
  type: "context_compact";
222
- strategy: "summary" | "window" | "snip" | "emergency";
229
+ strategy: "micro" | "summary" | "window" | "snip" | "emergency";
223
230
  before: number;
224
231
  after: number;
225
232
  agentId?: string;
233
+ } | {
234
+ type: "usage_update";
235
+ promptTokens: number;
236
+ agentId?: string;
226
237
  };
227
238
  export type StreamCallback = (event: StreamEvent) => void | Promise<void>;
228
239
  export interface LLMConfig {
@@ -1,7 +1,14 @@
1
+ interface Choice {
2
+ label: string;
3
+ description: string;
4
+ }
1
5
  interface AskUserPromptProps {
2
6
  question: string;
7
+ header?: string;
8
+ options?: Choice[];
9
+ multiSelect?: boolean;
3
10
  onAnswer: (answer: string) => void;
4
11
  onCancel: () => void;
5
12
  }
6
- export declare function AskUserPrompt({ question, onAnswer, onCancel }: AskUserPromptProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function AskUserPrompt({ question, header, options, multiSelect, onAnswer, onCancel, }: AskUserPromptProps): import("react/jsx-runtime").JSX.Element;
7
14
  export {};
@@ -0,0 +1,33 @@
1
+ export type DiffKind = "add" | "remove" | "hunk" | "context";
2
+ interface DiffLineProps {
3
+ kind: DiffKind;
4
+ /** Raw text WITHOUT the `+ ` / `- ` prefix — DiffLine renders the marker. */
5
+ text: string;
6
+ /**
7
+ * Left indent applied before the marker (and before the gutter, if any).
8
+ * Defaults to 0; ToolCallResult passes its own padding so diff blocks
9
+ * line up under the `✓ ToolName` header.
10
+ */
11
+ indent?: number;
12
+ /**
13
+ * Optional dim leading glyph rendered before the colored band (e.g. the
14
+ * `⎿ ` connector ToolCallResult uses to group output under its header).
15
+ * Padding to terminal width accounts for the glyph so the band still
16
+ * extends to the right edge.
17
+ */
18
+ gutter?: string;
19
+ }
20
+ export declare function DiffLine({ kind, text, indent, gutter }: DiffLineProps): import("react/jsx-runtime").JSX.Element;
21
+ /**
22
+ * Classify a raw diff text line. Matches `+\s` / `-\s` (so `+x` identifiers
23
+ * and `+++ / ---` file headers don't trip it), `@@` hunk markers, and falls
24
+ * through to context.
25
+ *
26
+ * Returns the kind and the text with its marker stripped (since `<DiffLine>`
27
+ * re-renders the marker itself).
28
+ */
29
+ export declare function classifyDiffLine(raw: string): {
30
+ kind: DiffKind;
31
+ text: string;
32
+ };
33
+ export {};
@@ -15,10 +15,29 @@ export type ArenaParticipantEntry = {
15
15
  kind: "object";
16
16
  label: string;
17
17
  };
18
+ /**
19
+ * Row data shown in the Providers tab. Counts/timestamps are derived by the
20
+ * parent from settings.providers[] + the model cache so this component stays
21
+ * presentational.
22
+ */
23
+ export interface ProviderManagerEntry {
24
+ key: string;
25
+ label: string;
26
+ kind: string;
27
+ modelCount: number;
28
+ cachedModels?: number;
29
+ cachedAt?: string;
30
+ baseUrl?: string;
31
+ apiKey?: string;
32
+ protocol?: string;
33
+ modelsPath?: string;
34
+ }
18
35
  interface ModelManagerProps {
19
36
  entries: ProtocolModelEntry[];
20
37
  snapshot: SnapshotInfo;
21
38
  arenaParticipants: ArenaParticipantEntry[];
39
+ /** Providers configured in settings.providers[] (Task 11+). */
40
+ providers?: ProviderManagerEntry[];
22
41
  /** Activate a model. */
23
42
  onSwitch: (key: string) => Promise<void>;
24
43
  /** Trigger an OpenRouter snapshot refresh. */
@@ -29,7 +48,21 @@ interface ModelManagerProps {
29
48
  }>;
30
49
  /** Persist updated participant list (string[]) to settings. */
31
50
  onSaveArena: (participants: string[]) => Promise<void>;
51
+ /** Open the parent-rendered ProviderModelFlow (covers both add-provider and add-model). */
52
+ onOpenFlow?: () => void;
53
+ /** Force-refresh a provider's cached model list. */
54
+ onRefreshProvider?: (key: string) => Promise<{
55
+ count: number;
56
+ error?: string;
57
+ }>;
58
+ /** Delete a provider (blocked if any model references it). */
59
+ onDeleteProvider?: (key: string) => Promise<{
60
+ ok: boolean;
61
+ error?: string;
62
+ }>;
63
+ /** Delete a model entry. */
64
+ onDeleteModel?: (key: string) => Promise<void>;
32
65
  onClose: () => void;
33
66
  }
34
- export declare function ModelManager({ entries, snapshot, arenaParticipants, onSwitch, onSync, onSaveArena, onClose, }: ModelManagerProps): import("react/jsx-runtime").JSX.Element;
67
+ export declare function ModelManager({ entries, snapshot, arenaParticipants, providers, onSwitch, onSync, onSaveArena, onOpenFlow, onRefreshProvider, onDeleteProvider, onDeleteModel, onClose, }: ModelManagerProps): import("react/jsx-runtime").JSX.Element;
35
68
  export {};
@@ -1,7 +1,16 @@
1
1
  import { type OnboardingResult } from "../../cli/onboarding.js";
2
+ import type { ProviderConfig } from "../../llm/provider-catalog.js";
2
3
  interface OnboardingPromptProps {
3
4
  onComplete: (result: OnboardingResult) => void;
4
5
  onCancel: () => void;
6
+ /** Existing providers — surfaces "Use existing" in the flow's first step.
7
+ * Optional: empty by default (first-run case). */
8
+ existingProviders?: ProviderConfig[];
9
+ /** Existing model aliases — used by the flow to derive unique aliases. */
10
+ existingModelKeys?: string[];
11
+ /** Model ids already in settings.models[] — used by the flow to disable
12
+ * rows for models the user has already added. */
13
+ existingModelIds?: string[];
5
14
  }
6
- export declare function OnboardingPrompt({ onComplete, onCancel }: OnboardingPromptProps): import("react/jsx-runtime").JSX.Element | null;
15
+ export declare function OnboardingPrompt({ onComplete, onCancel, existingProviders, existingModelKeys, existingModelIds, }: OnboardingPromptProps): import("react/jsx-runtime").JSX.Element | null;
7
16
  export {};
@@ -0,0 +1,58 @@
1
+ import { type ProviderKindName } from "../../llm/provider-kinds.js";
2
+ import type { ProviderConfig } from "../../llm/provider-catalog.js";
3
+ export interface EnvKeyHint {
4
+ envKey: string;
5
+ apiKey: string;
6
+ kindHint: ProviderKindName;
7
+ }
8
+ export interface FlowResult {
9
+ addedProvider?: ProviderConfig;
10
+ /**
11
+ * Self-describing model entries — credentials are duplicated from the
12
+ * provider on purpose. The engine reads these without a ProviderCatalog
13
+ * round-trip; providers[] is kept only as a credential source for the
14
+ * wizard's future "add model to existing provider" flow.
15
+ */
16
+ addedModels: Array<{
17
+ key: string;
18
+ label?: string;
19
+ providerKey: string;
20
+ /** LLM client/protocol ("openai"/"anthropic"). */
21
+ protocol: string;
22
+ /** Legacy mirror of `protocol` for downstream readers that still query it. */
23
+ provider: string;
24
+ model: string;
25
+ baseUrl: string;
26
+ apiKey?: string;
27
+ maxContextTokens?: number;
28
+ maxOutputTokens?: number;
29
+ }>;
30
+ activeModelKey?: string;
31
+ }
32
+ export interface ProviderModelFlowProps {
33
+ existingProviders: ProviderConfig[];
34
+ existingModelKeys: string[];
35
+ /**
36
+ * Model ids (e.g. "deepseek-v4-pro") already present in settings.models[]
37
+ * under SOME provider. The fetch step uses this to disable rows for
38
+ * models the user has already added — keeps the menu informative (shows
39
+ * the full catalog) without letting the user re-add duplicates that
40
+ * appendOnboardingResult would silently drop.
41
+ */
42
+ existingModelIds?: string[];
43
+ detectedEnvKeys?: EnvKeyHint[];
44
+ switchToNewModelOnFinish: boolean;
45
+ onFinish: (r: FlowResult) => void;
46
+ onCancel: () => void;
47
+ }
48
+ /**
49
+ * Pool-key generator for wizard-added models. Format is `provider-model` so
50
+ * the alias self-identifies (e.g. "deepseek-v4-pro", not just "v4-pro" or
51
+ * "deepseek"). Collisions get a numeric suffix.
52
+ *
53
+ * If the model id already starts with `<provider>-`, we don't duplicate.
54
+ */
55
+ export declare function deriveModelAlias(modelId: string, used: string[], providerKind?: string): string;
56
+ export declare function deriveProviderKey(kindOrUrl: string, used: string[]): string;
57
+ export declare function validateAlias(alias: string, used: string[]): string | null;
58
+ export declare function ProviderModelFlow({ existingProviders, existingModelKeys, existingModelIds, detectedEnvKeys, switchToNewModelOnFinish, onFinish, onCancel, }: ProviderModelFlowProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function UpdateBanner(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,17 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkMV7YI4WOcjs = require('./chunk-MV7YI4WO.cjs');
9
+ require('./chunk-KS3RYAYL.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ exports.__internal = _chunkMV7YI4WOcjs.__internal; exports.checkForUpdate = _chunkMV7YI4WOcjs.checkForUpdate; exports.getAutoUpdateDisabledReason = _chunkMV7YI4WOcjs.getAutoUpdateDisabledReason; exports.getCurrentVersion = _chunkMV7YI4WOcjs.getCurrentVersion; exports.getUpdateAvailable = _chunkMV7YI4WOcjs.getUpdateAvailable; exports.scheduleAutoInstallOnExit = _chunkMV7YI4WOcjs.scheduleAutoInstallOnExit;
@@ -0,0 +1,17 @@
1
+ import {
2
+ __internal,
3
+ checkForUpdate,
4
+ getAutoUpdateDisabledReason,
5
+ getCurrentVersion,
6
+ getUpdateAvailable,
7
+ scheduleAutoInstallOnExit
8
+ } from "./chunk-KE4EQOWA.js";
9
+ import "./chunk-MD32R22I.js";
10
+ export {
11
+ __internal,
12
+ checkForUpdate,
13
+ getAutoUpdateDisabledReason,
14
+ getCurrentVersion,
15
+ getUpdateAvailable,
16
+ scheduleAutoInstallOnExit
17
+ };
@@ -2,4 +2,5 @@
2
2
  * Shim for CC's utils/semver — re-exports semver comparison helpers.
3
3
  */
4
4
  export declare function gte(a: string, b: string): boolean;
5
+ export declare function gt(a: string, b: string): boolean;
5
6
  export declare function lt(a: string, b: string): boolean;
@@ -0,0 +1,6 @@
1
+ export interface NoiseResult {
2
+ isNoise: boolean;
3
+ reason: string;
4
+ cleaned: string;
5
+ }
6
+ export declare function detectPastedNoise(task: string): NoiseResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cjhyy/code-shell",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.6",
4
4
  "description": "Code Shell — general-purpose agent orchestration framework with a terminal coding preset",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -62,6 +62,7 @@
62
62
  "files": [
63
63
  "dist",
64
64
  "scripts/check-node.cjs",
65
+ "skills-builtin",
65
66
  "README.md",
66
67
  "LICENSE",
67
68
  "CHANGELOG.md"
@@ -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 _chunkBUJ5KYCIcjs = require('./chunk-BUJ5KYCI.cjs');
4
- require('./chunk-GZBD6QRS.cjs');
5
- require('./chunk-EL2RL5DG.cjs');
6
- require('./chunk-JHNCK7JP.cjs');
7
- require('./chunk-IJSHQGMP.cjs');
8
-
9
-
10
- exports.AnthropicClient = _chunkBUJ5KYCIcjs.AnthropicClient;
@@ -1,10 +0,0 @@
1
- import {
2
- AnthropicClient
3
- } from "./chunk-M2SVOKC6.js";
4
- import "./chunk-SCDKLTN3.js";
5
- import "./chunk-FUOKLKR2.js";
6
- import "./chunk-ZRVPCXI7.js";
7
- import "./chunk-DI7RDLOS.js";
8
- export {
9
- AnthropicClient
10
- };