@ecology91/skills 0.1.3 → 0.1.5

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
@@ -1,7 +1,7 @@
1
1
  # Skills For Real Engineers
2
2
 
3
- [![skills.sh](https://skills.sh/b/ecology9191/skills)](https://skills.sh/ecology9191/skills)
4
- [![npm](https://img.shields.io/npm/v/@ecology91/skills)](https://www.npmjs.com/package/@ecology91/skills)
3
+ [skills.sh](https://skills.sh/ecology9191/skills)
4
+ [npm](https://www.npmjs.com/package/@ecology91/skills)
5
5
 
6
6
  Agent skills for doing real engineering with opencode - not vibe coding.
7
7
 
@@ -9,34 +9,39 @@ Developing real applications is hard. Approaches like GSD, BMAD, and Spec-Kit tr
9
9
 
10
10
  These skills are designed to be small, easy to adapt, and composable. They work with any model. They're based on decades of engineering experience. Hack around with them. Make them your own. Enjoy.
11
11
 
12
- ## Quickstart For opencode
12
+ ## Quickstart
13
13
 
14
- 1. Install the skills into opencode from the fork repo:
14
+ 1. Install the skills globally from the fork repo (via [skills.sh](https://skills.sh)):
15
15
 
16
16
  ```bash
17
- npx skills@latest add ecology9191/skills -a opencode
17
+ npx skills@latest add ecology9191/skills -g
18
18
  ```
19
19
 
20
- 2. Or install the published npm package directly:
20
+ 1. Or install from a git checkout or the published npm package:
21
21
 
22
22
  ```bash
23
23
  npx --package @ecology91/skills ecology91-skills
24
24
  ```
25
25
 
26
- 3. For local development on this repo, link the checked-out skills into opencode's global skills directory:
26
+ This opens an interactive menu grouped by bucket (`engineering`, `productivity`, `misc`). Toggle a whole category or pick individual skills in one screen. Use `--all` to skip the menu, or `--bucket` / `--skill` for non-interactive partial installs.
27
+
28
+ From a git checkout this symlinks into `~/.agents/skills` so edits in the repo are live. From the published package it copies files instead.
27
29
 
28
30
  ```bash
29
- ./scripts/link-skills.sh
31
+ npx --package @ecology91/skills ecology91-skills --all
32
+ npx --package @ecology91/skills ecology91-skills --bucket engineering --skill tdd
30
33
  ```
31
34
 
32
- 4. Quit and restart opencode so it reloads the skill list.
35
+ 1. Force a copy install from a checkout with `--copy`.
33
36
 
34
- 5. Run `/setup-agent-skills` in opencode. It will:
35
- - Ask you which issue tracker you want to use (GitHub, GitLab, Beads, `.scratch`, or another workflow)
36
- - Ask you what labels you apply to issues when you triage them (`/triage` uses labels)
37
- - Ask you where you want to save any docs we create
37
+ OpenCode auto-loads `~/.agents/skills` alongside its own config tree, so one global install works across harnesses.
38
38
 
39
- 6. Bam - you're ready to go.
39
+ 1. Quit and restart your agent so it reloads the skill list.
40
+ 2. Run `/setup-agent-skills` in your coding agent. It will:
41
+ - Ask you which issue tracker you want to use (GitHub, GitLab, Beads, `.scratch`, or another workflow)
42
+ - Ask you what labels you apply to issues when you triage them (`/triage` uses labels)
43
+ - Ask you where you want to save any docs we create
44
+ 3. Bam - you're ready to go.
40
45
 
41
46
  This repo also includes `opencode.json`, so opencode loads the promoted skill buckets automatically when you open this repo directly.
42
47
 
@@ -56,10 +61,10 @@ This is just the same in the AI age. There is a communication gap between you an
56
61
 
57
62
  **The Fix** is to use:
58
63
 
59
- - [`/grill-me`](./skills/productivity/grill-me/SKILL.md) - for non-code uses
60
- - [`/grill-with-docs`](./skills/engineering/grill-with-docs/SKILL.md) - same as [`/grill-me`](./skills/productivity/grill-me/SKILL.md), but adds more goodies (see below)
64
+ - `[/grill-me](./skills/productivity/grill-me/SKILL.md)` - for non-code uses
65
+ - `[/grill-with-docs](./skills/engineering/grill-with-docs/SKILL.md)` - same as `[/grill-me](./skills/productivity/grill-me/SKILL.md)`, but adds more goodies (see below)
61
66
 
62
- These are my most popular skills. They help you align with the agent before you get started, and think deeply about the change you're making. Use them _every_ time you want to make a change.
67
+ These are my most popular skills. They help you align with the agent before you get started, and think deeply about the change you're making. Use them *every* time you want to make a change.
63
68
 
64
69
  ### #2: The Agent Is Way Too Verbose
65
70
 
@@ -73,10 +78,7 @@ I felt the same tension with my agents. Agents are usually dropped into a projec
73
78
 
74
79
  **The Fix** for this is a shared language. It's a document that helps agents decode the jargon used in the project.
75
80
 
76
- <details>
77
- <summary>
78
81
  Example
79
- </summary>
80
82
 
81
83
  Here's a before-and-after example. Which one is easier to read?
82
84
 
@@ -85,9 +87,9 @@ Here's a before-and-after example. Which one is easier to read?
85
87
 
86
88
  This concision pays off session after session.
87
89
 
88
- </details>
89
90
 
90
- This is built into [`/grill-with-docs`](./skills/engineering/grill-with-docs/SKILL.md). It's a grilling session, but that helps you build a shared language with the AI, and document hard-to-explain decisions in ADR's.
91
+
92
+ This is built into `[/grill-with-docs](./skills/engineering/grill-with-docs/SKILL.md)`. It's a grilling session, but that helps you build a shared language with the AI, and document hard-to-explain decisions in ADR's.
91
93
 
92
94
  It's hard to explain how powerful this is. It might be the single coolest technique in this repo. Try it, and see.
93
95
 
@@ -104,7 +106,7 @@ It's hard to explain how powerful this is. It might be the single coolest techni
104
106
  >
105
107
  > David Thomas & Andrew Hunt, [The Pragmatic Programmer](https://www.amazon.co.uk/Pragmatic-Programmer-Anniversary-Journey-Mastery/dp/B0833F1T3V)
106
108
 
107
- **The Problem**: Let's say that you and the agent are aligned on what to build. What happens when the agent _still_ produces crap?
109
+ **The Problem**: Let's say that you and the agent are aligned on what to build. What happens when the agent *still* produces crap?
108
110
 
109
111
  It's time to look at your feedback loops. Without feedback on how the code it produces actually runs, the agent will be flying blind.
110
112
 
@@ -112,13 +114,13 @@ It's time to look at your feedback loops. Without feedback on how the code it pr
112
114
 
113
115
  For automated tests, a red-green-refactor loop is critical. This is where the agent writes a failing test first, then fixes the test. This helps give the agent a consistent level of feedback that results in far better code.
114
116
 
115
- I've built a **[`/tdd`](./skills/engineering/tdd/SKILL.md) skill** you can slot into any project. It encourages red-green-refactor and gives the agent plenty of guidance on what makes good and bad tests.
117
+ I've built a `**[/tdd](./skills/engineering/tdd/SKILL.md)` skill** you can slot into any project. It encourages red-green-refactor and gives the agent plenty of guidance on what makes good and bad tests.
116
118
 
117
- For debugging, I've also built a **[`/diagnose`](./skills/engineering/diagnose/SKILL.md)** skill that wraps best debugging practices into a simple loop.
119
+ For debugging, I've also built a `**[/diagnose](./skills/engineering/diagnose/SKILL.md)`** skill that wraps best debugging practices into a simple loop.
118
120
 
119
121
  ### #4: We Built A Ball Of Mud
120
122
 
121
- > "Invest in the design of the system _every day_."
123
+ > "Invest in the design of the system *every day*."
122
124
  >
123
125
  > Kent Beck, [Extreme Programming Explained](https://www.amazon.co.uk/Extreme-Programming-Explained-Embrace-Change/dp/0321278658)
124
126
 
@@ -132,10 +134,10 @@ For debugging, I've also built a **[`/diagnose`](./skills/engineering/diagnose/S
132
134
 
133
135
  This is built in to every layer of these skills:
134
136
 
135
- - [`/to-prd`](./skills/engineering/to-prd/SKILL.md) quizzes you about which modules you're touching before creating a PRD
136
- - [`/zoom-out`](./skills/engineering/zoom-out/SKILL.md) tells the agent to explain code in the context of the whole system
137
+ - `[/to-prd](./skills/engineering/to-prd/SKILL.md)` quizzes you about which modules you're touching before creating a PRD
138
+ - `[/zoom-out](./skills/engineering/zoom-out/SKILL.md)` tells the agent to explain code in the context of the whole system
137
139
 
138
- And crucially, [`/improve-codebase-architecture`](./skills/engineering/improve-codebase-architecture/SKILL.md) helps you rescue a codebase that has become a ball of mud. I recommend running it on your codebase once every few days.
140
+ And crucially, `[/improve-codebase-architecture](./skills/engineering/improve-codebase-architecture/SKILL.md)` helps you rescue a codebase that has become a ball of mud. I recommend running it on your codebase once every few days.
139
141
 
140
142
  ### Summary
141
143
 
@@ -177,3 +179,4 @@ Tools I keep around but rarely use.
177
179
  - **[migrate-to-shoehorn](./skills/misc/migrate-to-shoehorn/SKILL.md)** — Migrate test files from `as` type assertions to @total-typescript/shoehorn.
178
180
  - **[scaffold-exercises](./skills/misc/scaffold-exercises/SKILL.md)** — Create exercise directory structures with sections, problems, solutions, and explainers.
179
181
  - **[setup-pre-commit](./skills/misc/setup-pre-commit/SKILL.md)** — Set up Husky pre-commit hooks with lint-staged, Prettier, type checking, and tests.
182
+
@@ -0,0 +1,97 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ export const buckets = [
5
+ { id: "engineering", label: "daily code work" },
6
+ { id: "productivity", label: "daily non-code workflow tools" },
7
+ { id: "misc", label: "kept around but rarely used" },
8
+ ];
9
+
10
+ const DESCRIPTION_MAX = 80;
11
+
12
+ function readDescription(skillMdPath) {
13
+ const content = fs.readFileSync(skillMdPath, "utf8");
14
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
15
+ if (!match) return "";
16
+
17
+ for (const line of match[1].split("\n")) {
18
+ const desc = line.match(/^description:\s*(.+)$/);
19
+ if (!desc) continue;
20
+
21
+ let value = desc[1].trim();
22
+ if (
23
+ (value.startsWith('"') && value.endsWith('"')) ||
24
+ (value.startsWith("'") && value.endsWith("'"))
25
+ ) {
26
+ value = value.slice(1, -1);
27
+ }
28
+
29
+ const firstLine = value.split("\n")[0].trim();
30
+ if (firstLine.length <= DESCRIPTION_MAX) return firstLine;
31
+ return `${firstLine.slice(0, DESCRIPTION_MAX - 1)}…`;
32
+ }
33
+
34
+ return "";
35
+ }
36
+
37
+ /**
38
+ * @param {string} root
39
+ * @param {string} destRoot
40
+ */
41
+ export function collectSkillsByBucket(root, destRoot) {
42
+ /** @type {{ id: string, label: string, skills: { name: string, src: string, dest: string, description: string, bucket: string }[] }[]} */
43
+ const catalog = [];
44
+
45
+ for (const bucket of buckets) {
46
+ const bucketDir = path.join(root, "skills", bucket.id);
47
+ if (!fs.existsSync(bucketDir)) continue;
48
+
49
+ /** @type {{ name: string, src: string, dest: string, description: string, bucket: string }[]} */
50
+ const skills = [];
51
+
52
+ for (const entry of fs.readdirSync(bucketDir, { withFileTypes: true })) {
53
+ if (!entry.isDirectory()) continue;
54
+
55
+ const src = path.join(bucketDir, entry.name);
56
+ const skillMd = path.join(src, "SKILL.md");
57
+ if (!fs.existsSync(skillMd)) continue;
58
+
59
+ skills.push({
60
+ name: entry.name,
61
+ src,
62
+ dest: path.join(destRoot, entry.name),
63
+ description: readDescription(skillMd),
64
+ bucket: bucket.id,
65
+ });
66
+ }
67
+
68
+ skills.sort((a, b) => a.name.localeCompare(b.name));
69
+ if (skills.length > 0) {
70
+ catalog.push({ id: bucket.id, label: bucket.label, skills });
71
+ }
72
+ }
73
+
74
+ return catalog;
75
+ }
76
+
77
+ /** @param {{ id: string, label: string, skills: { name: string }[] }[]} catalog */
78
+ export function flattenCatalog(catalog) {
79
+ return catalog.flatMap((bucket) => bucket.skills);
80
+ }
81
+
82
+ /** @param {{ name: string, bucket: string }[]} skills */
83
+ export function countByBucket(skills) {
84
+ /** @type {Record<string, number>} */
85
+ const counts = {};
86
+ for (const skill of skills) {
87
+ counts[skill.bucket] = (counts[skill.bucket] ?? 0) + 1;
88
+ }
89
+ return counts;
90
+ }
91
+
92
+ /** @param {Record<string, number>} counts */
93
+ export function formatBucketCounts(counts) {
94
+ return Object.entries(counts)
95
+ .map(([bucket, count]) => `${bucket}: ${count}`)
96
+ .join(", ");
97
+ }
package/bin/install.mjs CHANGED
@@ -3,50 +3,178 @@ import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import {
7
+ collectSkillsByBucket,
8
+ countByBucket,
9
+ flattenCatalog,
10
+ formatBucketCounts,
11
+ } from "./collect-skills.mjs";
12
+ import { promptSkillSelection } from "./prompt-skills.mjs";
13
+ import { parseArgs, resolveSelection, skillsFromNames } from "./resolve-selection.mjs";
6
14
 
7
15
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
8
- const buckets = ["engineering", "productivity", "misc"];
9
- const args = new Set(process.argv.slice(2));
16
+ const destRoot = path.join(os.homedir(), ".agents", "skills");
10
17
 
11
- if (args.has("--help") || args.has("-h")) {
12
- console.log(`Usage: npx @ecology91/skills [--dry-run]\n\nCopies promoted skills into ~/.config/opencode/skills.`);
18
+ function printHelp() {
19
+ console.log(`Usage: npx @ecology91/skills [options]
20
+
21
+ Install promoted skills into ~/.agents/skills.
22
+
23
+ From a git checkout, symlinks by default so local edits are picked up live.
24
+ From the published npm package, copies by default.
25
+
26
+ Interactive mode (TTY): pick buckets and individual skills in one menu.
27
+ Non-interactive (CI, pipes): installs all promoted skills.
28
+
29
+ --dry-run Print actions without installing
30
+ --copy Force copies instead of symlinks
31
+ --link Force symlinks
32
+ --all Skip menu; install all promoted skills
33
+ --bucket <ids> Comma-separated buckets (engineering, productivity, misc)
34
+ --skill <names> Comma-separated skill names`);
35
+ }
36
+
37
+ let parsed;
38
+ try {
39
+ parsed = parseArgs(process.argv.slice(2));
40
+ } catch (error) {
41
+ console.error(`error: ${error.message}`);
42
+ process.exit(1);
43
+ }
44
+
45
+ const { flags, values } = parsed;
46
+
47
+ if (flags.has("--help") || flags.has("-h")) {
48
+ printHelp();
13
49
  process.exit(0);
14
50
  }
15
51
 
16
- const dryRun = args.has("--dry-run");
17
- const destRoot = path.join(os.homedir(), ".config", "opencode", "skills");
52
+ const dryRun = flags.has("--dry-run");
53
+ const isGitCheckout = fs.existsSync(path.join(root, ".git"));
54
+ const link = flags.has("--link") || (isGitCheckout && !flags.has("--copy"));
55
+ const isInteractive =
56
+ Boolean(process.stdin.isTTY && process.stdout.isTTY) && !flags.has("--all");
18
57
 
19
- function copySkill(src, dest) {
20
- if (dryRun) {
21
- console.log(`would install ${path.basename(src)} -> ${dest}`);
58
+ const catalog = collectSkillsByBucket(root, destRoot);
59
+ const allSkills = flattenCatalog(catalog);
60
+
61
+ function assertSafeDest() {
62
+ if (!fs.lstatSync(destRoot, { throwIfNoEntry: false })?.isSymbolicLink()) {
22
63
  return;
23
64
  }
24
65
 
25
- fs.rmSync(dest, { recursive: true, force: true });
26
- fs.mkdirSync(path.dirname(dest), { recursive: true });
27
- fs.cpSync(src, dest, { recursive: true, force: true });
28
- console.log(`installed ${path.basename(src)} -> ${dest}`);
66
+ const resolved = fs.realpathSync(destRoot);
67
+ const repoReal = fs.realpathSync(root);
68
+ if (resolved === repoReal || resolved.startsWith(`${repoReal}${path.sep}`)) {
69
+ console.error(
70
+ `error: ${destRoot} is a symlink into this repo (${resolved}).`,
71
+ );
72
+ console.error(
73
+ `Remove it (rm "${destRoot}") and re-run; the installer will recreate it as a real dir.`,
74
+ );
75
+ process.exit(1);
76
+ }
29
77
  }
30
78
 
31
- const skills = [];
79
+ /** @param {{ bucket: string, name: string }[]} skills */
80
+ function groupSkillsByBucket(skills) {
81
+ /** @type {Map<string, typeof skills>} */
82
+ const grouped = new Map();
83
+ for (const skill of skills) {
84
+ const list = grouped.get(skill.bucket) ?? [];
85
+ list.push(skill);
86
+ grouped.set(skill.bucket, list);
87
+ }
88
+ return grouped;
89
+ }
32
90
 
33
- for (const bucket of buckets) {
34
- const bucketDir = path.join(root, "skills", bucket);
35
- if (!fs.existsSync(bucketDir)) continue;
91
+ /** @param {{ bucket: string, name: string, src: string, dest: string }[]} skills */
92
+ function installCopy(skills) {
93
+ if (!dryRun) {
94
+ assertSafeDest();
95
+ fs.mkdirSync(destRoot, { recursive: true });
96
+ }
36
97
 
37
- for (const entry of fs.readdirSync(bucketDir, { withFileTypes: true })) {
38
- if (!entry.isDirectory()) continue;
98
+ const grouped = groupSkillsByBucket(skills);
99
+ for (const [bucket, bucketSkills] of grouped) {
100
+ console.log(`${bucket} (${bucketSkills.length})`);
101
+ for (const skill of bucketSkills) {
102
+ if (dryRun) {
103
+ console.log(` would install ${skill.name} -> ${skill.dest}`);
104
+ continue;
105
+ }
39
106
 
40
- const src = path.join(bucketDir, entry.name);
41
- if (!fs.existsSync(path.join(src, "SKILL.md"))) continue;
107
+ fs.rmSync(skill.dest, { recursive: true, force: true });
108
+ fs.cpSync(skill.src, skill.dest, { recursive: true, force: true });
109
+ console.log(` installed ${skill.name} -> ${skill.dest}`);
110
+ }
111
+ }
112
+ }
113
+
114
+ /** @param {{ bucket: string, name: string, src: string, dest: string }[]} skills */
115
+ function installLink(skills) {
116
+ if (dryRun) {
117
+ const grouped = groupSkillsByBucket(skills);
118
+ for (const [bucket, bucketSkills] of grouped) {
119
+ console.log(`${bucket} (${bucketSkills.length})`);
120
+ for (const skill of bucketSkills) {
121
+ console.log(` would link ${skill.name} -> ${skill.dest} (${skill.src})`);
122
+ }
123
+ }
124
+ return;
125
+ }
126
+
127
+ assertSafeDest();
128
+ fs.mkdirSync(destRoot, { recursive: true });
42
129
 
43
- skills.push([src, path.join(destRoot, entry.name)]);
130
+ const grouped = groupSkillsByBucket(skills);
131
+ for (const [bucket, bucketSkills] of grouped) {
132
+ console.log(`${bucket} (${bucketSkills.length})`);
133
+ for (const skill of bucketSkills) {
134
+ const stat = fs.lstatSync(skill.dest, { throwIfNoEntry: false });
135
+ if (stat) {
136
+ fs.rmSync(skill.dest, { recursive: true, force: true });
137
+ }
138
+
139
+ fs.symlinkSync(skill.src, skill.dest);
140
+ console.log(` linked ${skill.name} -> ${skill.src}`);
141
+ }
44
142
  }
45
143
  }
46
144
 
47
- if (!dryRun) fs.mkdirSync(destRoot, { recursive: true });
145
+ let selectedSkills;
146
+ try {
147
+ selectedSkills = resolveSelection(catalog, parsed, isInteractive);
148
+ } catch (error) {
149
+ console.error(`error: ${error.message}`);
150
+ process.exit(1);
151
+ }
48
152
 
49
- for (const [src, dest] of skills) copySkill(src, dest);
153
+ if (selectedSkills === null) {
154
+ const selectedNames = await promptSkillSelection(catalog);
155
+ if (selectedNames === null) {
156
+ process.exit(0);
157
+ }
158
+ selectedSkills = skillsFromNames(selectedNames, allSkills);
159
+ }
160
+
161
+ if (selectedSkills.length === 0) {
162
+ console.log("No skills selected.");
163
+ process.exit(0);
164
+ }
165
+
166
+ if (link) {
167
+ installLink(selectedSkills);
168
+ const verb = dryRun ? "Checked" : "Linked";
169
+ console.log(
170
+ `${verb} ${selectedSkills.length} skills to ~/.agents/skills (${formatBucketCounts(countByBucket(selectedSkills))}).`,
171
+ );
172
+ } else {
173
+ installCopy(selectedSkills);
174
+ const verb = dryRun ? "Checked" : "Installed";
175
+ console.log(
176
+ `${verb} ${selectedSkills.length} skills to ~/.agents/skills (${formatBucketCounts(countByBucket(selectedSkills))}).`,
177
+ );
178
+ }
50
179
 
51
- console.log(`${dryRun ? "Checked" : "Installed"} ${skills.length} skills for opencode.`);
52
- console.log("Restart opencode to reload the skill list.");
180
+ console.log("Restart your agent (opencode, Cursor, etc.) to reload the skill list.");
@@ -0,0 +1,39 @@
1
+ import { cancel, groupMultiselect, intro, isCancel, outro } from "@clack/prompts";
2
+
3
+ /**
4
+ * @param {{ id: string, label: string, skills: { name: string, description: string }[] }[]} catalog
5
+ * @returns {Promise<string[] | null>}
6
+ */
7
+ export async function promptSkillSelection(catalog) {
8
+ /** @type {Record<string, { value: string, label: string }[]>} */
9
+ const options = {};
10
+ const allNames = [];
11
+
12
+ for (const bucket of catalog) {
13
+ options[`${bucket.id} — ${bucket.label}`] = bucket.skills.map((skill) => ({
14
+ value: skill.name,
15
+ label: skill.description
16
+ ? `${skill.name} — ${skill.description}`
17
+ : skill.name,
18
+ }));
19
+ allNames.push(...bucket.skills.map((skill) => skill.name));
20
+ }
21
+
22
+ intro("ecology91-skills");
23
+
24
+ const selected = await groupMultiselect({
25
+ message: "Select skills to install",
26
+ selectableGroups: true,
27
+ options,
28
+ initialValues: allNames,
29
+ required: true,
30
+ });
31
+
32
+ if (isCancel(selected)) {
33
+ cancel("Installation cancelled.");
34
+ return null;
35
+ }
36
+
37
+ outro(`Selected ${selected.length} skill${selected.length === 1 ? "" : "s"}.`);
38
+ return selected;
39
+ }
@@ -0,0 +1,107 @@
1
+ import { buckets } from "./collect-skills.mjs";
2
+
3
+ const bucketIds = new Set(buckets.map((bucket) => bucket.id));
4
+
5
+ /**
6
+ * @param {string[]} argv
7
+ */
8
+ export function parseArgs(argv) {
9
+ const flags = new Set();
10
+ /** @type {Record<string, string>} */
11
+ const values = {};
12
+
13
+ for (let i = 0; i < argv.length; i++) {
14
+ const arg = argv[i];
15
+
16
+ if (arg === "--bucket" || arg === "--skill") {
17
+ const value = argv[i + 1];
18
+ if (!value || value.startsWith("-")) {
19
+ throw new Error(`Missing value for ${arg}`);
20
+ }
21
+ values[arg.slice(2)] = value;
22
+ i++;
23
+ continue;
24
+ }
25
+
26
+ if (arg.startsWith("-")) {
27
+ flags.add(arg);
28
+ }
29
+ }
30
+
31
+ return { flags, values };
32
+ }
33
+
34
+ /**
35
+ * @param {string | undefined} raw
36
+ */
37
+ function splitList(raw) {
38
+ if (!raw) return [];
39
+ return raw
40
+ .split(",")
41
+ .map((part) => part.trim())
42
+ .filter(Boolean);
43
+ }
44
+
45
+ /**
46
+ * @param {{ id: string, skills: { name: string, bucket: string }[] }[]} catalog
47
+ * @param {{ flags: Set<string>, values: Record<string, string> }} parsed
48
+ * @param {boolean} isInteractive
49
+ */
50
+ export function resolveSelection(catalog, parsed, isInteractive) {
51
+ const allSkills = catalog.flatMap((bucket) => bucket.skills);
52
+ const allNames = new Set(allSkills.map((skill) => skill.name));
53
+ const { flags, values } = parsed;
54
+
55
+ const hasExplicitSelection =
56
+ flags.has("--all") || values.bucket || values.skill || !isInteractive;
57
+
58
+ if (hasExplicitSelection) {
59
+ return filterByFlags(allSkills, values, allNames);
60
+ }
61
+
62
+ return null;
63
+ }
64
+
65
+ /**
66
+ * @param {{ name: string, bucket: string }[]} allSkills
67
+ * @param {Record<string, string>} values
68
+ * @param {Set<string>} allNames
69
+ */
70
+ function filterByFlags(allSkills, values, allNames) {
71
+ const bucketFilter = new Set(splitList(values.bucket));
72
+ const skillFilter = new Set(splitList(values.skill));
73
+
74
+ for (const bucket of bucketFilter) {
75
+ if (!bucketIds.has(bucket)) {
76
+ throw new Error(
77
+ `Unknown bucket "${bucket}". Expected one of: ${[...bucketIds].join(", ")}`,
78
+ );
79
+ }
80
+ }
81
+
82
+ for (const skill of skillFilter) {
83
+ if (!allNames.has(skill)) {
84
+ throw new Error(`Unknown skill "${skill}".`);
85
+ }
86
+ }
87
+
88
+ return allSkills.filter((skill) => {
89
+ if (bucketFilter.size > 0 && !bucketFilter.has(skill.bucket)) {
90
+ return false;
91
+ }
92
+ if (skillFilter.size > 0 && !skillFilter.has(skill.name)) {
93
+ return false;
94
+ }
95
+ return true;
96
+ });
97
+ }
98
+
99
+ /**
100
+ * @param {string[] | null} selectedNames
101
+ * @param {{ name: string }[]} allSkills
102
+ */
103
+ export function skillsFromNames(selectedNames, allSkills) {
104
+ if (!selectedNames || selectedNames.length === 0) return [];
105
+ const byName = new Map(allSkills.map((skill) => [skill.name, skill]));
106
+ return selectedNames.map((name) => byName.get(name)).filter(Boolean);
107
+ }
@@ -0,0 +1,60 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+ import { parseArgs, resolveSelection, skillsFromNames } from "./resolve-selection.mjs";
4
+
5
+ const catalog = [
6
+ {
7
+ id: "engineering",
8
+ label: "daily code work",
9
+ skills: [
10
+ { name: "tdd", bucket: "engineering" },
11
+ { name: "diagnose", bucket: "engineering" },
12
+ ],
13
+ },
14
+ {
15
+ id: "productivity",
16
+ label: "daily non-code workflow tools",
17
+ skills: [{ name: "caveman", bucket: "productivity" }],
18
+ },
19
+ ];
20
+
21
+ test("parseArgs splits bucket and skill values", () => {
22
+ const parsed = parseArgs(["--bucket", "engineering", "--skill", "tdd,diagnose"]);
23
+ assert.equal(parsed.values.bucket, "engineering");
24
+ assert.equal(parsed.values.skill, "tdd,diagnose");
25
+ });
26
+
27
+ test("resolveSelection returns all skills when non-interactive", () => {
28
+ const parsed = parseArgs([]);
29
+ const selected = resolveSelection(catalog, parsed, false);
30
+ assert.equal(selected?.length, 3);
31
+ });
32
+
33
+ test("resolveSelection filters by bucket", () => {
34
+ const parsed = parseArgs(["--bucket", "engineering"]);
35
+ const selected = resolveSelection(catalog, parsed, true);
36
+ assert.deepEqual(
37
+ selected?.map((skill) => skill.name).sort(),
38
+ ["diagnose", "tdd"],
39
+ );
40
+ });
41
+
42
+ test("resolveSelection intersects bucket and skill filters", () => {
43
+ const parsed = parseArgs(["--bucket", "engineering", "--skill", "tdd"]);
44
+ const selected = resolveSelection(catalog, parsed, true);
45
+ assert.deepEqual(selected?.map((skill) => skill.name), ["tdd"]);
46
+ });
47
+
48
+ test("resolveSelection rejects unknown bucket", () => {
49
+ const parsed = parseArgs(["--bucket", "personal"]);
50
+ assert.throws(
51
+ () => resolveSelection(catalog, parsed, true),
52
+ /Unknown bucket "personal"/,
53
+ );
54
+ });
55
+
56
+ test("skillsFromNames preserves prompt order", () => {
57
+ const allSkills = catalog.flatMap((bucket) => bucket.skills);
58
+ const selected = skillsFromNames(["caveman", "tdd"], allSkills);
59
+ assert.deepEqual(selected.map((skill) => skill.name), ["caveman", "tdd"]);
60
+ });
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@ecology91/skills",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "opencode agent skills for real engineering workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
+ "dependencies": {
8
+ "@clack/prompts": "^0.11.0"
9
+ },
7
10
  "bin": {
8
11
  "ecology91-skills": "bin/install.mjs"
9
12
  },
@@ -35,5 +38,14 @@
35
38
  ],
36
39
  "publishConfig": {
37
40
  "access": "public"
41
+ },
42
+ "scripts": {
43
+ "typecheck": "node --check bin/install.mjs && node --check bin/collect-skills.mjs && node --check bin/prompt-skills.mjs && node --check bin/resolve-selection.mjs && node --check bin/resolve-selection.test.mjs && node --check scripts/verify-package-files.mjs",
44
+ "test": "node --test bin/resolve-selection.test.mjs && node bin/install.mjs --dry-run --copy --all",
45
+ "test:unit": "node --test bin/resolve-selection.test.mjs",
46
+ "link-skills": "./scripts/link-skills.sh",
47
+ "build": "node scripts/verify-package-files.mjs",
48
+ "validate:fast": "npm run typecheck && npm run test",
49
+ "validate": "npm run validate:fast && npm run build"
38
50
  }
39
51
  }
@@ -1,40 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- # Links promoted skills in the repository to opencode's global skills
5
- # directory, so they can be used from any opencode project.
6
-
7
4
  REPO="$(cd "$(dirname "$0")/.." && pwd)"
8
- DEST="$HOME/.config/opencode/skills"
9
-
10
- # If the destination is a symlink that resolves into this repo, we'd end up
11
- # writing the per-skill symlinks back into the repo's own skills/ tree. Detect
12
- # and bail out instead of polluting the working copy.
13
- if [ -L "$DEST" ]; then
14
- resolved="$(readlink -f "$DEST")"
15
- case "$resolved" in
16
- "$REPO"|"$REPO"/*)
17
- echo "error: $DEST is a symlink into this repo ($resolved)." >&2
18
- echo "Remove it (rm \"$DEST\") and re-run; the script will recreate it as a real dir." >&2
19
- exit 1
20
- ;;
21
- esac
22
- fi
23
-
24
- mkdir -p "$DEST"
25
-
26
- for bucket in engineering productivity misc; do
27
- find "$REPO/skills/$bucket" -name SKILL.md -not -path '*/node_modules/*' -print0
28
- done |
29
- while IFS= read -r -d '' skill_md; do
30
- src="$(dirname "$skill_md")"
31
- name="$(basename "$src")"
32
- target="$DEST/$name"
33
-
34
- if [ -e "$target" ] && [ ! -L "$target" ]; then
35
- rm -rf "$target"
36
- fi
37
-
38
- ln -sfn "$src" "$target"
39
- echo "linked $name -> $src"
40
- done
5
+ exec node "$REPO/bin/install.mjs" --link "$@"
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
7
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
8
+
9
+ for (const entry of pkg.files) {
10
+ const target = path.join(root, entry);
11
+ if (!fs.existsSync(target)) {
12
+ console.error(`Missing packaged path: ${entry}`);
13
+ process.exit(1);
14
+ }
15
+ }
16
+
17
+ console.log(`Verified ${pkg.files.length} packaged paths.`);
@@ -10,7 +10,7 @@
10
10
  ## Language
11
11
 
12
12
  **Order**:
13
- {A concise description of the term}
13
+ {A one or two sentence description of the term}
14
14
  _Avoid_: Purchase, transaction
15
15
 
16
16
  **Invoice**:
@@ -20,27 +20,13 @@ _Avoid_: Bill, payment request
20
20
  **Customer**:
21
21
  A person or organization that places orders.
22
22
  _Avoid_: Client, buyer, account
23
-
24
- ## Relationships
25
-
26
- - An **Order** produces one or more **Invoices**
27
- - An **Invoice** belongs to exactly one **Customer**
28
-
29
- ## Example dialogue
30
-
31
- > **Dev:** "When a **Customer** places an **Order**, do we create the **Invoice** immediately?"
32
- > **Domain expert:** "No — an **Invoice** is only generated once a **Fulfillment** is confirmed."
33
-
34
- ## Flagged ambiguities
35
-
36
- - "account" was used to mean both **Customer** and **User** — resolved: these are distinct concepts.
37
23
  ```
38
24
 
39
25
  ## Rules
40
26
 
41
27
  - **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others as aliases to avoid.
42
28
  - **Flag conflicts explicitly.** If a term is used ambiguously, call it out in "Flagged ambiguities" with a clear resolution.
43
- - **Keep definitions tight.** One sentence max. Define what it IS, not what it does.
29
+ - **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
44
30
  - **Show relationships.** Use bold term names and express cardinality where obvious.
45
31
  - **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
46
32
  - **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
@@ -0,0 +1,123 @@
1
+ # HTML Report Format
2
+
3
+ The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two — don't lean on Mermaid for everything, it'll start to look generic.
4
+
5
+ ## Scaffold
6
+
7
+ ```html
8
+ <!doctype html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <title>Architecture review — {{repo name}}</title>
13
+ <script src="https://cdn.tailwindcss.com"></script>
14
+ <script type="module">
15
+ import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
16
+ mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
17
+ </script>
18
+ <style>
19
+ /* small custom layer for things Tailwind doesn't cover cleanly:
20
+ dashed seam lines, hand-drawn-feeling arrow heads, etc. */
21
+ .seam { stroke-dasharray: 4 4; }
22
+ .leak { stroke: #dc2626; }
23
+ .deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
24
+ </style>
25
+ </head>
26
+ <body class="bg-stone-50 text-slate-900 font-sans">
27
+ <main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
28
+ <header>...</header>
29
+ <section id="candidates" class="space-y-10">...</section>
30
+ <section id="top-recommendation">...</section>
31
+ </main>
32
+ </body>
33
+ </html>
34
+ ```
35
+
36
+ ## Header
37
+
38
+ Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph — straight into the candidates.
39
+
40
+ ## Candidate card
41
+
42
+ The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms ([LANGUAGE.md](LANGUAGE.md)) without ceremony.
43
+
44
+ Each candidate is one `<article>`:
45
+
46
+ - **Title** — short, names the deepening (e.g. "Collapse the Order intake pipeline").
47
+ - **Badge row** — recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
48
+ - **Files** — monospaced list, `font-mono text-sm`.
49
+ - **Before / After diagram** — the centrepiece. Two columns, side by side. See patterns below.
50
+ - **Problem** — one sentence. What hurts.
51
+ - **Solution** — one sentence. What changes.
52
+ - **Wins** — bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
53
+ - **ADR callout** (if applicable) — one line in an amber-tinted box.
54
+
55
+ No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
56
+
57
+ ## Diagram patterns
58
+
59
+ Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same — variety is part of the point.
60
+
61
+ ### Mermaid graph (the workhorse for dependencies / call flow)
62
+
63
+ Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
64
+
65
+ ```html
66
+ <div class="rounded-lg border border-slate-200 bg-white p-4">
67
+ <pre class="mermaid">
68
+ flowchart LR
69
+ A[OrderHandler] --> B[OrderValidator]
70
+ B --> C[OrderRepo]
71
+ C -.leak.-> D[PricingClient]
72
+ classDef leak stroke:#dc2626,stroke-width:2px;
73
+ class C,D leak
74
+ </pre>
75
+ </div>
76
+ ```
77
+
78
+ ### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
79
+
80
+ Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals — Mermaid won't render that with the right weight.
81
+
82
+ ### Cross-section (good for layered shallowness)
83
+
84
+ Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
85
+
86
+ ### Mass diagram (good for "interface as wide as implementation")
87
+
88
+ Two rectangles per module — one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
89
+
90
+ ### Call-graph collapse
91
+
92
+ Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
93
+
94
+ ## Style guidance
95
+
96
+ - Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
97
+ - Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
98
+ - Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
99
+ - Use `text-xs uppercase tracking-wider` for module labels inside diagrams — they should read as schematic, not as UI.
100
+ - The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static — no app code, no interactivity beyond Mermaid's own rendering.
101
+
102
+ ## Top recommendation section
103
+
104
+ One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
105
+
106
+ ## Tone
107
+
108
+ Plain English, concise — but the architectural nouns and verbs come straight from [LANGUAGE.md](LANGUAGE.md). Concision is not an excuse to drift.
109
+
110
+ **Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
111
+
112
+ **Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
113
+
114
+ **Phrasings that fit the style:**
115
+
116
+ - "Order intake module is shallow — interface nearly matches the implementation."
117
+ - "Pricing leaks across the seam."
118
+ - "Deepen: one interface, one place to test."
119
+ - "Two adapters justify the seam: HTTP in prod, in-memory in tests."
120
+
121
+ **Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
122
+
123
+ No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in [LANGUAGE.md](LANGUAGE.md), reach for one that is before inventing a new one.
@@ -44,20 +44,30 @@ Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't
44
44
 
45
45
  Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
46
46
 
47
- ### 2. Present candidates
47
+ ### 2. Present candidates as an HTML report
48
48
 
49
- Present a numbered list of deepening opportunities. For each candidate:
49
+ Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user — `xdg-open <path>` on Linux, `open <path>` on macOS, `start <path>` on Windows — and tell them the absolute path.
50
+
51
+ The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
52
+
53
+ For each candidate, the same template as before, but rendered as a card:
50
54
 
51
55
  - **Files** — which files/modules are involved
52
56
  - **Problem** — why the current architecture is causing friction
53
57
  - **Solution** — plain English description of what would change
54
- - **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
58
+ - **Benefits** — explained in terms of locality and leverage, and how tests would improve
59
+ - **Before / After diagram** — side-by-side, custom-drawn, illustrating the shallowness and the deepening
60
+ - **Recommendation strength** — one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
61
+
62
+ End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
55
63
 
56
64
  **Use CONTEXT.md vocabulary for the domain, and [LANGUAGE.md](LANGUAGE.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
57
65
 
58
- **ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
66
+ **ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
67
+
68
+ See [HTML-REPORT.md](HTML-REPORT.md) for the full HTML scaffold, diagram patterns, and styling guidance.
59
69
 
60
- Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
70
+ Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
61
71
 
62
72
  ### 3. Grilling loop
63
73
 
@@ -4,10 +4,12 @@ description: Compact the current conversation into a handoff document for anothe
4
4
  argument-hint: "What will the next session be used for?"
5
5
  ---
6
6
 
7
- Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save it to a path produced by `mktemp -t handoff-XXXXXX.md` (read the file before you write to it).
7
+ Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS - not the current workspace.
8
8
 
9
- Suggest the skills to be used, if any, by the next session.
9
+ Include a "suggested skills" section in the document, which suggests skills that the agent should invoke.
10
10
 
11
11
  Do not duplicate content already captured in other artifacts (PRDs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
12
12
 
13
+ Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
14
+
13
15
  If the user passed arguments, treat them as a description of what the next session will focus on and tailor the doc accordingly.