@nitra/cursor 1.13.87 → 1.13.89

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/CHANGELOG.md CHANGED
@@ -4,6 +4,27 @@
4
4
 
5
5
  Формат — [Keep a Changelog](https://keepachangelog.com/uk/1.1.0/), нумерація — [SemVer](https://semver.org/lang/uk/).
6
6
 
7
+ ## [1.13.89] - 2026-05-23
8
+
9
+ ### Changed
10
+
11
+ - **Stop-hook кличе `fix` замість deprecated `check`:** `scripts/claude-stop-hook.mjs` тепер спавнить `npx --no @nitra/cursor fix` — без deprecation-warning'а на кожен Stop event Claude Code.
12
+ - **`.claude-template/commands/n-check.md` видалено** (разом з локальним `.claude/commands/n-check.md`). Після CLI-перейменування `check` → `fix` slash-команда `/n-check` вказувала на застарілу команду. У `syncClaudeConfig` логіка sync `commands/*.md` залишилась; зараз темплейт порожній. Тест `створює settings.json + slash-команди` переписано на «без slash-команд, коли темплейт порожній».
13
+ - **JSDoc/docstring чистка:** `bin/n-cursor.js` (CLI usage header), `scripts/claude-stop-hook.mjs`, `scripts/sync-claude-config.mjs`, `rules/image-compress/js/package_setup/check.mjs` — згадки `npx @nitra/cursor check`, `/n-check`, `npm/scripts/check-*.mjs` оновлено на актуальну CLI (`fix`) і шляхи (`rules/<id>/fix.mjs`, `rules/<id>/js/<concern>/check.mjs`).
14
+ - **`.cursor/rules/conftest.mdc`** — алгоритм рішення / патерн Rego-authoritative / Workflow / Red-flags переписано під фактичну структуру `rules/<rule>/js/<concern>/check.mjs` + `rules/<rule>/policy/<name>/`. Прибрано згадки `npm/scripts/check-<rule>.mjs` та `npm/policy/<rule>/` (legacy шляхи); приклади `check abie`, `check ga` → `fix abie`, `fix ga`.
15
+ - **`docs/fix-cursor-skill.md`** — ASCII-діаграми, workflow-кроки та таблиця "Анатомія Skill-файлу" → `npx @nitra/cursor fix`; згадка `check-*.mjs скрипти` → `rules/<id>/fix.mjs правил`.
16
+
17
+ ### Notes
18
+
19
+ - Споживачі: після оновлення вручну видалити `.claude/commands/n-check.md` (sync не вичищає orphan slash-команди з темплейту). Активна команда — `/n-fix` (зі скілу `n-fix`).
20
+ - В `.claude/settings.json` permission `Bash(npx @nitra/cursor check)` видалено як redundant — вайлдкард `Bash(npx @nitra/cursor *)` нижче вже покриває обидві команди.
21
+
22
+ ## [1.13.88] - 2026-05-23
23
+
24
+ ### Changed
25
+
26
+ - **`scripts/utils/with-lock.mjs` + тести:** локальна `sleep(ms)` через `new Promise(r => setTimeout(r, ms))` замінена на іменований імпорт `setTimeout as sleep` із `node:timers/promises`. Відповідає правилу `js-run` (без ручних `setTimeout`-промісів) — перевірка `npx @nitra/cursor fix js-run` стала зеленою.
27
+
7
28
  ## [1.13.87] - 2026-05-23
8
29
 
9
30
  ### Added
package/bin/n-cursor.js CHANGED
@@ -5,12 +5,12 @@
5
5
  *
6
6
  * Використання:
7
7
  * `npx \@nitra/cursor` — завантажити cursor-правила
8
- * `npx \@nitra/cursor check` — перевірити правила з `.cursor/rules/*.mdc`, для яких у пакеті є check/policy;
8
+ * `npx \@nitra/cursor fix` — перевірити правила з `.cursor/rules/*.mdc`, для яких у пакеті є `fix.mjs`/policy;
9
9
  * якщо в корені вже є `.n-cursor.json`, спочатку зчитується конфіг і за потреби дописується `$schema`
10
- * `npx \@nitra/cursor check bun` — перевірити лише вказані правила (ігнорує `.cursor/rules/`)
10
+ * `npx \@nitra/cursor fix bun` — перевірити лише вказані правила (ігнорує `.cursor/rules/`)
11
11
  * `npx \@nitra/cursor rename-yaml-extensions` — k8s `*.yml` → `*.yaml`, `.github` `*.yaml` → `*.yml` (опції: `--dry-run`, `--root=…`; див. bin/rename-yaml-extensions.mjs)
12
12
  * `npx \@nitra/cursor stop-hook` — точка входу Stop hook Claude Code (читає stdin, виходить 0 при `stop_hook_active`,
13
- * інакше викликає `check`); прописується автоматично в `.claude/settings.json`
13
+ * інакше викликає `fix`); прописується автоматично в `.claude/settings.json`
14
14
  * `npx \@nitra/cursor lint-ga` — канонічний lint-ga (ga.mdc): preflight на `shellcheck` →
