@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.
- package/CHANGELOG.md +30 -0
- package/dist/anthropic-UBSB5AQH.js +1 -0
- package/dist/arena/index.js +1 -104
- package/dist/arena-OW55ZCHT.js +3 -0
- package/dist/bwrap-PVZMLHZR.js +2 -0
- package/dist/chunk-2NS3JMNK.js +1 -0
- package/dist/chunk-3QP5BQ3L.js +1 -0
- package/dist/chunk-B7K2OWKC.js +2 -0
- package/dist/chunk-EWWK56K6.js +2 -0
- package/dist/chunk-FU7AHZNN.js +1 -0
- package/dist/chunk-HIJ2XXGX.js +1 -0
- package/dist/chunk-KCXSARAA.js +1 -0
- package/dist/chunk-NFH3UQ3E.js +2 -0
- package/dist/chunk-NMBYBGC7.js +250 -0
- package/dist/chunk-NVAZJ5XS.js +2 -0
- package/dist/chunk-O5HFCH2U.js +1 -0
- package/dist/chunk-P6JSTIFM.js +1 -0
- package/dist/chunk-PGANL6F2.js +3 -0
- package/dist/chunk-Q4O2HGWS.js +251 -0
- package/dist/chunk-QTWU7UNA.js +5 -0
- package/dist/chunk-RP26WO4R.js +1 -0
- package/dist/chunk-SNFAPSLA.js +1 -0
- package/dist/chunk-T222K6IV.js +18 -0
- package/dist/chunk-TKJA6W36.js +3 -0
- package/dist/chunk-UDPUTFQT.js +2 -0
- package/dist/chunk-W47Z7MGS.js +33 -0
- package/dist/chunk-WI6FSWGU.js +1 -0
- package/dist/chunk-WOP6MJKW.js +1 -0
- package/dist/chunk-XDOWC7EG.js +4 -0
- package/dist/chunk-Y2NS6HPO.js +641 -0
- package/dist/cli/main.js +303 -22037
- package/dist/cli/updater.d.ts +8 -0
- package/dist/client-base-6ZZJJYDY.js +1 -0
- package/dist/compaction-ECVQVOCT.js +1 -0
- package/dist/devtools-SGDUOOM4.js +1 -0
- package/dist/engine/engine.d.ts +15 -0
- package/dist/export-md-U72T7NW7.js +22 -0
- package/dist/file-history-7FQFEQOL.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -347
- package/dist/llm/token-counter.d.ts +17 -0
- package/dist/manager-C3TDN6MS.js +1 -0
- package/dist/mcp-manager-OP4XYV53.js +1 -0
- package/dist/memory-BNI4WEWL.js +1 -0
- package/dist/model-cache-HEDXI7UJ.js +1 -0
- package/dist/model-fetcher-BJ64META.js +1 -0
- package/dist/off-7SDVMMXW.js +1 -0
- package/dist/openai-KEWQ54TM.js +1 -0
- package/dist/openrouter-models-AM6M52D6.js +1 -0
- package/dist/openrouter-sync-5JNBL3Z6.js +1 -0
- package/dist/product/index.js +1 -21
- package/dist/run/index.js +1 -48
- package/dist/seatbelt-WBYROQT6.js +37 -0
- package/dist/session/session-manager.d.ts +2 -0
- package/dist/session-manager-AGWS5SMJ.js +1 -0
- package/dist/settings/schema.d.ts +72 -6
- package/dist/tool-summary-5UE62VU4.js +2 -0
- package/dist/tool-system/builtin/bash.d.ts +7 -1
- package/dist/tool-system/context.d.ts +7 -0
- package/dist/tool-system/investigation-guard.d.ts +9 -0
- package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
- package/dist/tool-system/sandbox/index.d.ts +71 -0
- package/dist/tool-system/sandbox/off.d.ts +2 -0
- package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
- package/dist/types.d.ts +4 -0
- package/dist/ui/components/SessionPicker.d.ts +2 -0
- package/dist/ui/components/SpinnerWithVerb.d.ts +2 -2
- package/dist/ui/components/StatusLine.d.ts +2 -2
- package/dist/updater-OCNU2K2Z.js +1 -0
- package/package.json +8 -10
- package/skills-builtin/codeshell-help.md +135 -0
- package/dist/anthropic-IBTI4WL2.cjs +0 -10
- package/dist/anthropic-PRZZKHEZ.js +0 -10
- package/dist/arena/index.cjs +0 -104
- package/dist/arena-KBQOPLFV.cjs +0 -261
- package/dist/arena-O2L4TN6A.js +0 -261
- package/dist/chunk-2EP3CLEN.js +0 -44
- package/dist/chunk-2YW4FPFG.cjs +0 -101
- package/dist/chunk-3OA5G4TM.js +0 -47
- package/dist/chunk-52LGZKT3.cjs +0 -47
- package/dist/chunk-55XGPMAP.cjs +0 -146
- package/dist/chunk-5ECBT4YA.js +0 -450
- package/dist/chunk-6QVAYW7C.cjs +0 -438
- package/dist/chunk-6S4BJ65N.js +0 -113
- package/dist/chunk-76HYEPDM.js +0 -307
- package/dist/chunk-76W334S4.js +0 -54
- package/dist/chunk-7EG3V4JY.cjs +0 -113
- package/dist/chunk-7JVTYEEC.js +0 -340
- package/dist/chunk-7K6SDRRF.js +0 -9047
- package/dist/chunk-7Y6S3OCX.js +0 -438
- package/dist/chunk-A5LCRPDP.cjs +0 -54
- package/dist/chunk-BSW22MPA.js +0 -146
- package/dist/chunk-BUU5PZK2.cjs +0 -9048
- package/dist/chunk-BWTOS5BH.cjs +0 -5128
- package/dist/chunk-BXCY2FSE.js +0 -203
- package/dist/chunk-C5YQBIRK.js +0 -5128
- package/dist/chunk-HEKQCI7B.cjs +0 -224
- package/dist/chunk-HS2MFNUC.cjs +0 -44
- package/dist/chunk-IK4EWJBP.cjs +0 -203
- package/dist/chunk-JMR33QVF.cjs +0 -169
- package/dist/chunk-KOVYSDHZ.cjs +0 -340
- package/dist/chunk-KS3RYAYL.cjs +0 -45
- package/dist/chunk-MD32R22I.js +0 -50
- package/dist/chunk-MY5XHADU.cjs +0 -216
- package/dist/chunk-NUNC3VFB.cjs +0 -307
- package/dist/chunk-QRM7IF2S.cjs +0 -4711
- package/dist/chunk-R47ROHGL.cjs +0 -298
- package/dist/chunk-RMYKO74M.js +0 -1252
- package/dist/chunk-SFXHZSRF.js +0 -101
- package/dist/chunk-SIHHIQLO.js +0 -224
- package/dist/chunk-SNT563K3.cjs +0 -107
- package/dist/chunk-T6VYG46N.js +0 -105
- package/dist/chunk-TUY2T5KP.cjs +0 -105
- package/dist/chunk-VIAGTYYW.js +0 -169
- package/dist/chunk-VYL4EFRC.cjs +0 -1252
- package/dist/chunk-W22P377T.js +0 -299
- package/dist/chunk-WASS5YWB.js +0 -215
- package/dist/chunk-XDIQWQJ4.js +0 -4711
- package/dist/chunk-YIQBXAYU.cjs +0 -264
- package/dist/chunk-YJ77GQK5.js +0 -107
- package/dist/chunk-YUI524OE.cjs +0 -450
- package/dist/chunk-ZBPSQCPU.js +0 -264
- package/dist/cli/main.cjs +0 -22133
- package/dist/client-base-HTF236ZD.cjs +0 -9
- package/dist/client-base-QKRKCOWB.js +0 -9
- package/dist/compaction-6VU2T643.js +0 -33
- package/dist/compaction-OKUNTCA7.cjs +0 -33
- package/dist/devtools-T2NIZBJK.cjs +0 -6
- package/dist/devtools-YXWHOVKR.js +0 -6
- package/dist/export-md-RXDW6F5W.cjs +0 -135
- package/dist/export-md-XXKZANW5.js +0 -135
- package/dist/file-history-KYPE3ECT.cjs +0 -7
- package/dist/file-history-LF4F7X26.js +0 -7
- package/dist/index.cjs +0 -347
- package/dist/manager-C2IUXKRC.js +0 -7
- package/dist/manager-YYKWYTRM.cjs +0 -7
- package/dist/mcp-manager-QMKWPBZ4.js +0 -8
- package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
- package/dist/memory-5LWZ6FI2.cjs +0 -9
- package/dist/memory-VIJLBAMQ.js +0 -9
- package/dist/model-cache-5KIYL5SL.js +0 -13
- package/dist/model-cache-OED3IM4R.cjs +0 -13
- package/dist/model-fetcher-HKGICACL.js +0 -8
- package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
- package/dist/openai-JR2WEKOF.js +0 -10
- package/dist/openai-YBTOET4O.cjs +0 -10
- package/dist/openrouter-models-OU4GRZQY.cjs +0 -15
- package/dist/openrouter-models-TGKDKY52.js +0 -15
- package/dist/openrouter-sync-BBHUM3R6.cjs +0 -11
- package/dist/openrouter-sync-UXUSJCIR.js +0 -11
- package/dist/product/index.cjs +0 -21
- package/dist/run/index.cjs +0 -48
- package/dist/session-manager-Q22BBMD3.js +0 -8
- package/dist/session-manager-XODQVL3C.cjs +0 -8
- package/dist/tool-summary-63DPIS7G.cjs +0 -31
- package/dist/tool-summary-NP5CDBKG.js +0 -31
- package/dist/updater-QW473OF4.cjs +0 -17
- package/dist/updater-VFUAHCVY.js +0 -17
package/dist/chunk-BXCY2FSE.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_esm_shims
|
|
3
|
-
} from "./chunk-MD32R22I.js";
|
|
4
|
-
|
|
5
|
-
// src/logging/logger.ts
|
|
6
|
-
init_esm_shims();
|
|
7
|
-
import {
|
|
8
|
-
appendFileSync,
|
|
9
|
-
mkdirSync,
|
|
10
|
-
existsSync,
|
|
11
|
-
readdirSync,
|
|
12
|
-
unlinkSync,
|
|
13
|
-
readFileSync
|
|
14
|
-
} from "fs";
|
|
15
|
-
import { join, dirname } from "path";
|
|
16
|
-
import { homedir } from "os";
|
|
17
|
-
var LEVEL_ORDER = {
|
|
18
|
-
debug: 0,
|
|
19
|
-
info: 1,
|
|
20
|
-
warn: 2,
|
|
21
|
-
error: 3
|
|
22
|
-
};
|
|
23
|
-
var LOGS_DIR = join(homedir(), ".code-shell", "logs");
|
|
24
|
-
var MAX_LOG_FILES = 7;
|
|
25
|
-
var MAX_IN_MEMORY_ERRORS = 100;
|
|
26
|
-
function isLocalDev() {
|
|
27
|
-
if (process.env.CODE_SHELL_DEV === "1") return true;
|
|
28
|
-
if (process.argv.includes("--debug") || process.argv.includes("-d")) return true;
|
|
29
|
-
if (process.argv.some((a) => a.startsWith("--debug="))) return true;
|
|
30
|
-
if (process.env.NODE_ENV === "test" || process.env.BUN_TEST === "1") return false;
|
|
31
|
-
if (process.argv.some((a) => a.includes("/tests/") || a.endsWith(".test.ts"))) return false;
|
|
32
|
-
const entry = process.argv[1] ?? "";
|
|
33
|
-
if (entry.includes(`${"/"}src${"/"}`)) return true;
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
function resolveDefaultLevel() {
|
|
37
|
-
const raw = process.env.CODE_SHELL_LOG_LEVEL?.toLowerCase().trim();
|
|
38
|
-
if (raw && Object.hasOwn(LEVEL_ORDER, raw)) return raw;
|
|
39
|
-
return isLocalDev() ? "debug" : "info";
|
|
40
|
-
}
|
|
41
|
-
function resolveCategoryFilter() {
|
|
42
|
-
const cliArg = process.argv.find((a) => a.startsWith("--debug="));
|
|
43
|
-
let raw;
|
|
44
|
-
if (cliArg) raw = cliArg.slice("--debug=".length);
|
|
45
|
-
else {
|
|
46
|
-
const env = process.env.CODE_SHELL_DEBUG;
|
|
47
|
-
if (env && env !== "1" && env !== "true") raw = env;
|
|
48
|
-
}
|
|
49
|
-
if (!raw) return null;
|
|
50
|
-
const set = new Set(
|
|
51
|
-
raw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean)
|
|
52
|
-
);
|
|
53
|
-
return set.size > 0 ? set : null;
|
|
54
|
-
}
|
|
55
|
-
var _currentSid = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
56
|
-
function setCurrentSid(sid) {
|
|
57
|
-
_currentSid = sid;
|
|
58
|
-
}
|
|
59
|
-
function getCurrentSid() {
|
|
60
|
-
return _currentSid;
|
|
61
|
-
}
|
|
62
|
-
var inMemoryErrors = [];
|
|
63
|
-
var errorLogSink = null;
|
|
64
|
-
var Logger = class _Logger {
|
|
65
|
-
constructor(context = {}) {
|
|
66
|
-
this.context = context;
|
|
67
|
-
this.enabled = process.env.CODE_SHELL_LOG !== "0";
|
|
68
|
-
this.minLevel = resolveDefaultLevel();
|
|
69
|
-
this.categoryFilter = resolveCategoryFilter();
|
|
70
|
-
this.stderrEcho = process.env.CODE_SHELL_DEBUG === "1" || process.argv.includes("--debug-to-stderr") || process.argv.includes("-d2e");
|
|
71
|
-
}
|
|
72
|
-
enabled;
|
|
73
|
-
minLevel;
|
|
74
|
-
categoryFilter;
|
|
75
|
-
stderrEcho;
|
|
76
|
-
dirReady = false;
|
|
77
|
-
child(extra) {
|
|
78
|
-
return new _Logger({ ...this.context, ...extra });
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Set the session id stamped on every subsequent log entry written by
|
|
82
|
-
* any logger in the process. Called by Engine once a run's
|
|
83
|
-
* authoritative session id is known.
|
|
84
|
-
*/
|
|
85
|
-
setSid(sid) {
|
|
86
|
-
setCurrentSid(sid);
|
|
87
|
-
}
|
|
88
|
-
getSid() {
|
|
89
|
-
return getCurrentSid();
|
|
90
|
-
}
|
|
91
|
-
debug(msg, data) {
|
|
92
|
-
this.write("debug", msg, data);
|
|
93
|
-
}
|
|
94
|
-
info(msg, data) {
|
|
95
|
-
this.write("info", msg, data);
|
|
96
|
-
}
|
|
97
|
-
warn(msg, data) {
|
|
98
|
-
this.write("warn", msg, data);
|
|
99
|
-
}
|
|
100
|
-
error(msgOrErr, data) {
|
|
101
|
-
let msg;
|
|
102
|
-
let entryData;
|
|
103
|
-
let errObj;
|
|
104
|
-
if (typeof msgOrErr === "string") {
|
|
105
|
-
msg = msgOrErr;
|
|
106
|
-
if (data instanceof Error) {
|
|
107
|
-
errObj = data;
|
|
108
|
-
entryData = { error: data.message, stack: data.stack };
|
|
109
|
-
} else {
|
|
110
|
-
entryData = data;
|
|
111
|
-
}
|
|
112
|
-
} else if (msgOrErr instanceof Error) {
|
|
113
|
-
msg = msgOrErr.message;
|
|
114
|
-
errObj = msgOrErr;
|
|
115
|
-
entryData = { stack: msgOrErr.stack };
|
|
116
|
-
} else {
|
|
117
|
-
msg = String(msgOrErr);
|
|
118
|
-
}
|
|
119
|
-
this.recordError(msg, entryData);
|
|
120
|
-
this.write("error", msg, entryData);
|
|
121
|
-
if (errObj) errorLogSink?.logError(errObj);
|
|
122
|
-
}
|
|
123
|
-
recordError(msg, data) {
|
|
124
|
-
if (inMemoryErrors.length >= MAX_IN_MEMORY_ERRORS) inMemoryErrors.shift();
|
|
125
|
-
inMemoryErrors.push({ msg, t: (/* @__PURE__ */ new Date()).toISOString(), data });
|
|
126
|
-
}
|
|
127
|
-
write(level, msg, data) {
|
|
128
|
-
if (!this.enabled) return;
|
|
129
|
-
if (LEVEL_ORDER[level] < LEVEL_ORDER[this.minLevel]) return;
|
|
130
|
-
const cat = data?.cat ?? this.context.cat;
|
|
131
|
-
if (level === "debug" && this.categoryFilter) {
|
|
132
|
-
if (!cat || !this.categoryFilter.has(cat.toLowerCase())) return;
|
|
133
|
-
}
|
|
134
|
-
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
135
|
-
const entry = { t, l: level, msg, ...this.context };
|
|
136
|
-
if (cat && !entry.cat) entry.cat = cat;
|
|
137
|
-
if (entry.sid === void 0) entry.sid = _currentSid;
|
|
138
|
-
if (data) entry.d = data;
|
|
139
|
-
const line = JSON.stringify(entry) + "\n";
|
|
140
|
-
if (this.stderrEcho) {
|
|
141
|
-
process.stderr.write(line);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
if (!this.dirReady) {
|
|
146
|
-
if (!existsSync(LOGS_DIR)) mkdirSync(LOGS_DIR, { recursive: true });
|
|
147
|
-
this.dirReady = true;
|
|
148
|
-
}
|
|
149
|
-
const dateStr = t.slice(0, 10);
|
|
150
|
-
appendFileSync(join(LOGS_DIR, `${dateStr}.log`), line, "utf-8");
|
|
151
|
-
} catch {
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
getMinLevel() {
|
|
155
|
-
return this.minLevel;
|
|
156
|
-
}
|
|
157
|
-
isCategoryActive(cat) {
|
|
158
|
-
return !this.categoryFilter || this.categoryFilter.has(cat.toLowerCase());
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Open a span: writes a `<name>.begin` debug entry now and returns a handle
|
|
162
|
-
* whose `end()` writes `<name>.end` with `duration_ms` populated. Use for
|
|
163
|
-
* any "I want begin → end + how long" pattern (tool exec, LLM request,
|
|
164
|
-
* permission ask, etc.) so the begin/end pair is grouped under one cat
|
|
165
|
-
* and the duration is computed once instead of by hand from timestamps.
|
|
166
|
-
*/
|
|
167
|
-
span(name, data) {
|
|
168
|
-
const startedAt = Date.now();
|
|
169
|
-
this.write("debug", `${name}.begin`, data);
|
|
170
|
-
return {
|
|
171
|
-
end: (extra) => {
|
|
172
|
-
const duration_ms = Date.now() - startedAt;
|
|
173
|
-
this.write("info", `${name}.end`, { ...data, ...extra, duration_ms });
|
|
174
|
-
},
|
|
175
|
-
fail: (err, extra) => {
|
|
176
|
-
const duration_ms = Date.now() - startedAt;
|
|
177
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
178
|
-
this.write("error", `${name}.fail`, { ...data, ...extra, duration_ms, error: message });
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
var logger = new Logger();
|
|
184
|
-
function rotateLogs() {
|
|
185
|
-
try {
|
|
186
|
-
if (!existsSync(LOGS_DIR)) return;
|
|
187
|
-
const files = readdirSync(LOGS_DIR).filter((f) => f.endsWith(".log")).sort();
|
|
188
|
-
if (files.length <= MAX_LOG_FILES) return;
|
|
189
|
-
for (const f of files.slice(0, files.length - MAX_LOG_FILES)) {
|
|
190
|
-
try {
|
|
191
|
-
unlinkSync(join(LOGS_DIR, f));
|
|
192
|
-
} catch {
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
} catch {
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export {
|
|
200
|
-
getCurrentSid,
|
|
201
|
-
logger,
|
|
202
|
-
rotateLogs
|
|
203
|
-
};
|