fix(core): static-import gray-matter, ajv-formats, schema.json (v1.5.1)#113
Conversation
parser.ts, validator.ts, and schema.ts used createRequire/readFileSync to load CJS deps and the embedded JSON Schema. That path breaks under single-file bundlers (bun build --compile), which downstream consumers (declarative_agent, marchese_method) were carrying as a local bun patch. Switch to static ESM imports, matching the fix already shipped in @marchese-md/core. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013GscHc7L1ssSRzJxYbACzM
|
Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here. |
📝 WalkthroughWalkthroughCore now loads ChangesCore ESM compatibility
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 30-34: Prune CHANGELOG.md to retain only the latest 20 release
entries, including [1.5.1], and remove older entries beyond that rolling window
without changing the remaining entry content.
In `@packages/core/schema.ts`:
- Line 10: Update the `@logic-md/core` compatibility contract for the JSON import
attribute in schema.ts: either replace the import-attribute usage with an
approach supported by the declared Node 18 floor, or raise the package.json Node
engine requirement to the minimum version that guarantees it (Node 20+). Keep
the tsconfig module setting and schema loading behavior consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 876fd135-7c05-48c8-bbde-b4a26e595aea
📒 Files selected for processing (7)
CHANGELOG.mdpackages/core/package.jsonpackages/core/parser.tspackages/core/schema.tspackages/core/tsconfig.jsonpackages/core/validator.tstsconfig.json
| ## [1.5.1] - 2026-07-24 | ||
|
|
||
| ### Fixed | ||
| - Core: `schema.ts`, `parser.ts`, `validator.ts` load `gray-matter`/`ajv-formats`/`schema.json` via static ESM imports instead of `createRequire`/`readFileSync`. The `createRequire` path broke under single-file bundlers (bun `--compile`); consumers were carrying this as a local patch. Matches the fix already shipped in `@marchese-md/core`. | ||
|
|
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Prune the changelog to the required 20-entry rolling window.
The file now contains substantially more than 20 notable entries, so adding [1.5.1] without removing older entries violates the repository’s changelog policy. Retain the latest 20 entries and move older history to git history or a separate archive.
As per coding guidelines, CHANGELOG.md maintains a rolling log of the last 20 entries.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@CHANGELOG.md` around lines 30 - 34, Prune CHANGELOG.md to retain only the
latest 20 release entries, including [1.5.1], and remove older entries beyond
that rolling window without changing the remaining entry content.
Source: Coding guidelines
| import { fileURLToPath } from "node:url"; | ||
| import { Ajv, type ValidateFunction } from "ajv"; | ||
| import addFormatsMod from "ajv-formats"; | ||
| import schemaJson from "./schema.json" with { type: "json" }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n \
--glob 'package.json' \
--glob '*.yml' \
--glob '*.yaml' \
--glob '.nvmrc' \
--glob '.node-version' \
--glob '.tool-versions' \
'"type"|"engines"|node-version|NODE_VERSION|bun' .
rg -n 'schema\.json|with \{ type: "json" \}' packages/coreRepository: SingularityAI-Dev/logic-md
Length of output: 1279
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- package engines ---\n'
python3 - <<'PY'
import json, pathlib
for p in sorted(pathlib.Path('.').rglob('package.json')):
if any(s in p.parts for s in ('node_modules', '.git')):
continue
try:
data=json.loads(p.read_text())
except Exception as e:
continue
fields={k:data.get(k) for k in ('type','engines') if k in data}
if fields:
print(f'{p}: {fields}')
PY
printf '\n--- core package metadata relevant to engines/typescript/bundlers ---\n'
sed -n '1,120p' packages/core/package.json
printf '\n--- TypeScript configs ---\n'
for f in package.json tsconfig.json packages/*/tsconfig.json; do
[ -f "$f" ] && { echo "===== $f ====="; sed -n '1,160p' "$f"; }
done
printf '\n--- CI/workflow node versions and package manager hints ---\n'
rg -n --glob '*.yml' --glob '*.yaml' --glob 'package-lock.json' --glob 'pnpm-lock.yaml' --glob 'bun.lockb' --glob 'bun.lock' 'node:|node-version|npm|pnpm|corepack|bun|engines|types' .github package.json packages/core/package.json packages/cli/package.json packages/mcp/package.json || true
printf '\n--- Read packages/core/schema.ts relevant lines ---\n'
sed -n '1,80p' packages/core/schema.ts
printf '\n--- static check: JSON import attribute usage ---\n'
python3 - <<'PY'
from pathlib import Path
for p in Path('.').rglob('*.ts'):
if not p.match('*schema.ts'):
continue
s=p.read_text()
if 'with { type: "json" }' in s or "with { type: 'json' }" in s:
print(p)
PYRepository: SingularityAI-Dev/logic-md
Length of output: 255
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- package engines ---'
python3 - <<'PY'
import json, pathlib
for p in sorted(pathlib.Path('.').rglob('package.json')):
if any(s in p.parts for s in ('node_modules', '.git')):
continue
try:
data=json.loads(p.read_text())
except Exception as e:
continue
fields={k:data.get(k) for k in ('type','engines') if k in data}
if fields:
print(f"{p}: {fields}")
PY
printf '%s\n' ''
printf '%s\n' '--- core package metadata relevant to engines/typescript/bundlers ---'
sed -n '1,120p' packages/core/package.json
printf '%s\n' ''
printf '%s\n' '--- TypeScript configs ---'
for f in package.json tsconfig.json packages/*/tsconfig.json; do
if [ -f "$f" ]; then
echo "===== $f ====="
sed -n '1,160p' "$f"
fi
done
printf '%s\n' ''
printf '%s\n' '--- CI/workflow node versions and package manager hints ---'
rg -n --glob '*.yml' --glob '*.yaml' --glob 'package-lock.json' --glob 'pnpm-lock.yaml' --glob 'bun.lockb' --glob 'bun.lock' 'node:|node-version|npm|pnpm|corepack|bun|engines|types' .github package.json packages/core/package.json packages/cli/package.json packages/mcp/package.json || true
printf '%s\n' ''
printf '%s\n' '--- Read packages/core/schema.ts relevant lines ---'
sed -n '1,80p' packages/core/schema.ts
printf '%s\n' ''
printf '%s\n' '--- static check: JSON import attribute usage ---'
python3 - <<'PY'
from pathlib import Path
for p in Path('.').rglob('*.ts'):
if not p.name.endswith('schema.ts'):
continue
s=p.read_text()
if 'with { type: "json" }' in s or "with { type: 'json' }" in s:
print(p)
PYRepository: SingularityAI-Dev/logic-md
Length of output: 8005
Raise the @logic-md/core Node engine floor to the JSON import attribute baseline.
packages/core/tsconfig.json is under the root tsconfig with module: "nodenext", and packages/core/package.json only declares node: ">=18", but this import attribute requires Node support not guaranteed by that lower bound. If the package must support Node 18, replace the JSON import attribute with an engine-guaranteed/ bundled alternative, or bump @logic-md/core engines to Node 20+.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/core/schema.ts` at line 10, Update the `@logic-md/core` compatibility
contract for the JSON import attribute in schema.ts: either replace the
import-attribute usage with an approach supported by the declared Node 18 floor,
or raise the package.json Node engine requirement to the minimum version that
guarantees it (Node 20+). Keep the tsconfig module setting and schema loading
behavior consistent.
Source: MCP tools
Summary
parser.ts,validator.ts,schema.tsloadedgray-matter/ajv-formatsviacreateRequireandschema.jsonviareadFileSync. That path breaks under single-file bundlers (bunbuild --compile).@marchese-md/corealready ships the static-import fix; this ports the same pattern here.import matter from "gray-matter",import schemaJson from "./schema.json" with { type: "json" }), addsresolveJsonModule+schema.jsonto the core tsconfiginclude, bumpspackages/coreto 1.5.1.Test plan
npm run typechecknpm run test(520 passed)npm run build:coreCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_013GscHc7L1ssSRzJxYbACzM
Summary by cubic
Fixes bundling failures by switching
@logic-md/coreto static ESM imports forgray-matter,ajv-formats, and the embeddedschema.json. This restores compatibility with single-file builds (e.g., bun--compile) and releases v1.5.1.createRequire/readFileSyncwith static imports, includingschema.jsonviawith { type: "json" }.ajv-formatsCJS interop and apply formats via an unwrapped default.structuredCloneof the imported schema.resolveJsonModuleand includeschema.jsonin the coretsconfig.@logic-md/coreto1.5.1and update the changelog.Written for commit 88fe3d5. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes