@cjhyy/code-shell 0.1.0-alpha.1 → 0.1.0-alpha.2
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/README.md +8 -0
- package/dist/anthropic-P5VETAFI.cjs +10 -0
- package/dist/{anthropic-NENYS535.js → anthropic-W2GU3D76.js} +3 -2
- package/dist/arena/context/context-tools.d.ts +1 -1
- package/dist/arena/index.cjs +4 -4
- package/dist/arena/index.js +3 -3
- package/dist/arena/providers/index.d.ts +19 -3
- package/dist/arena/strategies/utils.d.ts +6 -1
- package/dist/arena/types.d.ts +10 -1
- package/dist/{arena-46QQ6BZQ.js → arena-ENHBHB2W.js} +5 -7
- package/dist/{arena-HZZZ2GJH.cjs → arena-HHDYYVHJ.cjs} +19 -21
- package/dist/{chunk-BE6IPRDM.js → chunk-2EUAE7AY.js} +1 -1
- package/dist/{chunk-WYKNZ54E.cjs → chunk-3CAZIWUA.cjs} +6 -6
- package/dist/{chunk-J5XW6UYL.js → chunk-5C5HIOML.js} +63 -4
- package/dist/chunk-75E4BBFC.js +224 -0
- package/dist/{chunk-ZJV3YSY3.cjs → chunk-BUJ5KYCI.cjs} +53 -11
- package/dist/{chunk-BMH65OVB.cjs → chunk-C7C7ZZY4.cjs} +8 -8
- package/dist/{chunk-KO2FPF7G.js → chunk-F5BS3GUC.js} +20 -2
- package/dist/chunk-FA5KD34T.js +54 -0
- package/dist/chunk-FV2ARONZ.cjs +224 -0
- package/dist/chunk-G76E5FOB.cjs +54 -0
- package/dist/{chunk-DICG4AB7.cjs → chunk-GZBD6QRS.cjs} +42 -3
- package/dist/{chunk-FVP7XJGS.cjs → chunk-HOXQLX5R.cjs} +406 -196
- package/dist/{chunk-4PKZPFCD.js → chunk-I57ZD5IQ.js} +47 -14
- package/dist/{chunk-JUHRV2XF.js → chunk-ID6EJUHP.js} +1703 -438
- package/dist/chunk-JHNCK7JP.cjs +202 -0
- package/dist/{chunk-MOILS4WE.cjs → chunk-JHXNOB5G.cjs} +3 -3
- package/dist/{chunk-UK2SU23S.cjs → chunk-KOGV6PDQ.cjs} +20 -2
- package/dist/{chunk-VKGNCYRL.js → chunk-LMEKCQX4.js} +95 -13
- package/dist/{chunk-3EAEC566.cjs → chunk-M2QI5X3X.cjs} +51 -18
- package/dist/{chunk-YZ25SSWJ.js → chunk-M2SVOKC6.js} +46 -4
- package/dist/chunk-OMRGA6TI.js +4753 -0
- package/dist/{chunk-NG73UR3L.cjs → chunk-OP57WUWQ.cjs} +23 -1
- package/dist/{chunk-ZXYDDJEJ.js → chunk-OUC2DFA7.js} +2 -2
- package/dist/{chunk-AP5F6VYE.js → chunk-REFCCVDM.js} +1 -1
- package/dist/{chunk-O6F2EF2Z.js → chunk-SCDKLTN3.js} +41 -2
- package/dist/{chunk-FECTK5KJ.js → chunk-SW3L7HIM.js} +1 -1
- package/dist/chunk-TATCTZSB.cjs +4753 -0
- package/dist/{chunk-Q6BYFYGD.cjs → chunk-VWFET3MG.cjs} +1886 -621
- package/dist/{chunk-3EUDE77E.cjs → chunk-X2DNIMPC.cjs} +19 -19
- package/dist/{chunk-SQZHPD3S.js → chunk-Y7TSCDF6.js} +297 -87
- package/dist/{chunk-WHRTARDJ.cjs → chunk-YAFCN7ZW.cjs} +112 -30
- package/dist/{chunk-LRAY5IYC.cjs → chunk-YD7XTI7T.cjs} +65 -6
- package/dist/{chunk-S74VVJBF.js → chunk-ZLPJJZUW.js} +23 -1
- package/dist/chunk-ZRVPCXI7.js +202 -0
- package/dist/cli/commands/builtin/advanced-commands.d.ts +1 -1
- package/dist/cli/commands/builtin/extra-commands.d.ts +2 -2
- package/dist/cli/commands/builtin/more-commands.d.ts +1 -3
- package/dist/cli/commands/registry.d.ts +8 -0
- package/dist/cli/cost-tracker.d.ts +6 -0
- package/dist/cli/main.cjs +3534 -1996
- package/dist/cli/main.js +3646 -2108
- package/dist/cli/onboarding.d.ts +67 -14
- package/dist/client-base-TOVE25FA.js +9 -0
- package/dist/client-base-VDDIADAC.cjs +9 -0
- package/dist/compaction-D3KV2NWY.cjs +31 -0
- package/dist/{compaction-CCHWA4G6.js → compaction-YNWCEF7B.js} +1 -2
- package/dist/context/manager.d.ts +9 -0
- package/dist/data/openrouter-models.d.ts +35 -0
- package/dist/data/openrouter-sync.d.ts +16 -0
- package/dist/{devtools-KIY3LWQJ.js → devtools-IRQQPIRY.js} +1 -1
- package/dist/{devtools-LRP47DDV.cjs → devtools-WTC3NFNE.cjs} +1 -1
- package/dist/engine/engine.d.ts +29 -6
- package/dist/engine/turn-loop.d.ts +7 -0
- package/dist/engine/turn-state.d.ts +6 -0
- package/dist/index.cjs +19 -28
- package/dist/index.js +28 -37
- package/dist/llm/client-base.d.ts +7 -0
- package/dist/llm/model-pool.d.ts +4 -0
- package/dist/logging/logger.d.ts +69 -8
- package/dist/manager-FWLOVEEK.cjs +7 -0
- package/dist/manager-GEXJLOIS.js +7 -0
- package/dist/{mcp-manager-OKXHHWYR.js → mcp-manager-37GQLFGX.js} +2 -2
- package/dist/mcp-manager-U77NEXBY.cjs +8 -0
- package/dist/memory-ADGOWADP.cjs +9 -0
- package/dist/memory-EPFDBPII.js +9 -0
- package/dist/native-ts/yoga-layout/index.d.ts +2 -2
- package/dist/{openai-5HQGBL4L.js → openai-RXU5URYI.js} +3 -2
- package/dist/openai-SQW4H2K4.cjs +10 -0
- package/dist/openrouter-models-OL725CL6.js +15 -0
- package/dist/openrouter-models-UM3AOGZ4.cjs +15 -0
- package/dist/openrouter-sync-CWD5VNW2.js +11 -0
- package/dist/openrouter-sync-HYZZC6RX.cjs +11 -0
- package/dist/product/index.cjs +12 -16
- package/dist/product/index.js +11 -15
- package/dist/protocol/types.d.ts +11 -3
- package/dist/{ink → render}/hooks/use-input.d.ts +1 -1
- package/dist/run/index.cjs +12 -16
- package/dist/run/index.js +11 -15
- package/dist/session/memory.d.ts +23 -3
- package/dist/session/session-manager.d.ts +4 -1
- package/dist/{session-manager-UQKB564H.cjs → session-manager-HRSKENKB.cjs} +2 -2
- package/dist/{session-manager-JIIBCFTC.js → session-manager-NEKFEHF3.js} +1 -1
- package/dist/settings/manager.d.ts +9 -0
- package/dist/settings/schema.d.ts +48 -39
- package/dist/{tool-summary-J2ICNMWP.js → tool-summary-2RUFL5QK.js} +1 -1
- package/dist/{tool-summary-5P2GKRA4.cjs → tool-summary-RYNR4DDB.cjs} +2 -2
- package/dist/tool-system/builtin/agent.d.ts +3 -26
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
- package/dist/tool-system/builtin/apply-patch/index.d.ts +19 -0
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
- package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
- package/dist/tool-system/builtin/arena.d.ts +18 -5
- package/dist/tool-system/builtin/ask-user.d.ts +6 -6
- package/dist/tool-system/builtin/index.d.ts +11 -1
- package/dist/tool-system/builtin/tool-search.d.ts +2 -3
- package/dist/tool-system/context.d.ts +74 -0
- package/dist/tool-system/executor.d.ts +16 -0
- package/dist/tool-system/permission.d.ts +40 -5
- package/dist/tool-system/registry.d.ts +2 -0
- package/dist/types.d.ts +28 -1
- package/dist/ui/App.d.ts +1 -1
- package/dist/ui/components/AgentBlock.d.ts +1 -1
- package/dist/ui/components/AskUserPrompt.d.ts +7 -0
- package/dist/ui/components/MessageContent.d.ts +7 -3
- package/dist/ui/components/ModelManager.d.ts +35 -0
- package/dist/ui/components/ModelSelector.d.ts +10 -0
- package/dist/ui/components/OnboardingPrompt.d.ts +7 -0
- package/dist/ui/components/PermissionPrompt.d.ts +5 -2
- package/dist/ui/components/SessionPicker.d.ts +14 -0
- package/dist/ui/components/StatusLine.d.ts +4 -2
- package/dist/ui/components/ThemedBox.d.ts +1 -1
- package/dist/ui/components/ToolCall.d.ts +8 -1
- package/dist/ui/components/WelcomeTips.d.ts +5 -0
- package/dist/ui/onboarding-runner.d.ts +2 -0
- package/dist/ui/store.d.ts +1 -0
- package/dist/{updater-2N6745WR.cjs → updater-M7L42ASZ.cjs} +4 -4
- package/dist/{updater-PV7FKSUI.js → updater-ZRTONIR4.js} +4 -4
- package/dist/utils/debug.d.ts +17 -33
- package/package.json +4 -4
- package/dist/anthropic-XMTTVNSH.cjs +0 -9
- package/dist/bridge-4ZRXVWBN.js +0 -98
- package/dist/bridge-W476QDFH.cjs +0 -98
- package/dist/chunk-4RRUP4MM.js +0 -86
- package/dist/chunk-4SFPFHMG.js +0 -132
- package/dist/chunk-5LHVI777.cjs +0 -246
- package/dist/chunk-6ZIROYXX.js +0 -207
- package/dist/chunk-C7JBCO5V.js +0 -80
- package/dist/chunk-CSO5EOEP.cjs +0 -132
- package/dist/chunk-FGZGCFJX.cjs +0 -207
- package/dist/chunk-HD7MT5XU.cjs +0 -86
- package/dist/chunk-IMMTBZ33.cjs +0 -63
- package/dist/chunk-JT2WSQSR.cjs +0 -335
- package/dist/chunk-NZ4DQ72D.cjs +0 -664
- package/dist/chunk-OG4MIQJ6.js +0 -335
- package/dist/chunk-WRZJUQ5Z.js +0 -664
- package/dist/chunk-X4HAERTQ.js +0 -63
- package/dist/chunk-XHC2JMEC.cjs +0 -80
- package/dist/chunk-ZRSSGYA5.js +0 -246
- package/dist/compaction-44I55TLI.cjs +0 -32
- package/dist/coordinator-5HY7ALO2.js +0 -7
- package/dist/coordinator-INDLPVMF.cjs +0 -7
- package/dist/cost-tracker-IWYAUPXH.js +0 -9
- package/dist/cost-tracker-JXTJQQWE.cjs +0 -9
- package/dist/loader-DXFSUB4R.cjs +0 -91
- package/dist/loader-J5UID6CV.js +0 -91
- package/dist/manager-ETWDOCHN.cjs +0 -9
- package/dist/manager-HGMQNEJB.cjs +0 -11
- package/dist/manager-HUAQOORS.js +0 -9
- package/dist/manager-VJIZ2CQC.js +0 -11
- package/dist/mcp-manager-G4G2QASE.cjs +0 -8
- package/dist/memory-AP747G5H.js +0 -7
- package/dist/memory-BH3BYUN5.cjs +0 -7
- package/dist/onboarding-6WEPV7C2.js +0 -11
- package/dist/onboarding-QM5DY2TU.cjs +0 -11
- package/dist/openai-656VWUQW.cjs +0 -9
- package/dist/skills-63RBYQRX.js +0 -13
- package/dist/skills-V3BPLW3D.cjs +0 -13
- package/dist/token-counter-CHAXW5O7.cjs +0 -13
- package/dist/token-counter-DSOZGZ5Q.js +0 -13
- package/dist/utils/log.d.ts +0 -56
- package/dist/voice-KTZ7PAGO.js +0 -80
- package/dist/voice-KZE25GKB.cjs +0 -80
- /package/dist/{ink → render}/Ansi.d.ts +0 -0
- /package/dist/{ink → render}/bidi.d.ts +0 -0
- /package/dist/{ink → render}/clearTerminal.d.ts +0 -0
- /package/dist/{ink → render}/colorize.d.ts +0 -0
- /package/dist/{ink → render}/components/AlternateScreen.d.ts +0 -0
- /package/dist/{ink → render}/components/App.d.ts +0 -0
- /package/dist/{ink → render}/components/AppContext.d.ts +0 -0
- /package/dist/{ink → render}/components/Box.d.ts +0 -0
- /package/dist/{ink → render}/components/Button.d.ts +0 -0
- /package/dist/{ink → render}/components/ClockContext.d.ts +0 -0
- /package/dist/{ink → render}/components/CursorDeclarationContext.d.ts +0 -0
- /package/dist/{ink → render}/components/ErrorOverview.d.ts +0 -0
- /package/dist/{ink → render}/components/Link.d.ts +0 -0
- /package/dist/{ink → render}/components/Newline.d.ts +0 -0
- /package/dist/{ink → render}/components/NoSelect.d.ts +0 -0
- /package/dist/{ink → render}/components/RawAnsi.d.ts +0 -0
- /package/dist/{ink → render}/components/ScrollBox.d.ts +0 -0
- /package/dist/{ink → render}/components/Spacer.d.ts +0 -0
- /package/dist/{ink → render}/components/StdinContext.d.ts +0 -0
- /package/dist/{ink → render}/components/TerminalFocusContext.d.ts +0 -0
- /package/dist/{ink → render}/components/TerminalSizeContext.d.ts +0 -0
- /package/dist/{ink → render}/components/Text.d.ts +0 -0
- /package/dist/{ink → render}/constants.d.ts +0 -0
- /package/dist/{ink → render}/cursor.d.ts +0 -0
- /package/dist/{ink → render}/devtools.d.ts +0 -0
- /package/dist/{ink → render}/dom.d.ts +0 -0
- /package/dist/{ink → render}/events/click-event.d.ts +0 -0
- /package/dist/{ink → render}/events/dispatcher.d.ts +0 -0
- /package/dist/{ink → render}/events/emitter.d.ts +0 -0
- /package/dist/{ink → render}/events/event-handlers.d.ts +0 -0
- /package/dist/{ink → render}/events/event.d.ts +0 -0
- /package/dist/{ink → render}/events/focus-event.d.ts +0 -0
- /package/dist/{ink → render}/events/input-event.d.ts +0 -0
- /package/dist/{ink → render}/events/keyboard-event.d.ts +0 -0
- /package/dist/{ink → render}/events/paste-event.d.ts +0 -0
- /package/dist/{ink → render}/events/resize-event.d.ts +0 -0
- /package/dist/{ink → render}/events/terminal-event.d.ts +0 -0
- /package/dist/{ink → render}/events/terminal-focus-event.d.ts +0 -0
- /package/dist/{ink → render}/focus.d.ts +0 -0
- /package/dist/{ink → render}/frame.d.ts +0 -0
- /package/dist/{ink → render}/get-max-width.d.ts +0 -0
- /package/dist/{ink → render}/hit-test.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-animation-frame.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-app.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-declared-cursor.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-interval.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-search-highlight.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-selection.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-stdin.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-tab-status.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-focus.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-title.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-viewport.d.ts +0 -0
- /package/dist/{ink → render}/index.d.ts +0 -0
- /package/dist/{ink → render}/ink.d.ts +0 -0
- /package/dist/{ink → render}/instances.d.ts +0 -0
- /package/dist/{ink → render}/layout/engine.d.ts +0 -0
- /package/dist/{ink → render}/layout/geometry.d.ts +0 -0
- /package/dist/{ink → render}/layout/node.d.ts +0 -0
- /package/dist/{ink → render}/layout/yoga.d.ts +0 -0
- /package/dist/{ink → render}/line-width-cache.d.ts +0 -0
- /package/dist/{ink → render}/log-update.d.ts +0 -0
- /package/dist/{ink → render}/measure-element.d.ts +0 -0
- /package/dist/{ink → render}/measure-text.d.ts +0 -0
- /package/dist/{ink → render}/node-cache.d.ts +0 -0
- /package/dist/{ink → render}/optimizer.d.ts +0 -0
- /package/dist/{ink → render}/output.d.ts +0 -0
- /package/dist/{ink → render}/parse-keypress.d.ts +0 -0
- /package/dist/{ink → render}/reconciler.d.ts +0 -0
- /package/dist/{ink → render}/render-border.d.ts +0 -0
- /package/dist/{ink → render}/render-node-to-output.d.ts +0 -0
- /package/dist/{ink → render}/render-to-screen.d.ts +0 -0
- /package/dist/{ink → render}/renderer.d.ts +0 -0
- /package/dist/{ink → render}/root.d.ts +0 -0
- /package/dist/{ink → render}/screen.d.ts +0 -0
- /package/dist/{ink → render}/searchHighlight.d.ts +0 -0
- /package/dist/{ink → render}/selection.d.ts +0 -0
- /package/dist/{ink → render}/squash-text-nodes.d.ts +0 -0
- /package/dist/{ink → render}/stringWidth.d.ts +0 -0
- /package/dist/{ink → render}/styles.d.ts +0 -0
- /package/dist/{ink → render}/supports-hyperlinks.d.ts +0 -0
- /package/dist/{ink → render}/tabstops.d.ts +0 -0
- /package/dist/{ink → render}/terminal-focus-state.d.ts +0 -0
- /package/dist/{ink → render}/terminal-querier.d.ts +0 -0
- /package/dist/{ink → render}/terminal.d.ts +0 -0
- /package/dist/{ink → render}/termio/ansi.d.ts +0 -0
- /package/dist/{ink → render}/termio/csi.d.ts +0 -0
- /package/dist/{ink → render}/termio/dec.d.ts +0 -0
- /package/dist/{ink → render}/termio/esc.d.ts +0 -0
- /package/dist/{ink → render}/termio/osc.d.ts +0 -0
- /package/dist/{ink → render}/termio/parser.d.ts +0 -0
- /package/dist/{ink → render}/termio/sgr.d.ts +0 -0
- /package/dist/{ink → render}/termio/tokenize.d.ts +0 -0
- /package/dist/{ink → render}/termio/types.d.ts +0 -0
- /package/dist/{ink → render}/termio.d.ts +0 -0
- /package/dist/{ink → render}/useTerminalNotification.d.ts +0 -0
- /package/dist/{ink → render}/warn.d.ts +0 -0
- /package/dist/{ink → render}/widest-line.d.ts +0 -0
- /package/dist/{ink → render}/wrap-text.d.ts +0 -0
- /package/dist/{ink → render}/wrapAnsi.d.ts +0 -0
package/dist/chunk-HD7MT5XU.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
|
|
5
|
-
|
|
6
|
-
// src/context/token-counter.ts
|
|
7
|
-
function estimateStringTokens(text) {
|
|
8
|
-
if (!text) return 0;
|
|
9
|
-
const cjkChars = (_nullishCoalesce(text.match(/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g), () => ( []))).length;
|
|
10
|
-
const cjkRatio = cjkChars / text.length;
|
|
11
|
-
if (cjkRatio > 0.3) {
|
|
12
|
-
const cjkTokens = cjkChars / RATIOS.cjk;
|
|
13
|
-
const otherChars = text.length - cjkChars;
|
|
14
|
-
const otherTokens = otherChars / RATIOS.english;
|
|
15
|
-
return Math.ceil(cjkTokens + otherTokens);
|
|
16
|
-
}
|
|
17
|
-
const codeIndicators = ["{", "}", "(", ")", ";", "=>", "import ", "function ", "class ", "const "];
|
|
18
|
-
const codeScore = codeIndicators.reduce((s, ind) => s + (text.includes(ind) ? 1 : 0), 0);
|
|
19
|
-
if (codeScore >= 3) return Math.ceil(text.length / RATIOS.code);
|
|
20
|
-
if (text.startsWith("{") || text.startsWith("[")) return Math.ceil(text.length / RATIOS.json);
|
|
21
|
-
return Math.ceil(text.length / RATIOS.english);
|
|
22
|
-
}
|
|
23
|
-
function estimateMessagesTokens(messages) {
|
|
24
|
-
let total = 0;
|
|
25
|
-
for (const msg of messages) {
|
|
26
|
-
total += 4;
|
|
27
|
-
if (typeof msg.content === "string") {
|
|
28
|
-
total += estimateStringTokens(msg.content);
|
|
29
|
-
} else if (Array.isArray(msg.content)) {
|
|
30
|
-
for (const block of msg.content) {
|
|
31
|
-
total += estimateBlockTokens(block);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return total;
|
|
36
|
-
}
|
|
37
|
-
function estimateBlockTokens(block) {
|
|
38
|
-
let tokens = 2;
|
|
39
|
-
if (block.text) tokens += estimateStringTokens(block.text);
|
|
40
|
-
if (block.content && typeof block.content === "string") {
|
|
41
|
-
tokens += estimateStringTokens(block.content);
|
|
42
|
-
}
|
|
43
|
-
if (block.input) {
|
|
44
|
-
tokens += estimateStringTokens(JSON.stringify(block.input));
|
|
45
|
-
}
|
|
46
|
-
if (block.name) tokens += estimateStringTokens(block.name);
|
|
47
|
-
return tokens;
|
|
48
|
-
}
|
|
49
|
-
function calculateContextUsage(messages, systemPrompt, maxTokens) {
|
|
50
|
-
const systemPromptTokens = estimateStringTokens(systemPrompt);
|
|
51
|
-
const messagesTokens = estimateMessagesTokens(messages);
|
|
52
|
-
const usedTokens = systemPromptTokens + messagesTokens;
|
|
53
|
-
return {
|
|
54
|
-
usedTokens,
|
|
55
|
-
maxTokens,
|
|
56
|
-
usagePercent: usedTokens / maxTokens * 100,
|
|
57
|
-
systemPromptTokens,
|
|
58
|
-
messagesTokens,
|
|
59
|
-
headroom: maxTokens - usedTokens
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
var RATIOS;
|
|
63
|
-
var init_token_counter = _chunkIJSHQGMPcjs.__esm.call(void 0, {
|
|
64
|
-
"src/context/token-counter.ts"() {
|
|
65
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
66
|
-
RATIOS = {
|
|
67
|
-
english: 4,
|
|
68
|
-
// ~4 chars per token for English prose
|
|
69
|
-
code: 3.2,
|
|
70
|
-
// ~3.2 chars per token for code (more tokens per char)
|
|
71
|
-
json: 3.5,
|
|
72
|
-
// JSON structures
|
|
73
|
-
mixed: 3.6,
|
|
74
|
-
// Mixed content (typical for tool results)
|
|
75
|
-
cjk: 1.5
|
|
76
|
-
// CJK characters: ~1.5 chars per token
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
exports.estimateStringTokens = estimateStringTokens; exports.estimateMessagesTokens = estimateMessagesTokens; exports.calculateContextUsage = calculateContextUsage; exports.init_token_counter = init_token_counter;
|
package/dist/chunk-IMMTBZ33.cjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
|
|
4
|
-
|
|
5
|
-
// src/logging/logger.ts
|
|
6
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
7
|
-
var _fs = require('fs');
|
|
8
|
-
var _path = require('path');
|
|
9
|
-
var _os = require('os');
|
|
10
|
-
var LEVEL_ORDER = {
|
|
11
|
-
debug: 0,
|
|
12
|
-
info: 1,
|
|
13
|
-
warn: 2,
|
|
14
|
-
error: 3
|
|
15
|
-
};
|
|
16
|
-
var Logger = class {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.logDir = _path.join.call(void 0, _os.homedir.call(void 0, ), ".code-shell", "logs");
|
|
22
|
-
this.minLevel = _nullishCoalesce(process.env.CODE_SHELL_LOG_LEVEL, () => ( "info"));
|
|
23
|
-
this.enabled = process.env.CODE_SHELL_LOG !== "0";
|
|
24
|
-
}
|
|
25
|
-
debug(msg, data) {
|
|
26
|
-
this.log("debug", msg, data);
|
|
27
|
-
}
|
|
28
|
-
info(msg, data) {
|
|
29
|
-
this.log("info", msg, data);
|
|
30
|
-
}
|
|
31
|
-
warn(msg, data) {
|
|
32
|
-
this.log("warn", msg, data);
|
|
33
|
-
}
|
|
34
|
-
error(msg, data) {
|
|
35
|
-
this.log("error", msg, data);
|
|
36
|
-
}
|
|
37
|
-
log(level, msg, data) {
|
|
38
|
-
if (!this.enabled) return;
|
|
39
|
-
if (LEVEL_ORDER[level] < LEVEL_ORDER[this.minLevel]) return;
|
|
40
|
-
const now = /* @__PURE__ */ new Date();
|
|
41
|
-
const timestamp = now.toISOString();
|
|
42
|
-
const dateStr = timestamp.split("T")[0];
|
|
43
|
-
const entry = {
|
|
44
|
-
t: timestamp,
|
|
45
|
-
l: level,
|
|
46
|
-
msg
|
|
47
|
-
};
|
|
48
|
-
if (data) entry.d = data;
|
|
49
|
-
try {
|
|
50
|
-
if (!_fs.existsSync.call(void 0, this.logDir)) {
|
|
51
|
-
_fs.mkdirSync.call(void 0, this.logDir, { recursive: true });
|
|
52
|
-
}
|
|
53
|
-
const logFile = _path.join.call(void 0, this.logDir, `${dateStr}.log`);
|
|
54
|
-
_fs.appendFileSync.call(void 0, logFile, JSON.stringify(entry) + "\n", "utf-8");
|
|
55
|
-
} catch (e) {
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var logger = new Logger();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
exports.logger = logger;
|
package/dist/chunk-JT2WSQSR.cjs
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
|
-
|
|
3
|
-
var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
|
|
4
|
-
|
|
5
|
-
// src/lsp/manager.ts
|
|
6
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
7
|
-
|
|
8
|
-
// src/lsp/client.ts
|
|
9
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
10
|
-
var _child_process = require('child_process');
|
|
11
|
-
var _events = require('events');
|
|
12
|
-
var LSPClient = (_class = class extends _events.EventEmitter {
|
|
13
|
-
constructor(command, args = [], cwd) {
|
|
14
|
-
super();_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);;
|
|
15
|
-
this.command = command;
|
|
16
|
-
this.args = args;
|
|
17
|
-
this.cwd = cwd;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
__init() {this.nextId = 1}
|
|
21
|
-
__init2() {this.pending = /* @__PURE__ */ new Map()}
|
|
22
|
-
__init3() {this.buffer = ""}
|
|
23
|
-
__init4() {this.contentLength = -1}
|
|
24
|
-
__init5() {this.initialized = false}
|
|
25
|
-
async start() {
|
|
26
|
-
this.process = _child_process.spawn.call(void 0, this.command, this.args, {
|
|
27
|
-
cwd: this.cwd,
|
|
28
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
29
|
-
});
|
|
30
|
-
_optionalChain([this, 'access', _ => _.process, 'access', _2 => _2.stdout, 'optionalAccess', _3 => _3.on, 'call', _4 => _4("data", (data) => this.handleData(data.toString()))]);
|
|
31
|
-
_optionalChain([this, 'access', _5 => _5.process, 'access', _6 => _6.stderr, 'optionalAccess', _7 => _7.on, 'call', _8 => _8("data", (_data) => {
|
|
32
|
-
})]);
|
|
33
|
-
this.process.on("exit", (code) => {
|
|
34
|
-
this.emit("exit", code);
|
|
35
|
-
this.rejectAll(new Error(`LSP server exited with code ${code}`));
|
|
36
|
-
});
|
|
37
|
-
this.process.unref();
|
|
38
|
-
}
|
|
39
|
-
async initialize(rootUri) {
|
|
40
|
-
const result = await this.request("initialize", {
|
|
41
|
-
processId: process.pid,
|
|
42
|
-
rootUri,
|
|
43
|
-
capabilities: {
|
|
44
|
-
textDocument: {
|
|
45
|
-
definition: { dynamicRegistration: false },
|
|
46
|
-
references: { dynamicRegistration: false },
|
|
47
|
-
hover: { contentFormat: ["plaintext", "markdown"] },
|
|
48
|
-
documentSymbol: { dynamicRegistration: false },
|
|
49
|
-
completion: { dynamicRegistration: false }
|
|
50
|
-
},
|
|
51
|
-
workspace: {
|
|
52
|
-
symbol: { dynamicRegistration: false }
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
await this.notify("initialized", {});
|
|
57
|
-
this.initialized = true;
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
async request(method, params) {
|
|
61
|
-
if (!_optionalChain([this, 'access', _9 => _9.process, 'optionalAccess', _10 => _10.stdin])) throw new Error("LSP server not started");
|
|
62
|
-
const id = this.nextId++;
|
|
63
|
-
const message = { jsonrpc: "2.0", id, method, params };
|
|
64
|
-
const content = JSON.stringify(message);
|
|
65
|
-
const header = `Content-Length: ${Buffer.byteLength(content)}\r
|
|
66
|
-
\r
|
|
67
|
-
`;
|
|
68
|
-
return new Promise((resolve, reject) => {
|
|
69
|
-
const timer = setTimeout(() => {
|
|
70
|
-
if (this.pending.has(id)) {
|
|
71
|
-
this.pending.delete(id);
|
|
72
|
-
reject(new Error(`LSP request "${method}" timed out`));
|
|
73
|
-
}
|
|
74
|
-
}, 3e4);
|
|
75
|
-
_optionalChain([timer, 'access', _11 => _11.unref, 'optionalCall', _12 => _12()]);
|
|
76
|
-
this.pending.set(id, {
|
|
77
|
-
resolve: (value) => {
|
|
78
|
-
clearTimeout(timer);
|
|
79
|
-
resolve(value);
|
|
80
|
-
},
|
|
81
|
-
reject: (err) => {
|
|
82
|
-
clearTimeout(timer);
|
|
83
|
-
reject(err);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
this.process.stdin.write(header + content);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async notify(method, params) {
|
|
90
|
-
if (!_optionalChain([this, 'access', _13 => _13.process, 'optionalAccess', _14 => _14.stdin])) throw new Error("LSP server not started");
|
|
91
|
-
const message = { jsonrpc: "2.0", method, params };
|
|
92
|
-
const content = JSON.stringify(message);
|
|
93
|
-
const header = `Content-Length: ${Buffer.byteLength(content)}\r
|
|
94
|
-
\r
|
|
95
|
-
`;
|
|
96
|
-
this.process.stdin.write(header + content);
|
|
97
|
-
}
|
|
98
|
-
async shutdown() {
|
|
99
|
-
if (!this.process) return;
|
|
100
|
-
try {
|
|
101
|
-
await this.request("shutdown", {});
|
|
102
|
-
await this.notify("exit", {});
|
|
103
|
-
} catch (e) {
|
|
104
|
-
}
|
|
105
|
-
_optionalChain([this, 'access', _15 => _15.process, 'access', _16 => _16.stdout, 'optionalAccess', _17 => _17.removeAllListeners, 'call', _18 => _18()]);
|
|
106
|
-
_optionalChain([this, 'access', _19 => _19.process, 'access', _20 => _20.stderr, 'optionalAccess', _21 => _21.removeAllListeners, 'call', _22 => _22()]);
|
|
107
|
-
this.process.removeAllListeners();
|
|
108
|
-
this.process.kill();
|
|
109
|
-
this.process = void 0;
|
|
110
|
-
for (const { reject } of this.pending.values()) {
|
|
111
|
-
reject(new Error("LSP server shut down"));
|
|
112
|
-
}
|
|
113
|
-
this.pending.clear();
|
|
114
|
-
}
|
|
115
|
-
get isInitialized() {
|
|
116
|
-
return this.initialized;
|
|
117
|
-
}
|
|
118
|
-
get isAlive() {
|
|
119
|
-
return this.process !== void 0 && !this.process.killed;
|
|
120
|
-
}
|
|
121
|
-
handleData(data) {
|
|
122
|
-
this.buffer += data;
|
|
123
|
-
while (true) {
|
|
124
|
-
if (this.contentLength < 0) {
|
|
125
|
-
const headerEnd = this.buffer.indexOf("\r\n\r\n");
|
|
126
|
-
if (headerEnd < 0) break;
|
|
127
|
-
const header = this.buffer.slice(0, headerEnd);
|
|
128
|
-
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
129
|
-
if (!match) {
|
|
130
|
-
this.buffer = this.buffer.slice(headerEnd + 4);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
this.contentLength = parseInt(match[1], 10);
|
|
134
|
-
this.buffer = this.buffer.slice(headerEnd + 4);
|
|
135
|
-
}
|
|
136
|
-
if (this.buffer.length < this.contentLength) break;
|
|
137
|
-
const content = this.buffer.slice(0, this.contentLength);
|
|
138
|
-
this.buffer = this.buffer.slice(this.contentLength);
|
|
139
|
-
this.contentLength = -1;
|
|
140
|
-
try {
|
|
141
|
-
const message = JSON.parse(content);
|
|
142
|
-
if ("id" in message && this.pending.has(message.id)) {
|
|
143
|
-
const { resolve, reject } = this.pending.get(message.id);
|
|
144
|
-
this.pending.delete(message.id);
|
|
145
|
-
if (message.error) {
|
|
146
|
-
reject(new Error(`LSP error: ${message.error.message}`));
|
|
147
|
-
} else {
|
|
148
|
-
resolve(message.result);
|
|
149
|
-
}
|
|
150
|
-
} else if ("method" in message && !("id" in message)) {
|
|
151
|
-
this.emit("notification", message);
|
|
152
|
-
}
|
|
153
|
-
} catch (e2) {
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
rejectAll(error) {
|
|
158
|
-
for (const { reject } of this.pending.values()) {
|
|
159
|
-
reject(error);
|
|
160
|
-
}
|
|
161
|
-
this.pending.clear();
|
|
162
|
-
}
|
|
163
|
-
}, _class);
|
|
164
|
-
|
|
165
|
-
// src/lsp/servers.ts
|
|
166
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
167
|
-
var BUILTIN_LSP_SERVERS = [
|
|
168
|
-
{
|
|
169
|
-
name: "typescript",
|
|
170
|
-
language: "typescript",
|
|
171
|
-
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
172
|
-
command: "typescript-language-server",
|
|
173
|
-
args: ["--stdio"],
|
|
174
|
-
installHint: "npm install -g typescript-language-server typescript"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
name: "python",
|
|
178
|
-
language: "python",
|
|
179
|
-
extensions: [".py"],
|
|
180
|
-
command: "pylsp",
|
|
181
|
-
args: [],
|
|
182
|
-
installHint: "pip install python-lsp-server"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "go",
|
|
186
|
-
language: "go",
|
|
187
|
-
extensions: [".go"],
|
|
188
|
-
command: "gopls",
|
|
189
|
-
args: ["serve"],
|
|
190
|
-
installHint: "go install golang.org/x/tools/gopls@latest"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: "rust",
|
|
194
|
-
language: "rust",
|
|
195
|
-
extensions: [".rs"],
|
|
196
|
-
command: "rust-analyzer",
|
|
197
|
-
args: [],
|
|
198
|
-
installHint: "rustup component add rust-analyzer"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
name: "json",
|
|
202
|
-
language: "json",
|
|
203
|
-
extensions: [".json"],
|
|
204
|
-
command: "vscode-json-languageserver",
|
|
205
|
-
args: ["--stdio"],
|
|
206
|
-
installHint: "npm install -g vscode-langservers-extracted"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
name: "css",
|
|
210
|
-
language: "css",
|
|
211
|
-
extensions: [".css", ".scss", ".less"],
|
|
212
|
-
command: "vscode-css-languageserver",
|
|
213
|
-
args: ["--stdio"],
|
|
214
|
-
installHint: "npm install -g vscode-langservers-extracted"
|
|
215
|
-
}
|
|
216
|
-
];
|
|
217
|
-
function detectLSPServer(filePath) {
|
|
218
|
-
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
219
|
-
return BUILTIN_LSP_SERVERS.find((s) => s.extensions.includes(ext));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/lsp/manager.ts
|
|
223
|
-
|
|
224
|
-
var _url = require('url');
|
|
225
|
-
var LSPServerManager = (_class2 = class {
|
|
226
|
-
__init6() {this.servers = /* @__PURE__ */ new Map()}
|
|
227
|
-
|
|
228
|
-
constructor(cwd) {;_class2.prototype.__init6.call(this);
|
|
229
|
-
this.rootUri = _url.pathToFileURL.call(void 0, cwd).href;
|
|
230
|
-
for (const config of BUILTIN_LSP_SERVERS) {
|
|
231
|
-
this.servers.set(config.name, { config, client: void 0, state: "stopped" });
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Get or start a language server by name.
|
|
236
|
-
*/
|
|
237
|
-
async getClient(serverName) {
|
|
238
|
-
const managed = this.servers.get(serverName);
|
|
239
|
-
if (!managed) return void 0;
|
|
240
|
-
if (managed.state === "ready" && _optionalChain([managed, 'access', _23 => _23.client, 'optionalAccess', _24 => _24.isAlive])) {
|
|
241
|
-
return managed.client;
|
|
242
|
-
}
|
|
243
|
-
if (managed.state === "starting") {
|
|
244
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
245
|
-
return managed.client;
|
|
246
|
-
}
|
|
247
|
-
return this.startServer(serverName);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Start a specific language server.
|
|
251
|
-
*/
|
|
252
|
-
async startServer(name) {
|
|
253
|
-
const managed = this.servers.get(name);
|
|
254
|
-
if (!managed) return void 0;
|
|
255
|
-
if (!this.isCommandAvailable(managed.config.command)) {
|
|
256
|
-
managed.state = "error";
|
|
257
|
-
managed.error = `${managed.config.command} not found. Install: ${managed.config.installHint}`;
|
|
258
|
-
return void 0;
|
|
259
|
-
}
|
|
260
|
-
managed.state = "starting";
|
|
261
|
-
try {
|
|
262
|
-
const client = new LSPClient(managed.config.command, managed.config.args, this.rootUri.replace("file://", ""));
|
|
263
|
-
await client.start();
|
|
264
|
-
await client.initialize(this.rootUri);
|
|
265
|
-
managed.client = client;
|
|
266
|
-
managed.state = "ready";
|
|
267
|
-
return client;
|
|
268
|
-
} catch (err) {
|
|
269
|
-
managed.state = "error";
|
|
270
|
-
managed.error = err.message;
|
|
271
|
-
return void 0;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Check if any LSP server is connected.
|
|
276
|
-
*/
|
|
277
|
-
isConnected() {
|
|
278
|
-
for (const server of this.servers.values()) {
|
|
279
|
-
if (server.state === "ready" && _optionalChain([server, 'access', _25 => _25.client, 'optionalAccess', _26 => _26.isAlive])) return true;
|
|
280
|
-
}
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* List server statuses.
|
|
285
|
-
*/
|
|
286
|
-
listServers() {
|
|
287
|
-
return [...this.servers.values()].map((s) => ({
|
|
288
|
-
name: s.config.name,
|
|
289
|
-
language: s.config.language,
|
|
290
|
-
state: s.state,
|
|
291
|
-
error: s.error
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Shutdown all servers.
|
|
296
|
-
*/
|
|
297
|
-
async shutdownAll() {
|
|
298
|
-
for (const server of this.servers.values()) {
|
|
299
|
-
if (_optionalChain([server, 'access', _27 => _27.client, 'optionalAccess', _28 => _28.isAlive])) {
|
|
300
|
-
try {
|
|
301
|
-
await server.client.shutdown();
|
|
302
|
-
} catch (e3) {
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
server.state = "stopped";
|
|
306
|
-
server.client = void 0;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
isCommandAvailable(command) {
|
|
310
|
-
try {
|
|
311
|
-
_child_process.execSync.call(void 0, `which ${command} 2>/dev/null || where ${command} 2>nul`, {
|
|
312
|
-
encoding: "utf-8",
|
|
313
|
-
timeout: 5e3
|
|
314
|
-
});
|
|
315
|
-
return true;
|
|
316
|
-
} catch (e4) {
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}, _class2);
|
|
321
|
-
var _manager;
|
|
322
|
-
function initializeLSPManager(cwd) {
|
|
323
|
-
_manager = new LSPServerManager(cwd);
|
|
324
|
-
return _manager;
|
|
325
|
-
}
|
|
326
|
-
function getLSPManager() {
|
|
327
|
-
return _manager;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
exports.detectLSPServer = detectLSPServer; exports.LSPServerManager = LSPServerManager; exports.initializeLSPManager = initializeLSPManager; exports.getLSPManager = getLSPManager;
|