Skip to content

fix(core): static-import gray-matter, ajv-formats, schema.json (v1.5.1)#113

Merged
SingleSourceStudios merged 1 commit into
mainfrom
fix/core-static-imports-1.5.1
Jul 24, 2026
Merged

fix(core): static-import gray-matter, ajv-formats, schema.json (v1.5.1)#113
SingleSourceStudios merged 1 commit into
mainfrom
fix/core-static-imports-1.5.1

Conversation

@SingleSourceStudios

@SingleSourceStudios SingleSourceStudios commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • parser.ts, validator.ts, schema.ts loaded gray-matter/ajv-formats via createRequire and schema.json via readFileSync. That path breaks under single-file bundlers (bun build --compile).
  • Downstream consumers (declarative_agent, marchese_method) were carrying this as a local bun patch. @marchese-md/core already ships the static-import fix; this ports the same pattern here.
  • Switches all three to static ESM imports (import matter from "gray-matter", import schemaJson from "./schema.json" with { type: "json" }), adds resolveJsonModule + schema.json to the core tsconfig include, bumps packages/core to 1.5.1.

Test plan

  • npm run typecheck
  • npm run test (520 passed)
  • npm run build:core

Co-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/core to static ESM imports for gray-matter, ajv-formats, and the embedded schema.json. This restores compatibility with single-file builds (e.g., bun --compile) and releases v1.5.1.

  • Bug Fixes
    • Replace createRequire/readFileSync with static imports, including schema.json via with { type: "json" }.
    • Handle ajv-formats CJS interop and apply formats via an unwrapped default.
    • Use structuredClone of the imported schema.
    • Enable resolveJsonModule and include schema.json in the core tsconfig.
    • Bump @logic-md/core to 1.5.1 and update the changelog.

Written for commit 88fe3d5. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Pre-output quality-gate recovery actions are now preserved in compiled workflows.
    • Execution plans are now included in step traces and graph node metadata for improved visibility.
    • Dry-run execution now uses configured step verification settings.
  • Bug Fixes

    • Improved package compatibility with modern ESM bundlers.
    • Updated schema loading and validation behavior for more reliable packaged builds.
    • Released Core version 1.5.1.

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-security

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Core now loads gray-matter, ajv-formats, and schema.json through static ESM-compatible imports. TypeScript configuration supports JSON modules, the package version is bumped to 1.5.1, and the changelog records these updates and related Core execution changes.

Changes

Core ESM compatibility

Layer / File(s) Summary
Static schema and dependency loading
packages/core/schema.ts, packages/core/parser.ts, packages/core/validator.ts
Runtime filesystem and CommonJS loading are replaced with static ESM-compatible imports, including cloned imported schema data and direct ajv-formats integration.
JSON module build support
tsconfig.json, packages/core/tsconfig.json
TypeScript enables JSON module resolution and includes schema.json in the Core project.
Release metadata and changelog
packages/core/package.json, CHANGELOG.md
The Core package version changes to 1.5.1, and changelog entries document the import compatibility and Core execution updates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the summary and tests, but it is missing the required linked issue, spec impact, and checklist sections. Add the Linked issue and Spec impact sections, and complete the required Checklist items with pass/fail status for each.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the core bundler-compatibility fix and version bump.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/core-static-imports-1.5.1

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SingleSourceStudios
SingleSourceStudios merged commit 4ce3c23 into main Jul 24, 2026
3 of 4 checks passed
@SingleSourceStudios
SingleSourceStudios deleted the fix/core-static-imports-1.5.1 branch July 24, 2026 13:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 54aa001 and 88fe3d5.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • packages/core/package.json
  • packages/core/parser.ts
  • packages/core/schema.ts
  • packages/core/tsconfig.json
  • packages/core/validator.ts
  • tsconfig.json

Comment thread CHANGELOG.md
Comment on lines +30 to +34
## [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`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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

Comment thread packages/core/schema.ts
import { fileURLToPath } from "node:url";
import { Ajv, type ValidateFunction } from "ajv";
import addFormatsMod from "ajv-formats";
import schemaJson from "./schema.json" with { type: "json" };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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/core

Repository: 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)
PY

Repository: 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)
PY

Repository: 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant