Repository navigation
feat(skill)!: ship the agent skill, install it from tg, report account and daemon in validate - #182
Conversation
…t and daemon in validate skills/telegram-sync-cli/SKILL.md is the skill agents load, installable with bunx skills add. tg skill install --dir writes that same file, embedded in tg, and tg skill validate also reports the active account and whether the daemon runs. Every command in the skill runs in an e2e test. Refs neoromantic#3 BREAKING CHANGE: tg skill manifest is removed, and tg skill install needs --dir and writes <dir>/telegram-sync-cli/SKILL.md instead of <dataDir>/skill.json. Co-Authored-By: Claude Fable 5.2 <[email protected]>
fake-client-cli.ts: both descriptions kept. CHANGELOG: both sides' entries kept. SKILL.md: next and retryable, now on main. Co-Authored-By: Claude Fable 5.2 <[email protected]>
main now has neoromantic#179 (neoromantic#188). CHANGELOG: main's Changed section, then this PR's Removed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
main is now the 0.14.0 release (neoromantic#189). This PR's changelog entries move back under Unreleased: a plain merge left them in the released section. Co-Authored-By: Claude Fable 5.2 <[email protected]>
neoromantic
left a comment
There was a problem hiding this comment.
Let's ship one format, SKILL.md. The breaking change is fine, and reinstalling should automatically update an existing regular file, including a locally edited copy. I checked the npm tarball and the compiled binary offline. Both installed a byte-identical copy. Please address the following before merge.
-
Make
skill validatereport the account the next command will use. With two fixture accounts and account 1 active, I rantg config set activeAccount 2, then immediatelytg skill validate. It returnedvalid: true, account 1 and no issues. The nexttg accounts inforeported account 2. This matters before a send. The root setup skips the skill group, and validate reads the database flag directly. Use the same effective account selection as a normal command. Keep validate usable with a malformed config and report the config issue. Please add an e2e that follows this exact order. skill.ts, line 198 · cli.ts, line 91 -
Keep the offline diagnostics accurate when a check fails. With one account and a readable live PID file in a read-only directory, validate reported zero accounts and a stopped daemon. Read each available source independently and mark a value unknown if its check fails. A corrupt fixture
data.dbalso produced a SQLite stack trace before validate started. Return a structured diagnostic for that case and keep installation usable with a broken account database. Describe the two local checks as a configured account record and a live PID. Session authorization and per-account connectivity are separate. Cache reads can still work without API credentials. skill.ts, line 240 · db/index.ts, line 415 -
Require an actual destination. Both a bare
--dirand--dir=succeeded and wrotetelegram-sync-cli/SKILL.mdin the current directory. Reject empty values before writing. Document automatic replacement in the help and test it with different existing contents. Respect a user-selected skills root that is itself a symlink. Check links inside that root so reinstalling cannot silently overwrite a file in another managed tree. Cover both the skill directory and the final file. skill.ts, line 263 -
Make the history examples give an accurate answer. The second SQL example returns deleted messages as ordinary text. Add
is_deleted = 0. Explain that totals cover the local cache and how to check history coverage before reporting a whole-chat total. A running daemon or--limit 0alone doesn't establish completeness. On older caches, direct SQL can also see NULL text on a rich message until backfill runs;messages get/listcan already render it. Add a fixture with a deleted row and a gap, and assert the expected IDs or count. The current nonempty-result assertion passes even with the wrong answer. SKILL.md, lines 22–29 -
Tighten the remaining command guidance. The 100-row cap applies to
messages list;messages searchaccepts larger limits. Explain thatnextcan also suggest refreshing an empty cache, andmessages unreadcan have more messages vianextAfter. Givedaemon startits own exit codes (2 already running, 3 no accounts), and avoid truncating an existing log on a repeated start. For raw API calls, an omitted requiredrandomIdis generated. If the outcome of a write is unknown, tell the agent to verify it before retrying. In the testing docs, say that the daemon example reaches the credentials check and the API example uses a fake client. SKILL.md · example tests -
Finish the migration note. Keep only the Markdown installer. Under Unreleased, group the removed
tg skill manifest, the required--dir, the new output path and the removal ofdata.manifestfrom the JSON response. Show the replacement command. In the README and skill, identify the first tg version supporting the new install and validate behavior. This matters for people installing the skill from GitHub alongside an older binary. On v0.14.0,tg skill install --dir <path>exited 0 and wrote the oldskill.jsonin the data directory; the requested destination was never created.
main now has neoromantic#175 (neoromantic#194), neoromantic#174 and neoromantic#155. skill.ts: main's shared getErrorMessage, the manifest stays removed. CHANGELOG: both sides kept. Fixture groups take part in the tests: main caches a group's new messages only while the account writes there (neoromantic#155). Co-Authored-By: Claude Fable 5.2 <[email protected]>
…nstall working on broken state tg skill validate picks the account the next command uses (config.json's activeAccount, else the active one, else the only one) through the shared account selection, reports an invalid config.json as an issue, and reads data.db and daemon.pid each on its own, marking a value unknown when its check fails. data.db opens on first use, so a corrupt one gives an issue instead of a SQLite stack trace and tg skill install still works. tg skill install rejects an empty --dir, replaces the file atomically and refuses a symbolic link for the skill directory or SKILL.md, while a skills directory that is itself a link is followed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…guidance The read-a-chat SQL skips deleted messages, and the skill says a total covers only the cache, how to check history_ranges before calling it the whole chat's, and that rich messages from older caches read NULL in SQL until tg db migrate. It also corrects the --limit caps, what next and messages unread page with, the daemon start exits and a log that a repeated start would truncate, the randomId tg api generates, and asks to verify a failed write before running it again. The examples test seeds a deleted voice note, a deleted text and a gap, and checks the exact rows of every SQL example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hecks Groups the breaking tg skill changes under Unreleased with the replacement command, names tg newer than 0.14.0 as the first version with the new install and validate in the README and the skill, and documents replacement, the link rules and the unknown values in docs/api-design.md and the skill tests in docs/testing.md. validate's sample is real output. Co-Authored-By: Claude Opus 5.5 <[email protected]>
main now has neoromantic#195: Knip in bun run check, and long as a runtime dependency. No conflict; the check is clean. Co-Authored-By: Claude Fable 5.2 <[email protected]>
main now has neoromantic#196, a test time budget only. No conflict; the check is clean. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The skill command, lazy data.db, config and account-selector conflicts took this branch's code in main's oxfmt format, without prose comments or explicit return types; the moved skill, config and fake-client tests got their changes at main's new paths, and skill-examples moved to src/test. main's accounts test helper now reaches data.db through a new getDataDb(), since data.db opens on first use. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The staging file was named after the process ID, so a link already at that path redirected the write, and a failed write left the file behind. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Trimming --dir replaced a directory whose name ends in a space with its trimmed sibling. Trim only to reject a blank value. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Validate opened data.db with the normal initialisation, which creates the schema and deletes a legacy duplicate account row, and it took a directory named data.db for a missing file. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…fresh once A rerun of a write Telegram already accepted sends it again; with missing unread messages nextAfter can be null or skip older ones; an empty chat search repeated its refresh on every attempt. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…d db export Co-Authored-By: Claude Fable 5.2 <[email protected]>
# Conflicts: # CHANGELOG.md
What and why
Adds the agent skill from #3:
skills/telegram-sync-cli/SKILL.md, installable withbunx skills add neoromantic/telegram-sync-cli.tg skill install --dir <path>now writes that same file, embedded intg, in place of theskill.jsonno agent read, andtg skill validatealso reports the active account and whether the daemon runs. Refs #3: thesuggestionitem of the issue is in #177.BREAKING CHANGE:
tg skill manifestis removed, andtg skill installneeds--dirand writes<dir>/telegram-sync-cli/SKILL.mdinstead of<dataDir>/skill.json.Does the skill help? Measured, not assumed
Claude Opus 5.5 ran a real
tg(this branch's compiled binary) on a made-up cache, the same prompts with and without the skill, 3 runs per arm. Every arm got the answers right. What the skill changed is how:tg send--help--help--help--helpSo the skill does three things: it stops a send the user didn't confirm, it replaces the
--helpcrawl with the flags that matter, and it roughly halves the turns a task takes.What the measurements removed. A first draft was longer. Sections that made no difference when taken out were cut: how to read
itemsversusresultsand the two time units, the callactionfield, round videos, and a separate setup step. Agents handled all of those without being told. The skill is 62 lines.Not measured, because the sandbox has no network: the
tg apisection and the exit-code table. Both are in because the issue asks for them. The line saying that text read from Telegram is other people's words, not instructions, is a guardrail without a case.The commands
tg skill install --dir <path>writes<path>/telegram-sync-cli/SKILL.md. The file is embedded: a compiled binary run from another directory, with the source file moved away, writes a byte-identical copy.tg skill validateaddsaccount,accounts_totalanddaemon { status, pid }. No account, or several with none active, is an issue; a stopped daemon is reported but is not one, since cache reads work without it.package.jsonfilesgains the skill, since the npm package imports it.Every command in the skill's code blocks runs against a seeded cache in
src/__e2e__/skill-examples.e2e.test.ts, so an example can't rot.Decisions you may want to change:
tg skill manifestandskill.jsonare removed, not kept, so there aren't two descriptions of the tool that can disagree. Say if you'd rather keep the command for a release.--diris required. It is the agent's skills directory, sotgdoesn't guess one agent's layout;bunx skills addcovers the usual locations.The skill gains a line for each open PR as it lands.
next(#176) anderror.retryable(#177) are in now, see the update below;tg send --markdown(#175) andtg messages list --type voice,round(#180) follow when those merge.Found on
main, not changed here:tg chats list --freshkept retrying the connection for more than five minutes instead of failing withNETWORK_ERROR.INVALID_ARGSwith exit 3 as the docs say. The skill states what happens today.Update:
mainmerged in (5443e73)mainmoved to oxfmt and oxlint with the landmines rules, and moved every test beside its code. This branch follows: the same behaviour and output, the code restyled, prose comments and explicit return types removed.main's layout:src/test/skill.e2e.test.ts,src/test/skill-examples.e2e.test.ts,src/commands/skill.test.ts.getDataDb()insrc/db/index.ts:main's test helperaccounts.test-utils.tsimported thedbexport, which this PR removes becausedata.dbnow opens on first use.bun run checkclean (format, lint, types, Knip),bun run test1194 pass,bun run test:e2e360 pass, 0 fail. Totals are lower than before becausemainmerged and removed many tests.Review of 2026-11-18, addressed (22a6882, 18fe5a2, 79f7905)
skill validatereports the account the next command uses. It readsconfig.jsonas a command's start does and applies the same selection (configuredActiveAccount,findDefaultAccount, both now shared withresolveAccountand the root setup). An invalidconfig.jsonis an issue withaccount: null. E2E in your order:config set activeAccount 2, thenskill validate, thenaccounts infoagree on account 2.accounts_total: nullwith the reason whendata.dbcan't be read,daemon.status: "unknown"whendaemon.pidcan't be read.data.dbnow opens on first use (it opened at import), so a corrupt file gives validate a structured issue and install still works. The checks are described as an account record and a live PID. Other commands still stop on a corruptdata.db; that is left for its own change.--diror--dir=isINVALID_ARGSbefore anything is written. The help says the file is replaced; a test replaces different contents. A skills root that is a link is followed; a link at the skill directory or atSKILL.mdis refused, with a test that the other tree's file stays as it was. The write is a temp file renamed overSKILL.md.is_deleted = 0in the second query; a third example readshistory_ranges, with one line on when a result is the whole chat's; one line onNULLtext of rich messages cached by 0.13.1 or older. The fixture has deleted rows and a gap, each SQL example asserts its exact rows, and an example without an assertion fails the suite.messages list's andunread's;nextcan refresh an empty cache;nextAfter;daemon startexit codes 2 and 3; the log example appends; a generatedrandomId; verify a write before retrying.docs/testing.mdsays which examples reach only the credentials check or use the fake client.**Breaking:**item under Unreleased groups the removedtg skill manifest, the required--dir, the new path anddata.manifest, with the replacement command. README, skill anddocs/api-design.mdsay "tg newer than 0.14.0", the repo's own way to name versions; the release PR can put the number in.Decisions you may want to change:
accountsDbis a Proxy over the lazily opened database, so its importers stay unchanged (the alternative is a getter at every call site); install refuses a link inside the skills root instead of following it.How I checked it
bun run check: clean.bun run test: 2300 pass, 0 fail.bun run test:e2e: 443 pass, 0 fail.bun run build, thendist/tg skill install --dir <tmp>: identical toskills/telegram-sync-cli/SKILL.md.bunx skills add <checkout> --listfindstelegram-sync-cli. Installing from GitHub by name can only be checked once this is onmain.The eval suite: 7 tasks, 3 runs per arm, a trigger check (two Telegram questions loaded the skill, a Telegram-bot coding task did not).
Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard (README install line,
docs/api-design.md,docs/cli-commands.md,docs/testing.md, CHANGELOG)Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwiseUpdate: second code review (4d5555d)
A second, independent review of this branch. Each point below was first shown by a failing test, then fixed.
--diris used as given; it was trimmed, so a directory whose name ends in a space became its sibling.tg skill validateopeneddata.dbthrough the normal start-up, which creates the schema and can delete a legacy duplicate account row. It now reads through a read-only connection and changes nothing; adata.dbthat is a directory is reported as not a file. Adata.dbolder than the username and label columns is reported as unreadable instead of being migrated by validate.readInboxMaxIdwhenmissingis above 0 (nextAftercan benull); refresh the chat list at most once per query.valid: false, still exit 0;src/db/index.tsexportsgetDataDb()instead ofdb).main.After these commits:
bun run checkclean,bun run test1195 pass,bun run test:e2e362 pass, 0 fail.Update:
mainmerged in (649eef9)mainup to #220 merged in. One conflict, inCHANGELOG.md: both sides kept. No changes to this branch's code.After the merge:
bun run checkclean,bun run test1206 pass,bun run test:e2e363 pass, 0 fail.🤖 Generated with Claude Code