@cjhyy/code-shell 0.1.0-alpha.0 → 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/CHANGELOG.md +39 -0
- 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-WFQF3RT4.cjs → chunk-3CAZIWUA.cjs} +11 -8
- 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-7RMAR2Y3.js → chunk-ID6EJUHP.js} +1959 -473
- package/dist/chunk-JHNCK7JP.cjs +202 -0
- package/dist/{chunk-R32DJSJE.cjs → chunk-JHXNOB5G.cjs} +8 -5
- 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-6JOOLG6F.js → chunk-REFCCVDM.js} +5 -2
- package/dist/{chunk-O6F2EF2Z.js → chunk-SCDKLTN3.js} +41 -2
- package/dist/{chunk-BHGIJ2DJ.js → chunk-SW3L7HIM.js} +6 -3
- package/dist/chunk-TATCTZSB.cjs +4753 -0
- package/dist/{chunk-QHDYFC5U.cjs → chunk-VWFET3MG.cjs} +2132 -646
- 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 +3576 -2036
- package/dist/cli/main.js +3613 -2073
- 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 +39 -4
- package/dist/engine/turn-loop.d.ts +13 -4
- package/dist/engine/turn-state.d.ts +6 -0
- package/dist/index.cjs +19 -28
- package/dist/index.d.ts +1 -1
- 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/product/types.d.ts +2 -7
- package/dist/protocol/types.d.ts +11 -3
- package/dist/{ink → render}/hooks/use-input.d.ts +1 -1
- package/dist/run/EngineRunner.d.ts +3 -1
- package/dist/run/RunManager.d.ts +6 -0
- package/dist/run/factory.d.ts +7 -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-registry.d.ts +36 -0
- package/dist/tool-system/builtin/agent.d.ts +7 -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 +8 -0
- package/dist/types.d.ts +34 -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-URVNPDPW.cjs → updater-M7L42ASZ.cjs} +4 -4
- package/dist/{updater-AVD4LKTQ.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
|
@@ -8,7 +8,7 @@ var require_package = _chunkIJSHQGMPcjs.__commonJS.call(void 0, {
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@cjhyy/code-shell",
|
|
11
|
-
version: "0.1.0-alpha.
|
|
11
|
+
version: "0.1.0-alpha.2",
|
|
12
12
|
description: "Code Shell \u2014 general-purpose agent orchestration framework with a terminal coding preset",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
@@ -52,9 +52,10 @@ var require_package = _chunkIJSHQGMPcjs.__commonJS.call(void 0, {
|
|
|
52
52
|
access: "public"
|
|
53
53
|
},
|
|
54
54
|
scripts: {
|
|
55
|
-
build: "bun run tsup && bun run build:dts",
|
|
55
|
+
build: "bun run sync-models && bun run tsup && bun run build:dts",
|
|
56
56
|
"build:dts": "tsc --emitDeclarationOnly --declaration --outDir dist || true",
|
|
57
|
-
|
|
57
|
+
"sync-models": "bun run scripts/sync-models.ts",
|
|
58
|
+
dev: "CODE_SHELL_DEV=1 bun run src/cli/main.ts",
|
|
58
59
|
test: "bun test",
|
|
59
60
|
"test:watch": "bun test --watch",
|
|
60
61
|
lint: "eslint src/",
|
|
@@ -100,7 +101,6 @@ var require_package = _chunkIJSHQGMPcjs.__commonJS.call(void 0, {
|
|
|
100
101
|
"get-east-asian-width": "^1.5.0",
|
|
101
102
|
glob: "^11.0.0",
|
|
102
103
|
"indent-string": "^5.0.0",
|
|
103
|
-
ink: "^6.8.0",
|
|
104
104
|
"lodash-es": "^4.17.23",
|
|
105
105
|
marked: "^17.0.5",
|
|
106
106
|
"marked-terminal": "^7.3.0",
|
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@cjhyy/code-shell",
|
|
11
|
-
version: "0.1.0-alpha.
|
|
11
|
+
version: "0.1.0-alpha.2",
|
|
12
12
|
description: "Code Shell \u2014 general-purpose agent orchestration framework with a terminal coding preset",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
@@ -52,9 +52,10 @@ var require_package = __commonJS({
|
|
|
52
52
|
access: "public"
|
|
53
53
|
},
|
|
54
54
|
scripts: {
|
|
55
|
-
build: "bun run tsup && bun run build:dts",
|
|
55
|
+
build: "bun run sync-models && bun run tsup && bun run build:dts",
|
|
56
56
|
"build:dts": "tsc --emitDeclarationOnly --declaration --outDir dist || true",
|
|
57
|
-
|
|
57
|
+
"sync-models": "bun run scripts/sync-models.ts",
|
|
58
|
+
dev: "CODE_SHELL_DEV=1 bun run src/cli/main.ts",
|
|
58
59
|
test: "bun test",
|
|
59
60
|
"test:watch": "bun test --watch",
|
|
60
61
|
lint: "eslint src/",
|
|
@@ -100,7 +101,6 @@ var require_package = __commonJS({
|
|
|
100
101
|
"get-east-asian-width": "^1.5.0",
|
|
101
102
|
glob: "^11.0.0",
|
|
102
103
|
"indent-string": "^5.0.0",
|
|
103
|
-
ink: "^6.8.0",
|
|
104
104
|
"lodash-es": "^4.17.23",
|
|
105
105
|
marked: "^17.0.5",
|
|
106
106
|
"marked-terminal": "^7.3.0",
|
package/dist/utils/debug.d.ts
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Debug logging —
|
|
2
|
+
* Debug logging — thin facade over the unified logger.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* --debug — all debug output to file (~/.code-shell/debug/<session>.txt)
|
|
7
|
-
* --debug=api,hooks — filtered categories only
|
|
8
|
-
* --debug-file=/path/to/file — explicit output file
|
|
9
|
-
* --debug-to-stderr / -d2e — force stderr output
|
|
4
|
+
* Historically this module wrote to ~/.code-shell/debug/<session>.txt.
|
|
5
|
+
* It now delegates to logger so all output lands in ~/.code-shell/logs/.
|
|
10
6
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Activation knobs (still honored, parsed inside logger):
|
|
8
|
+
* CODE_SHELL_LOG_LEVEL=debug — explicit level
|
|
9
|
+
* CODE_SHELL_DEBUG=mcp,api — category filter
|
|
10
|
+
* --debug — local dev: defaults to debug level
|
|
11
|
+
* --debug=mcp,api — category filter (CLI form)
|
|
12
|
+
* --debug-to-stderr / -d2e — echo to stderr instead of file
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
categories: Set<string>;
|
|
17
|
-
};
|
|
14
|
+
import { type LogLevel } from "../logging/logger.js";
|
|
15
|
+
export type DebugLogLevel = "verbose" | LogLevel;
|
|
18
16
|
export declare function setDebugSessionId(id: string): void;
|
|
19
|
-
export declare function getMinDebugLogLevel(): DebugLogLevel;
|
|
20
17
|
export declare function isDebugMode(): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Enable debug logging mid-session (e.g. via /debug command).
|
|
23
|
-
* Returns true if logging was already active.
|
|
24
|
-
*/
|
|
25
18
|
export declare function enableDebugLogging(): boolean;
|
|
26
19
|
export declare function isDebugToStdErr(): boolean;
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function getDebugFilePath(): string | null;
|
|
20
|
+
export declare function getMinDebugLogLevel(): DebugLogLevel;
|
|
29
21
|
/**
|
|
30
|
-
* Log a debug message
|
|
31
|
-
*
|
|
32
|
-
* or to a file (~/.code-shell/debug/<session>.txt).
|
|
22
|
+
* Log a debug message. Optional level via opts.level.
|
|
23
|
+
* Embedded `[category]` tags are extracted into the structured `cat` field.
|
|
33
24
|
*/
|
|
34
25
|
export declare function logForDebugging(message: string, opts?: {
|
|
35
26
|
level?: DebugLogLevel | string;
|
|
@@ -40,18 +31,11 @@ export declare function logForDebugging(message: string, opts?: {
|
|
|
40
31
|
*/
|
|
41
32
|
export declare function debugCategory(category: string): (msg: string) => void;
|
|
42
33
|
/**
|
|
43
|
-
* Time a function and log the duration.
|
|
34
|
+
* Time a function and log the duration at debug level.
|
|
44
35
|
*/
|
|
45
36
|
export declare function debugTiming<T>(label: string, fn: () => T | Promise<T>): Promise<T>;
|
|
46
|
-
/**
|
|
47
|
-
* CC compatibility: log errors for Anthropic internal users.
|
|
48
|
-
* In Code Shell this is a debug-level error log.
|
|
49
|
-
*/
|
|
50
37
|
export declare function logAntError(msg: string, _err?: unknown): void;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*/
|
|
54
|
-
export declare function setHasFormattedOutput(_value: boolean): void;
|
|
38
|
+
export declare function getDebugFilePath(): string | null;
|
|
39
|
+
export declare function setHasFormattedOutput(_v: boolean): void;
|
|
55
40
|
export declare function getHasFormattedOutput(): boolean;
|
|
56
41
|
export declare function flushDebugLogs(): Promise<void>;
|
|
57
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjhyy/code-shell",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
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",
|
|
@@ -44,9 +44,10 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "bun run tsup && bun run build:dts",
|
|
47
|
+
"build": "bun run sync-models && bun run tsup && bun run build:dts",
|
|
48
48
|
"build:dts": "tsc --emitDeclarationOnly --declaration --outDir dist || true",
|
|
49
|
-
"
|
|
49
|
+
"sync-models": "bun run scripts/sync-models.ts",
|
|
50
|
+
"dev": "CODE_SHELL_DEV=1 bun run src/cli/main.ts",
|
|
50
51
|
"test": "bun test",
|
|
51
52
|
"test:watch": "bun test --watch",
|
|
52
53
|
"lint": "eslint src/",
|
|
@@ -92,7 +93,6 @@
|
|
|
92
93
|
"get-east-asian-width": "^1.5.0",
|
|
93
94
|
"glob": "^11.0.0",
|
|
94
95
|
"indent-string": "^5.0.0",
|
|
95
|
-
"ink": "^6.8.0",
|
|
96
96
|
"lodash-es": "^4.17.23",
|
|
97
97
|
"marked": "^17.0.5",
|
|
98
98
|
"marked-terminal": "^7.3.0",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkZJV3YSY3cjs = require('./chunk-ZJV3YSY3.cjs');
|
|
4
|
-
require('./chunk-DICG4AB7.cjs');
|
|
5
|
-
require('./chunk-EL2RL5DG.cjs');
|
|
6
|
-
require('./chunk-IJSHQGMP.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.AnthropicClient = _chunkZJV3YSY3cjs.AnthropicClient;
|
package/dist/bridge-4ZRXVWBN.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_esm_shims
|
|
3
|
-
} from "./chunk-DI7RDLOS.js";
|
|
4
|
-
|
|
5
|
-
// src/remote/bridge.ts
|
|
6
|
-
init_esm_shims();
|
|
7
|
-
import { spawn } from "child_process";
|
|
8
|
-
import { createInterface } from "readline";
|
|
9
|
-
var RemoteBridge = class {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
}
|
|
13
|
-
ssh;
|
|
14
|
-
connected = false;
|
|
15
|
-
/**
|
|
16
|
-
* Connect to the remote host via SSH and start code-shell in NDJSON mode.
|
|
17
|
-
*/
|
|
18
|
-
async connect() {
|
|
19
|
-
const sshArgs = this.buildSSHArgs();
|
|
20
|
-
const remoteCmd = this.config.remoteCommand ?? "code-shell run --output stream-json";
|
|
21
|
-
this.ssh = spawn("ssh", [...sshArgs, remoteCmd], {
|
|
22
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
23
|
-
});
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const timer = setTimeout(() => {
|
|
26
|
-
reject(new Error("SSH connection timed out"));
|
|
27
|
-
this.disconnect();
|
|
28
|
-
}, 3e4);
|
|
29
|
-
this.ssh.stdout?.once("data", () => {
|
|
30
|
-
clearTimeout(timer);
|
|
31
|
-
this.connected = true;
|
|
32
|
-
resolve();
|
|
33
|
-
});
|
|
34
|
-
this.ssh.on("error", (err) => {
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
reject(err);
|
|
37
|
-
});
|
|
38
|
-
this.ssh.on("exit", (code) => {
|
|
39
|
-
this.connected = false;
|
|
40
|
-
if (!this.connected) {
|
|
41
|
-
clearTimeout(timer);
|
|
42
|
-
reject(new Error(`SSH exited with code ${code}`));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Send a message to the remote code-shell.
|
|
49
|
-
*/
|
|
50
|
-
send(message) {
|
|
51
|
-
if (!this.connected || !this.ssh?.stdin) {
|
|
52
|
-
throw new Error("Not connected");
|
|
53
|
-
}
|
|
54
|
-
this.ssh.stdin.write(JSON.stringify(message) + "\n");
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Async iterator for messages from the remote code-shell.
|
|
58
|
-
*/
|
|
59
|
-
async *messages() {
|
|
60
|
-
if (!this.ssh?.stdout) return;
|
|
61
|
-
const rl = createInterface({ input: this.ssh.stdout, crlfDelay: Infinity });
|
|
62
|
-
for await (const line of rl) {
|
|
63
|
-
const trimmed = line.trim();
|
|
64
|
-
if (!trimmed) continue;
|
|
65
|
-
try {
|
|
66
|
-
yield JSON.parse(trimmed);
|
|
67
|
-
} catch {
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Disconnect from the remote host.
|
|
73
|
-
*/
|
|
74
|
-
disconnect() {
|
|
75
|
-
this.connected = false;
|
|
76
|
-
if (this.ssh) {
|
|
77
|
-
this.ssh.kill();
|
|
78
|
-
this.ssh = void 0;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
get isConnected() {
|
|
82
|
-
return this.connected;
|
|
83
|
-
}
|
|
84
|
-
buildSSHArgs() {
|
|
85
|
-
const args = ["-T"];
|
|
86
|
-
if (this.config.port) args.push("-p", String(this.config.port));
|
|
87
|
-
if (this.config.identityFile) args.push("-i", this.config.identityFile);
|
|
88
|
-
if (this.config.user) {
|
|
89
|
-
args.push(`${this.config.user}@${this.config.host}`);
|
|
90
|
-
} else {
|
|
91
|
-
args.push(this.config.host);
|
|
92
|
-
}
|
|
93
|
-
return args;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
export {
|
|
97
|
-
RemoteBridge
|
|
98
|
-
};
|
package/dist/bridge-W476QDFH.cjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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;
|
|
2
|
-
|
|
3
|
-
var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
|
|
4
|
-
|
|
5
|
-
// src/remote/bridge.ts
|
|
6
|
-
_chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
|
|
7
|
-
var _child_process = require('child_process');
|
|
8
|
-
var _readline = require('readline');
|
|
9
|
-
var RemoteBridge = (_class = class {
|
|
10
|
-
constructor(config) {;_class.prototype.__init.call(this);
|
|
11
|
-
this.config = config;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
__init() {this.connected = false}
|
|
15
|
-
/**
|
|
16
|
-
* Connect to the remote host via SSH and start code-shell in NDJSON mode.
|
|
17
|
-
*/
|
|
18
|
-
async connect() {
|
|
19
|
-
const sshArgs = this.buildSSHArgs();
|
|
20
|
-
const remoteCmd = _nullishCoalesce(this.config.remoteCommand, () => ( "code-shell run --output stream-json"));
|
|
21
|
-
this.ssh = _child_process.spawn.call(void 0, "ssh", [...sshArgs, remoteCmd], {
|
|
22
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
23
|
-
});
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const timer = setTimeout(() => {
|
|
26
|
-
reject(new Error("SSH connection timed out"));
|
|
27
|
-
this.disconnect();
|
|
28
|
-
}, 3e4);
|
|
29
|
-
_optionalChain([this, 'access', _ => _.ssh, 'access', _2 => _2.stdout, 'optionalAccess', _3 => _3.once, 'call', _4 => _4("data", () => {
|
|
30
|
-
clearTimeout(timer);
|
|
31
|
-
this.connected = true;
|
|
32
|
-
resolve();
|
|
33
|
-
})]);
|
|
34
|
-
this.ssh.on("error", (err) => {
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
reject(err);
|
|
37
|
-
});
|
|
38
|
-
this.ssh.on("exit", (code) => {
|
|
39
|
-
this.connected = false;
|
|
40
|
-
if (!this.connected) {
|
|
41
|
-
clearTimeout(timer);
|
|
42
|
-
reject(new Error(`SSH exited with code ${code}`));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Send a message to the remote code-shell.
|
|
49
|
-
*/
|
|
50
|
-
send(message) {
|
|
51
|
-
if (!this.connected || !_optionalChain([this, 'access', _5 => _5.ssh, 'optionalAccess', _6 => _6.stdin])) {
|
|
52
|
-
throw new Error("Not connected");
|
|
53
|
-
}
|
|
54
|
-
this.ssh.stdin.write(JSON.stringify(message) + "\n");
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Async iterator for messages from the remote code-shell.
|
|
58
|
-
*/
|
|
59
|
-
async *messages() {
|
|
60
|
-
if (!_optionalChain([this, 'access', _7 => _7.ssh, 'optionalAccess', _8 => _8.stdout])) return;
|
|
61
|
-
const rl = _readline.createInterface.call(void 0, { input: this.ssh.stdout, crlfDelay: Infinity });
|
|
62
|
-
for await (const line of rl) {
|
|
63
|
-
const trimmed = line.trim();
|
|
64
|
-
if (!trimmed) continue;
|
|
65
|
-
try {
|
|
66
|
-
yield JSON.parse(trimmed);
|
|
67
|
-
} catch (e) {
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Disconnect from the remote host.
|
|
73
|
-
*/
|
|
74
|
-
disconnect() {
|
|
75
|
-
this.connected = false;
|
|
76
|
-
if (this.ssh) {
|
|
77
|
-
this.ssh.kill();
|
|
78
|
-
this.ssh = void 0;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
get isConnected() {
|
|
82
|
-
return this.connected;
|
|
83
|
-
}
|
|
84
|
-
buildSSHArgs() {
|
|
85
|
-
const args = ["-T"];
|
|
86
|
-
if (this.config.port) args.push("-p", String(this.config.port));
|
|
87
|
-
if (this.config.identityFile) args.push("-i", this.config.identityFile);
|
|
88
|
-
if (this.config.user) {
|
|
89
|
-
args.push(`${this.config.user}@${this.config.host}`);
|
|
90
|
-
} else {
|
|
91
|
-
args.push(this.config.host);
|
|
92
|
-
}
|
|
93
|
-
return args;
|
|
94
|
-
}
|
|
95
|
-
}, _class);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
exports.RemoteBridge = RemoteBridge;
|
package/dist/chunk-4RRUP4MM.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__esm,
|
|
3
|
-
init_esm_shims
|
|
4
|
-
} from "./chunk-DI7RDLOS.js";
|
|
5
|
-
|
|
6
|
-
// src/context/token-counter.ts
|
|
7
|
-
function estimateStringTokens(text) {
|
|
8
|
-
if (!text) return 0;
|
|
9
|
-
const cjkChars = (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 = __esm({
|
|
64
|
-
"src/context/token-counter.ts"() {
|
|
65
|
-
init_esm_shims();
|
|
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
|
-
export {
|
|
82
|
-
estimateStringTokens,
|
|
83
|
-
estimateMessagesTokens,
|
|
84
|
-
calculateContextUsage,
|
|
85
|
-
init_token_counter
|
|
86
|
-
};
|
package/dist/chunk-4SFPFHMG.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_esm_shims
|
|
3
|
-
} from "./chunk-DI7RDLOS.js";
|
|
4
|
-
|
|
5
|
-
// src/skills/index.ts
|
|
6
|
-
init_esm_shims();
|
|
7
|
-
|
|
8
|
-
// src/skills/scanner.ts
|
|
9
|
-
init_esm_shims();
|
|
10
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
11
|
-
import { join, resolve } from "path";
|
|
12
|
-
import { homedir } from "os";
|
|
13
|
-
function scanSkills(cwd) {
|
|
14
|
-
const skills = [];
|
|
15
|
-
const seen = /* @__PURE__ */ new Set();
|
|
16
|
-
const dirs = [
|
|
17
|
-
// Project-level
|
|
18
|
-
join(cwd, ".code-shell", "skills"),
|
|
19
|
-
join(cwd, ".claude", "skills"),
|
|
20
|
-
// User-level
|
|
21
|
-
join(homedir(), ".code-shell", "skills"),
|
|
22
|
-
join(homedir(), ".claude", "skills")
|
|
23
|
-
];
|
|
24
|
-
for (const dir of dirs) {
|
|
25
|
-
if (!existsSync(dir)) continue;
|
|
26
|
-
try {
|
|
27
|
-
const files = readdirSync(dir).filter(
|
|
28
|
-
(f) => f.endsWith(".md") && statSync(join(dir, f)).isFile()
|
|
29
|
-
);
|
|
30
|
-
for (const file of files) {
|
|
31
|
-
const filePath = resolve(join(dir, file));
|
|
32
|
-
if (seen.has(filePath)) continue;
|
|
33
|
-
seen.add(filePath);
|
|
34
|
-
const skill = parseSkillFile(filePath);
|
|
35
|
-
if (skill) skills.push(skill);
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return skills;
|
|
41
|
-
}
|
|
42
|
-
function parseSkillFile(filePath) {
|
|
43
|
-
try {
|
|
44
|
-
const raw = readFileSync(filePath, "utf-8");
|
|
45
|
-
const match = raw.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);
|
|
46
|
-
if (!match) return null;
|
|
47
|
-
const frontmatter = match[1];
|
|
48
|
-
const content = match[2].trim();
|
|
49
|
-
const name = extractField(frontmatter, "name");
|
|
50
|
-
if (!name) return null;
|
|
51
|
-
const description = extractField(frontmatter, "description") ?? "";
|
|
52
|
-
const whenToUse = extractField(frontmatter, "when_to_use") ?? "";
|
|
53
|
-
const keywords = extractList(frontmatter, "keywords");
|
|
54
|
-
const tools = extractList(frontmatter, "tools");
|
|
55
|
-
const intents = extractList(frontmatter, "intents");
|
|
56
|
-
return {
|
|
57
|
-
name,
|
|
58
|
-
description,
|
|
59
|
-
triggers: { keywords, tools, intents },
|
|
60
|
-
whenToUse,
|
|
61
|
-
content,
|
|
62
|
-
filePath
|
|
63
|
-
};
|
|
64
|
-
} catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function extractField(frontmatter, field) {
|
|
69
|
-
const match = frontmatter.match(new RegExp(`^${field}:\\s*(.+)$`, "m"));
|
|
70
|
-
return match?.[1]?.trim();
|
|
71
|
-
}
|
|
72
|
-
function extractList(frontmatter, field) {
|
|
73
|
-
const match = frontmatter.match(new RegExp(`${field}:\\s*\\[([^\\]]+)\\]`));
|
|
74
|
-
if (!match) return [];
|
|
75
|
-
return match[1].split(",").map((s) => s.trim().replace(/^['"]|['"]$/g, ""));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// src/skills/matcher.ts
|
|
79
|
-
init_esm_shims();
|
|
80
|
-
function matchSkillsByInput(skills, input) {
|
|
81
|
-
const inputLower = input.toLowerCase();
|
|
82
|
-
const results = [];
|
|
83
|
-
for (const skill of skills) {
|
|
84
|
-
let bestScore = 0;
|
|
85
|
-
let matchedBy = "";
|
|
86
|
-
if (skill.triggers.keywords) {
|
|
87
|
-
for (const kw of skill.triggers.keywords) {
|
|
88
|
-
if (inputLower.includes(kw.toLowerCase())) {
|
|
89
|
-
const score = kw.length / input.length * 10 + 5;
|
|
90
|
-
if (score > bestScore) {
|
|
91
|
-
bestScore = score;
|
|
92
|
-
matchedBy = "keyword";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (skill.triggers.intents) {
|
|
98
|
-
for (const intent of skill.triggers.intents) {
|
|
99
|
-
if (inputLower.includes(intent.toLowerCase())) {
|
|
100
|
-
const score = 8;
|
|
101
|
-
if (score > bestScore) {
|
|
102
|
-
bestScore = score;
|
|
103
|
-
matchedBy = "intent";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (bestScore > 0) {
|
|
109
|
-
results.push({ skill, score: bestScore, matchedBy });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return results.sort((a, b) => b.score - a.score);
|
|
113
|
-
}
|
|
114
|
-
function matchSkillsByTool(skills, toolName) {
|
|
115
|
-
return skills.filter((s) => s.triggers.tools?.includes(toolName)).map((skill) => ({ skill, score: 10, matchedBy: "tool" }));
|
|
116
|
-
}
|
|
117
|
-
function buildSkillListing(skills) {
|
|
118
|
-
if (skills.length === 0) return "";
|
|
119
|
-
const lines = skills.map(
|
|
120
|
-
(s) => `- **${s.name}**: ${s.description}${s.whenToUse ? ` \u2014 Use when: ${s.whenToUse}` : ""}`
|
|
121
|
-
);
|
|
122
|
-
return `# Available Skills
|
|
123
|
-
|
|
124
|
-
${lines.join("\n")}`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
scanSkills,
|
|
129
|
-
matchSkillsByInput,
|
|
130
|
-
matchSkillsByTool,
|
|
131
|
-
buildSkillListing
|
|
132
|
-
};
|