15
15
  * `bunx github-actionlint` → `uvx zizmor --offline --collect=workflows .`
16
16
  * `npx \@nitra/cursor lint-rego` — канонічний lint-rego (conftest.mdc + rego.mdc):
@@ -25,9 +25,8 @@
25
25
  * `npx \@nitra/cursor skill claude taze ["task"]` — Claude Code CLI (`claude -p`)
26
26
  *
27
27
  * Agent інтеграція: під час синку, окрім `.cursor/rules` і `.claude/commands` (з skills), CLI ще раз
28
- * синхронізує `.claude/settings.json` (hooks + permissions; merge — користувацькі поля зберігаються),
29
- * `.cursor/hooks.json` (Cursor Agent hooks; merge — користувацькі hooks зберігаються),
30
- * і slash-команди checks (`/n-check`).
28
+ * синхронізує `.claude/settings.json` (hooks + permissions; merge — користувацькі поля зберігаються)
29
+ * і `.cursor/hooks.json` (Cursor Agent hooks; merge — користувацькі hooks зберігаються).
31
30
  * Опт-аут — поле `claude-config: false` у `.n-cursor.json`.
32
31
  *
33
32
  * Якщо у корені репозиторію немає .n-cursor.json, спочатку перейменовується за наявності nitra-cursor.json;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/cursor",
3
- "version": "1.13.87",
3
+ "version": "1.13.89",
4
4
  "description": "CLI для завантаження cursor-правил (префікс n-) у локальний репозиторій",
