Skip to content

Commit 1ce7374

Browse files
committed
refactor: migrate core config and routing to typescript
1 parent b423d90 commit 1ce7374

11 files changed

Lines changed: 1156 additions & 61 deletions

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
## Test Commands
1919

20-
- `npm test`: run the full unit test suite with `node --test`.
21-
- `npm run check`: run a syntax check on the entrypoint and fail fast on invalid JS.
20+
- `npm test`: run the full unit test suite with the Node test runner plus `tsx`.
21+
- `npm run check`: run the repository typecheck gate.
22+
- `npm run typecheck`: run `tsc --noEmit` directly.
2223
- `npm run healthcheck`: run the local runtime health check.
2324

2425
## Lint And Format

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ npm run healthcheck
8787

8888
- `npm run start` - start the bot
8989
- `npm run dev` - watch mode for local development
90-
- `npm run check` - syntax validation
90+
- `npm run check` - TypeScript-aware type and syntax validation for the mixed JS/TS codebase
91+
- `npm run typecheck` - run the TypeScript compiler in `--noEmit` mode
9192
- `npm run lint` - ESLint for source, tests, scripts, and local JS/CJS config files
9293
- `npm run lint:fix` - apply safe lint fixes
9394
- `npm run format` - format repository files with Prettier
@@ -102,7 +103,7 @@ npm run healthcheck
102103
```text
103104
Telegram Message
104105
-> src/bot/handlers.js
105-
-> src/orchestrator/router.js
106+
-> src/orchestrator/router.ts
106107
-> src/runner/ptyManager.js (coding tasks -> Codex CLI)
107108
-> src/orchestrator/skills/*.js (general tasks -> MCP/GitHub subagents)
108109
-> src/bot/formatter.js
@@ -112,7 +113,7 @@ Telegram Message
112113
Core modules:
113114

114115
- `src/index.js`: bootstrap and lifecycle
115-
- `src/config.js`: env parsing and validation
116+
- `src/config.ts`: env parsing and validation
116117
- `src/bot/`: auth middleware, formatting, command handlers
117118
- `src/orchestrator/`: routing + MCP client + skills
118119
- `src/runner/ptyManager.js`: Codex PTY process + streaming
@@ -153,8 +154,8 @@ How they are triggered:
153154

154155
Where this happens:
155156

156-
- Router decision order: [router.js](/Users/ding/Documents/Code/Github/codex-telegram-claws/src/orchestrator/router.js)
157-
- Skill toggles per chat: [skillRegistry.js](/Users/ding/Documents/Code/Github/codex-telegram-claws/src/orchestrator/skillRegistry.js)
157+
- Router decision order: [router.ts](/Users/ding/Documents/Code/Github/codex-telegram-claws/src/orchestrator/router.ts)
158+
- Skill toggles per chat: [skillRegistry.ts](/Users/ding/Documents/Code/Github/codex-telegram-claws/src/orchestrator/skillRegistry.ts)
158159
- Telegram command entrypoints: [handlers.js](/Users/ding/Documents/Code/Github/codex-telegram-claws/src/bot/handlers.js)
159160

160161
Operationally, subagents are the bot's control plane. Codex remains the coding execution plane.

docs/enterprise-architecture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ Implementation roadmap: [phase-1-roadmap.md](/Users/ding/Documents/Code/Github/c
107107

108108
For enterprise rollout, migrate the following first:
109109

110-
- `src/config.js`
111-
- `src/orchestrator/router.js`
112-
- `src/orchestrator/skillRegistry.js`
110+
- `src/config.ts`
111+
- `src/orchestrator/router.ts`
112+
- `src/orchestrator/skillRegistry.ts`
113113
- `src/orchestrator/mcpClient.js`
114114
- `src/runner/ptyManager.js`
115115
- `src/runner/shellManager.js`

docs/phase-1-roadmap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Phase 1 hardens the current single-host beta so it can be distributed to subsidi
1717

1818
Scope:
1919

20-
- Migrate `src/config.js`
21-
- Migrate `src/orchestrator/router.js`
22-
- Migrate `src/orchestrator/skillRegistry.js`
20+
- Migrate `src/config.ts`
21+
- Migrate `src/orchestrator/router.ts`
22+
- Migrate `src/orchestrator/skillRegistry.ts`
2323
- Migrate `src/orchestrator/mcpClient.js`
2424
- Migrate `src/runner/ptyManager.js`
2525
- Migrate `src/runner/shellManager.js`

eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import js from "@eslint/js";
2+
import tsPlugin from "@typescript-eslint/eslint-plugin";
3+
import tsParser from "@typescript-eslint/parser";
24
import globals from "globals";
35

46
export default [
@@ -23,5 +25,26 @@ export default [
2325
rules: {
2426
"no-console": "off"
2527
}
28+
},
29+
{
30+
files: ["**/*.ts"],
31+
languageOptions: {
32+
parser: tsParser,
33+
parserOptions: {
34+
ecmaVersion: "latest",
35+
sourceType: "module"
36+
},
37+
globals: {
38+
...globals.node
39+
}
40+
},
41+
plugins: {
42+
"@typescript-eslint": tsPlugin
43+
},
44+
rules: {
45+
...tsPlugin.configs.recommended.rules,
46+
"no-console": "off",
47+
"no-undef": "off"
48+
}
2649
}
2750
];

0 commit comments

Comments
 (0)