@samline/skills 0.0.0-stage → 0.3.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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Samuel Olvera (samline)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,114 @@
1
- # Temporary Holding Version
1
+ # @samline/skills
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Agent skills that work the way samline works: the workflow, the kickoff of a
4
+ new project, frontend and component conventions, QA and the lessons learned in
5
+ production. They are generic: any project, any stack.
6
+
7
+ ## Three layers
8
+
9
+ | Layer | Lives in | Skill names | Example |
10
+ | ------- | --------------------------------------------------------- | ----------------- | ------------------ |
11
+ | Generic | this package | `samline-<area>` | `samline-workflow` |
12
+ | Stack | its starter: `@samline/astro` (Next.js and Laravel later) | `samline-<stack>` | `samline-astro` |
13
+ | Package | each package (`@samline/drawer`, `@samline/forms`…) | `<package>` | `drawer` |
14
+
15
+ A generic skill never assumes a stack. When it needs stack details it defers to
16
+ the stack skill installed next to it.
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ npx @samline/skills list
22
+ npx @samline/skills add --profile site --dry-run
23
+ npx @samline/skills add --profile site
24
+ npx @samline/skills check
25
+ ```
26
+
27
+ `add` copies each skill into `.agents/skills/<name>/`, records it in
28
+ `skills-lock.json` with `"sourceType": "samline"` and links
29
+ `.claude/skills -> ../.agents/skills` when that link is missing. It never
30
+ replaces a skill that was edited locally unless `--force` is given. `check`
31
+ reports skills that are missing, edited locally or have an update.
32
+
33
+ Before the package is on npm, run it from a checkout:
34
+
35
+ ```sh
36
+ node /path/to/skills/bin/skills.mjs add --profile site --dir .
37
+ ```
38
+
39
+ ## Skills
40
+
41
+ | Skill | Use for |
42
+ | -------------------- | --------------------------------------------------------------------------- |
43
+ | `samline-workflow` | How samline works in every project: authority, Git, tools, evidence, memory |
44
+ | `samline-kickoff` | From a request to a running project; hands the scaffold to the stack skill |
45
+ | `samline-frontend` | HTML, CSS and platform: tokens, progressive enhancement, images, forms |
46
+ | `samline-components` | Ownership chain, component folders, variants and states |
47
+ | `samline-motion` | Motion principles and the scroll reveal recipe, vanilla CSS and JS |
48
+ | `samline-i18n` | Visitor copy in typed dictionaries, native locale routing |
49
+ | `samline-qa` | Evidence before "done": browser matrix, test policy, Lighthouse protocol |
50
+ | `samline-debugging` | Investigate before concluding; dependency patches; destructive commands |
51
+ | `samline-library` | Design and release rules for any JavaScript library |
52
+ | `samline-catalog` | Which @samline package solves each UI behavior |
53
+ | `samline-tasks` | Task lists, QA reports and Basecamp to-dos, one task per cycle |
54
+ | `samline-voice` | Opt-in: public text (posts, READMEs, releases) in samline's voice |
55
+ | `silence` | Opt-in minimal response mode |
56
+
57
+ ## Profiles
58
+
59
+ | Profile | Skills |
60
+ | ----------- | ----------------------------------------------------------------------------- |
61
+ | `core` | workflow, qa, debugging |
62
+ | `site` | workflow, catalog, kickoff, frontend, components, motion, i18n, qa, debugging |
63
+ | `client-qa` | `site` + tasks |
64
+ | `library` | workflow, library, qa, debugging, frontend, motion |
65
+
66
+ Names in the table omit the `samline-` prefix. `samline-voice` and `silence` are
67
+ opt-in: `npx @samline/skills add samline-voice`.
68
+
69
+ ## Evals
70
+
71
+ `evals/<skill>.json` holds three realistic prompts per skill with the behavior
72
+ expected from an agent that uses it. They are not shipped to npm.
73
+
74
+ ## Why `.agents/skills` and not `.agents/sam/skills`
75
+
76
+ Agents discover skills one level deep in `.agents/skills/` (and Claude Code in
77
+ `.claude/skills/`). A nested folder would be invisible to them. The lock file
78
+ marks which skills are samline's (`sourceType: "samline"`).
79
+
80
+ ## Integrity
81
+
82
+ `skills-index.json` records the SHA-256 of every file and a bundle hash per
83
+ skill. `add` refuses a skill whose files no longer match it. After editing a
84
+ skill, maintainers run `npx @samline/skills index`; `index --check` fails when
85
+ the index is stale. The bundle hash uses the same scheme as the autoskills
86
+ registry (sorted `path:sha256` lines), so every `computedHash` in
87
+ `skills-lock.json` has one format.
88
+
89
+ ## Next to autoskills
90
+
91
+ Both tools share `.agents/skills/` and `skills-lock.json` without conflict:
92
+ autoskills keeps entries it did not write, and this tool only touches entries
93
+ with `"sourceType": "samline"`.
94
+
95
+ - Run `npx autoskills -y -a universal`. With `-a universal` it installs only into
96
+ `.agents/skills/` and does not touch `.claude/` or `CLAUDE.md`.
97
+ - autoskills adds its `bun` skill whenever it finds `bun.lock`, `bun.lockb` or
98
+ `bunfig.toml`. Delete it after every refresh: it teaches `bun install`.
99
+ - autoskills replaces an edited skill silently when its hash differs; this tool
100
+ refuses unless `--force` is given.
101
+ - When `.claude/skills` is a real folder (autoskills links skills one by one
102
+ for Claude Code), `add` links each samline skill inside it.
103
+
104
+ ## Upstream skills
105
+
106
+ They are installed from their own source, never copied here. See `external` in
107
+ [skills.json](skills.json).
108
+
109
+ Every skill is written in English; agents still reply to the user in their
110
+ language.
111
+
112
+ ## License
113
+
114
+ MIT, see [LICENSE.md](LICENSE.md).
package/bin/skills.mjs ADDED
@@ -0,0 +1,344 @@
1
+ #!/usr/bin/env node
2
+ // Installs the samline skill collection into a project's .agents/skills folder.
3
+ // Zero dependencies. Every write is previewed with --dry-run and never
4
+ // overwrites a modified skill unless --force is given.
5
+
6
+ import { createHash } from "node:crypto";
7
+ import {
8
+ cpSync,
9
+ existsSync,
10
+ lstatSync,
11
+ mkdirSync,
12
+ readdirSync,
13
+ readFileSync,
14
+ readlinkSync,
15
+ rmSync,
16
+ symlinkSync,
17
+ writeFileSync,
18
+ } from "node:fs";
19
+ import { dirname, join, relative, resolve, sep } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+
22
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
23
+ const manifest = JSON.parse(readFileSync(join(root, "skills.json"), "utf8"));
24
+ const SOURCE = manifest.source;
25
+
26
+ const usage = `@samline/skills <command> [options]
27
+
28
+ Commands
29
+ list Show every skill, its profiles and status
30
+ add [names...] Install skills (by name, or by --profile)
31
+ check Compare installed skills with this collection
32
+ index [--check] Maintainers: write or verify skills-index.json
33
+
34
+ Options
35
+ --profile <id> Profile from skills.json (repeatable): ${Object.keys(manifest.profiles).join(", ")}
36
+ --dir <path> Project root (default: current directory)
37
+ --dry-run Print what would change, write nothing
38
+ --force Replace installed skills that differ from the collection
39
+ `;
40
+
41
+ const parse = (argv) => {
42
+ const opts = {
43
+ command: argv[0],
44
+ names: [],
45
+ profiles: [],
46
+ dir: process.cwd(),
47
+ dryRun: false,
48
+ force: false,
49
+ check: false,
50
+ };
51
+ for (let i = 1; i < argv.length; i++) {
52
+ const arg = argv[i];
53
+ const value = () => {
54
+ const next = argv[++i];
55
+ if (next === undefined || next.startsWith("--"))
56
+ fail(`Missing value for ${arg}`);
57
+ return next;
58
+ };
59
+ if (arg === "--profile") opts.profiles.push(value());
60
+ else if (arg === "--dir") opts.dir = resolve(value());
61
+ else if (arg === "--dry-run") opts.dryRun = true;
62
+ else if (arg === "--force") opts.force = true;
63
+ else if (arg === "--check") opts.check = true;
64
+ else if (arg.startsWith("--")) fail(`Unknown option ${arg}`);
65
+ else opts.names.push(arg);
66
+ }
67
+ return opts;
68
+ };
69
+
70
+ const fail = (message) => {
71
+ console.error(`@samline/skills: ${message}`);
72
+ process.exit(1);
73
+ };
74
+
75
+ // Files of a skill folder, sorted, as paths relative to the folder.
76
+ const filesOf = (dir) =>
77
+ readdirSync(dir, { recursive: true, withFileTypes: true })
78
+ .filter((entry) => entry.isFile() && entry.name !== ".DS_Store")
79
+ .map((entry) =>
80
+ relative(dir, join(entry.parentPath ?? entry.path, entry.name))
81
+ .split(sep)
82
+ .join("/"),
83
+ )
84
+ .sort();
85
+
86
+ const sha256 = (data) => createHash("sha256").update(data).digest("hex");
87
+
88
+ // Per-file hashes and the bundle hash, computed exactly like autoskills'
89
+ // registry (sorted "path:sha256" lines), so lock entries share one format.
90
+ const digestOf = (dir) => {
91
+ const files = filesOf(dir);
92
+ const fileHashes = Object.fromEntries(
93
+ files.map((file) => [file, sha256(readFileSync(join(dir, file)))]),
94
+ );
95
+ const bundleHash = sha256(
96
+ files
97
+ .map((file) => `${file}:${fileHashes[file]}`)
98
+ .sort()
99
+ .join("\n"),
100
+ );
101
+ return { files, sha256: fileHashes, bundleHash };
102
+ };
103
+
104
+ const hashOf = (dir) => digestOf(dir).bundleHash;
105
+
106
+ const indexPath = join(root, "skills-index.json");
107
+
108
+ const buildIndex = () => ({
109
+ version: manifest.version,
110
+ skills: Object.fromEntries(
111
+ Object.keys(manifest.skills)
112
+ .sort()
113
+ .map((name) => [name, digestOf(skillDir(name))]),
114
+ ),
115
+ });
116
+
117
+ // Refuse to install a collection whose files no longer match the index
118
+ // published with it (a tampered or half-edited package).
119
+ const verifySource = (name) => {
120
+ if (!existsSync(indexPath)) return;
121
+ const recorded = JSON.parse(readFileSync(indexPath, "utf8")).skills?.[name];
122
+ if (!recorded)
123
+ fail(
124
+ `"${name}" is missing from skills-index.json; run "npx @samline/skills index"`,
125
+ );
126
+ if (digestOf(skillDir(name)).bundleHash !== recorded.bundleHash)
127
+ fail(
128
+ `skills/${name} does not match skills-index.json; run "npx @samline/skills index" after editing`,
129
+ );
130
+ };
131
+
132
+ const skillDir = (name) => join(root, "skills", name);
133
+
134
+ const resolveNames = (opts) => {
135
+ const wanted = new Set(opts.names);
136
+ for (const id of opts.profiles) {
137
+ const profile = manifest.profiles[id];
138
+ if (!profile)
139
+ fail(
140
+ `Unknown profile "${id}". Known: ${Object.keys(manifest.profiles).join(", ")}`,
141
+ );
142
+ for (const name of profile.skills) wanted.add(name);
143
+ }
144
+ if (wanted.size === 0)
145
+ fail('Name a skill or pass --profile. Run "npx @samline/skills list".');
146
+ for (const name of wanted) {
147
+ const entry = manifest.skills[name];
148
+ if (!entry) fail(`Unknown skill "${name}"`);
149
+ if (entry.status === "retired") fail(`"${name}" is retired: ${entry.note}`);
150
+ if (!existsSync(join(skillDir(name), "SKILL.md")))
151
+ fail(`"${name}" is listed but skills/${name}/SKILL.md is missing`);
152
+ }
153
+ return [...wanted].sort();
154
+ };
155
+
156
+ const list = () => {
157
+ for (const [id, profile] of Object.entries(manifest.profiles)) {
158
+ console.log(
159
+ `profile ${id}: ${profile.description}\n ${profile.skills.join(", ")}`,
160
+ );
161
+ }
162
+ console.log("");
163
+ for (const [name, entry] of Object.entries(manifest.skills)) {
164
+ console.log(`${name.padEnd(28)} ${entry.status.padEnd(8)} ${entry.scope}`);
165
+ }
166
+ };
167
+
168
+ const readLock = (path) => {
169
+ if (!existsSync(path)) return { version: 1, skills: {} };
170
+ let lock;
171
+ try {
172
+ lock = JSON.parse(readFileSync(path, "utf8"));
173
+ } catch {
174
+ fail(`${path} is not valid JSON; fix it before installing`);
175
+ }
176
+ lock.skills ??= {};
177
+ return lock;
178
+ };
179
+
180
+ const add = (opts) => {
181
+ const names = resolveNames(opts);
182
+ const target = join(opts.dir, ".agents", "skills");
183
+ const lockPath = join(opts.dir, "skills-lock.json");
184
+ const lock = readLock(lockPath);
185
+ const plan = [];
186
+
187
+ for (const name of names) {
188
+ verifySource(name);
189
+ const from = skillDir(name);
190
+ const to = join(target, name);
191
+ const hash = hashOf(from);
192
+ if (!existsSync(to)) plan.push({ name, action: "install", from, to, hash });
193
+ else if (hashOf(to) === hash)
194
+ plan.push({ name, action: "unchanged", from, to, hash });
195
+ else if (opts.force) plan.push({ name, action: "replace", from, to, hash });
196
+ else
197
+ plan.push({
198
+ name,
199
+ action: "skip (differs, use --force)",
200
+ from,
201
+ to,
202
+ hash,
203
+ });
204
+ }
205
+
206
+ for (const step of plan)
207
+ console.log(
208
+ `${opts.dryRun ? "[dry-run] " : ""}${step.action.padEnd(28)} ${step.name}`,
209
+ );
210
+ if (opts.dryRun) return;
211
+
212
+ for (const step of plan) {
213
+ if (step.action === "install" || step.action === "replace") {
214
+ rmSync(step.to, { recursive: true, force: true });
215
+ mkdirSync(dirname(step.to), { recursive: true });
216
+ cpSync(step.from, step.to, {
217
+ recursive: true,
218
+ filter: (src) => !src.endsWith(".DS_Store"),
219
+ });
220
+ }
221
+ if (!step.action.startsWith("skip")) {
222
+ lock.skills[step.name] = {
223
+ source: SOURCE,
224
+ sourceType: "samline",
225
+ version: manifest.version,
226
+ computedHash: step.hash,
227
+ };
228
+ }
229
+ }
230
+ lock.skills = Object.fromEntries(
231
+ Object.entries(lock.skills).sort(([a], [b]) => a.localeCompare(b)),
232
+ );
233
+ writeFileSync(lockPath, `${JSON.stringify(lock, null, 2)}\n`);
234
+
235
+ // Claude Code reads .claude/skills; point it at the shared tree once.
236
+ const claudeSkills = join(opts.dir, ".claude", "skills");
237
+ const stat = (() => {
238
+ try {
239
+ return lstatSync(claudeSkills);
240
+ } catch {
241
+ return null;
242
+ }
243
+ })();
244
+ if (!stat) {
245
+ try {
246
+ mkdirSync(dirname(claudeSkills), { recursive: true });
247
+ symlinkSync("../.agents/skills", claudeSkills);
248
+ console.log("linked .claude/skills -> ../.agents/skills");
249
+ } catch (error) {
250
+ console.warn(
251
+ `Could not link .claude/skills (${error.code}). Create it by hand: .claude/skills -> ../.agents/skills`,
252
+ );
253
+ }
254
+ } else if (!stat.isSymbolicLink()) {
255
+ // A real folder (autoskills links one skill at a time): link each skill.
256
+ for (const step of plan) {
257
+ if (step.action.startsWith("skip")) continue;
258
+ const link = join(claudeSkills, step.name);
259
+ const wanted = `../../.agents/skills/${step.name}`;
260
+ let current = null;
261
+ try {
262
+ current = lstatSync(link);
263
+ } catch {}
264
+ if (!current) {
265
+ try {
266
+ symlinkSync(wanted, link);
267
+ console.log(`linked .claude/skills/${step.name}`);
268
+ } catch (error) {
269
+ console.warn(
270
+ `Could not link .claude/skills/${step.name} (${error.code})`,
271
+ );
272
+ }
273
+ } else if (!current.isSymbolicLink() || readlinkSync(link) !== wanted) {
274
+ console.warn(
275
+ `.claude/skills/${step.name} exists and is not a link to ${wanted}: Claude Code reads that copy. Merge it first.`,
276
+ );
277
+ }
278
+ }
279
+ } else if (readlinkSync(claudeSkills) !== "../.agents/skills") {
280
+ console.warn(
281
+ ".claude/skills links somewhere other than ../.agents/skills: Claude Code will not see these skills.",
282
+ );
283
+ }
284
+ };
285
+
286
+ const index = (opts) => {
287
+ const fresh = buildIndex();
288
+ const text = `${JSON.stringify(fresh, null, 2)}\n`;
289
+ if (opts.check) {
290
+ const current = existsSync(indexPath)
291
+ ? JSON.stringify(JSON.parse(readFileSync(indexPath, "utf8")))
292
+ : "";
293
+ if (current !== JSON.stringify(fresh)) {
294
+ console.error(
295
+ 'skills-index.json is stale; run "npx @samline/skills index"',
296
+ );
297
+ process.exitCode = 1;
298
+ } else console.log("skills-index.json is current");
299
+ return;
300
+ }
301
+ writeFileSync(indexPath, text);
302
+ console.log(
303
+ `wrote skills-index.json (${Object.keys(fresh.skills).length} skills)`,
304
+ );
305
+ };
306
+
307
+ const check = (opts) => {
308
+ const lock = readLock(join(opts.dir, "skills-lock.json"));
309
+ let drift = 0;
310
+ const ours = Object.entries(lock.skills).filter(
311
+ ([, entry]) => entry.sourceType === "samline",
312
+ );
313
+ if (ours.length === 0)
314
+ console.log("No samline skills recorded in skills-lock.json.");
315
+ for (const [name, entry] of ours) {
316
+ const installed = join(opts.dir, ".agents", "skills", name);
317
+ const known = manifest.skills[name];
318
+ let state = "ok";
319
+ if (!known) state = "unknown to this collection";
320
+ else if (known.status === "retired") state = `retired: ${known.note}`;
321
+ else if (!existsSync(installed)) state = "missing";
322
+ else if (hashOf(installed) !== entry.computedHash) state = "edited locally";
323
+ else if (!existsSync(skillDir(name)))
324
+ state = "missing from this collection";
325
+ else if (hashOf(skillDir(name)) !== entry.computedHash)
326
+ state = "update available";
327
+ if (state !== "ok") drift++;
328
+ console.log(`${state.padEnd(28)} ${name}`);
329
+ }
330
+ process.exitCode = drift ? 1 : 0;
331
+ };
332
+
333
+ const opts = parse(process.argv.slice(2));
334
+ if (opts.command === "list") list();
335
+ else if (opts.command === "add") add(opts);
336
+ else if (opts.command === "check") check(opts);
337
+ else if (opts.command === "index") index(opts);
338
+ else {
339
+ console.log(usage);
340
+ process.exitCode =
341
+ opts.command && opts.command !== "help" && opts.command !== "--help"
342
+ ? 1
343
+ : 0;
344
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@samline/skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Agent skills that work the way samline works: workflow, kickoff, frontend, components, QA and more, for any project and stack.",
5
+ "license": "MIT",
6
+ "author": "Samuel Olvera (samline)",
7
+ "type": "module",
8
+ "bin": {
9
+ "samline-skills": "bin/skills.mjs"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "skills",
14
+ "skills.json",
15
+ "skills-index.json",
16
+ "LICENSE.md"
17
+ ],
18
+ "engines": {
19
+ "node": ">=20.12"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/samline/skills.git"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: samline-catalog
3
+ description: Choose the right @samline/* package for a UI behavior (forms, input formatting, autocomplete, drawers and sheets, toasts, marquees, reveal on scroll, counters, scroll spy, smooth scrolling, horizontal scroll, scroll lock, themes, visibility callbacks, debounce, string helpers) before writing custom code. Use when planning or building a site, a design handoff or a component that needs one of these behaviors, in any project and framework.
4
+ license: MIT
5
+ ---
6
+
7
+ # Pick a samline package before writing behavior
8
+
9
+ Every package does one job, has zero runtime dependencies, works without a
10
+ framework and keeps content usable without JavaScript. Before writing a
11
+ controller, check this table. Reuse a package instead of recreating its
12
+ behavior, and never wrap it in a component that re-implements its state.
13
+
14
+ ## Catalog
15
+
16
+ | Need | Package | Not for |
17
+ | --------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------ |
18
+ | Validation, reactive state, serialization and submit for native forms | `@samline/forms` | Re-implementing validation per form |
19
+ | Input masks (numbers, dates, times, cards, custom, phones) with display and raw values; Intl display and date helpers | `@samline/formatter` | Server-side validation; `@samline/date` is deprecated, use `@samline/formatter/date` |
20
+ | Text input with suggestions from an endpoint, async function or array (accessible combobox) | `@samline/autocomplete` | Static option lists: use a native `select` |
21
+ | Bottom sheets and side panels with snap points | `@samline/drawer` | Turning every undefined action into a panel |
22
+ | Toast notifications, async feedback, actions | `@samline/notify` | Inline form errors (Forms owns them) |
23
+ | Marquees and continuous carousels | `@samline/ticker` | Financial data; paged sliders |
24
+ | Reveal elements on scroll, stagger, CSS-only scrub | `@samline/reveal` | Hiding content already on screen |
25
+ | Numbers counting up or down when they appear | `@samline/counter` | Values that must not be in the HTML |
26
+ | Highlight the nav link of the section in view (TOC, one-page menus) | `@samline/scroll-spy` | Generic visibility callbacks |
27
+ | Smooth scroll to anchors and positions with fixed-header offsets and focus | `@samline/scroll-to` | Plain CSS `scroll-behavior` when it is enough |
28
+ | Pin a section and move a row sideways as the page scrolls | `@samline/horizontal-scroll` | Swipe carousels |
29
+ | Lock page or panel scroll for modals, drawers and menus (nested, iOS) | `@samline/scroll-lock` | Hiding overflow by hand |
30
+ | Light, dark and system themes without a flash, with controls | `@samline/theme` | Per-component color toggles |
31
+ | Run code when elements enter or leave the viewport | `@samline/is-visible` | Layout or styling that CSS can do |
32
+ | Debounce, throttle, frame-throttle with cancel and flush | `@samline/debounce` | One-off timeouts |
33
+ | Case conversion, slugs, accents, truncate, initials | `@samline/string` | Sorting or comparing text by locale (use `Intl.Collator`) |
34
+
35
+ `@samline/internal` is a build-time primitive bundled into the packages; never
36
+ install it in a site.
37
+
38
+ ## Before using one
39
+
40
+ 1. Check whether it is already installed and which version (`package.json`, the
41
+ lockfile). In a project generated by `@samline/astro`, Forms and Formatter
42
+ come with the `forms` feature.
43
+ 2. Install with the project's package manager (`pnpm add`, `npm install` or
44
+ `bun add` as the project already uses). In samline's own repositories,
45
+ install with pnpm.
46
+ 3. Read the package's own skill for its API: it is served at
47
+ `https://samline.github.io/<name>/skills/<name>/SKILL.md` (docs at
48
+ `https://samline.github.io/<name>/`). Verify the installed version against
49
+ it; do not use APIs from memory.
50
+ 4. Use the declarative `data-<name>` attributes or the vanilla controller the
51
+ package documents. Mount each controller once in its owner (layout, section
52
+ or component) and call its cleanup (`destroy()`) on navigation.
53
+
54
+ ## Combining packages
55
+
56
+ - Behaviors stay with their package: do not animate the same transform from two
57
+ owners (for example Reveal on an element that Ticker or Drawer moves).
58
+ - Forms owns validation and state; Formatter owns masks inside it. Do not build
59
+ a parallel state or validation engine around them.
60
+ - Record which package was chosen for each design pattern in the project's
61
+ decisions, with what it replaced.
62
+ - If no package fits, say so and propose the smallest custom code. A behavior
63
+ needed in two or more projects is a candidate for a new package: suggest it,
64
+ do not create it.
65
+
66
+ ## Reporting defects
67
+
68
+ A package bug goes to `.local/upstream/<package>.md` with the installed version,
69
+ a sanitized reproduction and expected versus actual behavior. Post it as an
70
+ issue only when the user asks.