5
5
  "keywords": [
6
6
  "cli",
@@ -9,8 +9,8 @@
9
9
  * - застарілий `.minify-image-cache.tsv` (з версій < 3.2) видалений з кореня та
10
10
  * з `.gitignore`.
11
11
  *
12
- * **Що покрила Rego** (`npx \@nitra/cursor check`,
13
- * `npm/policy/image_compress/package_json/`):
12
+ * **Що покрила Rego** (`npx \@nitra/cursor fix`,
13
+ * `npm/rules/image-compress/policy/package_json/`):
14
14
  * - `scripts.lint-image` викликає `npx \@nitra/minify-image --src=. --write`
15
15
  * без `--avif` (AVIF — окреме правило `image-avif`);
16
16
  * - агрегований `lint` (якщо є) містить `bun run lint-image`;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stop-hook для Claude Code: запускається hook'ом із `.claude/settings.json` після того,
3
- * як агент сигналізує завершення ходу. Прозоро прокидає `npx \@nitra/cursor check`
3
+ * як агент сигналізує завершення ходу. Прозоро прокидає `npx \@nitra/cursor fix`
4
4
  * і повертає його exit code, щоб помилки правил блокували завершення.
5
5
  *
6
6
  * Захист від нескінченної рекурсії: якщо stdin містить `"stop_hook_active": true`
@@ -63,7 +63,7 @@ export async function runStopHookCli() {
63
63
  return 0
64
64
  }
65
65
 
66
- const child = spawn('npx', ['--no', '@nitra/cursor', 'check'], { stdio: 'inherit' })
66
+ const child = spawn('npx', ['--no', '@nitra/cursor', 'fix'], { stdio: 'inherit' })
67
67
  try {
68
68
  const [code] = await once(child, 'exit')
69
69
  return code ?? 1
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * Синхронізує конфігурацію Claude Code (`.claude/settings.json`,
3
- * slash-команди для checks, ADR Stop-hook) і Cursor hooks (`.cursor/hooks.json`)
4
- * у поточний проєкт із темплейтів пакету
3
+ * slash-команди з `commands/` темплейту, ADR Stop-hook) і Cursor hooks
4
+ * (`.cursor/hooks.json`) у поточний проєкт із темплейтів пакету
5
5
  * `npm/.claude-template/`.
6
6
  *
7
7
  * Архітектура:
8
8
  * - `settings.json` — **merge**: користувацькі поля зберігаються; наші hooks
9
9
  * ідентифікуються командою-маркером (`MANAGED_HOOK_COMMAND_MARKERS`) і
10
10
  * перезаписуються; permissions.allow зливається через union (із дедублікацією).
11
- * - `.claude/commands/n-check.md` — fully owned slash-команда.
11
+ * - `.claude/commands/*.md` — fully owned slash-команди з темплейту
12
+ * `.claude-template/commands/` (зараз порожньо; sync no-op).
12
13
  * - `.claude/hooks/capture-decisions.sh` — fully owned bash-скрипт ADR capture Stop-hook;
13
14
  * копіюється з `.claude-template/hooks/`, лише коли в `.n-cursor.json` `rules`
14
15
  * присутнє `adr` (правило увімкнене за замовчуванням; вимикається через
@@ -5,21 +5,23 @@
5
5
  import * as fs from 'node:fs'
6
6
  import * as path from 'node:path'
7
7
  import * as os from 'node:os'
8
+ import { setTimeout as sleep } from 'node:timers/promises'
8
9
  import { worktreeFingerprint } from './worktree-fingerprint.mjs'
9
10
 
10
11
  const DEFAULTS = {
11
12
  ttl: 600_000,
12
13
  staleThreshold: 1_800_000,
13
14
  waitTimeout: 1_200_000,
14
- pollInterval: 1_500,
15
+ pollInterval: 1_500
15
16
  }
16
17
 
17
18
  function isAlive(pid) {
18
- try { process.kill(pid, 0); return true } catch { return false }
19
- }
20
-
21
- function sleep(ms) {
22
- return new Promise(r => setTimeout(r, ms))
19
+ try {
20
+ process.kill(pid, 0)
21
+ return true
22
+ } catch {
23
+ return false
24
+ }
23
25
  }
24
26
 
25
27
  function makeRelease(lockDir) {
@@ -67,18 +69,23 @@ export async function withLock(key, runFn, opts = {}) {
67
69
  }
68
70
  try {
69
71
  fs.mkdirSync(lockDir)
70
- fs.writeFileSync(ownerFile, JSON.stringify({ pid: process.pid, host: os.hostname(), startedAt: Date.now(), fingerprint }))
72
+ fs.writeFileSync(
73
+ ownerFile,
74
+ JSON.stringify({ pid: process.pid, host: os.hostname(), startedAt: Date.now(), fingerprint })
75
+ )
71
76
  locked = true
72
77
  break
73
78
  } catch (error) {
74
79
  if (error.code !== 'EEXIST') throw error
75
80
  let owner
76
- try { owner = JSON.parse(fs.readFileSync(ownerFile, 'utf8')) } catch {
81
+ try {
82
+ owner = JSON.parse(fs.readFileSync(ownerFile, 'utf8'))
83
+ } catch {
77
84
  fs.rmSync(lockDir, { recursive: true, force: true })
78
85
  continue
79
86
  }
80
- const stale = (Date.now() - owner.startedAt > staleThreshold) ||
81
- (os.hostname() === owner.host && !isAlive(owner.pid))
87
+ const stale =
88
+ Date.now() - owner.startedAt > staleThreshold || (os.hostname() === owner.host && !isAlive(owner.pid))
82
89
  if (stale) {
83
90
  console.error(`🧹 ${key}: знайдено застарілий лок — очищаю`)
84
91
  fs.rmSync(lockDir, { recursive: true, force: true })
@@ -100,9 +107,14 @@ export async function withLock(key, runFn, opts = {}) {
100
107
  release()
101
108
  return 0
102
109
  }
103
- } catch { /* result.json не існує або пошкоджений */ }
110
+ } catch {
111
+ /* result.json не існує або пошкоджений */
112
+ }
104
113
 
105
- const onSignal = () => { release(); process.exit(130) }
114
+ const onSignal = () => {
115
+ release()
116
+ process.exit(130)
117
+ }
106
118
  process.once('SIGINT', onSignal)
107
119
  process.once('SIGTERM', onSignal)
108
120
 
@@ -1,11 +0,0 @@
1
- ---
2
- description: >-
3
- Запустити всі програмні перевірки правил (`npx @nitra/cursor fix`)
4
- ---
5
-
6
- # n-check
7
-
8
- Запусти `npx @nitra/cursor fix` і пройдися по результатах.
9
-
10
- - Якщо є помилки — виправи відповідно до правила, на яке вказує перевірка.
11
- - Якщо все чисто — підтверди коротким повідомленням і переходь до наступного кроку.