@wringer/gunshi 0.1.0 → 0.2.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.
Files changed (47) hide show
  1. package/README.md +45 -2
  2. package/dist/build-lint-command.d.ts +2 -0
  3. package/dist/build-linted-wringer.d.ts +2 -0
  4. package/dist/collect-dead-globs.d.ts +6 -0
  5. package/dist/collect-journey-commands.d.ts +11 -0
  6. package/dist/collect-lint-files.d.ts +11 -0
  7. package/dist/find-skill-copy-refusal.d.ts +8 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/parse-shell-words.d.ts +1 -0
  10. package/dist/parse-skill-install-args.d.ts +3 -0
  11. package/dist/parse-skill-metadata.d.ts +9 -0
  12. package/dist/resolve-invocation.d.ts +3 -0
  13. package/dist/resolve-journey-problem.d.ts +2 -0
  14. package/dist/resolve-lint-failures.d.ts +26 -0
  15. package/dist/run-cli.d.ts +1 -2
  16. package/dist/run-verify.d.ts +4 -1
  17. package/dist/template-version.d.ts +1 -0
  18. package/dist/wringer-gunshi.d.ts +2 -0
  19. package/dist/write-skill-copy.d.ts +12 -0
  20. package/package.json +13 -6
  21. package/skills/wringer/SKILL.md +143 -0
  22. package/skills/wringer/references/create.md +90 -0
  23. package/skills/wringer/references/fresh-subagent-brief.md +34 -0
  24. package/skills/wringer/references/maintain.md +78 -0
  25. package/skills/wringer/references/prove.md +42 -0
  26. package/skills/wringer/template/verify/SKILL.md +176 -0
  27. package/skills/wringer/template/verify/references/feature-map.md +17 -0
  28. package/skills/wringer/template/verify-registry.ts +83 -0
  29. package/skills/wringer/template/verify.ts +6 -0
  30. package/src/build-lint-command.ts +91 -0
  31. package/src/build-linted-wringer.ts +16 -0
  32. package/src/collect-dead-globs.ts +21 -0
  33. package/src/collect-journey-commands.ts +140 -0
  34. package/src/collect-lint-files.ts +36 -0
  35. package/src/find-skill-copy-refusal.ts +34 -0
  36. package/src/index.ts +1 -0
  37. package/src/parse-shell-words.ts +67 -0
  38. package/src/parse-skill-install-args.ts +25 -0
  39. package/src/parse-skill-metadata.ts +56 -0
  40. package/src/resolve-invocation.ts +94 -0
  41. package/src/resolve-journey-problem.ts +64 -0
  42. package/src/resolve-lint-failures.ts +111 -0
  43. package/src/run-cli.ts +6 -97
  44. package/src/run-verify.ts +27 -16
  45. package/src/template-version.ts +3 -0
  46. package/src/wringer-gunshi.ts +27 -0
  47. package/src/write-skill-copy.ts +75 -0
