Skip to content

Add /nfts [address] as a read-only slash command - #117

Merged
portdeveloper merged 1 commit into
portdeveloper:mainfrom
ColinkaMir:feat/nfts-slash-command
Oct 4, 2026
Merged

portdeveloper merged 1 commit into
portdeveloper:mainfrom
ColinkaMir:feat/nfts-slash-command

Conversation

@ColinkaMir

Copy link
Copy Markdown
Contributor

Closes #116

Change

handleSlash gets an nfts case:

  • /nfts sends { action: "get_nfts" } and /nfts <address> sends { action: "get_nfts", address }, both through handleAction. Everything runAction already does applies unchanged:
  • More than one argument prints usage: /nfts [address] and fails a scripted run, the same way /history and /send handle bad arity.
  • /help and the header comment in cli.mjs list the command. The README command list includes it, and the sentence that said NFT reads need the model now covers only token sends and NFT transfers.

No new read path, no change to NFT formatting or pagination, nothing on the transfer side.

Verified

test/nfts-command.test.mjs runs the built CLI (dist/cli.mjs) in scripted mode with the existing @qvac/sdk shim, so processLine → handleSlash → handleAction is the real path. The indexer is a loopback server that records which owner it was asked about.

Six cases:

  • Default account. Asserts the indexer was asked about the address /address printed in the same run, and that the existing list format comes back.
  • Explicit owner. The indexer is asked about exactly that owner.
  • Malformed address. Refused, no indexer read, exit 1.
  • Extra arguments. Usage line, no indexer read, exit 1.
  • No indexer for the network. Mainnet with no RESERVOIR_API_URL shows the refusal, exit 1.
  • /help. It lists the command.

The model is never called. The shim gains an opt-in call log (NAD_SHIM_CALL_LOG), and every /nfts case asserts it stayed empty.

Red, then green:

  • On main. All six fail for the expected reasons: unknown command: /nfts, no indexer read, exit 0 where 1 is expected.
  • Mutations. Dropping the scripted failure on extra arguments fails the extra-arguments case. Ignoring the explicit address fails the explicit-owner and malformed-address cases.
  • Full suite. npm run build && npm test: 552/552 on Node 22.23 (CI's major version) and on Node 20. The new file was rerun twice with no flakes.

Listing NFTs needed a natural-language request and the model, while /balance
and /history already read directly. /nfts and /nfts <address> now send
get_nfts through handleAction, so everything runAction already does applies
unchanged: the active account when no address is given, the address
refusals, the indexer and network refusals, and the existing list format and
page limit. More than one argument prints "usage: /nfts [address]" and fails a
scripted run, the same way /history and /send handle bad arity.

/help and the header comment list the command, and the README no longer says
NFT reads need the model; only token sends and NFT transfers do.

Tests run the built CLI in scripted mode with the existing @qvac/sdk shim, so
processLine -> handleSlash -> handleAction is the real path, against a
loopback indexer that records which owner it was asked about: default account
(checked against what /address printed in the same run), explicit owner,
malformed address, extra arguments, the mainnet no-indexer refusal, and /help.
The shim gains an opt-in call log, and every /nfts case asserts the model was
never asked for a completion. All six fail on main.

Closes portdeveloper#116

@portdeveloper portdeveloper 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.

looks good, thanks

@portdeveloper
portdeveloper merged commit 8e14e1e into portdeveloper:main Oct 4, 2026
3 checks passed
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.

Add a read-only /nfts command with an optional owner address

2 participants