@kirill.konshin/lint 0.8.8 → 0.8.9
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 +23 -1
- package/dist/config.d.ts +13 -0
- package/dist/config.js +7 -1
- package/dist/graphify.d.ts +91 -0
- package/dist/graphify.js +260 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lib.js +1 -0
- package/dist/lintPrepare.d.ts +4 -4
- package/dist/lintPrepare.js +19 -8
- package/dist/vitePlus.js +1 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -146,8 +146,12 @@ export default defineLintConfig({
|
|
|
146
146
|
'vercel-labs/agent-skills': { skills: { 'vercel-react-native-skills': false } }, // a default source, one skill left out
|
|
147
147
|
'mattpocock/skills': { skills: { tdd: true } }, // an extra source, only this skill
|
|
148
148
|
'@kirill.konshin/lint': { skills: { 'lint-electron': false } }, // this package's own skills
|
|
149
|
+
'GoogleChrome/modern-web-guidance': { skills: { 'chrome-extensions': true } }, // an opt-in skill of a default source
|
|
149
150
|
},
|
|
150
151
|
|
|
152
|
+
// graphify code graph, see "graphify"; left out: used when `graphify` is on PATH
|
|
153
|
+
graphify: { version: '0.9.102' }, // true or options: installed into .venv with uv; false: off
|
|
154
|
+
|
|
151
155
|
// package rules by name: false leaves a rule out
|
|
152
156
|
rules: { redux: false },
|
|
153
157
|
});
|
|
@@ -487,7 +491,7 @@ In the project root, `lint-prepare`:
|
|
|
487
491
|
- 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
492
|
- 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
493
|
- 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`). 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`.
|
|
494
|
+
- 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`), and [Modern Web Guidance](https://developer.chrome.com/docs/modern-web-guidance) (`GoogleChrome/modern-web-guidance`: `modern-web-guidance`; `chrome-extensions` is opt-in). The Modern Web Guidance skill runs its CLI with `npx`: no dependency to add. 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
495
|
- A skill folder of yours with the same name in `.agents/skills/` wins.
|
|
492
496
|
- A failed CLI run is a warning, the install goes on: run `lint-prepare` again.
|
|
493
497
|
- On CI (`CI` set) nothing remote is fetched (`--no-remote`, no `skills add`): no network needed.
|
|
@@ -498,6 +502,24 @@ In the project root, `lint-prepare`:
|
|
|
498
502
|
- Removes dead links (e.g. after renaming a file) and the links it placed before but no longer needs, including what older versions placed (skill links, `commands/`). Each directory gets a generated `.gitignore` listing its links and the skills the `skills` CLI installed, so your own entries stay tracked.
|
|
499
503
|
- Writes an empty marker pair for each section another tool owns into the generated `AGENTS.md` — currently Vite+ (`<!--VITE PLUS START-->`). The tool fills it, so run it **after** `lint-prepare` in the same install script (`lint-prepare init && vp config`): tools write their own agent content, nothing is copied by hand.
|
|
500
504
|
- Generates `AGENTS.md` for other assistants (Codex, Cursor, Copilot, …) with a `# Rules` section — one entry per rule (the package's and yours): its title, frontmatter `description`, the `paths` it is scoped to and a plain link to its `.agents/rules/<file>` entry — and symlinks `CLAUDE.md` to it. The links are never `@` imports: Claude Code loads `.claude/rules` itself and honours each rule's `paths`, while an import would load every rule into every session.
|
|
505
|
+
- Sets up [graphify](#graphify) when `lint.config.ts` asks for it or finds it.
|
|
506
|
+
|
|
507
|
+
### graphify
|
|
508
|
+
|
|
509
|
+
[graphify](https://graphify.com) builds a code knowledge graph (`graphify-out/`) that agents query instead of grepping. It is a Python tool (PyPI `graphifyy`), so it is not a dependency: `lint-prepare` sets it up by the `graphify` key of [`lint.config.ts`](#lintconfigts):
|
|
510
|
+
|
|
511
|
+
| `graphify` | Executable | Skill | AGENTS.md section, Claude Code hooks | Root `.gitignore` |
|
|
512
|
+
| ------------------------------ | ------------------------------------------------------------- | ----- | ------------------------------------ | ------------------------- |
|
|
513
|
+
| left out | `graphify` on `PATH` (any install); none: skipped with a note | yes | no | `/graphify-out` |
|
|
514
|
+
| `true`, `{ version: '0.9.x' }` | project `.venv`, created with `uv` (required) | yes | yes | `/graphify-out`, `/.venv` |
|
|
515
|
+
| `false` | none | no | removed | none |
|
|
516
|
+
|
|
517
|
+
- The skills: graphify installs them where skills live (`graphify install --project`): the generic flavor into `.agents/skills/graphify` (Codex), the Claude Code flavor into `.claude/skills/graphify`, which also registers it in `.claude/CLAUDE.md`. Both are git-ignored like the skills the `skills` CLI installs (`lint-prepare` knows them by graphify's `.graphify_version` stamp); `false` removes them and the registration.
|
|
518
|
+
- The graph: `graphify update .` (code only, no LLM, no API key) after everything else. Commit nothing of `graphify-out/`.
|
|
519
|
+
- `true` only, committed, so every clone gets the same: `lint-prepare` writes a `## graphify` heading into the generated `AGENTS.md`, followed by its own `## graphify virtualenv` heading with how to reach `.venv`; then `graphify claude install` fills the `## graphify` section (it replaces up to the next `##` heading) and writes its hooks into `.claude/settings.json`, which `lint-prepare` points at `"$CLAUDE_PROJECT_DIR"/.venv/bin/graphify`. The next generation keeps the section.
|
|
520
|
+
- `graphifyy` version for `.venv`: `GRAPHIFY_VERSION` of `@kirill.konshin/lint/config`, or `version`.
|
|
521
|
+
- Nothing on CI; a failed graphify run is a warning, except a missing `uv` for `true`. `engines.uv` of this package documents the `uv` version.
|
|
522
|
+
- The root `.gitignore` gets a marked block (`# @kirill.konshin/lint: graphify`); it follows `lint.config.ts` only, never what a machine has. Vite+ ignores `graphify-out` too.
|
|
501
523
|
|
|
502
524
|
### OpenSpec
|
|
503
525
|
|
package/dist/config.d.ts
CHANGED
|
@@ -59,6 +59,15 @@ export type SkillSourceOptions = ToggleOptions & {
|
|
|
59
59
|
* `false` is `{ enabled: false }`.
|
|
60
60
|
*/
|
|
61
61
|
export type SkillsConfig = Record<string, boolean | SkillSourceOptions>;
|
|
62
|
+
/**
|
|
63
|
+
* graphify (https://graphify.com), a code knowledge graph for agents, set up by `lint-prepare`. Left out, it is
|
|
64
|
+
* detected: a `graphify` on `PATH` gets the skill and a graph build. `true` (or options) installs it into the project
|
|
65
|
+
* `.venv` with `uv` and also writes its AGENTS.md section and Claude Code hooks. `false` turns it off.
|
|
66
|
+
*/
|
|
67
|
+
export type GraphifyOptions = ToggleOptions & {
|
|
68
|
+
/** Version of the `graphifyy` PyPI package installed into `.venv`, see {@link GRAPHIFY_VERSION}. */
|
|
69
|
+
version?: string;
|
|
70
|
+
};
|
|
62
71
|
export type LintConfig = {
|
|
63
72
|
detection?: boolean | DetectionOptions;
|
|
64
73
|
next?: boolean | NextOptions;
|
|
@@ -72,10 +81,14 @@ export type LintConfig = {
|
|
|
72
81
|
vitePlus?: VitePlusOptions;
|
|
73
82
|
/** Skills `lint-prepare` installs, merged over {@link DEFAULT_LINT_CONFIG}. */
|
|
74
83
|
skills?: SkillsConfig;
|
|
84
|
+
/** Detected when left out, see {@link GraphifyOptions}. */
|
|
85
|
+
graphify?: boolean | GraphifyOptions;
|
|
75
86
|
/** Package rules by name (file name without `.md`): `false` leaves a rule out. */
|
|
76
87
|
rules?: Record<string, boolean>;
|
|
77
88
|
};
|
|
78
89
|
export declare const LINT_CONFIG_FILE = "lint.config.ts";
|
|
90
|
+
/** The `graphifyy` version `graphify: true` installs into `.venv`, unless `version` overrides it. */
|
|
91
|
+
export declare const GRAPHIFY_VERSION = "0.9.102";
|
|
79
92
|
/**
|
|
80
93
|
* The base every resolved config starts from. Every project gets every skill below, except the skills a package name
|
|
81
94
|
* gates (`'vercel-cli': 'vercel'`), which only the projects depending on that package get; `lint.config.ts` turns off
|
package/dist/config.js
CHANGED
|
@@ -5,6 +5,8 @@ import { join } from "node:path";
|
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
//#region src/config.ts
|
|
7
7
|
const LINT_CONFIG_FILE = "lint.config.ts";
|
|
8
|
+
/** The `graphifyy` version `graphify: true` installs into `.venv`, unless `version` overrides it. */
|
|
9
|
+
const GRAPHIFY_VERSION = "0.9.102";
|
|
8
10
|
/** `{ name: true }` for each name. */
|
|
9
11
|
const only = (...names) => Object.fromEntries(names.map((name) => [name, true]));
|
|
10
12
|
/**
|
|
@@ -72,6 +74,10 @@ const DEFAULT_LINT_CONFIG = { skills: {
|
|
|
72
74
|
"microsoft/playwright-cli": {
|
|
73
75
|
ref: "b1a5903c5b633b8c9f843ad7b629c2a78437040c",
|
|
74
76
|
skills: only("playwright-cli")
|
|
77
|
+
},
|
|
78
|
+
"GoogleChrome/modern-web-guidance": {
|
|
79
|
+
ref: "64a6d708f5a43f2cd3fde5d4d7db3905ba1bdf65",
|
|
80
|
+
skills: only("modern-web-guidance")
|
|
75
81
|
}
|
|
76
82
|
} };
|
|
77
83
|
/** Type-checks `lint.config.ts`; returns the config as it is. */
|
|
@@ -117,4 +123,4 @@ async function resolveLintConfig(overrides = {}, root = findWorkspaceRoot()) {
|
|
|
117
123
|
return mergeLintConfig(mergeLintConfig(DEFAULT_LINT_CONFIG, await loadLintConfig(root)), overrides);
|
|
118
124
|
}
|
|
119
125
|
//#endregion
|
|
120
|
-
export { DEFAULT_LINT_CONFIG, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig, scanWorkspace, tsExts };
|
|
126
|
+
export { DEFAULT_LINT_CONFIG, GRAPHIFY_VERSION, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig, scanWorkspace, tsExts };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { GraphifyOptions } from "./config.js";
|
|
2
|
+
import { RunCommand } from "./lintPrepare.js";
|
|
3
|
+
//#region src/graphify.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* graphify (https://graphify.com, PyPI `graphifyy`) for `lint-prepare`, by the `graphify` option of `lint.config.ts`:
|
|
6
|
+
*
|
|
7
|
+
* - left out (`detect`): a `graphify` on `PATH` gets its skills and a graph build
|
|
8
|
+
* - `true` or options (`venv`): installed into the project `.venv` with `uv`, plus its AGENTS.md section and Claude
|
|
9
|
+
* Code hooks, which are committed: every clone gets the same `.venv`
|
|
10
|
+
* - `false` (`off`): nothing, and what earlier runs installed is removed
|
|
11
|
+
*
|
|
12
|
+
* graphify writes its own files: its skills into `.agents/skills` (the generic flavor) and `.claude/skills` (the Claude
|
|
13
|
+
* Code flavor), its section into AGENTS.md between the anchors lint-prepare generates, its hooks into
|
|
14
|
+
* `.claude/settings.json`. lint-prepare only points the hooks at `.venv` and keeps the section on the next generation.
|
|
15
|
+
*/
|
|
16
|
+
export type GraphifyMode = 'off' | 'detect' | 'venv';
|
|
17
|
+
/** What setUpGraphify() leaves for the rest of `lint-prepare`. */
|
|
18
|
+
export type GraphifySetup = {
|
|
19
|
+
mode: GraphifyMode;
|
|
20
|
+
/** The executable, when graphify can run. */
|
|
21
|
+
exe?: string;
|
|
22
|
+
};
|
|
23
|
+
/** The skill name graphify installs. */
|
|
24
|
+
export declare const GRAPHIFY_SKILL = "graphify";
|
|
25
|
+
/** The mode the `graphify` option asks for, and the version `venv` installs. */
|
|
26
|
+
export declare function graphifyMode(option: boolean | GraphifyOptions | undefined): {
|
|
27
|
+
mode: GraphifyMode;
|
|
28
|
+
version: string;
|
|
29
|
+
};
|
|
30
|
+
/** The absolute path of `command` on `PATH`, undefined when there is none. */
|
|
31
|
+
export declare function findOnPath(command: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
32
|
+
/** The graphify executable of the project `.venv`. */
|
|
33
|
+
export declare const venvExe: (cwd: string) => string;
|
|
34
|
+
/** A skill folder graphify installed: it holds graphify's version stamp. */
|
|
35
|
+
export declare const isGraphifySkill: (dir: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Create the project `.venv` with `uv` (kept when it exists) and install `graphifyy==version` into it. Throws when `uv`
|
|
38
|
+
* is missing: `graphify: true` asks for it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function installGraphifyVenv(cwd: string, version: string, run: RunCommand): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Let graphify install its skills where skills live: the generic flavor into `.agents/skills/graphify` (Codex and the
|
|
43
|
+
* rest), the Claude Code flavor into `.claude/skills/graphify` (it also registers the skill in `.claude/CLAUDE.md`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function installGraphifySkills(cwd: string, exe: string, run: RunCommand): boolean;
|
|
46
|
+
/** Remove what graphify installed: its skill folders (only the ones with its stamp) and its skill registration. */
|
|
47
|
+
export declare function removeGraphifySkills(cwd: string): void;
|
|
48
|
+
/** `content` without the section that starts at the exact line `heading` and ends before the next `boundary` line. */
|
|
49
|
+
export declare function removeSection(content: string, heading: string, boundary: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* The AGENTS.md anchors for `venv`: graphify's `## graphify` section, kept from `previous` (graphify fills it right
|
|
52
|
+
* after, `graphify claude install`), then the `## graphify virtualenv` heading, which ends graphify's section, with how
|
|
53
|
+
* to reach `.venv`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function graphifyAgentsSection(previous?: string): string;
|
|
56
|
+
/** A graphify hook command, any executable path, run from `.venv`. */
|
|
57
|
+
export declare const toVenvCommand: (command: string) => string;
|
|
58
|
+
/**
|
|
59
|
+
* `settings` with graphify's hooks run from `.venv` (`venv`), or without them (an emptied group, event or `hooks`
|
|
60
|
+
* goes too).
|
|
61
|
+
*/
|
|
62
|
+
export declare function updateGraphifyHooks(settings: Record<string, unknown>, venv: boolean): Record<string, unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* Run updateGraphifyHooks() over `.claude/settings.json`, writing it only when it changes; a file that does not parse
|
|
65
|
+
* is left alone.
|
|
66
|
+
*/
|
|
67
|
+
export declare function updateClaudeSettings(cwd: string, venv: boolean): void;
|
|
68
|
+
/**
|
|
69
|
+
* `graphify claude install`: its section into AGENTS.md (through the `CLAUDE.md` link, between the anchors) and its
|
|
70
|
+
* hooks into `.claude/settings.json`, then the hooks pointed at `.venv`. Not `--project`: that installs the skill
|
|
71
|
+
* again.
|
|
72
|
+
*/
|
|
73
|
+
export declare function installGraphifyInstructions(cwd: string, exe: string, run: RunCommand): void;
|
|
74
|
+
/**
|
|
75
|
+
* The root `.gitignore` with lint-prepare's graphify block listing `entries`, or without it when there are none. The
|
|
76
|
+
* block depends on `lint.config.ts` only, never on what a machine has, so every clone writes the same.
|
|
77
|
+
*/
|
|
78
|
+
export declare function updateGitignoreBlock(content: string, entries: string[]): string;
|
|
79
|
+
/** Write updateGitignoreBlock() into `cwd/.gitignore` when it changes. */
|
|
80
|
+
export declare function writeGitignoreBlock(cwd: string, mode: GraphifyMode): void;
|
|
81
|
+
/**
|
|
82
|
+
* Set graphify up for `mode` before the agent dirs are synced: the executable (`.venv` installed for `venv`, `PATH`
|
|
83
|
+
* for `detect`) and its skills; `off` removes them. Nothing on CI. Throws when `venv` has no `uv`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function setUpGraphify(cwd: string, option: boolean | GraphifyOptions | undefined, run: RunCommand): GraphifySetup;
|
|
86
|
+
/**
|
|
87
|
+
* After AGENTS.md is generated: `venv` gets graphify's section and hooks, the other modes lose the hooks. Then the code
|
|
88
|
+
* graph in `graphify-out` is built or refreshed (`graphify update .`: code only, no LLM, no API key). Nothing on CI.
|
|
89
|
+
*/
|
|
90
|
+
export declare function finishGraphify(cwd: string, { mode, exe }: GraphifySetup, run: RunCommand): void;
|
|
91
|
+
//#endregion
|
package/dist/graphify.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { GRAPHIFY_VERSION } from "./config.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/graphify.ts
|
|
5
|
+
/** The skill name graphify installs. */
|
|
6
|
+
const GRAPHIFY_SKILL = "graphify";
|
|
7
|
+
const SECTION_HEADING = "## graphify";
|
|
8
|
+
const VENV_HEADING = "## graphify virtualenv";
|
|
9
|
+
const GITIGNORE_BEGIN = "# @kirill.konshin/lint: graphify";
|
|
10
|
+
const GITIGNORE_END = "# @kirill.konshin/lint: graphify end";
|
|
11
|
+
const VENV = ".venv";
|
|
12
|
+
const VENV_HOOK_EXE = `"$CLAUDE_PROJECT_DIR"/${VENV}/bin/graphify`;
|
|
13
|
+
const VERSION_STAMP = ".graphify_version";
|
|
14
|
+
const REGISTRATION_HEADING = "# graphify";
|
|
15
|
+
const QUIET = { stdio: [
|
|
16
|
+
"ignore",
|
|
17
|
+
"ignore",
|
|
18
|
+
"inherit"
|
|
19
|
+
] };
|
|
20
|
+
const isWindows = process.platform === "win32";
|
|
21
|
+
/** The mode the `graphify` option asks for, and the version `venv` installs. */
|
|
22
|
+
function graphifyMode(option) {
|
|
23
|
+
if (option === void 0) return {
|
|
24
|
+
mode: "detect",
|
|
25
|
+
version: GRAPHIFY_VERSION
|
|
26
|
+
};
|
|
27
|
+
if (typeof option === "boolean") return {
|
|
28
|
+
mode: option ? "venv" : "off",
|
|
29
|
+
version: GRAPHIFY_VERSION
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
mode: option.enabled === false ? "off" : "venv",
|
|
33
|
+
version: option.version ?? "0.9.102"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The absolute path of `command` on `PATH`, undefined when there is none. */
|
|
37
|
+
function findOnPath(command, env = process.env) {
|
|
38
|
+
const exts = isWindows ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
39
|
+
for (const dir of (env.PATH ?? "").split(path.delimiter).filter(Boolean)) for (const ext of exts) {
|
|
40
|
+
const file = path.join(dir, command + ext);
|
|
41
|
+
try {
|
|
42
|
+
fs.accessSync(file, fs.constants.X_OK);
|
|
43
|
+
if (fs.statSync(file).isFile()) return file;
|
|
44
|
+
} catch {}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The graphify executable of the project `.venv`. */
|
|
48
|
+
const venvExe = (cwd) => isWindows ? path.join(cwd, VENV, "Scripts", "graphify.exe") : path.join(cwd, VENV, "bin", "graphify");
|
|
49
|
+
/** A skill folder graphify installed: it holds graphify's version stamp. */
|
|
50
|
+
const isGraphifySkill = (dir) => fs.existsSync(path.join(dir, VERSION_STAMP));
|
|
51
|
+
function runQuiet(run, command, args, cwd) {
|
|
52
|
+
const result = run(command, args, {
|
|
53
|
+
cwd,
|
|
54
|
+
...QUIET
|
|
55
|
+
});
|
|
56
|
+
if (result.status === 0) return true;
|
|
57
|
+
console.warn(`[lint-prepare] ${path.basename(command)} ${args.join(" ")} failed (${result.error?.message ?? `exit code ${result.status}`}), graphify may be incomplete: re-run lint-prepare`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create the project `.venv` with `uv` (kept when it exists) and install `graphifyy==version` into it. Throws when `uv`
|
|
62
|
+
* is missing: `graphify: true` asks for it.
|
|
63
|
+
*/
|
|
64
|
+
function installGraphifyVenv(cwd, version, run) {
|
|
65
|
+
const uv = findOnPath("uv");
|
|
66
|
+
if (!uv) throw new Error("[lint-prepare] graphify: true in lint.config.ts needs uv, install it: https://docs.astral.sh/uv/getting-started/installation/");
|
|
67
|
+
return runQuiet(run, uv, [
|
|
68
|
+
"venv",
|
|
69
|
+
"--allow-existing",
|
|
70
|
+
VENV
|
|
71
|
+
], cwd) && runQuiet(run, uv, [
|
|
72
|
+
"pip",
|
|
73
|
+
"install",
|
|
74
|
+
"--python",
|
|
75
|
+
VENV,
|
|
76
|
+
`graphifyy==${version}`
|
|
77
|
+
], cwd);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Let graphify install its skills where skills live: the generic flavor into `.agents/skills/graphify` (Codex and the
|
|
81
|
+
* rest), the Claude Code flavor into `.claude/skills/graphify` (it also registers the skill in `.claude/CLAUDE.md`).
|
|
82
|
+
*/
|
|
83
|
+
function installGraphifySkills(cwd, exe, run) {
|
|
84
|
+
return ["agents", "claude"].every((platform) => runQuiet(run, exe, [
|
|
85
|
+
"install",
|
|
86
|
+
"--project",
|
|
87
|
+
"--platform",
|
|
88
|
+
platform
|
|
89
|
+
], cwd));
|
|
90
|
+
}
|
|
91
|
+
/** Remove what graphify installed: its skill folders (only the ones with its stamp) and its skill registration. */
|
|
92
|
+
function removeGraphifySkills(cwd) {
|
|
93
|
+
for (const dir of [".agents", ".claude"]) {
|
|
94
|
+
const skill = path.join(cwd, dir, "skills", GRAPHIFY_SKILL);
|
|
95
|
+
if (isGraphifySkill(skill)) fs.rmSync(skill, {
|
|
96
|
+
recursive: true,
|
|
97
|
+
force: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const claudeMd = path.join(cwd, ".claude", "CLAUDE.md");
|
|
101
|
+
if (!fs.existsSync(claudeMd)) return;
|
|
102
|
+
const content = fs.readFileSync(claudeMd, "utf-8");
|
|
103
|
+
const updated = removeSection(content, REGISTRATION_HEADING, "# ");
|
|
104
|
+
if (updated === content) return;
|
|
105
|
+
if (updated.trim()) fs.writeFileSync(claudeMd, updated);
|
|
106
|
+
else fs.unlinkSync(claudeMd);
|
|
107
|
+
}
|
|
108
|
+
/** `content` without the section that starts at the exact line `heading` and ends before the next `boundary` line. */
|
|
109
|
+
function removeSection(content, heading, boundary) {
|
|
110
|
+
const lines = content.split("\n");
|
|
111
|
+
const start = lines.findIndex((line) => line.trim() === heading);
|
|
112
|
+
if (start === -1) return content;
|
|
113
|
+
const length = lines.slice(start + 1).findIndex((line) => line.startsWith(boundary));
|
|
114
|
+
return `${[...lines.slice(0, start), ...length === -1 ? [] : lines.slice(start + 1 + length)].join("\n").replace(/\n{3,}/g, "\n\n").trim()}\n`;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The AGENTS.md anchors for `venv`: graphify's `## graphify` section, kept from `previous` (graphify fills it right
|
|
118
|
+
* after, `graphify claude install`), then the `## graphify virtualenv` heading, which ends graphify's section, with how
|
|
119
|
+
* to reach `.venv`.
|
|
120
|
+
*/
|
|
121
|
+
function graphifyAgentsSection(previous = "") {
|
|
122
|
+
const lines = previous.split("\n");
|
|
123
|
+
const start = lines.indexOf(SECTION_HEADING);
|
|
124
|
+
const end = start === -1 ? -1 : lines.indexOf(VENV_HEADING, start);
|
|
125
|
+
return [
|
|
126
|
+
end === -1 ? SECTION_HEADING : lines.slice(start, end).join("\n").trim(),
|
|
127
|
+
"",
|
|
128
|
+
VENV_HEADING,
|
|
129
|
+
"",
|
|
130
|
+
`graphify is installed in the project \`${VENV}\`, not on \`PATH\`: run every \`graphify\` and \`python3\` command of the graphify skill as \`source ${VENV}/bin/activate && <command>\`, from the repository root.`
|
|
131
|
+
].join("\n");
|
|
132
|
+
}
|
|
133
|
+
const isGraphifyCommand = (command = "") => command.includes("graphify") && /\bhook-(guard|check)\b/.test(command);
|
|
134
|
+
/** A graphify hook command, any executable path, run from `.venv`. */
|
|
135
|
+
const toVenvCommand = (command) => command.replace(/^(?:"[^"]*"|\S+)(?=\s+hook-(?:guard|check)\b)/, VENV_HOOK_EXE);
|
|
136
|
+
/**
|
|
137
|
+
* `settings` with graphify's hooks run from `.venv` (`venv`), or without them (an emptied group, event or `hooks`
|
|
138
|
+
* goes too).
|
|
139
|
+
*/
|
|
140
|
+
function updateGraphifyHooks(settings, venv) {
|
|
141
|
+
const hooks = {};
|
|
142
|
+
for (const [event, groups] of Object.entries(settings.hooks ?? {})) {
|
|
143
|
+
const kept = groups.flatMap((group) => {
|
|
144
|
+
if (!group.hooks?.some((hook) => isGraphifyCommand(hook.command))) return [group];
|
|
145
|
+
const own = venv ? group.hooks.map((hook) => isGraphifyCommand(hook.command) ? {
|
|
146
|
+
...hook,
|
|
147
|
+
command: toVenvCommand(hook.command)
|
|
148
|
+
} : hook) : group.hooks.filter((hook) => !isGraphifyCommand(hook.command));
|
|
149
|
+
return own.length ? [{
|
|
150
|
+
...group,
|
|
151
|
+
hooks: own
|
|
152
|
+
}] : [];
|
|
153
|
+
});
|
|
154
|
+
if (kept.length) hooks[event] = kept;
|
|
155
|
+
}
|
|
156
|
+
const rest = { ...settings };
|
|
157
|
+
delete rest.hooks;
|
|
158
|
+
return Object.keys(hooks).length ? {
|
|
159
|
+
...rest,
|
|
160
|
+
hooks
|
|
161
|
+
} : rest;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Run updateGraphifyHooks() over `.claude/settings.json`, writing it only when it changes; a file that does not parse
|
|
165
|
+
* is left alone.
|
|
166
|
+
*/
|
|
167
|
+
function updateClaudeSettings(cwd, venv) {
|
|
168
|
+
const file = path.join(cwd, ".claude", "settings.json");
|
|
169
|
+
if (!fs.existsSync(file)) return;
|
|
170
|
+
let settings;
|
|
171
|
+
try {
|
|
172
|
+
settings = JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.warn(`[lint-prepare] ${file} does not parse, graphify hooks not updated`, { error });
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const updated = updateGraphifyHooks(settings, venv);
|
|
178
|
+
if (JSON.stringify(updated) !== JSON.stringify(settings)) fs.writeFileSync(file, `${JSON.stringify(updated, null, 2)}\n`);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* `graphify claude install`: its section into AGENTS.md (through the `CLAUDE.md` link, between the anchors) and its
|
|
182
|
+
* hooks into `.claude/settings.json`, then the hooks pointed at `.venv`. Not `--project`: that installs the skill
|
|
183
|
+
* again.
|
|
184
|
+
*/
|
|
185
|
+
function installGraphifyInstructions(cwd, exe, run) {
|
|
186
|
+
if (runQuiet(run, exe, ["claude", "install"], cwd)) updateClaudeSettings(cwd, true);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The root `.gitignore` with lint-prepare's graphify block listing `entries`, or without it when there are none. The
|
|
190
|
+
* block depends on `lint.config.ts` only, never on what a machine has, so every clone writes the same.
|
|
191
|
+
*/
|
|
192
|
+
function updateGitignoreBlock(content, entries) {
|
|
193
|
+
const lines = content.split("\n");
|
|
194
|
+
const from = lines.indexOf(GITIGNORE_BEGIN);
|
|
195
|
+
const to = from === -1 ? -1 : lines.indexOf(GITIGNORE_END, from);
|
|
196
|
+
const text = (to === -1 ? lines : [...lines.slice(0, from), ...lines.slice(to + 1)]).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
197
|
+
const block = entries.length ? [
|
|
198
|
+
GITIGNORE_BEGIN,
|
|
199
|
+
...entries,
|
|
200
|
+
GITIGNORE_END
|
|
201
|
+
].join("\n") : "";
|
|
202
|
+
return [text, block].filter(Boolean).join("\n\n") + (text || block ? "\n" : "");
|
|
203
|
+
}
|
|
204
|
+
/** Write updateGitignoreBlock() into `cwd/.gitignore` when it changes. */
|
|
205
|
+
function writeGitignoreBlock(cwd, mode) {
|
|
206
|
+
const file = path.join(cwd, ".gitignore");
|
|
207
|
+
const entries = {
|
|
208
|
+
off: [],
|
|
209
|
+
detect: ["/graphify-out"],
|
|
210
|
+
venv: ["/graphify-out", `/${VENV}`]
|
|
211
|
+
}[mode];
|
|
212
|
+
const content = fs.existsSync(file) ? fs.readFileSync(file, "utf-8") : "";
|
|
213
|
+
const updated = updateGitignoreBlock(content, entries);
|
|
214
|
+
if (updated !== content) fs.writeFileSync(file, updated);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Set graphify up for `mode` before the agent dirs are synced: the executable (`.venv` installed for `venv`, `PATH`
|
|
218
|
+
* for `detect`) and its skills; `off` removes them. Nothing on CI. Throws when `venv` has no `uv`.
|
|
219
|
+
*/
|
|
220
|
+
function setUpGraphify(cwd, option, run) {
|
|
221
|
+
const { mode, version } = graphifyMode(option);
|
|
222
|
+
const setup = { mode };
|
|
223
|
+
if (process.env.CI) return setup;
|
|
224
|
+
if (mode === "off") {
|
|
225
|
+
removeGraphifySkills(cwd);
|
|
226
|
+
return setup;
|
|
227
|
+
}
|
|
228
|
+
if (mode === "detect") {
|
|
229
|
+
const exe = findOnPath("graphify");
|
|
230
|
+
if (!exe) {
|
|
231
|
+
console.log("graphify is not on PATH, skipped (graphify: false in lint.config.ts silences this)");
|
|
232
|
+
return setup;
|
|
233
|
+
}
|
|
234
|
+
setup.exe = exe;
|
|
235
|
+
} else {
|
|
236
|
+
if (!installGraphifyVenv(cwd, version, run)) return setup;
|
|
237
|
+
setup.exe = venvExe(cwd);
|
|
238
|
+
}
|
|
239
|
+
if (!installGraphifySkills(cwd, setup.exe, run)) return { mode };
|
|
240
|
+
console.log(`Set up graphify (${mode === "venv" ? `${VENV}, graphifyy ${version}` : setup.exe})`);
|
|
241
|
+
return setup;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* After AGENTS.md is generated: `venv` gets graphify's section and hooks, the other modes lose the hooks. Then the code
|
|
245
|
+
* graph in `graphify-out` is built or refreshed (`graphify update .`: code only, no LLM, no API key). Nothing on CI.
|
|
246
|
+
*/
|
|
247
|
+
function finishGraphify(cwd, { mode, exe }, run) {
|
|
248
|
+
if (process.env.CI) return;
|
|
249
|
+
if (mode !== "venv") updateClaudeSettings(cwd, false);
|
|
250
|
+
else if (exe) installGraphifyInstructions(cwd, exe, run);
|
|
251
|
+
if (!exe) return;
|
|
252
|
+
console.log("Building the graphify code graph (graphify update .)");
|
|
253
|
+
const result = run(exe, ["update", "."], {
|
|
254
|
+
cwd,
|
|
255
|
+
stdio: "inherit"
|
|
256
|
+
});
|
|
257
|
+
if (result.status !== 0) console.warn(`[lint-prepare] graphify update failed (${result.error?.message ?? `exit code ${result.status}`}): run "graphify update ." to retry`);
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
260
|
+
export { GRAPHIFY_SKILL, findOnPath, finishGraphify, graphifyAgentsSection, graphifyMode, installGraphifyInstructions, installGraphifySkills, installGraphifyVenv, isGraphifySkill, removeGraphifySkills, removeSection, setUpGraphify, toVenvCommand, updateClaudeSettings, updateGitignoreBlock, updateGraphifyHooks, venvExe, writeGitignoreBlock };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
2
2
|
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate, workspaceDependsOn } from "./lib.js";
|
|
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";
|
|
3
|
+
import { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, GRAPHIFY_VERSION, GraphifyOptions, 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";
|
|
6
6
|
import { nxConfig, nxPlugin } from "./configs/nx.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, workspaceDependsOn };
|
|
34
|
+
export { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, GLOBAL_IGNORES, GRAPHIFY_VERSION, GraphifyOptions, 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,6 +1,6 @@
|
|
|
1
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
|
-
import { DEFAULT_LINT_CONFIG, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
3
|
+
import { DEFAULT_LINT_CONFIG, GRAPHIFY_VERSION, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
4
4
|
import { findTailwindEntry, jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate, vitestGate } from "./gates.js";
|
|
5
5
|
import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
|
|
6
6
|
import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.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, workspaceDependsOn };
|
|
57
|
+
export { DEFAULT_LINT_CONFIG, GLOBAL_IGNORES, GRAPHIFY_VERSION, 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.js
CHANGED
package/dist/lintPrepare.d.ts
CHANGED
|
@@ -97,8 +97,8 @@ export declare function syncRemoteSkills(cwd: string, remote: RemoteSkills[], ru
|
|
|
97
97
|
/** Package rules the `rules` map of `lint.config.ts` keeps. */
|
|
98
98
|
export declare function enabledRules(rules: Rule[], config: LintConfig): Rule[];
|
|
99
99
|
/**
|
|
100
|
-
* List the skills the `skills` CLI installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
101
|
-
* the links this tool placed keep their own list.
|
|
100
|
+
* List the skills the `skills` CLI and graphify installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
101
|
+
* of git, and the links this tool placed keep their own list.
|
|
102
102
|
*/
|
|
103
103
|
export declare function recordSyncedSkills(cwd: string): void;
|
|
104
104
|
/**
|
|
@@ -138,9 +138,9 @@ export declare function symlinkClaudeMd(cwd: string): void;
|
|
|
138
138
|
*
|
|
139
139
|
* The links are plain, never `@path` imports: Claude Code loads `.claude/rules` itself (syncAgentDirs() links them
|
|
140
140
|
* there) and honours each rule's `paths`, while an `@` import would load every rule into every session, scoped or not.
|
|
141
|
-
* Codex, which expands no `@`, reads this index.
|
|
141
|
+
* Codex, which expands no `@`, reads this index. `graphifySection` (graphify.ts) follows the tool sections.
|
|
142
142
|
*/
|
|
143
|
-
export declare function generateAgentsFile(rules: Rule[], customSection: string | null, previous?: string): string;
|
|
143
|
+
export declare function generateAgentsFile(rules: Rule[], customSection: string | null, previous?: string, graphifySection?: string): string;
|
|
144
144
|
/**
|
|
145
145
|
* Check if AGENTS.md exists and was generated by this tool. When it was, also return
|
|
146
146
|
* whatever follows the marker (the user's custom section) so it can be carried forward -
|
package/dist/lintPrepare.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { asOptions, findWorkspaceRoot, workspaceDependsOn } from "./lib.js";
|
|
3
3
|
import { LINT_CONFIG_FILE, resolveLintConfig } from "./config.js";
|
|
4
|
+
import { GRAPHIFY_SKILL, finishGraphify, graphifyAgentsSection, isGraphifySkill, setUpGraphify, writeGitignoreBlock } from "./graphify.js";
|
|
4
5
|
import { createRequire } from "node:module";
|
|
5
6
|
import fs from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
@@ -314,7 +315,7 @@ function readUserEntries(cwd) {
|
|
|
314
315
|
const own = manifestNames(root);
|
|
315
316
|
for (const name of fs.readdirSync(root)) {
|
|
316
317
|
const entry = path.join(root, name);
|
|
317
|
-
const isSynced = kind === "skills" && (synced
|
|
318
|
+
const isSynced = kind === "skills" && (isToolSkill(entry, synced) || isPackageLink(entry));
|
|
318
319
|
if (!name.startsWith(".") && !own.has(name) && !isSynced && fs.existsSync(entry)) entries.set(path.join(kind, name), entry);
|
|
319
320
|
}
|
|
320
321
|
}
|
|
@@ -445,18 +446,23 @@ function enabledRules(rules, config) {
|
|
|
445
446
|
return rules.filter((rule) => config.rules?.[rule.name] !== false);
|
|
446
447
|
}
|
|
447
448
|
/**
|
|
448
|
-
* List the skills the `skills` CLI installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
449
|
-
* the links this tool placed keep their own list.
|
|
449
|
+
* List the skills the `skills` CLI and graphify installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
450
|
+
* of git, and the links this tool placed keep their own list.
|
|
450
451
|
*/
|
|
451
452
|
function recordSyncedSkills(cwd) {
|
|
452
|
-
const synced =
|
|
453
|
+
const synced = readSyncedSkills(cwd);
|
|
453
454
|
for (const dir of AGENT_DIRS) {
|
|
454
455
|
const root = path.join(cwd, dir, "skills");
|
|
455
456
|
if (!lstat(root)?.isDirectory()) continue;
|
|
456
457
|
const gitignore = path.join(root, GITIGNORE);
|
|
457
|
-
writeManifest(gitignore, readManifest(gitignore), synced.filter((name) =>
|
|
458
|
+
writeManifest(gitignore, readManifest(gitignore), [.../* @__PURE__ */ new Set([...synced, GRAPHIFY_SKILL])].filter((name) => isToolSkill(path.join(root, name), synced)));
|
|
458
459
|
}
|
|
459
460
|
}
|
|
461
|
+
/** A skill a tool installed: the `skills` CLI (its lock lists it) or graphify (its stamp is inside). */
|
|
462
|
+
function isToolSkill(entry, synced) {
|
|
463
|
+
const name = path.basename(entry);
|
|
464
|
+
return !!lstat(entry) && (synced.has(name) || name === "graphify" && isGraphifySkill(entry));
|
|
465
|
+
}
|
|
460
466
|
/**
|
|
461
467
|
* Make `rules` and `skills` real directories in every agent dir and link the top-level entries we know into them:
|
|
462
468
|
* package rule files into both, pointing straight at the package, the user's own `.agents` entries into `.claude`.
|
|
@@ -538,9 +544,9 @@ function symlinkClaudeMd(cwd) {
|
|
|
538
544
|
*
|
|
539
545
|
* The links are plain, never `@path` imports: Claude Code loads `.claude/rules` itself (syncAgentDirs() links them
|
|
540
546
|
* there) and honours each rule's `paths`, while an `@` import would load every rule into every session, scoped or not.
|
|
541
|
-
* Codex, which expands no `@`, reads this index.
|
|
547
|
+
* Codex, which expands no `@`, reads this index. `graphifySection` (graphify.ts) follows the tool sections.
|
|
542
548
|
*/
|
|
543
|
-
function generateAgentsFile(rules, customSection, previous = "") {
|
|
549
|
+
function generateAgentsFile(rules, customSection, previous = "", graphifySection) {
|
|
544
550
|
const entries = rules.map((rule) => {
|
|
545
551
|
const rulePath = `${CANONICAL_AGENT_DIR}/rules/${rule.file}`;
|
|
546
552
|
const description = rule.description ? ` — ${rule.description}` : "";
|
|
@@ -552,6 +558,7 @@ function generateAgentsFile(rules, customSection, previous = "") {
|
|
|
552
558
|
const to = from === -1 ? -1 : previous.indexOf(end, from);
|
|
553
559
|
return to === -1 ? `${start}\n${end}` : previous.slice(from, to + end.length);
|
|
554
560
|
});
|
|
561
|
+
if (graphifySection) sections.push(graphifySection);
|
|
555
562
|
const generated = `${HEADER}\n\n# Rules\n\n${entries.join("\n")}\n\n${sections.join("\n\n")}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
|
|
556
563
|
return customSection ? `${generated}\n\n${customSection}\n` : `${generated}\n`;
|
|
557
564
|
}
|
|
@@ -602,6 +609,8 @@ async function main() {
|
|
|
602
609
|
const config = await resolveLintConfig({}, root);
|
|
603
610
|
const rules = enabledRules(readRules(), config);
|
|
604
611
|
console.log(`Found ${rules.length} rule files: ${rules.map((r) => r.name).join(", ")}`);
|
|
612
|
+
const graphify = setUpGraphify(cwd, config.graphify, spawnSync);
|
|
613
|
+
writeGitignoreBlock(cwd, graphify.mode);
|
|
605
614
|
const userEntries = readUserEntries(cwd);
|
|
606
615
|
syncAgentDirs(cwd, packageEntries(rules), userEntries);
|
|
607
616
|
console.log(`Synced ${AGENT_DIRS.join(", ")}, mirrored ${userEntries.size} own entries from ${CANONICAL_AGENT_DIR}`);
|
|
@@ -611,11 +620,13 @@ async function main() {
|
|
|
611
620
|
syncRemoteSkills(cwd, plan.remote);
|
|
612
621
|
recordSyncedSkills(cwd);
|
|
613
622
|
const previous = exists ? fs.readFileSync(targetPath, "utf-8") : "";
|
|
614
|
-
const
|
|
623
|
+
const graphifySection = graphify.mode === "venv" ? graphifyAgentsSection(previous) : void 0;
|
|
624
|
+
const content = generateAgentsFile(installedRules(rules, userEntries), customSection, previous, graphifySection);
|
|
615
625
|
fs.writeFileSync(targetPath, content, "utf-8");
|
|
616
626
|
console.log(`${exists ? "Updated" : "Created"} ${AGENTS_FILE}`);
|
|
617
627
|
symlinkClaudeMd(cwd);
|
|
618
628
|
console.log(`Symlinked ${CLAUDE_FILE} -> ${AGENTS_FILE}`);
|
|
629
|
+
finishGraphify(cwd, graphify, spawnSync);
|
|
619
630
|
return;
|
|
620
631
|
}
|
|
621
632
|
console.log(`Unknown command: ${command}`);
|
package/dist/vitePlus.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.8.
|
|
7
|
+
"version": "0.8.9",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"skipGenerate": true,
|
|
10
10
|
"bin": {
|
|
@@ -153,6 +153,9 @@
|
|
|
153
153
|
"optional": true
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
|
+
"engines": {
|
|
157
|
+
"uv": ">=0.11"
|
|
158
|
+
},
|
|
156
159
|
"publishConfig": {
|
|
157
160
|
"access": "public"
|
|
158
161
|
},
|