You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository is currently minimal and does not yet include application code, tests, or build tooling. Until a concrete stack is added, keep contributions organized with a predictable layout:
3
+
## Repo Structure
5
4
6
-
-`src/` for production code
7
-
-`tests/` for automated tests
8
-
-`assets/` for static files such as images or fixtures
9
-
-`docs/` for design notes or operational guides
5
+
-`src/index.js`: application entrypoint and subsystem wiring.
-`src/runner/`: Codex PTY/exec management and restricted shell execution.
9
+
-`src/cron/`: scheduled proactive jobs.
10
+
-`tests/`: Node built-in test suite, one `*.test.js` file per module area.
10
11
11
-
Keep modules small and grouped by feature. For example, place Telegram client code in `src/telegram/` and matching tests in `tests/telegram/`.
12
+
## Start And Dev Commands
12
13
13
-
## Build, Test, and Development Commands
14
-
No project-specific commands are defined yet. When adding tooling, expose a minimal, documented set of commands such as:
14
+
-`npm install`: install dependencies.
15
+
-`npm run start`: start the Telegram bot with the current `.env`.
16
+
-`npm run dev`: run the bot in watch mode for local development.
15
17
16
-
-`npm install` or equivalent to install dependencies
17
-
-`npm test` to run the full test suite
18
-
-`npm run lint` to enforce style rules
19
-
-`npm run dev` to start local development
18
+
## Test Commands
20
19
21
-
If you introduce a different stack, update this file in the same change so contributors have one reliable entry point.
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.
22
+
-`npm run healthcheck`: run the local runtime health check.
22
23
23
-
## Coding Style & Naming Conventions
24
-
Use 4 spaces for indentation in Markdown, YAML, and Python-style formats; follow the formatter defaults for any language-specific toolchain you add. Prefer descriptive, lowercase directory names (`src/bot/`), `snake_case` for Python files, and `kebab-case` or framework-standard naming for frontend assets.
24
+
## Lint And Format
25
25
26
-
Add formatting and linting early and run them before opening a PR. Keep files ASCII unless the file already requires Unicode.
26
+
-`npm run lint`: run ESLint over source, tests, scripts, and local JS/CJS config files.
27
+
-`npm run lint:fix`: apply safe ESLint fixes.
28
+
-`npm run format`: run Prettier across the repository.
29
+
-`npm run format:check`: verify formatting without writing changes.
30
+
- Do not submit formatting-only churn or rewrap unrelated files.
27
31
28
-
## Testing Guidelines
29
-
Place tests under `tests/` and mirror the source layout. Name test files after the unit under test, such as `tests/telegram/test_dispatcher.py` or `dispatcher.test.ts`. Cover new behavior and important edge cases; avoid merging untested logic.
32
+
## Files And Paths You Must Not Change
30
33
31
-
Document the exact test command in the project README and here once the framework is chosen.
34
+
- Do not edit `.git/` or `node_modules/`.
35
+
- Do not commit or rewrite `.env`, secrets, Telegram tokens, or local session artifacts.
36
+
- Do not manually edit `.codex-telegram-claws-state.json`; it is runtime state.
37
+
- Avoid changing files outside this repository root, even when `/repo` or shell features reference other workspaces.
32
38
33
-
## Commit & Pull Request Guidelines
34
-
There is no Git history in the current workspace, so no established commit pattern can be inferred. Use short, imperative commit messages and prefer Conventional Commit prefixes where helpful, such as `feat: add webhook handler` or `fix: guard empty update payload`.
39
+
## Contribution Rules
35
40
36
-
Pull requests should include a clear summary, testing notes, and linked issue references when applicable. Include screenshots or sample bot interactions for user-facing changes.
41
+
- Use ES Modules and keep new files under the existing feature-oriented layout.
42
+
- Keep user-facing bot copy in English by default. Localized strings must go through `src/bot/i18n.js`.
43
+
- Prefer focused changes. Do not mix feature work with unrelated refactors.
44
+
- Add or update tests for behavior changes in `tests/`.
37
45
38
-
## Configuration & Secrets
39
-
Do not commit API tokens, session files, or `.env` values. Keep local configuration in ignored files and document required environment variables in `README.md`.
46
+
## Required Verification Before Commit
47
+
48
+
- Run `npm run check`.
49
+
- Run `npm run lint`.
50
+
- Run `npm run format:check`.
51
+
- Run `npm test`.
52
+
- Run `npm run healthcheck`.
53
+
- Review `git diff --stat` and `git status --short` for accidental edits.
54
+
- If bot commands or behavior changed, update `README.md` and include a Telegram usage example in the PR or commit notes.
Operationally, subagents are the bot's control plane. Codex remains the coding execution plane.
158
+
117
159
## Commands
118
160
119
161
General:
@@ -192,6 +234,7 @@ PTY output is streamed with throttled `editMessageText` updates.
192
234
- quote block (if `REASONING_RENDER_MODE=quote`)
193
235
- If `node-pty` cannot spawn on the current host, the runner falls back to `codex exec` for per-request execution
194
236
- In `codex exec` fallback mode, Telegram output is cleaned to hide the Codex banner, raw tool trace, `mcp startup`, and duplicate `tokens used` footer
237
+
- On macOS, startup now auto-repairs `node-pty` helper execute permissions before the first PTY session
195
238
196
239
## Project-Scoped Conversation State
197
240
@@ -262,6 +305,33 @@ GITHUB_DEFAULT_BRANCH=main
262
305
E2E_TEST_COMMAND=npx playwright test --reporter=line
263
306
```
264
307
308
+
## CI And Release Automation
309
+
310
+
GitHub Actions now includes:
311
+
312
+
-`CI` workflow on push and pull request
313
+
-`Telegram Smoke` manual workflow for live bot-token validation when repository secrets are configured
314
+
-`Release` workflow on `v*` tags, which reruns validation and publishes a GitHub Release
- Whitelist-only access (`ALLOWED_USER_IDS`) is mandatory
@@ -275,6 +345,21 @@ E2E_TEST_COMMAND=npx playwright test --reporter=line
275
345
- If you allow write commands, mark high-risk prefixes in `SHELL_DANGEROUS_COMMANDS` and require `/sh --confirm ...`
276
346
- Prefer least-privilege GitHub PAT
277
347
348
+
## Operations
349
+
350
+
The recommended production supervisor is PM2.
351
+
352
+
Basic flow:
353
+
354
+
```bash
355
+
pm2 start ecosystem.config.cjs
356
+
pm2 status codex-telegram-claws
357
+
pm2 logs codex-telegram-claws
358
+
pm2 restart codex-telegram-claws
359
+
```
360
+
361
+
Run exactly one polling process per bot token.
362
+
278
363
## Should You Enable `/sh`?
279
364
280
365
Usually not for general users. Codex itself can run commands as part of a coding task, so `/sh` is not required for normal code-edit workflows.
@@ -305,7 +390,7 @@ Telegram can manage runtime usage of Bot-side MCP and skills, but not install ar
305
390
-**MCP failures**: run `/mcp tools <server>` first to validate server availability
306
391
-**GitHub API failures**: verify `GITHUB_TOKEN` scope (`repo`) and account permissions
307
392
-**Duplicate MCP suspicion**: ensure coding tasks are routed directly to Codex, and bot MCP is used only for `/mcp`
308
-
-**`posix_spawnp failed`**: this means PTY spawn is blocked on the host; the runner will fall back to `codex exec`
393
+
-**`posix_spawnp failed`**: this usually means the `node-pty` helper lost execute permissions; startup now auto-repairs it, and `npm run healthcheck` reports the result
0 commit comments