Bake in thread directives
This commit is contained in:
@@ -9,16 +9,20 @@ Use this skill to change a Codex thread's stored working directory (`cwd`) in Co
|
||||
|
||||
## Required Inputs
|
||||
|
||||
- Target `thread_id`, usually a Codex UUID. If the user refers to a client-specific current thread, inspect that client's state only to discover the Codex `thread_id`; do not edit that client state unless explicitly asked.
|
||||
- Target absolute `cwd`. Do not assume a machine-specific path; derive it from the user's request, the current repo, or an explicit argument.
|
||||
- Target absolute `cwd`. Derive it from the user's request, the current repo, or an explicit argument. Do not assume a machine-specific path.
|
||||
- Target thread is normally the active Telegram/Codex thread unless the user specifies another one.
|
||||
|
||||
## Preferred Workflow
|
||||
## Telegram Bot Directive
|
||||
|
||||
1. Resolve the target thread ID.
|
||||
- For this repo's Telegram bot, read its configured SQLite DB only to discover `sessions.active_thread_id -> threads.codex_thread_id` for the relevant Telegram user.
|
||||
- If ambiguous, list candidates and ask the user to choose.
|
||||
2. Confirm the target cwd is absolute and exists, unless the user intentionally wants a path that does not exist yet.
|
||||
3. Run the bundled script from the skill directory:
|
||||
When working through this Telegram bot, emit exactly one hidden directive line in normal assistant output, outside code fences:
|
||||
|
||||
`<!-- codex-thread-cwd {"cwd":"<absolute-cwd>"} -->`
|
||||
|
||||
The bot strips the directive, updates Codex-side cwd state, and syncs its local workspace tracking from the new Codex cwd. Do not run the bundled script or other tool calls when this directive is available.
|
||||
|
||||
## Script Fallback
|
||||
|
||||
Use the bundled script only outside the Telegram bot directive path, or when repairing state manually:
|
||||
|
||||
```bash
|
||||
python3 path/to/codex-thread-cwd/scripts/set_thread_cwd.py THREAD_ID /absolute/new/cwd
|
||||
@@ -26,23 +30,8 @@ python3 path/to/codex-thread-cwd/scripts/set_thread_cwd.py THREAD_ID /absolute/n
|
||||
|
||||
Use `--codex-home`, `--state-db`, or `CODEX_HOME` when the Codex state is not under the current user's default Codex home.
|
||||
|
||||
4. Verify Codex-side state, preferably with app-server `thread/read` if a socket is available. DB-level verification from the script is acceptable when app-server is unavailable.
|
||||
5. Trigger the dependent tool's normal sync path, such as asking a bot for `/workspace` or `/threads`. Do not manually insert or update downstream workspace rows unless the user explicitly asks for emergency repair.
|
||||
|
||||
## Notes
|
||||
|
||||
- The app-server schema exposes `cwd` on `thread/resume`, `thread/fork`, and `turn/start`; `thread/metadata/update` does not patch `cwd`.
|
||||
- In observed behavior, `thread/resume` with `cwd` may return the original cwd and not mutate existing stored thread cwd.
|
||||
- `turn/start.cwd` is schema-supported as an override for that turn and subsequent turns, but it starts a new turn.
|
||||
- The proven no-turn approach is to update Codex's own `state_*.sqlite` `threads.cwd` row and the first `session_meta.payload.cwd` line in the rollout JSONL. This is Codex-side state, not downstream client state.
|
||||
- The script preserves a rollout backup by default; it writes `<rollout>.bak.<timestamp>` unless `--no-backup` is passed.
|
||||
|
||||
## Verification Examples
|
||||
|
||||
Inspect Codex state directly:
|
||||
|
||||
```bash
|
||||
python3 path/to/codex-thread-cwd/scripts/set_thread_cwd.py THREAD_ID /absolute/new/cwd --verify-only
|
||||
```
|
||||
|
||||
Read through app-server and check `result.thread.cwd` equals the requested path.
|
||||
- The bot implementation performs that no-turn update when configured with access to Codex state.
|
||||
|
||||
@@ -14,9 +14,17 @@ Keep thread titles short and useful for later resume lists.
|
||||
- Do not include dates, user names, punctuation-heavy labels, or generic words like "chat" unless needed.
|
||||
- Rename once the task goal is clear, and again only if the goal materially changes.
|
||||
|
||||
## How to Rename
|
||||
## How to Rename in Telegram Bot Threads
|
||||
|
||||
- If the client exposes a thread rename or `thread/name/set` capability, use it with the concise title.
|
||||
Emit exactly one hidden directive line in normal assistant output, outside code fences:
|
||||
|
||||
`<!-- codex-thread-rename {"title":"<short title>"} -->`
|
||||
|
||||
The bot strips the directive, calls Codex thread rename, and syncs its local thread title. Do not use extra tool calls or Telegram commands when this directive is available.
|
||||
|
||||
## Fallbacks
|
||||
|
||||
- If the client exposes another direct thread rename capability, use it with the concise title.
|
||||
- If only Telegram commands are available, tell the user the exact `/rename TITLE` command to run.
|
||||
- If no rename mechanism is available, include a short suggested title in the final answer.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user