@hasna/skills 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Skills library for AI coding agents — discover, pin, and run reusable capabili
11
11
  bun install -g @hasna/skills
12
12
  ```
13
13
 
14
- Requires [Bun](https://bun.sh/) 1.0+.
14
+ Requires [Bun](https://bun.sh/) 1.3+.
15
15
 
16
16
  ## Quick Start
17
17
 
@@ -175,7 +175,7 @@ of app folders, and `XDG_CONFIG_HOME` is not consulted at all.
175
175
  | `skills billing status` | | Show server account plan and balance |
176
176
  | `skills billing checkout` | | Create a checkout session when billing is enabled |
177
177
  | `skills billing portal` | | Create a customer portal session when billing is enabled |
178
- | `skills credits buy <amount>` | | Create a credit-pack checkout session when billing is enabled |
178
+ | `skills credits buy <pack-id>` | | Create a credit-pack checkout session when billing is enabled |
179
179
  | `skills setup-info` | | Version, pinned skills, agent configs, paths |
180
180
  | `skills export` | | Export pinned skills as JSON |
181
181
  | `skills import <file>` | | Pin skills from a JSON export |
@@ -366,16 +366,100 @@ skills mcp --register all # Register with all supported agents
366
366
 
367
367
  ## Skills API
368
368
 
369
+ Use a named profile for each independently operated instance. A commercial Skills instance
370
+ and an internal instance have separate credentials, accounts,
371
+ credits and data. Selecting one does not change another profile or the fleet
372
+ resolver's existing defaults.
373
+
369
374
  ```bash
