@agentex/agent 0.0.13 → 0.0.14

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.
Files changed (2) hide show
  1. package/README.md +111 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -55,7 +55,10 @@ console.log(result.raw); // the final provider-native event, verbatim (es
55
55
  | `openclaw` | gateway HTTP | OpenClaw HTTP-gateway agent |
56
56
  | `process` | any executable | Generic process executor (arbitrary binary) |
57
57
 
58
- Provider capabilities (sessions, skills, workspaces, MCP, model discovery, quota probing, instructions) are declared on each module's `capabilities` field — check `provider.capabilities` to branch on what's supported.
58
+ Provider capabilities (sessions, skills, workspaces, MCP, model discovery, quota probing, instructions) are declared on each module's `capabilities` field — check `provider.capabilities` to branch on what's supported. Skill-aware providers also report:
59
+
60
+ - `skillInventory` — `"provider-init"` for Claude's runtime inventory, `"local-discovery"` for Codex, or `"none"`.
61
+ - `skillInvocation` — `"native-slash"` for Claude, `"expanded-prompt"` for Codex, `"configured-only"`, or `"unsupported"`.
59
62
 
60
63
  ## Execution Context
61
64
 
@@ -181,7 +184,7 @@ interface BaseStreamEventFields {
181
184
 
182
185
  Variants:
183
186
 
184
- - `system` — Session init (`subtype`, `model`, `cwd`, `tools`, `permissionMode`)
187
+ - `system` — Session init (`subtype`, `model`, `cwd`, `tools`, `permissionMode`). Claude init events also include `slashCommands?: string[]` and `skills?: string[]` when Claude Code reports them.
185
188
  - `assistant` — Text output from the agent (`text`)
186
189
  - `thinking` — Agent's internal reasoning (`text`)
187
190
  - `tool_call` — Agent invoked a tool (`toolCallId: string | null`, `name`, `input`)
@@ -497,24 +500,118 @@ const results = await executeAll(
497
500
  );
498
501
  ```
499
502
 
500
- ## Skills
503
+ ## Skills And Slash Commands
504
+
505
+ AgentEx supports both skill installation and the higher-level slash-command UI flow:
506
+
507
+ 1. Install or pass skill directories through `config.skillDirs`.
508
+ 2. Discover rich local metadata for the UI.
509
+ 3. Reconcile that metadata with the provider runtime inventory when one exists.
510
+ 4. Invoke the selected skill using provider-appropriate semantics.
511
+
512
+ ### Install Or List Skills
501
513
 
502
514
  Install and remove reusable agent skills across multiple runtimes at once, into either the user's home or a workspace directory.
503
515
 
504
516
  ```typescript
505
517
  import { installSkills, listInstalledSkills, removeSkills } from "@agentex/agent";
506
518
 
507
- await installSkills({
508
- location: "global", // or "workspace" with cwd
519
+ const skillDirs = ["/path/to/code-review", "/path/to/testing"];
520
+
521
+ await installSkills(skillDirs, {
522
+ location: "workspace", // or "global"
523
+ cwd: process.cwd(), // required for workspace installs
509
524
  includeNativeDirs: false, // true also installs into ~/.gemini/skills/, etc.
510
525
  });
511
526
 
512
- const installed = await listInstalledSkills({ location: "global" });
513
- await removeSkills({ location: "global" });
527
+ const installed = await listInstalledSkills({ location: "workspace", cwd: process.cwd() });
528
+ await removeSkills(skillDirs, { location: "workspace", cwd: process.cwd() });
514
529
  ```
515
530
 
516
531
  Channels and locations follow the emerging `.agents/skills/` + `.claude/skills/` convention — see the `SkillRuntime`, `SkillLocation`, and `SkillChannel` types.
517
532
 
533
+ ### Discover Slash-Invokable Skills
534
+
535
+ Use `discoverSkillCommands(...)` to parse local `SKILL.md` files into UI-ready descriptors. It reads frontmatter fields such as `description`, `argument-hint`, and `user-invocable`; if no description is present, it falls back to the first non-empty body paragraph.
536
+
537
+ ```typescript
538
+ import {
539
+ discoverSkillCommands,
540
+ reconcileSkillCommands,
541
+ commandInventoryFromEvent,
542
+ invokeSkill,
543
+ getProvider,
544
+ type RuntimeCommandInventory,
545
+ } from "@agentex/agent";
546
+
547
+ const providerType = "claude";
548
+ const provider = getProvider(providerType);
549
+ const skillDirs = ["/path/to/code-review"];
550
+
551
+ let inventory: RuntimeCommandInventory | null = null;
552
+
553
+ const session = await provider.createSession!({
554
+ cwd: process.cwd(),
555
+ config: { skillDirs },
556
+ onEvent(event) {
557
+ inventory ??= commandInventoryFromEvent(event);
558
+ },
559
+ });
560
+
561
+ const { commands, diagnostics } = await discoverSkillCommands({
562
+ cwd: process.cwd(),
563
+ skillDirs,
564
+ runtime: providerType,
565
+ });
566
+
567
+ for (const diagnostic of diagnostics) {
568
+ console.warn(diagnostic.message);
569
+ }
570
+
571
+ const visibleCommands = reconcileSkillCommands({
572
+ discovered: commands,
573
+ inventory,
574
+ provider: providerType,
575
+ }).filter((command) => command.available && command.userInvocable);
576
+
577
+ await invokeSkill(session, visibleCommands[0]!, {
578
+ args: "review the auth changes",
579
+ });
580
+ ```
581
+
582
+ For a slash menu, render `visibleCommands` and show at least:
583
+
584
+ - `/${command.name}`
585
+ - `command.description`
586
+ - `command.argumentHint`
587
+ - `command.source`
588
+
589
+ Ranking/typeahead is host-owned in core v1. A typical UI opens suggestions when the composer starts with `/`, filters by command name and description, inserts `/name ` on selection, and submits through `invokeSkill(...)`.
590
+
591
+ ### Provider Semantics
592
+
593
+ Claude Code exposes runtime names in its `system/init` event as `slash_commands` and `skills`. AgentEx parses those into `event.slashCommands` and `event.skills`, and `commandInventoryFromEvent(...)` normalizes them. For Claude, `reconcileSkillCommands(...)` marks provider-slash commands unavailable when the running session did not report them.
594
+
595
+ Claude invocation uses native slash dispatch:
596
+
597
+ ```typescript
598
+ await invokeSkill(session, command, { args: "focus on regressions" });
599
+ // sends: /command-name focus on regressions
600
+ ```
601
+
602
+ Claude Code then resolves the slash command, expands `SKILL.md`, substitutes arguments, and applies provider-native metadata.
603
+
604
+ Codex does not currently expose a runtime slash/skill inventory through AgentEx. For Codex, discovered skills default to expanded-prompt invocation:
605
+
606
+ ```typescript
607
+ await invokeSkill(codexSession, command, {
608
+ args: "review src/server.ts",
609
+ userRequest: "Focus on missing tests.",
610
+ });
611
+ ```
612
+
613
+ AgentEx reads the skill body, substitutes supported argument placeholders, wraps it with skill metadata, and sends the expanded prompt as the turn input. If Codex later exposes native slash dispatch, AgentEx can switch that command's `execution.kind` to `provider-slash` without changing host UI code.
614
+
518
615
  ## Temporary Config Override
519
616
 
520
617
  Run a CLI with a throwaway config directory (useful for injecting system prompts or custom settings without touching the user's real home).
@@ -621,10 +718,16 @@ registerProvider(myProvider);
621
718
  - `prepareWorkspace({ strategy, baseBranch?, branchName?, targetDir? })` → `PreparedWorkspace` with `cwd`, `diff()`, `cleanup()`.
622
719
 
623
720
  ### Skills
624
- - `installSkills(opts)` / `removeSkills(opts)` / `listInstalledSkills(opts)`
721
+ - `installSkills(skillDirs, opts?)` / `removeSkills(skillDirs, opts?)` / `listInstalledSkills(opts?)`
625
722
  - `resolveSkillsHome(channel)` / `resolveSkillsWorkspace(channel, cwd)`
626
723
  - `resolveNativeSkillsHome(runtime)` / `resolveNativeSkillsWorkspace(runtime, cwd)`
627
724
  - `ensureSkillSymlink(...)`
725
+ - `commandInventoryFromEvent(event)` — extract provider-reported slash/skill names from a `system/init` event.
726
+ - `discoverSkillCommands({ cwd?, skillDirs?, includeInstalled?, runtime? })` — parse local `SKILL.md` metadata into `SkillCommandDescriptor[]`.
727
+ - `reconcileSkillCommands({ discovered, inventory?, provider, appCommands? })` — merge app commands and apply provider runtime availability.
728
+ - `formatSlashInvocation(command, args?)` — build `/name args` text.
729
+ - `invokeSkill(session, command, options?)` — send native slash text for `provider-slash` commands or an expanded prompt for `expanded-prompt` commands.
730
+ - `buildExpandedSkillPrompt(command, options?)` — construct the expanded-prompt payload without sending it.
628
731
 
629
732
  ### Runtime config
630
733
  - `withTempConfig({ runtime, seedFromDefault?, overrides? })` → env + configDir + cleanup.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentex/agent",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Programmatic execution of AI coding agents (Claude Code, Codex, OpenClaw)",
5
5
  "type": "module",
6
6
  "exports": {