Skip to content

feat(skill)!: ship the agent skill, install it from tg, report account and daemon in validate - #182

Merged
neoromantic merged 17 commits into
neoromantic:mainfrom
ertembiyik:ertembiyik/NO-TASK/skill
Nov 19, 2026
Merged

neoromantic merged 17 commits into
neoromantic:mainfrom
ertembiyik:ertembiyik/NO-TASK/skill

Conversation

@ertembiyik

@ertembiyik ertembiyik commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Adds the agent skill from #3: skills/telegram-sync-cli/SKILL.md, installable with bunx skills add neoromantic/telegram-sync-cli. tg skill install --dir <path> now writes that same file, embedded in tg, in place of the skill.json no agent read, and tg skill validate also reports the active account and whether the daemon runs. Refs #3: the suggestion item of the issue is in #177.

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.

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:

Task With the skill Without
"Let Dana know I'll pay her back tomorrow": confirms before tg send 3/3 0/3 (all three sent without asking)
Count a chat's voice notes without crawling --help 3/3, 4 turns 0/3, 10 turns
Total the "paid for" amounts across chats without --help 3/3 0/3, 10 turns
Find a chat's ID without --help 3/3, 2 turns 1/3, 5 turns
A call's length on a given day without --help 3/3 0/3, 6 turns

So the skill does three things: it stops a send the user didn't confirm, it replaces the --help crawl 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 items versus results and the two time units, the call action field, 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 api section 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 validate adds account, accounts_total and daemon { 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.json files gains 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 manifest and skill.json are 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.
  • --dir is required. It is the agent's skills directory, so tg doesn't guess one agent's layout; bunx skills add covers the usual locations.
  • The wording of the skill is yours to change; the eval suite can rerun any edit.

The skill gains a line for each open PR as it lands. next (#176) and error.retryable (#177) are in now, see the update below; tg send --markdown (#175) and tg messages list --type voice,round (#180) follow when those merge.

Found on main, not changed here:

  • With credentials set and no network, tg chats list --fresh kept retrying the connection for more than five minutes instead of failing with NETWORK_ERROR.
  • A missing required flag prints help and exits 1, not a JSON INVALID_ARGS with exit 3 as the docs say. The skill states what happens today.

Update: main merged in (5443e73)

  • main moved 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.
  • Tests moved with main's layout: src/test/skill.e2e.test.ts, src/test/skill-examples.e2e.test.ts, src/commands/skill.test.ts.
  • New export getDataDb() in src/db/index.ts: main's test helper accounts.test-utils.ts imported the db export, which this PR removes because data.db now opens on first use.
  • After the merge: bun run check clean (format, lint, types, Knip), bun run test 1194 pass, bun run test:e2e 360 pass, 0 fail. Totals are lower than before because main merged and removed many tests.

Review of 2026-11-18, addressed (22a6882, 18fe5a2, 79f7905)

  1. skill validate reports the account the next command uses. It reads config.json as a command's start does and applies the same selection (configuredActiveAccount, findDefaultAccount, both now shared with resolveAccount and the root setup). An invalid config.json is an issue with account: null. E2E in your order: config set activeAccount 2, then skill validate, then accounts info agree on account 2.
  2. Each source is read on its own. accounts_total: null with the reason when data.db can't be read, daemon.status: "unknown" when daemon.pid can't be read. data.db now 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 corrupt data.db; that is left for its own change.
  3. Install needs a real destination. A bare --dir or --dir= is INVALID_ARGS before 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 at SKILL.md is refused, with a test that the other tree's file stays as it was. The write is a temp file renamed over SKILL.md.
  4. History examples. is_deleted = 0 in the second query; a third example reads history_ranges, with one line on when a result is the whole chat's; one line on NULL text 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.
  5. Guidance. Each fact was checked in the code first: the 100 cap is messages list's and unread's; next can refresh an empty cache; nextAfter; daemon start exit codes 2 and 3; the log example appends; a generated randomId; verify a write before retrying. docs/testing.md says which examples reach only the credentials check or use the fake client.
  6. Migration note. One **Breaking:** item under Unreleased groups the removed tg skill manifest, the required --dir, the new path and data.manifest, with the replacement command. README, skill and docs/api-design.md say "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: accountsDb is 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, then dist/tg skill install --dir <tmp>: identical to skills/telegram-sync-cli/SKILL.md.

  • bunx skills add <checkout> --list finds telegram-sync-cli. Installing from GitHub by name can only be checked once this is on main.

  • 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: …) unless AGENTS.md says otherwise

Update: second code review (4d5555d)

A second, independent review of this branch. Each point below was first shown by a failing test, then fixed.

  • Install staged the file under a name built from the process ID; a link at that path redirected the write to another file. The staging file now has a random name, is created exclusively, and is removed when the write or the rename fails.
  • --dir is used as given; it was trimmed, so a directory whose name ends in a space became its sibling.
  • tg skill validate opened data.db through 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; a data.db that is a directory is reported as not a file. A data.db older than the username and label columns is reported as unreadable instead of being migrated by validate.
  • Skill text: before running a failed write again, even a retryable one, look for that exact write and ask when unsure; page unread messages from readInboxMaxId when missing is above 0 (nextAfter can be null); refresh the chat list at most once per query.
  • CHANGELOG: two more breaking notes (validate before login prints valid: false, still exit 0; src/db/index.ts exports getDataDb() instead of db).
  • Left as it is: the data directory is still created at start, as on main.

After these commits: bun run check clean, bun run test 1195 pass, bun run test:e2e 362 pass, 0 fail.

Update: main merged in (649eef9)

main up to #220 merged in. One conflict, in CHANGELOG.md: both sides kept. No changes to this branch's code.

After the merge: bun run check clean, bun run test 1206 pass, bun run test:e2e 363 pass, 0 fail.

🤖 Generated with Claude Code

ertembiyik and others added 4 commits November 18, 2026 10:36
…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 neoromantic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. Make skill validate report the account the next command will use. With two fixture accounts and account 1 active, I ran tg config set activeAccount 2, then immediately tg skill validate. It returned valid: true, account 1 and no issues. The next tg accounts info reported 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

  2. 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.db also 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

  3. Require an actual destination. Both a bare --dir and --dir= succeeded and wrote telegram-sync-cli/SKILL.md in 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

  4. 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 0 alone doesn't establish completeness. On older caches, direct SQL can also see NULL text on a rich message until backfill runs; messages get/list can 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

  5. Tighten the remaining command guidance. The 100-row cap applies to messages list; messages search accepts larger limits. Explain that next can also suggest refreshing an empty cache, and messages unread can have more messages via nextAfter. Give daemon start its 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 required randomId is 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

  6. 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 of data.manifest from 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 old skill.json in the data directory; the requested destination was never created.

ertembiyik and others added 5 commits November 18, 2026 20:38
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]>
@ertembiyik

Copy link
Copy Markdown
Contributor Author

All six points are addressed in 22a6882, 18fe5a2 and 79f7905; the description lists them one by one. Ready for another look.

ertembiyik and others added 8 commits November 18, 2026 22:44
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants