@osdlc/wayfinder 0.12.11 → 0.13.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # @osdlc/wayfinder
2
2
 
3
+ ## 0.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8e61f33]
8
+ - @osdlc/system-model@0.9.0
9
+
10
+ ## 0.13.3
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [3f84b08]
15
+ - @osdlc/typed-git@0.21.0
16
+ - @osdlc/trust-repo@0.5.13
17
+
18
+ ## 0.13.2
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [1ba6088]
23
+ - @osdlc/typed-git@0.20.0
24
+ - @osdlc/trust-repo@0.5.12
25
+
26
+ ## 0.13.1
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [49b2314]
31
+ - @osdlc/system-model@0.8.0
32
+ - @osdlc/config-layers@0.11.1
33
+
34
+ ## 0.13.0
35
+
36
+ ### Minor Changes
37
+
38
+ - dfea0da: New: hand an agent skill to an agent's CLI, as an explicit action beside copy. `way run /<name> --agent -- <args>` starts the first of `claude`, `codex` and `cursor-agent` on `PATH` whose agent reads the skill, in this terminal and the repository root, with `/<name> <args>` as its first prompt (`$<name>` for Codex), and exits with its code. `--harness <claude|codex|cursor>` picks the agent; `--dry-run --json` prints the run document, with the skill's id as `task`. In the terminal UI, `^g` on a skill does the same, asking first for what the skill's `argument-hint` names; the line under a skill says which agent `^g` starts. Enter, `^y` and the web view still copy `/<name>`, and plain `way run /<name>` still refuses, now suggesting `--agent` when an agent CLI is on `PATH`.
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [976bbee]
43
+ - Updated dependencies [976bbee]
44
+ - Updated dependencies [6d37030]
45
+ - Updated dependencies [0297b95]
46
+ - Updated dependencies [2ee6d62]
47
+ - Updated dependencies [c8470d6]
48
+ - Updated dependencies [0ce8abc]
49
+ - Updated dependencies [9c0f5ae]
50
+ - @osdlc/cli-tool@0.21.0
51
+ - @osdlc/command-seam@0.15.1
52
+ - @osdlc/config-layers@0.11.0
53
+ - @osdlc/typed-git@0.19.0
54
+ - @osdlc/detect-harness@0.7.4
55
+ - @osdlc/trust-repo@0.5.11
56
+
57
+ ## 0.12.13
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [b0ff1b3]
62
+ - Updated dependencies [cb56f16]
63
+ - @osdlc/typed-git@0.18.0
64
+ - @osdlc/trust-repo@0.5.10
65
+
66
+ ## 0.12.12
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [acf57e6]
71
+ - @osdlc/cli-tool@0.20.0
72
+
3
73
  ## 0.12.11
4
74
 
5
75
  ### Patch Changes
package/README.md CHANGED
@@ -106,8 +106,10 @@ order.
106
106
 
107
107
  Skills are not tasks. An agent runs one when you type `/<name>`, so Run
108
108
  copies `/<name>` and nothing is spawned; `way run /review` says so and exits
109
- 1. `list` and `query` print a `/<name> [hint]` line for each skill after the
110
- tasks, and search matches a skill's name and description as it matches a
109
+ 1. Starting an agent with the skill is a separate action you ask for:
110
+ `way run /review --agent -- 123` or `^g` in the terminal UI (see
111
+ [Handing a skill to an agent](#handing-a-skill-to-an-agent)). `list` and
112
+ `query` print a `/<name> [hint]` line for each skill after the tasks, and search matches a skill's name and description as it matches a
111
113
  task. `--json` puts them in `skills`: `name`, `description`, `argumentHint`,
112
114
  `path`, `scope`, `origin` (`project`, `user` or `plugin:<id>`), `harnesses`
113
115
  and `invoke`. They are read from files by `@osdlc/detect-harness`; nothing
@@ -115,12 +117,47 @@ runs. The `skills` setting chooses which: `project` (the default) lists the
115
117
  repository's own, `all` adds yours and your plugins' from the home folder, and
116
118
  `off` lists none.
117
119
 
120
+ ### Handing a skill to an agent
121
+
122
+ `way run /<name> --agent` starts an agent's CLI in this terminal, in the
123
+ repository root, with the skill as its first prompt, and exits with the
124
+ agent's exit code. It is an interactive session, heavier than a task, so it
125
+ is never the default: Run and Enter still copy.
126
+
127
+ ```text
128
+ way run /review --agent -- 123 claude '/review 123'
129
+ way run /release --harness codex codex '$release', for a skill Codex reads
130
+ way run /review --agent --dry-run what it would start; --json for the run document
131
+ ```
132
+
133
+ - **Which agent.** Of the agents that read the skill (its `harnesses`), the
134
+ first whose CLI is on `PATH`, in this order: Claude Code (`claude`), Codex
135
+ (`codex`), Cursor (`cursor-agent`). `--harness <claude|codex|cursor>`
136
+ picks one, and is refused when that agent does not read the skill or is
137
+ not on `PATH`. Only absolute `PATH` entries are searched, so a file the
138
+ repository ships is never started.
139
+ - **The prompt.** The skill as that agent names it, `/<name>` (Codex:
140
+ `$<name>`), then the words after `--`, joined by spaces. The skill's
141
+ `argument-hint` says what they are; it is never sent itself. With no
142
+ words, `run` notes what the hint asks for and starts the agent anyway.
143
+ - **Nothing else changes.** The CLI is spawned without a shell, with no
144
+ added variables. A skill name or words holding a control character start
145
+ nothing.
146
+
147
+ In the terminal UI, `^g` on a skill does the same with the first agent. A
148
+ skill with an `argument-hint` asks first: the key line becomes
149
+ `claude ▸ /review `, Enter starts the agent with what you typed (which may
150
+ be nothing), and `esc` goes back. The line under a skill row says which
151
+ agent `^g` starts. The web view only copies. Why these choices:
152
+ [D-QMVA](https://github.com/osdlc/osdlc/blob/main/docs/decisions/D-QMVA-wayfinder-skill-handoff.md).
153
+
118
154
  ## The terminal UI
119
155
 
120
156
  ```text
121
157
  enter run the selected task, handing it this terminal
122
158
  (a task that takes arguments asks for them first)
123
159
  ^y copy its command line (on a skill: /<name>)
160
+ ^g on a skill: start an agent CLI with it (claude "/<name> …")
124
161
  tab next tab (all · just · node-scripts │ dependencies │ tools … │ skills)
125
162
  , settings: runners, discovery, excluded paths and trust
126
163
  ^s trust this repository, when runners are withheld for want of it
@@ -498,7 +535,9 @@ as `way run 'npm run build'`. Arguments after `--` are bound the way the tool
498
535
  expects, as the terminal UI and the page bind them. A task that ends on a
499
536
  signal exits 128 plus the signal number. `--dry-run --json` prints the
500
537
  `argv`, `cwd` and `env` it would run. A plain `run --json` is refused,
501
- because the task owns stdout.
538
+ because the task owns stdout. On an agent skill, `--agent` (or `--harness`)
539
+ starts an agent CLI with it instead; its run document has the skill's id as
540
+ `task` and `/<name> [hint]` as `display`.
502
541
 
503
542
  Global flags go before or after the command word: `way -C ../app list` and
504
543
  `way list -C ../app` are the same. A start directory that does not exist is an
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * `way run <id> [-- args]`: run one task by id, with the argument rules the
3
- * terminal UI and the web view use.
3
+ * terminal UI and the web view use. With `--agent`, hand an agent skill to
4
+ * an agent's CLI instead.
4
5
  */
5
6
  /** Make the `run` command. */
6
7
  export declare function runCommand(home: string): import("@osdlc/cli-tool/command").DataCommand<{
@@ -17,6 +18,16 @@ export declare function runCommand(home: string): import("@osdlc/cli-tool/comman
17
18
  hidden: true;
18
19
  help: string;
19
20
  };
21
+ agent: {
22
+ kind: "boolean";
23
+ help: string;
24
+ };
25
+ harness: {
26
+ kind: "enum";
27
+ choices: readonly ["claude", "codex", "cursor"];
28
+ valueName: string;
29
+ help: string;
30
+ };
20
31
  }, {
21
32
  readonly dir: {
22
33
  readonly kind: "string";
@@ -1,15 +1,33 @@
1
1
  /**
2
2
  * `way run <id> [-- args]`: run one task by id, with the argument rules the
3
- * terminal UI and the web view use.
3
+ * terminal UI and the web view use. With `--agent`, hand an agent skill to
4
+ * an agent's CLI instead.
4
5
  */
5
6
  import { CommandError, UsageError, outcome } from '@osdlc/cli-tool/command';
6
7
  import { commandString } from '@osdlc/command-seam';
8
+ import { BIN } from "../app.js";
7
9
  import { handOff } from "../core/run.js";
8
10
  import { SessionError } from "../core/session.js";
11
+ import { HANDOFF_HARNESSES, skillLine } from "../core/skills.js";
9
12
  import { RunOutput } from "../documents.js";
13
+ import { agentClis, planSkillHandOff, SkillHandOffError } from "../skills.js";
10
14
  import { terminalSafe } from "../terminal-text.js";
11
15
  import { parametersUnknownLabel } from "../vocabulary.js";
12
16
  import { kit, openSession } from "./shared.js";
17
+ /** The run document for a skill handed to an agent: `task` is the skill's id. */
18
+ function skillDocument(plan, ran, exit) {
19
+ return {
20
+ task: plan.skill.id,
21
+ display: skillLine(plan.skill),
22
+ argv: plan.argv,
23
+ command: commandString(plan.argv),
24
+ cwd: plan.cwd,
25
+ env: plan.env,
26
+ ran,
27
+ exit,
28
+ unknowns: [],
29
+ };
30
+ }
13
31
  function runDocument(plan, ran, exit, unknowns) {
14
32
  return {
15
33
  task: plan.task.id,
@@ -33,7 +51,11 @@ export function runCommand(home) {
33
51
  'just x a). The same rules as Enter in the terminal UI and Run in the web view. Exits ' +
34
52
  "with the task's exit code. --dry-run prints what would run instead; with --json it is " +
35
53
  'the run document. A task that uses an editor variable is not run, and neither is an ' +
36
- 'agent skill: type its /<name> in the agent.',
54
+ 'agent skill: type its /<name> in the agent. --agent hands a skill to an agent CLI ' +
55
+ 'instead, starting an interactive session in this terminal with the skill as its first ' +
56
+ 'prompt (claude "/review 123"); the words after -- follow the name, as its argument hint ' +
57
+ 'asks. It starts the first of claude, codex and cursor-agent on PATH that reads the ' +
58
+ 'skill, or the one --harness names.',
37
59
  positionals: [
38
60
  {
39
61
  name: 'id',
@@ -53,6 +75,16 @@ export function runCommand(home) {
53
75
  hidden: true,
54
76
  help: "with --cached --dry-run, probe the task's runner again as a run does",
55
77
  },
78
+ agent: {
79
+ kind: 'boolean',
80
+ help: 'on an agent skill: start an agent CLI with it as the first prompt',
81
+ },
82
+ harness: {
83
+ kind: 'enum',
84
+ choices: HANDOFF_HARNESSES,
85
+ valueName: 'H',
86
+ help: 'with --agent, the agent to start (default: the first on PATH that reads the skill)',
87
+ },
56
88
  },
57
89
  output: RunOutput,
58
90
  kind: 'run',
@@ -60,6 +92,7 @@ export function runCommand(home) {
60
92
  'run just:justfile:build',
61
93
  'run node-scripts:package.json:test -- --watch',
62
94
  'run x --dry-run --json',
95
+ 'run /review --agent -- 123',
63
96
  ],
64
97
  // Running a task is the command line's; an adapter may only ask what would run.
65
98
  exposureOf: (input) => (input.flags.dryRun === true ? 'all' : 'cli-only'),
@@ -69,16 +102,62 @@ export function runCommand(home) {
69
102
  }
70
103
  const session = await openSession(globals, ctx, home);
71
104
  const snapshot = await session.catalog({ cached: flags.cached });
105
+ const id = positionals[0];
106
+ const named = snapshot.skills.filter((s) => s.id === id || s.invoke === id);
107
+ // With --harness, prefer the row that agent reads: two harnesses can each have a /review.
108
+ const skill = (flags.harness !== undefined
109
+ ? named.find((s) => s.harnesses.includes(flags.harness))
110
+ : undefined) ?? named[0];
111
+ if (flags.agent || flags.harness !== undefined) {
112
+ if (skill === undefined) {
113
+ throw new UsageError(`--agent starts an agent skill, and ${terminalSafe(id)} is not one`);
114
+ }
115
+ let started;
116
+ try {
117
+ started = planSkillHandOff(skill, {
118
+ root: session.root,
119
+ env: session.env,
120
+ args: rest.join(' '),
121
+ harness: flags.harness,
122
+ });
123
+ }
124
+ catch (err) {
125
+ if (err instanceof SkillHandOffError) {
126
+ throw new CommandError(err.message, {
127
+ code: 'not-runnable',
128
+ ...(err.hint !== undefined ? { hint: err.hint } : {}),
129
+ });
130
+ }
131
+ throw err;
132
+ }
133
+ if (skill.argumentHint !== null && rest.length === 0) {
134
+ ctx.note(terminalSafe(`${skill.invoke} takes ${skill.argumentHint}; none given`));
135
+ }
136
+ if (flags.dryRun)
137
+ return skillDocument(started, false, null);
138
+ ctx.io.stderr(`$ ${terminalSafe(commandString(started.argv))}\n`);
139
+ const ended = handOff(started);
140
+ if (ended.error !== undefined) {
141
+ throw new CommandError(terminalSafe(`${started.argv[0]}: ${ended.error}`), {
142
+ code: 'spawn',
143
+ });
144
+ }
145
+ return outcome(skillDocument(started, true, ended.exit), ended.exit);
146
+ }
72
147
  let plan;
73
148
  try {
74
- plan = session.resolveRun(snapshot.catalog, positionals[0], rest);
149
+ plan = session.resolveRun(snapshot.catalog, id, rest);
75
150
  }
76
151
  catch (err) {
77
- const skill = snapshot.skills.find((s) => s.id === positionals[0] || s.invoke === positionals[0]);
78
152
  if (err instanceof SessionError && err.code === 'task-not-found' && skill !== undefined) {
79
- throw new CommandError(`${skill.invoke}: a skill runs in an agent, not here`, {
153
+ const shown = terminalSafe(skill.invoke);
154
+ const readers = terminalSafe(skill.harnesses.join(', '));
155
+ const startable = agentClis(skill, session.env).length > 0;
156
+ throw new CommandError(`${shown}: a skill runs in an agent, not here`, {
80
157
  code: 'not-runnable',
81
- hint: `type ${skill.invoke} in ${skill.harnesses.join(', ')}`,
158
+ hint: startable
159
+ ? `type ${shown} in ${readers}, or start one with it: ${BIN} run ${shown} --agent`
160
+ : `type ${shown} in ${readers}`,
82
161
  });
83
162
  }
84
163
  if (err instanceof SessionError) {
@@ -2,6 +2,8 @@
2
2
  * Agent skills as catalog rows: the Skills group. A skill is not a task. It
3
3
  * has no command line; an agent runs it when a person types `/<name>`. So
4
4
  * the run action copies {@link SkillRow.invoke} and nothing is spawned.
5
+ * Handing a skill to an agent's CLI is a separate action, asked for
6
+ * explicitly; {@link skillPrompt} is the prompt it starts with.
5
7
  *
6
8
  * Skill names, descriptions and hints come from files in the repository or
7
9
  * the user's config. Filter them like any repository text before printing.
@@ -45,6 +47,24 @@ export interface SkillHit {
45
47
  }
46
48
  /** The text a surface shows for a skill: `/review [pr-number]`. */
47
49
  export declare function skillLine(skill: Pick<SkillRow, 'invoke' | 'argumentHint'>): string;
50
+ /**
51
+ * The harnesses a skill can be handed off to, in the order one is chosen
52
+ * when several read the skill: the order `@osdlc/detect-harness` reports
53
+ * them in. Each one's CLI starts an interactive session with a first prompt
54
+ * given as its one argument.
55
+ */
56
+ export declare const HANDOFF_HARNESSES: readonly ["claude", "codex", "cursor"];
57
+ /** One of {@link HANDOFF_HARNESSES}. */
58
+ export type HandOffHarness = (typeof HANDOFF_HARNESSES)[number];
59
+ /** Whether `harness` is one of {@link HANDOFF_HARNESSES}. */
60
+ export declare function isHandOffHarness(harness: string): harness is HandOffHarness;
61
+ /**
62
+ * The first prompt that runs `skill` in `harness`: its mention, such as
63
+ * `/review`, then `args` after a space when there are any. `args` is what
64
+ * the skill's `argument-hint` asks for, trimmed; it is prompt text, not
65
+ * argv, so it is sent as one string.
66
+ */
67
+ export declare function skillPrompt(skill: Pick<SkillRow, 'name'>, harness: HandOffHarness, args?: string): string;
48
68
  /**
49
69
  * The skills that pass `filter`, matched like tasks: by name, then the
50
70
  * `/<name>` line, the description and the origin. With a query they are
@@ -2,6 +2,8 @@
2
2
  * Agent skills as catalog rows: the Skills group. A skill is not a task. It
3
3
  * has no command line; an agent runs it when a person types `/<name>`. So
4
4
  * the run action copies {@link SkillRow.invoke} and nothing is spawned.
5
+ * Handing a skill to an agent's CLI is a separate action, asked for
6
+ * explicitly; {@link skillPrompt} is the prompt it starts with.
5
7
  *
6
8
  * Skill names, descriptions and hints come from files in the repository or
7
9
  * the user's config. Filter them like any repository text before printing.
@@ -15,6 +17,33 @@ export const SKILLS_SETTING_VALUES = ['project', 'all', 'off'];
15
17
  export function skillLine(skill) {
16
18
  return skill.argumentHint === null ? skill.invoke : `${skill.invoke} ${skill.argumentHint}`;
17
19
  }
20
+ /**
21
+ * The harnesses a skill can be handed off to, in the order one is chosen
22
+ * when several read the skill: the order `@osdlc/detect-harness` reports
23
+ * them in. Each one's CLI starts an interactive session with a first prompt
24
+ * given as its one argument.
25
+ */
26
+ export const HANDOFF_HARNESSES = ['claude', 'codex', 'cursor'];
27
+ /**
28
+ * What names a skill in each harness's prompt. Claude Code and Cursor run
29
+ * `/<name>`; Codex mentions a skill as `$<name>`.
30
+ */
31
+ const MENTION = { claude: '/', codex: '$', cursor: '/' };
32
+ /** Whether `harness` is one of {@link HANDOFF_HARNESSES}. */
33
+ export function isHandOffHarness(harness) {
34
+ return HANDOFF_HARNESSES.includes(harness);
35
+ }
36
+ /**
37
+ * The first prompt that runs `skill` in `harness`: its mention, such as
38
+ * `/review`, then `args` after a space when there are any. `args` is what
39
+ * the skill's `argument-hint` asks for, trimmed; it is prompt text, not
40
+ * argv, so it is sent as one string.
41
+ */
42
+ export function skillPrompt(skill, harness, args = '') {
43
+ const rest = args.trim();
44
+ const mention = `${MENTION[harness]}${skill.name}`;
45
+ return rest === '' ? mention : `${mention} ${rest}`;
46
+ }
18
47
  /** Whether `skill` passes the parts of `filter` a skill has. */
19
48
  function keepsSkill(filter) {
20
49
  // A skill does not run until stopped, and is not a runner's.
package/dist/keys.d.ts CHANGED
@@ -26,7 +26,11 @@ export interface KeyBinding {
26
26
  action: string;
27
27
  /** The footer's short form, such as `^y copy`. Absent: help only. */
28
28
  hint?: string | undefined;
29
- /** The footer's form while a skill row is selected, when the key does something else there. */
29
+ /**
30
+ * The footer's form while a skill row is selected, when the key does
31
+ * something else there. A key with this and no `hint` is shown on skill
32
+ * rows only.
33
+ */
30
34
  skillHint?: string | undefined;
31
35
  /** The footer shows it at every width. */
32
36
  always?: boolean | undefined;
package/dist/keys.js CHANGED
@@ -29,6 +29,14 @@ export const KEY_TABLE = Object.freeze([
29
29
  hint: '^y copy',
30
30
  rank: 2,
31
31
  },
32
+ {
33
+ surface: 'tui',
34
+ view: 'list',
35
+ keys: ['^g'],
36
+ action: 'on a skill: start an agent CLI with it, asking first for what its hint names',
37
+ skillHint: '^g agent',
38
+ rank: 2,
39
+ },
32
40
  {
33
41
  surface: 'tui',
34
42
  view: 'list',
@@ -241,8 +249,8 @@ export function keysFor(surface, view) {
241
249
  */
242
250
  export function footerHints(bindings, width, separator = ' ', row = 'task') {
243
251
  const hinted = bindings
244
- .filter((k) => k.hint !== undefined)
245
- .map((k) => (row === 'skill' && k.skillHint !== undefined ? { ...k, hint: k.skillHint } : k));
252
+ .map((k) => (row === 'skill' && k.skillHint !== undefined ? { ...k, hint: k.skillHint } : k))
253
+ .filter((k) => k.hint !== undefined);
246
254
  const kept = new Set(hinted.filter((k) => k.always === true));
247
255
  const widthOf = (set) => [...set].reduce((n, k) => n + k.hint.length, 0) + Math.max(0, set.size - 1) * separator.length;
248
256
  const optional = hinted
package/dist/skills.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  /**
2
2
  * Read the agent skills for the Skills group from `@osdlc/detect-harness`.
3
3
  * It reads files only. No harness program runs, and no skill runs.
4
+ *
5
+ * {@link planSkillHandOff} plans the one explicit action that does start a
6
+ * program: an agent's CLI with the skill as its first prompt. It looks the
7
+ * CLI up on `PATH` and spawns nothing itself.
4
8
  */
5
- import type { SkillRow, SkillsSetting } from './core/skills.ts';
9
+ import { type HandOffHarness, type SkillRow, type SkillsSetting } from './core/skills.ts';
6
10
  /** What {@link readSkills} needs. */
7
11
  export interface ReadSkillsOptions {
8
12
  /** Which skills: `project` reads the repository only; `all` adds the home folder's. */
@@ -17,3 +21,55 @@ export interface ReadSkillsOptions {
17
21
  * nothing.
18
22
  */
19
23
  export declare function readSkills(root: string, opts: ReadSkillsOptions): Promise<SkillRow[]>;
24
+ /** An agent CLI on `PATH` that reads a skill. */
25
+ export interface AgentCli {
26
+ harness: HandOffHarness;
27
+ /** The binary's name, as `@osdlc/detect-harness` knows it: `claude`, `codex`, `cursor-agent`. */
28
+ binary: string;
29
+ /** Where it was found: absolute. */
30
+ path: string;
31
+ }
32
+ /**
33
+ * The agent CLIs that can start `skill`, best first: each harness that reads
34
+ * it, in {@link HANDOFF_HARNESSES} order, whose binary is on `env.PATH`.
35
+ * Only absolute `PATH` entries are searched, so a file the repository ships
36
+ * is never found. Nothing runs.
37
+ */
38
+ export declare function agentClis(skill: Pick<SkillRow, 'harnesses'>, env: Readonly<Record<string, string | undefined>>, platform?: NodeJS.Platform): AgentCli[];
39
+ /** Why a skill cannot be handed off, with what to do instead. */
40
+ export declare class SkillHandOffError extends Error {
41
+ readonly hint: string | undefined;
42
+ constructor(message: string, hint?: string);
43
+ }
44
+ /** A skill ready to hand to an agent's CLI. */
45
+ export interface SkillHandOffPlan {
46
+ skill: SkillRow;
47
+ harness: HandOffHarness;
48
+ /** The first prompt: `/review 123`. */
49
+ prompt: string;
50
+ /** The CLI's absolute path, then the prompt. Spawned without a shell. */
51
+ argv: string[];
52
+ /** Nothing is added to the environment. */
53
+ env: Record<string, string>;
54
+ /** The project root: the agent starts in the repository. */
55
+ cwd: string;
56
+ }
57
+ /** What {@link planSkillHandOff} needs. */
58
+ export interface SkillHandOffOptions {
59
+ /** The project root, where the agent starts. */
60
+ root: string;
61
+ env: Readonly<Record<string, string | undefined>>;
62
+ /** What follows the skill's name in the prompt, as typed. */
63
+ args?: string | undefined;
64
+ /** The harness to start. Default: the first of {@link agentClis}. */
65
+ harness?: string | undefined;
66
+ platform?: NodeJS.Platform | undefined;
67
+ }
68
+ /**
69
+ * The plan that starts `skill` in an agent's CLI, as `claude "/review 123"`
70
+ * does. Throws {@link SkillHandOffError} when the name or the arguments
71
+ * hold a control character, when the harness asked for is not one wayfinder
72
+ * starts or does not read the skill, or when no CLI that reads it is on
73
+ * `PATH`.
74
+ */
75
+ export declare function planSkillHandOff(skill: SkillRow, opts: SkillHandOffOptions): SkillHandOffPlan;
package/dist/skills.js CHANGED
@@ -1,9 +1,16 @@
1
1
  /**
2
2
  * Read the agent skills for the Skills group from `@osdlc/detect-harness`.
3
3
  * It reads files only. No harness program runs, and no skill runs.
4
+ *
5
+ * {@link planSkillHandOff} plans the one explicit action that does start a
6
+ * program: an agent's CLI with the skill as its first prompt. It looks the
7
+ * CLI up on `PATH` and spawns nothing itself.
4
8
  */
5
9
  import { isAbsolute, relative } from 'node:path';
6
- import { detect } from '@osdlc/detect-harness';
10
+ import { detect, LOCATIONS, which } from '@osdlc/detect-harness';
11
+ import { BIN } from "./app.js";
12
+ import { HANDOFF_HARNESSES, isHandOffHarness, skillPrompt, } from "./core/skills.js";
13
+ import { hasControls, terminalSafe } from "./terminal-text.js";
7
14
  /** `path` relative to `root` with `/` separators when it is inside it, else as given. */
8
15
  function underRoot(root, path) {
9
16
  const rel = relative(root, path);
@@ -52,3 +59,71 @@ export async function readSkills(root, opts) {
52
59
  const rank = (s) => (s.origin === 'project' || s.origin === 'local' ? 0 : 1);
53
60
  return [...byPath.values()].sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name));
54
61
  }
62
+ /**
63
+ * The agent CLIs that can start `skill`, best first: each harness that reads
64
+ * it, in {@link HANDOFF_HARNESSES} order, whose binary is on `env.PATH`.
65
+ * Only absolute `PATH` entries are searched, so a file the repository ships
66
+ * is never found. Nothing runs.
67
+ */
68
+ export function agentClis(skill, env, platform = process.platform) {
69
+ const clis = [];
70
+ for (const harness of HANDOFF_HARNESSES) {
71
+ if (!skill.harnesses.includes(harness))
72
+ continue;
73
+ const binary = LOCATIONS[harness].binary;
74
+ const path = which(binary, env, platform);
75
+ if (path !== null)
76
+ clis.push({ harness, binary, path });
77
+ }
78
+ return clis;
79
+ }
80
+ /** Why a skill cannot be handed off, with what to do instead. */
81
+ export class SkillHandOffError extends Error {
82
+ hint;
83
+ constructor(message, hint) {
84
+ super(message);
85
+ this.name = 'SkillHandOffError';
86
+ this.hint = hint;
87
+ }
88
+ }
89
+ /**
90
+ * The plan that starts `skill` in an agent's CLI, as `claude "/review 123"`
91
+ * does. Throws {@link SkillHandOffError} when the name or the arguments
92
+ * hold a control character, when the harness asked for is not one wayfinder
93
+ * starts or does not read the skill, or when no CLI that reads it is on
94
+ * `PATH`.
95
+ */
96
+ export function planSkillHandOff(skill, opts) {
97
+ const shown = terminalSafe(skill.invoke);
98
+ const readers = terminalSafe(skill.harnesses.join(', '));
99
+ const args = opts.args ?? '';
100
+ if (hasControls(skill.name) || hasControls(args)) {
101
+ throw new SkillHandOffError(`${shown}: not started: it holds a control character`);
102
+ }
103
+ const clis = agentClis(skill, opts.env, opts.platform);
104
+ const asked = opts.harness;
105
+ let cli;
106
+ if (asked === undefined) {
107
+ cli = clis[0];
108
+ if (cli === undefined) {
109
+ const wanted = HANDOFF_HARNESSES.filter((h) => skill.harnesses.includes(h));
110
+ throw new SkillHandOffError(`${shown}: no agent CLI that reads it is on PATH`, wanted.length > 0
111
+ ? `looked for ${wanted.map((h) => LOCATIONS[h].binary).join(', ')}; type ${shown} in ${readers}`
112
+ : `${BIN} starts ${HANDOFF_HARNESSES.join(', ')}; type ${shown} in ${readers}`);
113
+ }
114
+ }
115
+ else {
116
+ if (!isHandOffHarness(asked)) {
117
+ throw new SkillHandOffError(`${BIN} cannot start ${terminalSafe(asked)}`, `it starts ${HANDOFF_HARNESSES.join(', ')}`);
118
+ }
119
+ if (!skill.harnesses.includes(asked)) {
120
+ throw new SkillHandOffError(`${shown}: ${asked} does not read this skill`, `it is for ${readers}`);
121
+ }
122
+ cli = clis.find((c) => c.harness === asked);
123
+ if (cli === undefined) {
124
+ throw new SkillHandOffError(`${shown}: ${LOCATIONS[asked].binary} is not on PATH`, `install ${asked}, or type ${shown} in ${readers}`);
125
+ }
126
+ }
127
+ const prompt = skillPrompt(skill, cli.harness, args);
128
+ return { skill, harness: cli.harness, prompt, argv: [cli.path, prompt], env: {}, cwd: opts.root };
129
+ }
package/dist/tui/app.d.ts CHANGED
@@ -16,6 +16,7 @@ import type { TaskHit } from '../core/filter.ts';
16
16
  import type { HandOffResult } from '../core/run.ts';
17
17
  import { type CacheState, type RunPlan, type Session } from '../core/session.ts';
18
18
  import { type SkillHit, type SkillRow } from '../core/skills.ts';
19
+ import { type AgentCli } from '../skills.ts';
19
20
  import { type SettingsItem } from './settings.ts';
20
21
  import { type Styles } from './style.ts';
21
22
  /** What the terminal UI needs from the terminal it runs in. */
@@ -29,8 +30,8 @@ export interface TuiHost {
29
30
  clipboard(text: string): Promise<boolean>;
30
31
  /** Give the terminal back: leave raw mode and the alternate screen. Idempotent. */
31
32
  release(): void;
32
- /** Run a task with the terminal, after {@link release}. */
33
- handOff(plan: RunPlan): HandOffResult;
33
+ /** Run a task, or an agent CLI with a skill, with the terminal, after {@link release}. */
34
+ handOff(plan: Pick<RunPlan, 'argv' | 'env' | 'cwd'>): HandOffResult;
34
35
  /** End the process. The real host never returns. */
35
36
  exit(code: number): void;
36
37
  }
@@ -121,9 +122,18 @@ export interface TuiState {
121
122
  confirmingTrust: boolean;
122
123
  /** The tool the pending grant is for, or null for the whole repository. */
123
124
  trustScope: string | null;
124
- /** The task whose arguments are being typed, and the text so far. */
125
+ /**
126
+ * The task whose arguments are being typed, or the skill whose prompt is,
127
+ * before it is handed to an agent; and the text so far.
128
+ */
125
129
  entering: {
126
130
  task: Task;
131
+ skill?: undefined;
132
+ text: string;
133
+ } | {
134
+ skill: SkillRow;
135
+ agent: AgentCli;
136
+ task?: undefined;
127
137
  text: string;
128
138
  } | null;
129
139
  view: 'list' | 'settings' | 'help';
package/dist/tui/app.js CHANGED
@@ -18,9 +18,10 @@ import { splitArgs } from "../args.js";
18
18
  import { inDisplayOrder, orderedCatalog } from "../catalog.js";
19
19
  import { COPY_REFUSED, skillCopyText, taskCopyText } from "../core/copy-text.js";
20
20
  import { SessionError } from "../core/session.js";
21
- import { skillLine } from "../core/skills.js";
21
+ import { skillLine, skillPrompt } from "../core/skills.js";
22
22
  import { groupOf, SKILLS_GROUP } from "../groups.js";
23
23
  import { footerHints, keyLines, keysFor } from "../keys.js";
24
+ import { agentClis, planSkillHandOff, SkillHandOffError } from "../skills.js";
24
25
  import { terminalSafe } from "../terminal-text.js";
25
26
  import { countRunners, displayPath, parametersUnknownLabel, probeTimeLabel, runnerLabel, withheldLabel, WAITING_AFTER_MS, } from "../vocabulary.js";
26
27
  import { isText, namedKey, splitKeys } from "./keys-input.js";
@@ -109,6 +110,17 @@ function failureText(r) {
109
110
  export function createTui({ session, host, styles: s }) {
110
111
  /** `argv` quoted for the shell, as the CLI prints the run line. */
111
112
  const commandLine = (argv) => commandString(argv, { platform: host.platform });
113
+ /** The agent CLIs that can start each skill, looked up once: `PATH` is fixed for a run. */
114
+ const agentsBySkill = new Map();
115
+ const agentsFor = (skill) => {
116
+ const key = skill.harnesses.join(',');
117
+ let found = agentsBySkill.get(key);
118
+ if (found === undefined) {
119
+ found = agentClis(skill, session.env, host.platform);
120
+ agentsBySkill.set(key, found);
121
+ }
122
+ return found;
123
+ };
112
124
  const state = {
113
125
  catalog: null,
114
126
  partial: null,
@@ -501,7 +513,9 @@ export function createTui({ session, host, styles: s }) {
501
513
  { text: '' },
502
514
  { text: 'SKILLS', heading: true },
503
515
  { text: ' An agent skill is typed in the agent as /<name>. Enter and ^y copy it;' },
504
- { text: ' nothing runs here.' },
516
+ { text: ' nothing runs. ^g starts an agent CLI with it instead: the first of claude,' },
517
+ { text: ' codex and cursor-agent on PATH that reads it, asking first for what the' },
518
+ { text: " skill's argument hint names." },
505
519
  ];
506
520
  return lines.flatMap((l) => l.heading === true ? [l] : wrapHanging(l.text, width).map((text) => ({ text })));
507
521
  }
@@ -630,7 +644,9 @@ export function createTui({ session, host, styles: s }) {
630
644
  if (currentEntry?.skill !== undefined) {
631
645
  const skill = currentEntry.skill.skill;
632
646
  const text = terminalSafe(skillLine(skill));
633
- const where = terminalSafe(`skill for ${skill.harnesses.join(', ')}`);
647
+ const agent = agentsFor(skill)[0];
648
+ const where = terminalSafe(`skill for ${skill.harnesses.join(', ')}` +
649
+ (agent !== undefined ? ` · ^g starts ${agent.binary}` : ''));
634
650
  const gap = width - text.length - where.length - 1;
635
651
  out.push(line(gap >= 3
636
652
  ? [{ text, paint: s.bold }, { text: ' '.repeat(gap) }, { text: where, paint: s.dim }]
@@ -660,7 +676,20 @@ export function createTui({ session, host, styles: s }) {
660
676
  out.push(line([], width));
661
677
  out.push(line([], width));
662
678
  }
663
- if (state.entering) {
679
+ if (state.entering?.skill !== undefined) {
680
+ const { skill, agent, text } = state.entering;
681
+ out.push(line([
682
+ { text: `${agent.binary} ▸ `, paint: s.dim },
683
+ { text: terminalSafe(skillPrompt(skill, agent.harness)) + ' ', paint: s.bold },
684
+ { text },
685
+ { text: '█', paint: s.accent },
686
+ ], width));
687
+ const hints = footerHints(keysFor('tui', 'arguments'), width);
688
+ const about = `takes ${skill.argumentHint}; type any, or none`;
689
+ const aboutRoom = Math.max(0, width - hints.length - 6);
690
+ out.push(line([{ text: ` ${fitWidth(terminalSafe(about), aboutRoom)} ${hints}`, paint: s.dim }], width));
691
+ }
692
+ else if (state.entering) {
664
693
  const { task, text } = state.entering;
665
694
  out.push(line([
666
695
  { text: '$ ', paint: s.dim },
@@ -1013,6 +1042,48 @@ export function createTui({ session, host, styles: s }) {
1013
1042
  async function copySkill(skill) {
1014
1043
  await toClipboard(skillCopyText(skill), terminalSafe(`copied ${skill.invoke}; type it in ${skill.harnesses.join(', ')}`));
1015
1044
  }
1045
+ /**
1046
+ * `^g` on a skill: hand it to the first agent CLI on `PATH` that reads it.
1047
+ * A skill with an argument hint asks for its arguments first, on the entry
1048
+ * line; one without starts at once. With no such CLI it says why.
1049
+ */
1050
+ function startSkill(skill) {
1051
+ const agent = agentsFor(skill)[0];
1052
+ if (agent === undefined || skill.argumentHint === null) {
1053
+ handOverSkill(skill, '', agent);
1054
+ return;
1055
+ }
1056
+ state.entering = { skill, agent, text: '' };
1057
+ }
1058
+ /** Hand the terminal to an agent CLI started with `skill`, and exit with its code. A refused plan is shown as an error and the UI stays. */
1059
+ function handOverSkill(skill, args, agent) {
1060
+ let plan;
1061
+ try {
1062
+ plan = planSkillHandOff(skill, {
1063
+ root: session.root,
1064
+ env: session.env,
1065
+ args,
1066
+ platform: host.platform,
1067
+ ...(agent !== undefined ? { harness: agent.harness } : {}),
1068
+ });
1069
+ }
1070
+ catch (err) {
1071
+ if (err instanceof SkillHandOffError) {
1072
+ say(err.hint !== undefined ? `${err.message} — ${err.hint}` : err.message, 'error');
1073
+ return;
1074
+ }
1075
+ throw err;
1076
+ }
1077
+ state.inFlight?.abort();
1078
+ ended = true;
1079
+ host.release();
1080
+ host.write(`$ ${terminalSafe(commandLine(plan.argv))}\n`);
1081
+ const result = host.handOff(plan);
1082
+ if (result.error !== undefined) {
1083
+ host.write(terminalSafe(`${BIN}: ${plan.argv[0]}: ${result.error}`) + '\n');
1084
+ }
1085
+ host.exit(result.exit);
1086
+ }
1016
1087
  /** Copy `text`; null is text that holds a control character, which is refused. */
1017
1088
  async function toClipboard(text, done) {
1018
1089
  if (text === null) {
@@ -1284,7 +1355,10 @@ export function createTui({ session, host, styles: s }) {
1284
1355
  state.entering = null;
1285
1356
  else if (key === '\r' || key === '\n') {
1286
1357
  state.entering = null;
1287
- run(entering.task, splitArgs(entering.text));
1358
+ if (entering.skill !== undefined)
1359
+ handOverSkill(entering.skill, entering.text, entering.agent);
1360
+ else
1361
+ run(entering.task, splitArgs(entering.text));
1288
1362
  }
1289
1363
  else if (key === '\x7f' || key === '\x08')
1290
1364
  entering.text = entering.text.slice(0, -1);
@@ -1322,6 +1396,15 @@ export function createTui({ session, host, styles: s }) {
1322
1396
  track(copy(entry.task.task));
1323
1397
  return;
1324
1398
  }
1399
+ case '\x07': {
1400
+ // ctrl-g
1401
+ const entry = entries()[cursor()];
1402
+ if (entry?.skill !== undefined)
1403
+ startSkill(entry.skill.skill);
1404
+ else if (entry?.task !== undefined)
1405
+ say('^g starts an agent with a skill; this is a task');
1406
+ return;
1407
+ }
1325
1408
  case '\x05': // ctrl-e
1326
1409
  state.mode = state.mode === 'fuzzy' ? 'exact' : 'fuzzy';
1327
1410
  resetSelection();
@@ -1,2 +1,2 @@
1
1
  /** This package's version, from its package.json when it was built. */
2
- export declare const VERSION = "0.12.11";
2
+ export declare const VERSION = "0.13.4";
@@ -1,3 +1,3 @@
1
1
  // Generated by cli-tool-stamp-version from package.json. Do not edit.
2
2
  /** This package's version, from its package.json when it was built. */
3
- export const VERSION = '0.12.11';
3
+ export const VERSION = '0.13.4';
package/dist/web/main.js CHANGED
@@ -516,6 +516,8 @@ function skillCopyText(skill) {
516
516
  * Agent skills as catalog rows: the Skills group. A skill is not a task. It
517
517
  * has no command line; an agent runs it when a person types `/<name>`. So
518
518
  * the run action copies {@link SkillRow.invoke} and nothing is spawned.
519
+ * Handing a skill to an agent's CLI is a separate action, asked for
520
+ * explicitly; {@link skillPrompt} is the prompt it starts with.
519
521
  *
520
522
  * Skill names, descriptions and hints come from files in the repository or
521
523
  * the user's config. Filter them like any repository text before printing.
@@ -784,6 +786,14 @@ const KEY_TABLE = Object.freeze([
784
786
  hint: "^y copy",
785
787
  rank: 2
786
788
  },
789
+ {
790
+ surface: "tui",
791
+ view: "list",
792
+ keys: ["^g"],
793
+ action: "on a skill: start an agent CLI with it, asking first for what its hint names",
794
+ skillHint: "^g agent",
795
+ rank: 2
796
+ },
787
797
  {
788
798
  surface: "tui",
789
799
  view: "list",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdlc/wayfinder",
3
- "version": "0.12.11",
3
+ "version": "0.13.4",
4
4
  "description": "Browse and run every task in a repository from one list: a terminal UI where Enter runs the selected task, a live web view, and JSON for scripts. Tasks, installs, tool trust and git hooks come from @osdlc/system-model.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "sksizer",
@@ -55,17 +55,17 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "zod": "^4.6.6",
58
- "@osdlc/cli-tool": "^0.19.0",
59
- "@osdlc/command-seam": "^0.15.0",
60
- "@osdlc/config-layers": "^0.10.0",
61
- "@osdlc/detect-harness": "^0.7.3",
58
+ "@osdlc/cli-tool": "^0.21.0",
59
+ "@osdlc/command-seam": "^0.15.1",
60
+ "@osdlc/config-layers": "^0.11.1",
61
+ "@osdlc/detect-harness": "^0.7.4",
62
62
  "@osdlc/etag-write": "^0.3.1",
63
63
  "@osdlc/path-guard": "^0.3.1",
64
- "@osdlc/system-model": "^0.7.2",
64
+ "@osdlc/system-model": "^0.9.0",
65
+ "@osdlc/trust-repo": "^0.5.13",
65
66
  "@osdlc/tiered-dirs": "^0.5.0",
66
- "@osdlc/trust-repo": "^0.5.9",
67
- "@osdlc/typed-git": "^0.17.0",
68
- "@osdlc/ux": "^0.1.1"
67
+ "@osdlc/ux": "^0.1.1",
68
+ "@osdlc/typed-git": "^0.21.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/node": "^26.1.0",
@@ -76,8 +76,8 @@
76
76
  "rolldown": "^1.2.14",
77
77
  "typescript": "~6.0.3",
78
78
  "vitest": "^5.0.5",
79
- "@osdlc/color": "^1.1.0",
80
79
  "@osdlc/prettier-config": "^0.3.1",
80
+ "@osdlc/color": "^1.1.0",
81
81
  "@osdlc/tsconfig": "^0.4.1"
82
82
  },
83
83
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://unpkg.com/@osdlc/wayfinder@0.12/schema/config.json",
3
+ "$id": "https://unpkg.com/@osdlc/wayfinder@0.13/schema/config.json",
4
4
  "title": "wayfinder configuration",
5
5
  "type": "object",
6
6
  "properties": {