@wringer/gunshi 0.1.0 → 0.1.1

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 +138 -0
  22. package/skills/wringer/references/create.md +81 -0
  23. package/skills/wringer/references/fresh-subagent-brief.md +34 -0
  24. package/skills/wringer/references/maintain.md +74 -0
  25. package/skills/wringer/references/prove.md +40 -0
  26. package/skills/wringer/template/verify/SKILL.md +175 -0
  27. package/skills/wringer/template/verify/references/feature-map.md +17 -0
  28. package/skills/wringer/template/verify-registry.ts +82 -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,75 @@
1
+ import { cp, rm, stat } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { z } from 'zod';
4
+ import { findSkillCopyRefusal } from './find-skill-copy-refusal.ts';
5
+ import type { DestinationState } from './find-skill-copy-refusal.ts';
6
+
7
+ export interface SkillCopyPaths {
8
+ readonly source: string;
9
+ readonly destination: string;
10
+ readonly cwd: string;
11
+ }
12
+
13
+ export type SkillCopyResult =
14
+ | { readonly ok: true }
15
+ | { readonly ok: false; readonly reason: string };
16
+
17
+ // Removes the destination first: `cp` into a folder that exists would nest the copy inside it.
18
+ export async function writeSkillCopy(paths: SkillCopyPaths): Promise<SkillCopyResult> {
19
+ const state = await readDestinationState(paths.destination);
20
+
21
+ const reason = findSkillCopyRefusal({ ...paths, state });
22
+
23
+ if (reason !== null) {
24
+ return { ok: false, reason };
25
+ }
26
+
27
+ await rm(paths.destination, { recursive: true, force: true });
28
+
29
+ await cp(paths.source, paths.destination, {
30
+ recursive: true,
31
+ filter: (path) => !path.endsWith('.test.ts'),
32
+ });
33
+
34
+ return { ok: true };
35
+ }
36
+
37
+ async function readDestinationState(destination: string): Promise<DestinationState> {
38
+ const exists = await stat(destination).then(
39
+ () => true,
40
+ () => false,
41
+ );
42
+
43
+ if (!exists) {
44
+ return 'absent';
45
+ }
46
+
47
+ const skill = Bun.file(join(destination, 'SKILL.md'));
48
+
49
+ const hasSkill = await skill.exists();
50
+
51
+ if (!hasSkill) {
52
+ return 'other';
53
+ }
54
+
55
+ const text = await skill.text();
56
+
57
+ return isWringerSkill(text) ? 'wringer-skill' : 'other';
58
+ }
59
+
60
+ const frontmatterPattern = /^---\r?\n(?<yaml>[\s\S]*?)\r?\n---\r?\n/u;
61
+ const frontmatterSchema = z.looseObject({ name: z.literal('wringer') });
62
+
63
+ function isWringerSkill(text: string): boolean {
64
+ const yaml = frontmatterPattern.exec(text)?.groups?.['yaml'];
65
+
66
+ if (yaml === undefined) {
67
+ return false;
68
+ }
69
+
70
+ try {
71
+ return frontmatterSchema.safeParse(Bun.YAML.parse(yaml)).success;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }