Skip to content

CTORNDGAIN-1321: Hooks runtime, md-file-advisory hook, plugin sync improvements#75

Merged
isolomatov-gd merged 9 commits into
v3from
ctorndgain-1321_mk
Apr 29, 2026
Merged

CTORNDGAIN-1321: Hooks runtime, md-file-advisory hook, plugin sync improvements#75
isolomatov-gd merged 9 commits into
v3from
ctorndgain-1321_mk

Conversation

@mkuznietsov
Copy link
Copy Markdown
Contributor

Summary

CTORNDGAIN-1321

  • Implement common hook input adapter: normalize IDE hooks (Claude Code, Codex, Copilot, Cursor, Windsurf) to a canonical format with per-IDE output formatting
  • Add md-file-advisory hook — advisory context injected on markdown file edits
  • Generalize build-bundles.mjs to iterate a HOOK_SOURCES array instead of hardcoding a single entry point
  • Register new hooks in hooks.json configs across all IDE plugins (Claude, Codex, Copilot, Cursor)
  • Add r3 instruction set (skills, agents, workflows, rules, configure docs)
  • Plugin generator improvements and Copilot plugin support
  • MCP bundler and instruction tool fixes, verify_mcp updates
  • Rosettify version bump and test config update
  • Documentation: ARCHITECTURE.md, CODEMAP.md, TECHSTACK.md, DEPENDENCIES.md, PATTERNS, ASSUMPTIONS

Test plan

  • node --test passes for all hooks tests (adapter, loose-files, md-file-advisory, lock)
  • build-bundles.mjs produces bundles for all 5 IDEs with both loose-files.js and md-file-advisory.js
  • scripts/pre_commit.py copies built bundles into all plugin folders correctly
  • MCP validation: verify_mcp.py passes for r2
  • MCP unit tests pass (pytest ims-mcp-server/tests/)
  • Rosettify tests pass (npm run test in rosettify/)

- New hook: md-file-advisory.ts with tests and per-IDE bundles
- Refactor build-bundles.mjs to iterate HOOK_SOURCES array instead of hardcoding a single entry
- Register md-file-advisory.js in hooks.json configs for Claude, Codex, Copilot, Cursor
- Document HOOK_SOURCES registration step in ARCHITECTURE.md
- Add .codex to .gitignore

Made-with: Cursor
@github-actions github-actions Bot added enhancement New feature or request documentation Improvements or additions to documentation labels Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Rosetta Triage Review

Summary: Implements the md-file-advisory hook (CTORNDGAIN-1321) that advises AI agents when Markdown files are created outside standard Rosetta documentation locations, with a generalized build system and multi-IDE hook registration across Claude Code, Codex, Copilot, and Cursor.

Findings:

  • Test coverage is comprehensive (237-line test suite covering pure-function unit tests and integration tests for both Claude Code and Cursor output formats, including error-handling edge cases)
  • Build system refactoring from a single hardcoded entry point to a HOOK_SOURCES array in build-bundles.mjs is clean and extensible — adding future hooks now requires one line
  • hooks/dist/src/md-file-advisory.js (intermediate compiled output) is committed alongside the TypeScript source; .gitignore excludes hooks/dist/bundles/ but not hooks/dist/src/ — verify this is intentional and not an accidental commit of build artifacts
  • Per-IDE compiled bundles (plugins/core-*/hooks/md-file-advisory.js) are committed as expected per the pre_commit.py workflow
  • PR is substantial (~1,361 net lines) spanning hook implementation, build system, plugin configs, and documentation; the PR description also mentions r3 instruction set, plugin generator improvements, MCP bundler fixes, and rosettify changes that are not fully visible in the displayed diff — ensure all areas receive review coverage
  • CTORNDGAIN-1321 is currently in Blocked status in Jira — confirm blocker dependencies are resolved before merging

Suggestions:

  • Consider whether hooks/dist/src/md-file-advisory.js should be added to .gitignore alongside hooks/dist/bundles/, or document why the dist/src/ pre-compiled artifact is intentionally tracked
  • Update CTORNDGAIN-1321 status in Jira once blocker is cleared to keep traceability aligned with the PR

Automated triage by Rosetta agent

Copy link
Copy Markdown
Contributor

@isolomatov-gd isolomatov-gd left a comment

Choose a reason for hiding this comment

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

hooks.json.tmpl is missing in core-copilot and in core-cursor.
md-file-advisory.js is missing in core-codex.

Comment thread .gitignore Outdated
rosetta-mcp-server/dist

#codex
.codex No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will make all folders regardless where they are to be ignored. Technically this should be committed as well, likely this was used for testing, so I suggest deleting this change in .gitignore and deleting test .codex folder too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

];