@@ -0,0 +1,67 @@
1
+ const operatorCharacters = new Set(['|', '&', ';', '<', '>']);
2
+
3
+ // Splits one shell command line into its words as a POSIX shell would: single quotes keep their
4
+ // text as it is, double quotes and a backslash escape. The words end at the first unquoted
5
+ // operator, such as a pipe into `jq`, or at a `#` that starts a word. Null for an unclosed quote.
6
+ export function parseShellWords(line: string): readonly string[] | null {
7
+ const words: string[] = [];
8
+ let word: string | null = null;
9
+ let quote: "'" | '"' | null = null;
10
+ let quoted = false;
11
+
12
+ for (let index = 0; index < line.length; index += 1) {
13
+ const character = line.charAt(index);
14
+
15
+ if (quote === "'") {
16
+ if (character === "'") {
17
+ quote = null;
18
+ } else {
19
+ word = `${word ?? ''}${character}`;
20
+ }
21
+ } else if (quote === '"') {
22
+ if (character === '"') {
23
+ quote = null;
24
+ } else if (character === '\\' && '"\\$`'.includes(line.charAt(index + 1))) {
25
+ index += 1;
26
+ word = `${word ?? ''}${line.charAt(index)}`;
27
+ } else {
28
+ word = `${word ?? ''}${character}`;
29
+ }
30
+ } else if (character === "'" || character === '"') {
31
+ quote = character;
32
+ quoted = true;
33
+ word ??= '';
34
+ } else if (character === '\\') {
35
+ quoted = true;
36
+ index += 1;
37
+ word = `${word ?? ''}${line.charAt(index)}`;
38
+ } else if (/\s/u.test(character)) {
39
+ if (word !== null) {
40
+ words.push(word);
41
+ }
42
+
43
+ word = null;
44
+ quoted = false;
45
+ } else if (operatorCharacters.has(character) || (character === '#' && word === null)) {
46
+ // In `2>&1`, the digits name the stream the redirect moves, and the command never sees them.
47
+ if (
48
+ (character === '<' || character === '>') &&
49
+ !quoted &&
50
+ word !== null &&
51
+ /^\d+$/u.test(word)
52
+ ) {
53
+ word = null;
54
+ }
55
+
56
+ break;
57
+ } else {
58
+ word = `${word ?? ''}${character}`;
59
+ }
60
+ }
61
+
62
+ if (quote !== null) {
63
+ return null;
64
+ }
65
+
66
+ return word === null ? words : [...words, word];
67
+ }
@@ -0,0 +1,25 @@
1
+ import { parseArgs } from 'node:util';
2
+
3
+ // Users type `--dir`; the naming lint rejects `dir` as a literal key, so the name lives in a value.
4
+ const directoryFlag = 'dir';
5
+ const defaultDestination = '.claude/skills/wringer';
6
+
7
+ // Answers the destination folder, or null when the arguments are not `skill install [--dir <path>]`.
8
+ export function parseSkillInstallArgs(argv: readonly string[]): { destination: string } | null {
9
+ try {
10
+ const parsed = parseArgs({
11
+ args: [...argv],
12
+ options: { [directoryFlag]: { type: 'string' } },
13
+ allowPositionals: true,
14
+ strict: true,
15
+ });
16
+
17
+ if (parsed.positionals.join(' ') !== 'skill install') {
18
+ return null;
19
+ }
20
+
21
+ return { destination: parsed.values[directoryFlag] ?? defaultDestination };
22
+ } catch {
23
+ return null;
24
+ }
25
+ }
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ import { parseShellWords } from './parse-shell-words.ts';
3
+
4
+ export type SkillMetadata =
5
+ | {
6
+ readonly ok: true;
7
+ readonly templateVersion: number;
8
+ readonly cliWords: readonly string[];
9
+ }
10
+ | { readonly ok: false; readonly reason: string };
11
+
12
+ const frontmatterSchema = z.looseObject({
13
+ metadata: z.looseObject({
14
+ 'wringer-template': z.number().int().positive(),
15
+ 'wringer-command': z.string().min(1),
16
+ }),
17
+ });
18
+
19
+ const frontmatterPattern = /^---\r?\n(?<yaml>[\s\S]*?)\r?\n---\r?\n/u;
20
+
21
+ // The wringer fields of a verify skill's YAML frontmatter: the template version the skill was
22
+ // written from, and the words that call the repo's CLI, such as `bun verify`.
23
+ export function parseSkillMetadata(text: string): SkillMetadata {
24
+ const yaml = frontmatterPattern.exec(text)?.groups?.['yaml'];
25
+
26
+ if (yaml === undefined) {
27
+ return { ok: false, reason: 'The skill has no YAML frontmatter.' };
28
+ }
29
+
30
+ const parsed = frontmatterSchema.safeParse(parseYAML(yaml));
31
+
32
+ if (!parsed.success) {
33
+ return {
34
+ ok: false,
35
+ reason:
36
+ 'The frontmatter lacks `metadata.wringer-template` as a whole number or `metadata.wringer-command` as text.',
37
+ };
38
+ }
39
+
40
+ const cliWords = parseShellWords(parsed.data.metadata['wringer-command']);
41
+
42
+ if (cliWords === null || cliWords.length === 0) {
43
+ return { ok: false, reason: '`metadata.wringer-command` is not a command line.' };
44
+ }
45
+
46
+ return { ok: true, templateVersion: parsed.data.metadata['wringer-template'], cliWords };
47
+ }
48
+
49
+ // Bun's YAML parser throws on text that is not YAML; the schema then reports the field as missing.
50
+ function parseYAML(yaml: string): unknown {
51
+ try {
52
+ return Bun.YAML.parse(yaml);
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
@@ -0,0 +1,94 @@
1
+ import { WringerError } from '@wringer/core';
2
+ import type { Wringer } from '@wringer/core';
3
+ import { cli, parseArgs } from 'gunshi';
4
+ import { buildGunshiCommands } from './build-gunshi-commands.ts';
5
+ import type { InvokeResult } from './build-gunshi-commands.ts';
6
+ import { findSignedValueFlag } from './find-signed-value-flag.ts';
7
+ import type { SignedValueFlag } from './find-signed-value-flag.ts';
8
+ import type { ParsedInvocation } from './pick-cli-outcome.ts';
9
+ import { pickCommandName } from './pick-command-name.ts';
10
+
11
+ // gunshi only records the invocation; the command runs after `cli` returns, so a gunshi parse error
12
+ // and a command error never mix. gunshi resolves the command path before it checks the flags, so a
13
+ // flag error still names the command.
14
+ export async function resolveInvocation(
15
+ wringer: Wringer,
16
+ argv: readonly string[],
17
+ ): Promise<ParsedInvocation> {
18
+ let invoked: InvokeResult | null = null;
19
+ let commandPath: readonly string[] = [];
20
+
21
+ const subCommands = buildGunshiCommands(wringer, (result) => {
22
+ invoked = result;
23
+ });
24
+
25
+ try {
26
+ const printed = await cli(
27
+ [...argv],
28
+ {
29
+ name: wringer.name,
30
+ run: () => {
31
+ throw new WringerError('usage', {
32
+ message: 'Name a command.',
33
+ hint: `Run \`${wringer.name} --help\` to list them.`,
34
+ });
35
+ },
36
+ },
37
+ {
38
+ name: wringer.name,
39
+ subCommands,
40
+ strict: true,
41
+ usageSilent: true,
42
+ renderHeader: null,
43
+ renderValidationErrors: null,
44
+ onBeforeCommand: (ctx) => {
45
+ commandPath = ctx.commandPath;
46
+ },
47
+ },
48
+ );
49
+
50
+ return pickParsedInvocation(invoked, printed, pickCommandName(commandPath, argv));
51
+ } catch (error) {
52
+ return {
53
+ kind: 'failed',
54
+ command: pickCommandName(commandPath, argv),
55
+ error: toUsageError(error, findSignedValueFlag(parseArgs([...argv]), argv)),
56
+ };
57
+ }
58
+ }
59
+
60
+ // gunshi ran no command when it printed help or a version.
61
+ function pickParsedInvocation(
62
+ invoked: InvokeResult | null,
63
+ printed: string | undefined,
64
+ command: string,
65
+ ): ParsedInvocation {
66
+ if (invoked === null) {
67
+ return { kind: 'printed', text: `${printed ?? ''}\n` };
68
+ }
69
+
70
+ if (invoked.kind === 'refused') {
71
+ return { kind: 'failed', command, error: invoked.error };
72
+ }
73
+
74
+ return { kind: 'invoked', invocation: invoked.invocation };
75
+ }
76
+
77
+ // gunshi throws an AggregateError for a parse failure, with one error per problem.
78
+ function toUsageError(error: unknown, signed: SignedValueFlag | undefined): WringerError {
79
+ if (error instanceof WringerError) {
80
+ return error;
81
+ }
82
+
83
+ const problems = error instanceof AggregateError ? error.errors.map(String) : [String(error)];
84
+
85
+ const hint =
86
+ signed === undefined
87
+ ? 'Add `--help` to the command to see its arguments.'
88
+ : `Join a negative value to its flag with \`=\`: \`${signed.flag}=${signed.value}\`.`;
89
+
90
+ return new WringerError('usage', {
91
+ message: problems.map((problem) => problem.replace(/^\w*Error: /u, '')).join(' '),
92
+ hint,
93
+ });
94
+ }
@@ -0,0 +1,64 @@
1
+ import { prepareArgs } from '@wringer/core';
2
+ import type { RegisteredCommand, Wringer } from '@wringer/core';
3
+ import invariant from 'tiny-invariant';
4
+ import { match } from 'ts-pattern';
5
+ import type { Invocation } from './build-gunshi-commands.ts';
6
+ import { resolveInvocation } from './resolve-invocation.ts';
7
+
8
+ // Why one journey command would fail before it ran, or null when it would run: the words go through
9
+ // the CLI's own parser, the arguments through the command's schema, and a feature or a target it
10
+ // names must be one the registry declares.
11
+ export async function resolveJourneyProblem(
12
+ wringer: Wringer,
13
+ argv: readonly string[],
14
+ ): Promise<string | null> {
15
+ const parsed = await resolveInvocation(wringer, argv);
16
+
17
+ return match(parsed)
18
+ .with({ kind: 'printed' }, () => null)
19
+ .with({ kind: 'failed' }, (failed) => failed.error.message)
20
+ .with({ kind: 'invoked' }, (invoked) => findInvocationProblem(wringer, invoked.invocation))
21
+ .exhaustive();
22
+ }
23
+
24
+ function findInvocationProblem(wringer: Wringer, invocation: Invocation): string | null {
25
+ const command = wringer.commands.get(invocation.path.join(' '));
26
+
27
+ invariant(command, 'gunshi invoked a command that the registry lacks.');
28
+
29
+ const prepared = prepareArgs(command.info.args, invocation.raw, () => null);
30
+
31
+ if (!prepared.ok) {
32
+ return prepared.message;
33
+ }
34
+
35
+ return findNameProblem(wringer, command, invocation);
36
+ }
37
+
38
+ // A built-in command, such as `use` or `done`, takes the feature and the target as its own
39
+ // arguments; a repo command's argument of that name means something of the repo's.
40
+ function findNameProblem(
41
+ wringer: Wringer,
42
+ command: RegisteredCommand,
43
+ invocation: Invocation,
44
+ ): string | null {
45
+ const own = command.kind === 'builtin' ? invocation.raw : {};
46
+ const feature = invocation.globals.feature ?? findText(own, 'feature');
47
+ const target = invocation.globals.target ?? findText(own, 'target');
48
+
49
+ if (feature !== undefined && !wringer.features.some((entry) => entry.name === feature)) {
50
+ return `The feature map has no feature named ${feature}.`;
51
+ }
52
+
53
+ if (target !== undefined && !wringer.targets.has(target)) {
54
+ return `The repo has no target named ${target}.`;
55
+ }
56
+
57
+ return null;
58
+ }
59
+
60
+ function findText(raw: Readonly<Record<string, unknown>>, key: string): string | undefined {
61
+ const value = raw[key];
62
+
63
+ return typeof value === 'string' ? value : undefined;
64
+ }
@@ -0,0 +1,111 @@
1
+ import type { Wringer } from '@wringer/core';
2
+ import { z } from 'zod';
3
+ import { collectDeadGlobs } from './collect-dead-globs.ts';
4
+ import { collectJourneyCommands } from './collect-journey-commands.ts';
5
+ import type { JourneyCommand, MarkdownFile } from './collect-journey-commands.ts';
6
+ import { parseSkillMetadata } from './parse-skill-metadata.ts';
7
+ import type { SkillMetadata } from './parse-skill-metadata.ts';
8
+ import { resolveJourneyProblem } from './resolve-journey-problem.ts';
9
+
10
+ export const lintFailureSchema = z.strictObject({
11
+ check: z.enum(['paths', 'journey', 'template']),
12
+ where: z.string(),
13
+ problem: z.string(),
14
+ });
15
+
16
+ type LintFailure = z.infer<typeof lintFailureSchema>;
17
+
18
+ export interface LintInput {
19
+ readonly wringer: Wringer;
20
+
21
+ // Every file of the repo that git tracks or does not ignore, relative to its root.
22
+ readonly files: readonly string[];
23
+ readonly skillPath: string;
24
+
25
+ // The Markdown files of the verify skill's folder, its SKILL.md included when it exists.
26
+ readonly skillFiles: readonly MarkdownFile[];
27
+ readonly templateVersion: number;
28
+ }
29
+
30
+ export interface LintResult {
31
+ readonly commands: number;
32
+ readonly failures: readonly LintFailure[];
33
+ }
34
+
35
+ // The lint failures of a repo: a `paths` glob that matches no file, a CLI line in the verify
36
+ // skill's code blocks that would fail to parse, and a skill that lacks the template version this
37
+ // package ships. It reads nothing; the CLI parser it calls is async but does no I/O.
38
+ export async function resolveLintFailures(input: LintInput): Promise<LintResult> {
39
+ const skill = input.skillFiles.find((file) => file.path === input.skillPath);
40
+ const metadata = skill === undefined ? null : parseSkillMetadata(skill.text);
41
+
42
+ const journeys =
43
+ metadata?.ok === true ? collectJourneyCommands(input.skillFiles, metadata.cliWords) : [];
44
+
45
+ const journeyFailures = await Promise.all(
46
+ journeys.map((journey) => resolveJourneyFailure(input.wringer, journey)),
47
+ );
48
+
49
+ const pathFailures = collectDeadGlobs(input.wringer.features, input.files).map(
50
+ (dead): LintFailure => ({
51
+ check: 'paths',
52
+ where: `feature ${dead.feature}`,
53
+ problem: `The glob \`${dead.glob}\` matches no file.`,
54
+ }),
55
+ );
56
+
57
+ return {
58
+ commands: journeys.length,
59
+ failures: [
60
+ ...pathFailures,
61
+ ...journeyFailures.filter((failure) => failure !== null),
62
+ ...collectTemplateFailures(metadata, input.skillPath, input.templateVersion),
63
+ ],
64
+ };
65
+ }
66
+
67
+ async function resolveJourneyFailure(
68
+ wringer: Wringer,
69
+ journey: JourneyCommand,
70
+ ): Promise<LintFailure | null> {
71
+ const problem =
72
+ journey.argv === null
73
+ ? 'The line has an unclosed quote.'
74
+ : await resolveJourneyProblem(wringer, journey.argv);
75
+
76
+ if (problem === null) {
77
+ return null;
78
+ }
79
+
80
+ return {
81
+ check: 'journey',
82
+ where: `${journey.path}:${journey.line}`,
83
+ problem: `\`${journey.text}\`: ${problem}`,
84
+ };
85
+ }
86
+
87
+ function collectTemplateFailures(
88
+ metadata: SkillMetadata | null,
89
+ skillPath: string,
90
+ templateVersion: number,
91
+ ): readonly LintFailure[] {
92
+ if (metadata === null) {
93
+ return [{ check: 'template', where: skillPath, problem: 'The verify skill is missing.' }];
94
+ }
95
+
96
+ if (!metadata.ok) {
97
+ return [{ check: 'template', where: skillPath, problem: metadata.reason }];
98
+ }
99
+
100
+ if (metadata.templateVersion === templateVersion) {
101
+ return [];
102
+ }
103
+
104
+ return [
105
+ {
106
+ check: 'template',
107
+ where: skillPath,
108
+ problem: `The skill follows template ${metadata.templateVersion}, and the installed @wringer/gunshi ships template ${templateVersion}.`,
109
+ },
110
+ ];
111
+ }
package/src/run-cli.ts CHANGED
@@ -1,19 +1,14 @@
1
- import { WringerError, dispatch, supervisorCommandName } from '@wringer/core';
2
- import type { RepoHost, StatePort, SupervisorPort, Wringer } from '@wringer/core';
3
- import { cli, parseArgs } from 'gunshi';
4
- import type { ArgToken } from 'gunshi';
5
- import { buildGunshiCommands } from './build-gunshi-commands.ts';
6
- import type { Invocation, InvokeResult } from './build-gunshi-commands.ts';
7
- import { findSignedValueFlag } from './find-signed-value-flag.ts';
8
- import type { SignedValueFlag } from './find-signed-value-flag.ts';
1
+ import { dispatch, supervisorCommandName } from '@wringer/core';
2
+ import type { RepoHost, StatePort, SupervisorPort, Wringer, WringerError } from '@wringer/core';
3
+ import { parseArgs } from 'gunshi';
4
+ import type { Invocation } from './build-gunshi-commands.ts';
9
5
  import { pickCLIOutcome } from './pick-cli-outcome.ts';
10
- import type { ParsedInvocation } from './pick-cli-outcome.ts';
11
- import { pickCommandName } from './pick-command-name.ts';
12
6
  import { pickDispatchPlan } from './pick-dispatch-plan.ts';
13
7
  import { pickOutputMode } from './pick-output-mode.ts';
14
8
  import type { OutputMode } from './pick-output-mode.ts';
15
9
  import { renderEnvelope } from './render-envelope.ts';
16
10
  import { renderHumanEvent } from './render-human-event.ts';
11
+ import { resolveInvocation } from './resolve-invocation.ts';
17
12
 
18
13
  interface RepoPorts {
19
14
  readonly state: StatePort;
@@ -46,7 +41,7 @@ export async function runCLI(wringer: Wringer, ports: CLIPorts): Promise<number>
46
41
  const tokens = parseArgs([...ports.argv]);
47
42
  const mode = pickOutputMode({ tokens, isTTY: ports.isTTY, isAgent: ports.isAgent });
48
43
 
49
- const parsed = await readInvocation(wringer, ports, tokens);
44
+ const parsed = await resolveInvocation(wringer, ports.argv);
50
45
 
51
46
  const outcome = pickCLIOutcome(parsed, mode);
52
47
 
@@ -59,92 +54,6 @@ export async function runCLI(wringer: Wringer, ports: CLIPorts): Promise<number>
59
54
  return outcome.exitCode;
60
55
  }
61
56
 
62
- // gunshi only records the invocation; the command runs after `cli` returns, so a gunshi parse error
63
- // and a command error never mix. gunshi resolves the command path before it checks the flags, so a
64
- // flag error still names the command.
65
- async function readInvocation(
66
- wringer: Wringer,
67
- ports: CLIPorts,
68
- tokens: readonly ArgToken[],
69
- ): Promise<ParsedInvocation> {
70
- let invoked: InvokeResult | null = null;
71
- let commandPath: readonly string[] = [];
72
-
73
- const subCommands = buildGunshiCommands(wringer, (result) => {
74
- invoked = result;
75
- });
76
-
77
- try {
78
- const printed = await cli(
79
- [...ports.argv],
80
- {
81
- name: wringer.name,
82
- run: () => {
83
- throw new WringerError('usage', {
84
- message: 'Name a command.',
85
- hint: `Run \`${wringer.name} --help\` to list them.`,
86
- });
87
- },
88
- },
89
- {
90
- name: wringer.name,
91
- subCommands,
92
- strict: true,
93
- usageSilent: true,
94
- renderHeader: null,
95
- renderValidationErrors: null,
96
- onBeforeCommand: (ctx) => {
97
- commandPath = ctx.commandPath;
98
- },
99
- },
100
- );
101
-
102
- return pickParsedInvocation(invoked, printed, pickCommandName(commandPath, ports.argv));
103
- } catch (error) {
104
- return {
105
- kind: 'failed',
106
- command: pickCommandName(commandPath, ports.argv),
107
- error: toUsageError(error, findSignedValueFlag(tokens, ports.argv)),
108
- };
109
- }
110
- }
111
-
112
- // gunshi ran no command when it printed help or a version.
113
- function pickParsedInvocation(
114
- invoked: InvokeResult | null,
115
- printed: string | undefined,
116
- command: string,
117
- ): ParsedInvocation {
118
- if (invoked === null) {
119
- return { kind: 'printed', text: `${printed ?? ''}\n` };
120
- }
121
-
122
- if (invoked.kind === 'refused') {
123
- return { kind: 'failed', command, error: invoked.error };
124
- }
125
-
126
- return { kind: 'invoked', invocation: invoked.invocation };
127
- }
128
-
129
- // gunshi throws an AggregateError for a parse failure, with one error per problem.
130
- function toUsageError(error: unknown, signed: SignedValueFlag | undefined): WringerError {
131
- if (error instanceof WringerError) {
132
- return error;
133
- }
134
-
135
- const problems = error instanceof AggregateError ? error.errors.map(String) : [String(error)];
136
-
137
- const hint =
138
- signed === undefined
139
- ? 'Add `--help` to the command to see its arguments.'
140
- : `Join a negative value to its flag with \`=\`: \`${signed.flag}=${signed.value}\`.`;
141
-
142
- return new WringerError('usage', {
143
- message: problems.map((problem) => problem.replace(/^\w*Error: /u, '')).join(' '),
144
- hint,
145
- });
146
- }
147
-
148
57
  async function dispatchInvocation(
149
58
  wringer: Wringer,
150
59
  ports: CLIPorts,
package/src/run-verify.ts CHANGED
@@ -6,30 +6,41 @@ import {
6
6
  } from '@wringer/core';
7
7
  import type { Wringer } from '@wringer/core';
8
8
  import { getAgentProfile } from 'gunshi/agent';
9
+ import { buildLintedWringer } from './build-linted-wringer.ts';
9
10
  import { readRepoRoot } from './read-repo-root.ts';
10
11
  import { runCLI } from './run-cli.ts';
11
12
 
13
+ export interface VerifyOptions {
14
+ // The folder of the repo's verify skill, relative to the repo root, which `lint` checks.
15
+ readonly skill?: string | undefined;
16
+ }
17
+
18
+ const defaultSkillFolder = '.claude/skills/verify';
19
+
12
20
  // The repo's verify script calls this with its registry. The script restarts itself as the run's
13
21
  // supervisor, so the supervisor's command is the runtime and the script, without the user's
14
22
  // arguments.
15
- export async function runVerify(wringer: Wringer): Promise<void> {
23
+ export async function runVerify(wringer: Wringer, options: VerifyOptions = {}): Promise<void> {
16
24
  const [, script] = process.argv;
17
25
  const selfCommand = script === undefined ? [process.execPath] : [process.execPath, script];
18
26
 
19
- process.exitCode = await runCLI(wringer, {
20
- argv: process.argv.slice(2),
21
- cwd: process.cwd(),
22
- isTTY: process.stdout.isTTY,
23
- isAgent: getAgentProfile().isAgent,
24
- writeStdout: (text) => {
25
- process.stdout.write(text);
27
+ process.exitCode = await runCLI(
28
+ buildLintedWringer(wringer, options.skill ?? defaultSkillFolder),
29
+ {
30
+ argv: process.argv.slice(2),
31
+ cwd: process.cwd(),
32
+ isTTY: process.stdout.isTTY,
33
+ isAgent: getAgentProfile().isAgent,
34
+ writeStdout: (text) => {
35
+ process.stdout.write(text);
36
+ },
37
+ readRepoRoot,
38
+ openRepo: (root) => ({
39
+ state: createRepoState(root, wringer.stateDir),
40
+ repoHost: createNodeRepoHost(),
41
+ supervisor: makeProcessSupervisorPort({ selfCommand, root, stateDir: wringer.stateDir }),
42
+ }),
43
+ runSupervisor: runSupervisorProcess,
26
44
  },
27
- readRepoRoot,
28
- openRepo: (root) => ({
29
- state: createRepoState(root, wringer.stateDir),
30
- repoHost: createNodeRepoHost(),
31
- supervisor: makeProcessSupervisorPort({ selfCommand, root, stateDir: wringer.stateDir }),
32
- }),
33
- runSupervisor: runSupervisorProcess,
34
- });
45
+ );
35
46
  }
@@ -0,0 +1,3 @@
1
+ // The version of the verify skill template that this package ships. A repo's verify skill records
2
+ // the version it was written from in its frontmatter, and `lint` fails until the two match.
3
+ export const templateVersion = 1;
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bun
2
+ import { join, resolve } from 'node:path';
3
+ import { parseSkillInstallArgs } from './parse-skill-install-args.ts';
4
+ import { writeSkillCopy } from './write-skill-copy.ts';
5
+
6
+ const usage = 'Usage: wringer-gunshi skill install [--dir <path>]';
7
+ const args = parseSkillInstallArgs(process.argv.slice(2));
8
+
9
+ if (args === null) {
10
+ console.error(usage);
11
+ process.exit(2);
12
+ }
13
+
14
+ const destination = resolve(args.destination);
15
+
16
+ const result = await writeSkillCopy({
17
+ source: join(import.meta.dir, '..', 'skills', 'wringer'),
18
+ destination,
19
+ cwd: process.cwd(),
20
+ });
21
+
22
+ if (!result.ok) {
23
+ console.error(`Refused: ${result.reason} Pass --dir with the folder for the wringer skill.`);
24
+ process.exit(2);
25
+ }
26
+
27
+ console.log(`Installed the wringer skill to ${destination}`);