@kirill.konshin/lint 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/config.d.ts +8 -5
- package/dist/config.js +11 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lib.d.ts +6 -0
- package/dist/lib.js +17 -1
- package/dist/lintPrepare.d.ts +5 -4
- package/dist/lintPrepare.js +19 -12
- package/package.json +1 -1
- package/rules/agent.md +9 -0
- package/rules/security.md +7 -0
- package/rules/vercel.md +14 -0
- package/skills/lint-vercel/SKILL.md +30 -0
package/README.md
CHANGED
|
@@ -484,10 +484,10 @@ In the project root, `lint-prepare`:
|
|
|
484
484
|
|
|
485
485
|
- Creates real `rules/` and `skills/` directories in `.agents/` (canonical, cross-tool — Codex reads it) and `.claude/` (Claude Code).
|
|
486
486
|
- Links every `rules/*.md` file into both, except the ones the `rules` map of [`lint.config.ts`](#lintconfigts) turns off (`rules: { redux: false }`). Links point straight at the installed package's real location (`node_modules/@kirill.konshin/lint`, or the workspace package). A rule of yours with the same name in `.agents/` wins, the package one is not installed.
|
|
487
|
-
- Installs the skills of the `skills` map of `lint.config.ts`, merged over the defaults, with the [`skills` CLI](https://github.com/vercel-labs/skills), into `.agents/skills/` and from there into `.claude/skills/`. The map is keyed by source, each value uses the toggle notation; `skills: { name: true | false }` picks skills of a source — with no `true` entry every skill except the `false` ones:
|
|
487
|
+
- Installs the skills of the `skills` map of `lint.config.ts`, merged over the defaults, with the [`skills` CLI](https://github.com/vercel-labs/skills), into `.agents/skills/` and from there into `.claude/skills/`. The map is keyed by source, each value uses the toggle notation; `skills: { name: true | false | 'package' }` picks skills of a source — with no `true` or package entry every skill except the `false` ones; with one, only the skills that are on. A package name gates a skill: it is on when the root or a workspace package declares that package in `dependencies` or `devDependencies` (`'vercel-cli': 'vercel'`), off with `detection: false`; `true` / `false` in `lint.config.ts` overrides the gate:
|
|
488
488
|
- npm packages (`@scope/name`, or a name without `/`) are dependencies that ship skills: `skills experimental_sync -y -r -a codex claude-code` links every `skills/<name>/` folder of the dependencies of the root and of every workspace package; the map only leaves some out (`--exclude`). Default: this package's own skills (`'@kirill.konshin/lint': true`) — e.g. `lint-repo`, which sets up the tooling above and audits the repo against the rules.
|
|
489
489
|
- Git sources (`owner/repo`) are installed with `skills add`, at `ref` when set (pin a full 40-character commit SHA). A source whose skills `skills-lock.json` already has at the same ref is not fetched again. `lint.config.ts` owns the remote skills of `skills-lock.json`: a remote skill it no longer lists is removed (`skills remove`).
|
|
490
|
-
- Defaults — every project gets them, turn off what it does not need: the [Core Pack](https://skills.sh/p/DxVN7q53wGdAcZQt) (`vercel-labs/agent-skills` incl. `web-design-guidelines`, `vercel/ai`, `shadcn-ui/ui`, `heroui-inc/heroui`, `mui/material-ui` without `material-ui-tailwind`, `neondatabase/agent-skills`) and the official skills of the libraries the rules cover (`vercel/next.js`, `reduxjs/redux-toolkit`, `vercel/turborepo`, `nrwl/nx-ai-agents-config`, `expo/skills`, `microsoft/playwright-cli`). Each source lists its skills and pins a commit: `DEFAULT_LINT_CONFIG` in `src/config.ts`.
|
|
490
|
+
- Defaults — every project gets them, turn off what it does not need: the [Core Pack](https://skills.sh/p/DxVN7q53wGdAcZQt) (`vercel-labs/agent-skills` incl. `web-design-guidelines`, `vercel/ai`, `shadcn-ui/ui`, `heroui-inc/heroui`, `mui/material-ui` without `material-ui-tailwind`, `neondatabase/agent-skills`) and the official skills of the libraries the rules cover (`vercel/next.js`, `reduxjs/redux-toolkit`, `vercel/turborepo`, `nrwl/nx-ai-agents-config`, `expo/skills`, `microsoft/playwright-cli`). Gated by the `vercel` dependency (projects that install the Vercel CLI): `vercel/vercel` (`vercel-cli`) and `deploy-to-vercel` of `vercel-labs/agent-skills`. Each source lists its skills and pins a commit: `DEFAULT_LINT_CONFIG` in `src/config.ts`.
|
|
491
491
|
- A skill folder of yours with the same name in `.agents/skills/` wins.
|
|
492
492
|
- A failed CLI run is a warning, the install goes on: run `lint-prepare` again.
|
|
493
493
|
- On CI (`CI` set) nothing remote is fetched (`--no-remote`, no `skills add`): no network needed.
|
package/dist/config.d.ts
CHANGED
|
@@ -43,13 +43,15 @@ export type VitePlusOptions = UserConfig & {
|
|
|
43
43
|
typeAware?: boolean | ToggleOptions;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
|
-
* One skill source. `skills` names skills of the source: `true` installs one, `false` leaves one out
|
|
47
|
-
*
|
|
46
|
+
* One skill source. `skills` names skills of the source: `true` installs one, `false` leaves one out, a package name
|
|
47
|
+
* installs one when the root or a workspace package declares that package in `dependencies` or `devDependencies`
|
|
48
|
+
* (none with `detection: false`). With no `true` or package entry, every skill of the source is installed except the
|
|
49
|
+
* `false` ones; with one, only the skills that are on, none when every one is off.
|
|
48
50
|
*/
|
|
49
51
|
export type SkillSourceOptions = ToggleOptions & {
|
|
50
52
|
/** Git ref of a remote source. */
|
|
51
53
|
ref?: string;
|
|
52
|
-
skills?: Record<string, boolean>;
|
|
54
|
+
skills?: Record<string, boolean | string>;
|
|
53
55
|
};
|
|
54
56
|
/**
|
|
55
57
|
* Skill sources, keyed by source: a git source (`owner/repo`) is installed with `skills add`; an npm package
|
|
@@ -75,8 +77,9 @@ export type LintConfig = {
|
|
|
75
77
|
};
|
|
76
78
|
export declare const LINT_CONFIG_FILE = "lint.config.ts";
|
|
77
79
|
/**
|
|
78
|
-
* The base every resolved config starts from. Every project gets every skill below
|
|
79
|
-
*
|
|
80
|
+
* The base every resolved config starts from. Every project gets every skill below, except the skills a package name
|
|
81
|
+
* gates (`'vercel-cli': 'vercel'`), which only the projects depending on that package get; `lint.config.ts` turns off
|
|
82
|
+
* what it does not need (`'expo/skills': false`) and turns a gated skill on or off with `true` / `false`.
|
|
80
83
|
*
|
|
81
84
|
* Remote sources follow the Core Pack https://skills.sh/p/DxVN7q53wGdAcZQt (synced by hand, see the repository's
|
|
82
85
|
* `curated-skills-update` skill), plus the official skills of the libraries the rules cover. Each source lists its
|
package/dist/config.js
CHANGED
|
@@ -8,8 +8,9 @@ const LINT_CONFIG_FILE = "lint.config.ts";
|
|
|
8
8
|
/** `{ name: true }` for each name. */
|
|
9
9
|
const only = (...names) => Object.fromEntries(names.map((name) => [name, true]));
|
|
10
10
|
/**
|
|
11
|
-
* The base every resolved config starts from. Every project gets every skill below
|
|
12
|
-
*
|
|
11
|
+
* The base every resolved config starts from. Every project gets every skill below, except the skills a package name
|
|
12
|
+
* gates (`'vercel-cli': 'vercel'`), which only the projects depending on that package get; `lint.config.ts` turns off
|
|
13
|
+
* what it does not need (`'expo/skills': false`) and turns a gated skill on or off with `true` / `false`.
|
|
13
14
|
*
|
|
14
15
|
* Remote sources follow the Core Pack https://skills.sh/p/DxVN7q53wGdAcZQt (synced by hand, see the repository's
|
|
15
16
|
* `curated-skills-update` skill), plus the official skills of the libraries the rules cover. Each source lists its
|
|
@@ -19,7 +20,10 @@ const DEFAULT_LINT_CONFIG = { skills: {
|
|
|
19
20
|
"@kirill.konshin/lint": true,
|
|
20
21
|
"vercel-labs/agent-skills": {
|
|
21
22
|
ref: "063bee94c3f4df8453406c830b0a7df0f2860278",
|
|
22
|
-
skills:
|
|
23
|
+
skills: {
|
|
24
|
+
...only("vercel-react-best-practices", "vercel-composition-patterns", "vercel-react-native-skills", "vercel-react-view-transitions", "web-design-guidelines"),
|
|
25
|
+
"deploy-to-vercel": "vercel"
|
|
26
|
+
}
|
|
23
27
|
},
|
|
24
28
|
"vercel/ai": {
|
|
25
29
|
ref: "682e2dd71456f14f9da33a1b983d1998c3a1184c",
|
|
@@ -53,6 +57,10 @@ const DEFAULT_LINT_CONFIG = { skills: {
|
|
|
53
57
|
ref: "8003ff0fe919160f68367cd08465b179410e0692",
|
|
54
58
|
skills: only("turborepo")
|
|
55
59
|
},
|
|
60
|
+
"vercel/vercel": {
|
|
61
|
+
ref: "84878e532142f0ac584953695658b324eb9e5b80",
|
|
62
|
+
skills: { "vercel-cli": "vercel" }
|
|
63
|
+
},
|
|
56
64
|
"nrwl/nx-ai-agents-config": {
|
|
57
65
|
ref: "525ce266e22ec54e006d630d3b560658e8c3001c",
|
|
58
66
|
skills: only("link-workspace-packages", "monitor-ci", "nx-cloud-api", "nx-cloud-cache-investigator", "nx-cloud-ci-failure-review", "nx-generate", "nx-import", "nx-plugins", "nx-run-tasks", "nx-workspace")
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
2
|
-
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
2
|
+
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate, workspaceDependsOn } from "./lib.js";
|
|
3
3
|
import { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, LINT_CONFIG_FILE, LintConfig, NextOptions, SkillSourceOptions, SkillsConfig, TailwindOptions, ToggleOptions, TypeAwareOptions, VitePlusOptions, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
4
4
|
import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
|
|
5
5
|
import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.js";
|
|
@@ -31,4 +31,4 @@ import { Linter } from "eslint";
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function eslintConfig(overrides?: LintConfig): Promise<Linter.Config[]>;
|
|
33
33
|
//#endregion
|
|
34
|
-
export { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, GLOBAL_IGNORES, LINT_CONFIG_FILE, LintConfig, NextOptions, Restriction, SkillSourceOptions, SkillsConfig, TailwindOptions, ToggleOptions, TypeAwareOptions, VitePlusOptions, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin };
|
|
34
|
+
export { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, GLOBAL_IGNORES, LINT_CONFIG_FILE, LintConfig, NextOptions, Restriction, SkillSourceOptions, SkillsConfig, TailwindOptions, ToggleOptions, TypeAwareOptions, VitePlusOptions, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin, workspaceDependsOn };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
1
|
+
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate, workspaceDependsOn } from "./lib.js";
|
|
2
2
|
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
3
3
|
import { DEFAULT_LINT_CONFIG, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
4
4
|
import { findTailwindEntry, jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate, vitestGate } from "./gates.js";
|
|
@@ -54,4 +54,4 @@ async function eslintConfig(overrides = {}) {
|
|
|
54
54
|
];
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
|
-
export { DEFAULT_LINT_CONFIG, GLOBAL_IGNORES, LINT_CONFIG_FILE, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin };
|
|
57
|
+
export { DEFAULT_LINT_CONFIG, GLOBAL_IGNORES, LINT_CONFIG_FILE, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin, workspaceDependsOn };
|
package/dist/lib.d.ts
CHANGED
|
@@ -45,6 +45,12 @@ export declare function isPackageResolvable(packageName: string): boolean;
|
|
|
45
45
|
* Returns an absolute path, or `cwd` itself when there is no package.json anywhere above.
|
|
46
46
|
*/
|
|
47
47
|
export declare function findWorkspaceRoot(cwd?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Does the root or a workspace package of `root` declare `packageName` in `dependencies` or `devDependencies`?
|
|
50
|
+
* Peer/optional declarations are ignored, as in {@link dependsOnNext}. Reads the manifests the workspace globs name
|
|
51
|
+
* (`@manypkg/get-packages`), no scan; false without a `package.json`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function workspaceDependsOn(packageName: string, root?: string): boolean;
|
|
48
54
|
/**
|
|
49
55
|
* The workspace package owning `file` (e.g. the Tailwind entry CSS) - matched against the real
|
|
50
56
|
* workspace package dirs (see {@link findWorkspacePackages}), NOT by walking to the nearest
|
package/dist/lib.js
CHANGED
|
@@ -91,6 +91,22 @@ function findWorkspacePackages() {
|
|
|
91
91
|
return dirs;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
+
* Does the root or a workspace package of `root` declare `packageName` in `dependencies` or `devDependencies`?
|
|
95
|
+
* Peer/optional declarations are ignored, as in {@link dependsOnNext}. Reads the manifests the workspace globs name
|
|
96
|
+
* (`@manypkg/get-packages`), no scan; false without a `package.json`.
|
|
97
|
+
*/
|
|
98
|
+
function workspaceDependsOn(packageName, root = findWorkspaceRoot()) {
|
|
99
|
+
try {
|
|
100
|
+
const { rootPackage, packages } = getPackagesSync(root);
|
|
101
|
+
return [rootPackage, ...packages].some((pkg) => {
|
|
102
|
+
const { dependencies, devDependencies } = pkg?.packageJson ?? {};
|
|
103
|
+
return Boolean(dependencies?.[packageName] ?? devDependencies?.[packageName]);
|
|
104
|
+
});
|
|
105
|
+
} catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
94
110
|
* The workspace package owning `file` (e.g. the Tailwind entry CSS) - matched against the real
|
|
95
111
|
* workspace package dirs (see {@link findWorkspacePackages}), NOT by walking to the nearest
|
|
96
112
|
* package.json: a directory that is not a declared workspace member belongs to the root. Returns
|
|
@@ -321,4 +337,4 @@ function toolGate(option, strict, spec) {
|
|
|
321
337
|
}, enabled ? "forced on" : "detected");
|
|
322
338
|
}
|
|
323
339
|
//#endregion
|
|
324
|
-
export { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate };
|
|
340
|
+
export { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate, workspaceDependsOn };
|
package/dist/lintPrepare.d.ts
CHANGED
|
@@ -82,11 +82,12 @@ export type SkillsPlan = {
|
|
|
82
82
|
*/
|
|
83
83
|
export declare function readPackageSkills(cwd: string, packageName: string): string[];
|
|
84
84
|
/**
|
|
85
|
-
* Turn the `skills` map into CLI work.
|
|
86
|
-
*
|
|
87
|
-
* `skills
|
|
85
|
+
* Turn the `skills` map into CLI work. A skill gated by a package name is on when `hasDependency` says the workspace
|
|
86
|
+
* declares that package. npm sources become `experimental_sync` exclusions: a disabled package, the `false` skills,
|
|
87
|
+
* or - when a package lists `true` or gated skills - every other skill it ships. Enabled git sources become
|
|
88
|
+
* `skills add` work; a source whose listed skills are all off is left out.
|
|
88
89
|
*/
|
|
89
|
-
export declare function planSkills(skills: SkillsConfig, packageSkills?: (packageName: string) => string[]): SkillsPlan;
|
|
90
|
+
export declare function planSkills(skills: SkillsConfig, packageSkills?: (packageName: string) => string[], hasDependency?: (packageName: string) => boolean): SkillsPlan;
|
|
90
91
|
/**
|
|
91
92
|
* Install the git sources of the plan with `skills add`, skipping a source whose skills the lock already has at the
|
|
92
93
|
* same ref, then remove what the plan no longer wants: `lint.config.ts` owns the remote skills of `skills-lock.json`
|
package/dist/lintPrepare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { asOptions, findWorkspaceRoot } from "./lib.js";
|
|
2
|
+
import { asOptions, findWorkspaceRoot, workspaceDependsOn } from "./lib.js";
|
|
3
3
|
import { LINT_CONFIG_FILE, resolveLintConfig } from "./config.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import fs from "node:fs";
|
|
@@ -364,31 +364,37 @@ function readPackageSkills(cwd, packageName) {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
|
-
* Turn the `skills` map into CLI work.
|
|
368
|
-
*
|
|
369
|
-
* `skills
|
|
367
|
+
* Turn the `skills` map into CLI work. A skill gated by a package name is on when `hasDependency` says the workspace
|
|
368
|
+
* declares that package. npm sources become `experimental_sync` exclusions: a disabled package, the `false` skills,
|
|
369
|
+
* or - when a package lists `true` or gated skills - every other skill it ships. Enabled git sources become
|
|
370
|
+
* `skills add` work; a source whose listed skills are all off is left out.
|
|
370
371
|
*/
|
|
371
|
-
function planSkills(skills, packageSkills = () => []) {
|
|
372
|
+
function planSkills(skills, packageSkills = () => [], hasDependency = () => false) {
|
|
372
373
|
const plan = {
|
|
373
374
|
syncExclude: [],
|
|
374
375
|
remote: []
|
|
375
376
|
};
|
|
376
377
|
for (const [source, option] of Object.entries(skills)) {
|
|
377
|
-
const { enabled = true, ref, skills:
|
|
378
|
-
const
|
|
379
|
-
|
|
378
|
+
const { enabled = true, ref, skills: entries = {} } = asOptions(option);
|
|
379
|
+
const names = Object.entries(entries).map(([name, on]) => ({
|
|
380
|
+
name,
|
|
381
|
+
on: typeof on === "string" ? hasDependency(on) : on
|
|
382
|
+
}));
|
|
383
|
+
const listed = names.filter(({ on }) => on).map(({ name }) => name);
|
|
384
|
+
const excluded = names.filter(({ on }) => !on).map(({ name }) => name);
|
|
385
|
+
const picky = Object.values(entries).some((on) => on !== false);
|
|
380
386
|
if (isNpmSkillSource(source)) {
|
|
381
387
|
if (!enabled) plan.syncExclude.push(source);
|
|
382
388
|
else {
|
|
383
|
-
const left =
|
|
389
|
+
const left = picky ? packageSkills(source).filter((name) => !listed.includes(name)) : excluded;
|
|
384
390
|
plan.syncExclude.push(...left.map((name) => `${source}#${name}`));
|
|
385
391
|
}
|
|
386
392
|
continue;
|
|
387
393
|
}
|
|
388
|
-
if (enabled) plan.remote.push({
|
|
394
|
+
if (enabled && (!picky || listed.length)) plan.remote.push({
|
|
389
395
|
source,
|
|
390
396
|
ref,
|
|
391
|
-
skills:
|
|
397
|
+
skills: picky ? listed : "*",
|
|
392
398
|
exclude: excluded
|
|
393
399
|
});
|
|
394
400
|
}
|
|
@@ -599,7 +605,8 @@ async function main() {
|
|
|
599
605
|
const userEntries = readUserEntries(cwd);
|
|
600
606
|
syncAgentDirs(cwd, packageEntries(rules), userEntries);
|
|
601
607
|
console.log(`Synced ${AGENT_DIRS.join(", ")}, mirrored ${userEntries.size} own entries from ${CANONICAL_AGENT_DIR}`);
|
|
602
|
-
const
|
|
608
|
+
const { enabled: detect = true } = asOptions(config.detection);
|
|
609
|
+
const plan = planSkills(config.skills ?? {}, (packageName) => readPackageSkills(cwd, packageName), detect ? (packageName) => workspaceDependsOn(packageName, root) : void 0);
|
|
603
610
|
if (runSkillsSync(cwd, spawnSync, plan.syncExclude)) console.log(`Synced skills with the skills CLI, see ${SKILLS_LOCK}`);
|
|
604
611
|
syncRemoteSkills(cwd, plan.remote);
|
|
605
612
|
recordSyncedSkills(cwd);
|
package/package.json
CHANGED
package/rules/agent.md
CHANGED
|
@@ -123,3 +123,12 @@ Do not use `.claude/commands` for anything. It's not portable (`.agent/commands`
|
|
|
123
123
|
- If project uses Spec Driven Development framework like OpenSpec, these files should be free from product specifications / external behavior, and only focused on general coding instructions
|
|
124
124
|
- Preferred instructions/rules syntax how to structure plain human language: `EARS` for requirements and `BDD` (Given/When/Then) for scenarios
|
|
125
125
|
- Rules & instructions in these files can't be cited from tests or code, so their proof is tooling, never a citation
|
|
126
|
+
|
|
127
|
+
# Machine resources
|
|
128
|
+
|
|
129
|
+
- Before a build, codegen, branch switch, mass edit or anything else that rewrites many files, ask the user to turn on the IDE's power save mode (JetBrains: File → Power Save Mode) and wait for the answer: the IDE indexes every changed file, and indexing that already runs keeps going after power save turns on
|
|
130
|
+
- While tests or builds run, watch CPU (`top -o cpu` on macOS, `top` or `htop` elsewhere); when the machine saturates, stop the run and report
|
|
131
|
+
- Verification runs on the user's own machine: run the narrowest check that covers the change, the full suite once at the end of a change
|
|
132
|
+
- Cap parallelism (Vitest `--maxWorkers=2`, Turbo `--concurrency=2`, Nx `--parallel=2`) and run heavy commands at background priority (`taskpolicy -b` on macOS, `nice` elsewhere)
|
|
133
|
+
- Full builds, packaging, signing and deploys only when the user asks, once per request; never in a retry loop; deploy only after a build that exited 0
|
|
134
|
+
- On a network error or when the user reports slowness, stop and report instead of retrying
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: always_apply
|
|
3
|
+
description: Security rules for every project
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
- A form that carries a password, token or other secret ALWAYS submits with POST: `<form action={serverAction}>` gets it from React, every other form sets `method="post"` explicitly, also when JavaScript handles the submit — a submit before hydration is the browser's own, and its default GET puts the secret in the URL
|
|
7
|
+
- NEVER put credentials or secrets in a URL: query strings, redirects, links and request logs keep them
|
package/rules/vercel.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: always_apply
|
|
3
|
+
description: Set of rules for projects which use Vercel
|
|
4
|
+
paths:
|
|
5
|
+
- '**/vercel.json'
|
|
6
|
+
- '**/.vercel/**'
|
|
7
|
+
- '**/.gitignore'
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
- Applies only when the project uses Vercel (a `vercel` dependency, `vercel.json` or `.vercel/`)
|
|
11
|
+
- The Vercel CLI is a `devDependency`
|
|
12
|
+
- `.vercel/repo.json` (from `vercel link --repo`) is committed; the rest of `.vercel/` stays ignored: `.vercel/*` with `!.vercel/repo.json` in `.gitignore`, never a bare `.vercel` line
|
|
13
|
+
- After `vercel link`, remove the `.vercel` line it appends to `.gitignore`
|
|
14
|
+
- Setup and checks: the `lint-vercel` skill
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lint-vercel
|
|
3
|
+
description: Vercel project setup - the Vercel CLI as a dev dependency, the committed repository link (`.vercel/repo.json`) so every clone is linked without `vercel link`, what stays out of git in `.vercel/`. Use when adding Vercel to a project, running `vercel link`, or editing the `.vercel` lines of `.gitignore`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Platform operations (deploy, env vars, domains, logs): the `vercel-cli` skill.
|
|
7
|
+
|
|
8
|
+
# CLI
|
|
9
|
+
|
|
10
|
+
- `vercel` is a `devDependency` of the root `package.json`, run through the package manager (`vp exec vercel`, `yarn vercel`), never a global install
|
|
11
|
+
- The `vercel` dependency turns on the `vercel-cli` and `deploy-to-vercel` skills (`lint-prepare`)
|
|
12
|
+
- Login: `vercel login` once per machine, credentials stay outside the repository; CI uses a `VERCEL_TOKEN` secret
|
|
13
|
+
|
|
14
|
+
# Repository link
|
|
15
|
+
|
|
16
|
+
Link with `vercel link --repo`: it writes `.vercel/repo.json`, which maps the Git remote to the team and its projects (one entry per project root, monorepos included). It holds IDs and the remote name, no secrets. Commit it: every clone and machine is then linked.
|
|
17
|
+
|
|
18
|
+
Everything else in `.vercel/` is local and stays out of git: env files of `vercel pull` (`.vercel/.env.*.local`, secrets), build output of `vercel build` (`.vercel/output`), the per-directory link of plain `vercel link` (`.vercel/project.json`), `README.txt`.
|
|
19
|
+
|
|
20
|
+
`.gitignore`:
|
|
21
|
+
|
|
22
|
+
```gitignore
|
|
23
|
+
# Vercel: the repository link is shared, the rest of .vercel is local (env files with secrets, build output)
|
|
24
|
+
.vercel/*
|
|
25
|
+
!.vercel/repo.json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `.vercel/*`, not `.vercel`: git cannot re-include a file inside an ignored directory
|
|
29
|
+
- `vercel link` appends a `.vercel` line to `.gitignore` when that exact line is missing, which silently drops the exception: after every `vercel link`, remove the appended `.vercel` line
|
|
30
|
+
- Check: `git check-ignore -q .vercel/repo.json` exits 1 (not ignored), `git status -uall` shows `.vercel/repo.json` and nothing else from `.vercel/`
|