// Hook source files to bundle per plugin.
const HOOK_SOURCES = ['loose-files.ts', 'md-file-advisory.ts'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we list all *.ts files in hooks/src and use it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, this would be a bad idea, and here's why:
Not all .ts files in hooks/src are hook entry points. Looking at the directory, there are 16 .ts files there, but most are internal modules:
adapter.ts — shared adapter interface
types.ts, lock.ts, debug-log.ts — utility/support modules
entrypoints/adapter-.ts — per-IDE adapter implementations
adapters/
.ts — adapter logic

@@ -13,6 +13,10 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

'.codex' folder contains also 'hooks' folder there should be added the file with the hook

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, the file was missed from the commit. Will add it now.

@@ -0,0 +1,230 @@
"use strict";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In plugins/core-copilot/.github/plugin folder hooks.json and hooks.json.tmpl should be modified. We don't need to add the hook itself there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, will remove the hook file from .github/plugin/ and add the md-file-advisory entry to hooks.json and hooks.json.tmpl instead.

@@ -0,0 +1,231 @@
"use strict";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In plugins/core-copilot/hooks folder hooks.json and hooks.json.tmpl should be modified also

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed

@@ -0,0 +1,231 @@
"use strict";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hooks.json in core-copilot folder should be also modified

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,201 @@
"use strict";
Copy link
Copy Markdown
Contributor

@YevheniiaLementova YevheniiaLementova Apr 28, 2026

Choose a reason for hiding this comment

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

In plugins/core-cursor/hooks folder hooks.json and hooks.json.tmpl should be modified as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Contributor

@YevheniiaLementova YevheniiaLementova left a comment

Choose a reason for hiding this comment

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

According to the example with loose-files.js, I think hooks/dist/bundles should also contain hook files for every tool (core-claude, core-codex, core-copilot, etc.)

UPD: Turns out hooks/dist/bundles is in .gitignore, so it’s not relevant after all.

maksym.kuznietsov added 4 commits April 28, 2026 14:02
Remove md-file-advisory.js from .github/plugin/ (not needed there) and
add the md-file-advisory hook entry to PostToolUse in both hooks.json
and hooks.json.tmpl so the hook is properly invoked at runtime.

Made-with: Cursor
Add md-file-advisory.js entry to PostToolUse in both hooks.json and
hooks.json.tmpl under plugins/core-copilot/hooks/.

Made-with: Cursor
Add md-file-advisory.js entry to postToolUse in both hooks.json and
hooks.json.tmpl under plugins/core-cursor/hooks/.

Made-with: Cursor
Comment thread hooks/src/md-file-advisory.ts Outdated
import type { CanonicalOutput } from './types';

export const ADVISORY_MESSAGE =
'[Rosetta Advisory] This Markdown file is outside standard Rosetta documentation locations ' +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Rosetta Advisory] {file-name} is created in non-standard location, think if it is truly needed or you should have updated existing file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

{file-name} to be replaced with file name without path.

Comment thread hooks/src/md-file-advisory.ts Outdated
const normalized = normalize(raw);
const filePath =
(normalized.tool_input?.file_path as string) ||
(normalized.tool_input?.path as string) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This normalization belongs to common adapter. Moreover, you should also check for filePath (this is copilot standard)

import { readStdin, normalize, formatOutput, detectIDE } from './adapter';
import { debugLog } from './debug-log';
import type { CanonicalOutput } from './types';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are missing filter by ALLOWED_TOOLS (see example in loose-files). So that we only react to creation of files. Otherwise there will be a lot of noise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added but now we need review and make BIG re-test =)

maksym.kuznietsov added 4 commits April 28, 2026 22:48
Gate md-file-advisory on PostToolUse event and file-write tools only
(Write, Edit, apply_patch, create_file, etc.) to prevent noise from
Read, Bash, Search and other non-mutating tools. Extract getFilePath()
helper with file_path/filePath/path priority chain and apply_patch
command parsing. Add 29 new tests covering shouldCheck, getFilePath,
and integration scenarios for filtered tools.

Addresses PR #75 review comment from isolomatov-gd.
Made-with: Cursor
Remove stale .codex ignore rule and trailing-newline fix in .gitignore.
Add md-file-advisory.js hook entry to core-copilot/hooks.json PostToolUse.

Made-with: Cursor
Replace static ADVISORY_MESSAGE constant with advisoryMessage(filePath)
that interpolates the file's basename into the message, per reviewer
suggestion: "[Rosetta Advisory] {name} is created in non-standard
location, think if it is truly needed or you should have updated
existing file."

Addresses PR #75 review comment from isolomatov-gd.
Made-with: Cursor
The reviewer (PR #75 comment #3) noted that filePath normalization
logic was duplicated in each hook and belonged in the common adapter.
Added extractFilePath() to adapter.ts, enriched normalize() to
populate file_path on NormalizedInput, and removed duplicate
getFilePath() from md-file-advisory.ts and loose-files.ts.
This also fixes loose-files missing the `path` key fallback.

Made-with: Cursor
sharkich added a commit that referenced this pull request Apr 29, 2026
@isolomatov-gd isolomatov-gd merged commit f8a64f6 into v3 Apr 29, 2026
1 check passed
sharkich added a commit that referenced this pull request Apr 30, 2026
Brings in hooks runtime adapter, md-file-advisory hook, r3 instruction set,
plugin generator improvements, and analytics changes from PR #75.
Conflict resolution:
- agents/MEMORY.md: both sides' entries preserved
- analytics/tracker.py: mypy fixes (PR #73) + analytics changes (PR #75) both kept
- plugins/*/hooks.json: regenerated via build-bundles.mjs; both md-file-advisory
  (PR #75) and loose-files creation-only matchers (PR #73) present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants