Skip to content

Develop#19

Merged
sampleXbro merged 9 commits into
masterfrom
develop
Apr 27, 2026
Merged

Develop#19
sampleXbro merged 9 commits into
masterfrom
develop

Conversation

@sampleXbro

@sampleXbro sampleXbro commented Apr 26, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Test coverage

Checklist

  • Tests written first (TDD)
  • All CI checks pass (pnpm test, pnpm lint, pnpm typecheck)
  • Changeset added (pnpm changeset) for user-visible changes

- Add plugin-error-paths test coverage for CLI plugin command
- Add builtin-targets unit tests for catalog resolution
- Add registry unit tests for target descriptor registration
…PI parity

- Add loadProjectContext() for CLI-parity execution context loading
- Fix loadCanonical() to merge extends and packs when config available
- Fix importFrom() to resolve registered plugin descriptors
- Fix plugin buildImportPaths() hooks for shared import normalization
- Make getTargetCatalog() return immutable snapshots
- Reject non-none capabilities without generators in descriptor registration
- Update all public barrel exports with new types
- Update tests for new API surface and stricter assertions
- Update CHANGELOG with complete API changes
- Add Windows path safety utilities (windows-path-safety.ts)
- Add portable path handling for cross-platform compatibility
- Update install manifest and pack operations for Windows paths
- Update all target skills with prepare-release improvements
- Add Windows support metadata and CI workflow updates
- Add comprehensive Windows path safety tests
- Update documentation for Windows installation
@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.31507% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/public/canonical.ts 95.00% 1 Missing ⚠️
src/public/targets.ts 96.15% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/cli/commands/init.ts 98.38% <100.00%> (+1.61%) ⬆️
src/cli/commands/target-scaffold/templates.ts 100.00% <ø> (ø)
src/core/generate/engine.ts 100.00% <100.00%> (ø)
src/core/generate/feature-loop.ts 100.00% <100.00%> (+25.49%) ⬆️
src/core/generate/optional-features.ts 100.00% <100.00%> (+33.33%) ⬆️
src/core/reference/import-map-shared.ts 98.19% <100.00%> (+1.13%) ⬆️
src/core/reference/import-map.ts 100.00% <100.00%> (ø)
src/core/reference/link-rebaser-helpers.ts 93.90% <100.00%> (ø)
src/core/reference/output-source-map.ts 100.00% <100.00%> (ø)
src/core/reference/pack-skill-artifact-paths.ts 100.00% <100.00%> (ø)
... and 24 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Between mkdir(lockPath) and writeFile(holder.json), a competing
acquirer saw a metadata-less lock dir, treated it as orphaned, and
rm -rf'd the live mutex. Both processes then entered the critical
section concurrently and raced writeFileAtomic on .agentsmesh/.lock,
producing the intermittent CI failure: ENOENT renaming .lock.tmp.

Lock dirs younger than a 2s grace window are now treated as held even
when holder.json is missing; only older dirs without metadata are
considered orphaned and evicted. The grace check accepts negative
ageMs to absorb FS-vs-clock skew under suite load.

Covered by a new unit test in tests/unit/utils/process-lock.test.ts
plus the existing parallel-CLI integration test.
Eight rule generators built the output slug via
rule.source.split('/').pop()!.replace(/\.md$/, ''), which on Windows
where rule.source uses \ separators silently returned the entire
absolute path. Generation then emitted paths like
'.cursor\rules\C:\Users\...\rules' and writeFileAtomic ENOENT'd on
mkdir. All 10 occurrences across claude-code, codex-cli, copilot,
cursor, continue, and catalog now use basename(rule.source, '.md')
from node:path, which honors native separators.

Three importer tests asserted on POSIX-style fromPath substrings
(.codex/agents/..., .gemini/antigravity/workflows, etc.) which fail
on Windows where fromPath legitimately uses \. Added
tests/helpers/posix-path.ts toPosixPath() and applied it to the
codex/junie/antigravity assertions.

src/cli/commands/watch.ts now sets usePolling: process.platform ===
'win32' on chokidar.watch — ReadDirectoryChangesW under the GitHub
Actions AppData\Local\Temp short-name path misses events for files
newly created in just-watched subdirectories. macOS/Linux keep the
native watcher.
Production fixes:
- buildArtifactPathMap, addPackSkillArtifactMappings,
  applyCopilotInstructionArtifactRefs, collectPlannedPaths, and the
  generated-markdown-link validator all used native node:path.join /
  normalize. The link rebaser uses pathApi(projectRoot) which is path-
  format-aware, not host-platform-aware. The mismatch silently no-op'd
  the rewriter when synthetic POSIX project roots were combined with a
  Windows host (or vice versa). All five sites now route through
  pathApi(projectRoot) so map keys and lookups always agree.
- tests/fixtures/plugins/rich-plugin/index.js: rule.source.split('/')
  swapped for path.basename — same Windows pattern as the builtin
  generators.