370
- skills setup --api-url https://skills.example.com # only for your own instance
371
- skills auth login --api-key "$HASNA_SKILLS_API_KEY"
372
- skills billing status
375
+ # Configure the commercial instance before signing in.
376
+ skills --profile customer setup --api-url https://skills.example.com/api/v1 --json
377
+ skills --profile customer auth signup --email you@example.com --json
378
+ skills --profile customer auth login --email you@example.com --code <CODE> --json
379
+ skills --profile customer auth whoami --json
380
+ skills --profile customer capabilities --json
381
+ skills --profile customer list --remote --json
382
+
383
+ # Quote without spending. Put CLI flags before the skill name.
384
+ skills --profile customer quote --json blog-article --topic "Your topic"
385
+ skills --profile customer run --remote --yes --wait --json --idempotency-key article-001 blog-article --topic "Your topic"
386
+ skills --profile customer runs status <run-id> --json
387
+ skills --profile customer runs logs <run-id> --json
388
+ skills --profile customer runs artifacts <run-id> --json
389
+ skills --profile customer exports download <run-id> --json
390
+
391
+ skills --profile customer billing status --json
392
+ skills --profile customer billing usage --json
393
+ skills --profile customer billing invoices --json
394
+ skills --profile customer credits packs --json
395
+ skills --profile customer credits buy <pack-id> --json
396
+ skills --profile customer billing portal --json
397
+ skills --profile customer auth keys list --email you@example.com --code <FRESH-CODE> --json
398
+ # Request a fresh OTP, then create a separately scoped key (shown once).
399
+ skills --profile customer auth signup --email you@example.com --json
400
+ skills --profile customer auth keys create automation --email you@example.com --code <CODE> --scope runs:read --json
401
+ skills --profile customer auth logout --json
402
+ ```
403
+
404
+ An origin, a full `/api/v1` base and a base with a path prefix normalize to the
405
+ same routes. `HASNA_PROFILE=customer` selects the same profile as `--profile`.
406
+ `HASNA_SKILLS_API_URL` (or the compatible `SKILLS_API_URL`) is an explicit URL
407
+ override, not permission to send a saved key to a different instance. Stored
408
+ keys retain their original instance binding; sign in to a separate profile to
409
+ switch instances. `HASNA_HOME` / `HASNA_CONFIG_HOME` isolate credential state;
410
+ `HASNA_SKILLS_DIR` separately isolates corpus/configuration data. They do not
411
+ require changing `HOME`.
412
+
413
+ A paid remote run requires explicit approval. Interactive runs ask before
414
+ submission; JSON and other noninteractive runs require `--yes`. The approved
415
+ quote becomes the server-enforced credit ceiling. A changed price above that
416
+ ceiling fails before admission. A compatible server must advertise bounded
417
+ approval; older or unsupported APIs return errors, not local results. Reuse the
418
+ same idempotency key only for an identical submission to safely recover an
419
+ interrupted response. `runs cancel` and `runs resume` call the server's lifecycle
420
+ operations and can be refused when the current state does not allow them.
421
+
422
+ `run --remote --file input.txt ...` declares upload hashes before admission and
423
+ uploads bytes without forwarding the account key to storage. Failed uploads
424
+ request cancellation. Upload support must be advertised by the server.
425
+ Downloads verify authenticated size and SHA-256 metadata before writing files;
426
+ existing files and unsafe paths are refused. CLI/SDK downloads are bounded to
427
+ 64 MiB; MCP inline artifacts and input files are limited to 1 MiB. Listing, creating and revoking API keys require fresh email OTP reauthentication; an existing
428
+ API key cannot grant new key authority. Checkout
429
+ commands return external links; payment confirmation remains in the browser.
430
+
431
+ The MCP server uses the same account, quote, run and artifact client. Agent
432
+ hosts must launch `skills-mcp --stdio`; the standalone default is loopback HTTP.
433
+ Configure its environment with the selected `HASNA_PROFILE` and isolated state
434
+ paths. `run_skill` accepts `remote:true`, `maxCredits`, `idempotency_key`, and
435
+ optional inline `files:[{name,base64,contentType}]`. An omitted ceiling permits
436
+ only free execution. `quote_skill` never submits a run.
437
+
438
+ ```ts
439
+ import { RemoteSkillsAuthClient, createRemoteSkillsClient } from "@hasna/skills/sdk";
440
+
441
+ // Auth transports never write credentials; the embedding application owns storage.
442
+ const auth = new RemoteSkillsAuthClient("https://skills.example.com/api/v1");
443
+ await auth.requestCode("you@example.com");
444
+ // await auth.verifyCode("you@example.com", code);
445
+
446
+ // Uses the same selected profile and credential binding as CLI/MCP.
447
+ const client = await createRemoteSkillsClient(process.env);
448
+ if (!client) throw new Error("Configure an instance and sign in first");
449
+ const quote = await client.quoteRun("blog-article", {}, ["--topic", "Your topic"]);
450
+ // Obtain explicit user approval of quote.pricing.costCents before this call.
451
+ const run = await client.submitQuotedRun("blog-article", {}, ["--topic", "Your topic"], {
452
+ maxCredits: quote.pricing.costCents,
453
+ idempotencyKey: "article-001",
454
+ });
373
455
  ```
374
456
 
375
- Account, run, log, artifact, and optional billing commands use the configured
376
- Skills API. The public package stores only local configuration
377
- and CLI credentials. Artifacts can be stored in S3 when `HASNA_SKILLS_S3_BUCKET`
378
- is configured.
457
+ `submitRun` remains a low-level compatibility transport. New paid integrations
458
+ should use `submitQuotedRun` or `submitQuotedRunWithFiles` so capability and
459
+ approval checks run before submission. Credit counts are integers; `maxCostCents`
460
+ is a legacy spelling for the same credit ceiling. Missing billing capabilities
461
+ on an internal instance are explicit unsupported responses; this package does
462
+ not add a billing engine to the OSS server.
379
463
 
380
464
  ### Server database
381
465
 
@@ -516,7 +600,7 @@ skills/ # Public skill contracts and local OSS skills
516
600
  |---|---|---|
517
601
  | Catalog skills | 86 | `SKILLS.length` (`src/lib/registry-data/`) |
518
602
  | Categories | 17 | `CATEGORIES` (`src/lib/registry-types.ts`) |
519
- | MCP tools | 37 | `tools/list` against a live `buildServer()` |
603
+ | MCP tools | 56 | `tools/list` against a live `buildServer()` |
520
604
 
521
605
  Every number in this table is re-derived from the source tree on each test run by
522
606
  `src/lib/readme-derived-counts.test.ts`, so a drifted figure fails a test rather