Test-side fixes (no behavior change):
- matrix-codegen + matrix-drift-guard execFileSync('tsx', ...) needs
  shell:true on Windows to invoke tsx.cmd.
- github-remote.test.ts mock buildCacheKey replaces ':' with '_' so the
  resulting cache dir name is Windows-safe.
- agents.e2e.test.ts bodyWithoutFrontmatter regex normalizes CRLF first
  so Windows checkouts (autocrlf) parse correctly.
- windows-support-metadata.test.ts CRLF normalization on read.
- skills.test.ts hardcodes the POSIX relativePath the parser intentionally
  emits.
- install-sync, run-install-pack, run-install, generate, extends-native,
  git-remote, native-skill-scan tests use platform-agnostic regex / join
  for path assertions.

Skipped on Windows (CI environment limits, behavior unaffected):
- install-remote.e2e and extends.e2e refresh-cache: stub git via
  chmod-755 Node script and NODE_OPTIONS=--import; neither works on
  Windows.
- generate-global-path-rebasing symlink test: requires admin/dev mode.
- remote-fetcher-git native-format / cached: cache key embeds full
  repo URL, blowing past MAX_PATH on Windows. Hashed cache keys
  would unblock; tracked for follow-up.
…rewrite matrix

- Update artifact-path-map-packs unit tests
- Update generate-reference-rewrite-matrix e2e tests
- Update matrix drift guard integration tests
- Update lessons and agents-last-run tracking
- Update link-rebaser-helpers.ts with improvements
- Update generate-reference-rewrite-matrix e2e tests
- Update import-reference-rewrite e2e tests
- Update lessons and agents-last-run tracking
- Add unit tests for core/reference/ module
- Add portable-paths tests for install module
- Update feature-loop.ts with improvements
- Update programmatic-api integration tests
- Update agents-last-run tracking
@sampleXbro
sampleXbro merged commit a3db667 into master Apr 27, 2026
15 checks passed
sampleXbro pushed a commit that referenced this pull request Jun 3, 2026
Introduces `src/lessons/store.ts` — a target-agnostic high-level layer
that sits between the low-level primitives (parser, matcher, hash) and
the operations every harness needs:

- `loadLessonsIndex(projectRoot)` — parse + validate the canonical
  index from its canonical location.
- `readTriggeredLessons(projectRoot, event)` — normalize tool-event
  paths, match against cluster triggers, return content with
  per-call file-read memoization.
- `formatLessonBullet(input)` — validate + format a capture bullet
  in the canonical journal shape (rejects empty heading / sentence).
- `appendLessonToJournal(projectRoot, input)` — atomic append with
  newline normalization, returns the resolved line number for
  Evidence citations.

**Cross-tool unification.** The store normalizes every Edit/Write
event path to canonical project-relative POSIX form BEFORE applying
`file_globs`. Tools across harnesses give paths in different forms
(absolute `/proj/src/foo.ts`, Windows `C:\proj\src\foo.ts`,
backslash-relative `src\utils\foo.ts`, leading-dot `./src/foo.ts`)
— all now resolve to the same `src/utils/foo.ts` and match the same
glob. This is the single fix that makes triggers behave identically
across Codex (`apply_patch`), Cline (`write_to_file` /
`replace_in_file`), Cursor (IDE), Gemini CLI, Aider, Goose, and
Claude Code.

**Security boundary.** `resolveProjectFile` rejects `..`-escape AND
Windows-absolute paths (`/^[A-Za-z]:[\\/]/`) regardless of host OS,
protecting against malicious or malformed `index.yaml` files reading
outside the project root.

**Import-side safety net.** `src/cli/commands/import.ts` gains
`ensureImportedLessonsSubsystem`: when an imported `_root.md`
contains the lessons paragraph but `.agentsmesh/lessons/index.yaml`
doesn't exist, auto-scaffolds the subsystem so the rule isn't
orphaned. Idempotent.

**Contract matrix lock.** `tests/contract/target-contract.matrix.test.ts`
adds a per-target test: every supported target's generated root file
MUST project the lessons ritual. The e2e matrix gets the same lock.
A future regression in any target's projection pipeline will fail
this gate.

**Public API.** Helpers exported from both `agentsmesh/lessons`
(focused subpath) and the root `agentsmesh` barrel. Programmatic
API test asserts root-barrel exposure.

**Distill test isolation.** Rewrites `distill-tool.integration.test.ts`
to seed an isolated tmpdir with explicit fixtures and invoke the
script via absolute `tsx` path with `cwd=tmpdir`. No longer mutates
the real project journal.

Adds 13 journal entries + 2 topic Rules captured during the work,
including the path-normalization rule (windows-paths #19) and the
`-e`/`--` rg-flag-leading rule (shell-quoting #14).
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.

2 participants