-
Notifications
You must be signed in to change notification settings - Fork 0
Refresh canonical skill-lib snapshot #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,15 @@ | ||
| # Repo-local agent skills | ||
| # Local agent skills | ||
|
|
||
| This repo consumes The Interdependency organization skill library. | ||
| This directory contains repo-local copies of canonical skills from | ||
| `The-Interdependency/skill-lib`. | ||
|
|
||
| Canonical source: | ||
| - Preferred: `The-Interdependency/skill-lib` | ||
| - Temporary source: `The-Interdependency/a0/skill-lib` | ||
| Source commit: `c14ee9d500579a4b5d6821f62c9d82ca96e73608` | ||
|
|
||
| Source commit: `The-Interdependency/skill-lib` @ `a0cb6285e37734609b4b487ae4a2e44c6108d2b8` (verbatim sync). | ||
| Repo-local copies are not the source of truth. Edit `skill-lib` first, | ||
| then propagate from the canonical source. | ||
|
|
||
| Installed skills: | ||
| - `msdmd/` — Module Self-Declared Metadata Markdown | ||
| - `test-build/` — test contract metadata blocks | ||
| - `meta-module-build/` — metadata-first module scaffolding | ||
|
|
||
| Agents working in this repo should read `meta-module-build/SKILL.md` before | ||
| creating new modules, routes, services, schemas, adapters, workers, engines, | ||
| UI panels, migrations, or experiments. | ||
| - `meta-module-build/` | ||
| - `msdmd/` | ||
| - `test-build/` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # ratios: loc_comments=128:49 imports_exports=4:7 calls_definitions=51:10 | ||
| # ratios: loc_comments=161:57 imports_exports=4:7 calls_definitions=55:10 | ||
| """Universal msdmd parser — pure stdlib. | ||
|
|
||
| Implements the parser contract from ``msdmd/SKILL.md``: extracts every | ||
|
|
@@ -7,6 +7,8 @@ | |
|
|
||
| Comment marker is auto-detected by file extension. The block syntax | ||
| itself is identical across languages; only the per-line marker changes. | ||
| ``COMMENT_MARKERS`` is public so runners can distinguish parser support | ||
| from their narrower language-specific execution or metric coverage. | ||
|
|
||
| Public API: | ||
|
|
||
|
|
@@ -15,12 +17,13 @@ | |
| walk_tree(root, block_name, *, skip=None, extensions=None) -> tuple[annotated, untested] | ||
|
|
||
| RATIOS is the one msdmd declaration that is *not* a fenced block — it is a | ||
| single comment line carried on a file's first and last non-blank lines. The | ||
| reader for it lives here too, as a sanctioned extension rather than a fork: | ||
| single comment line carried on a file's opening and closing source boundaries. | ||
| A valid interpreter shebang owns literal line 1, so the opening RATIOS line is | ||
| literal line 2 in that case. The reader lives here as a sanctioned extension: | ||
|
|
||
| parse_ratios(text, marker="#") -> list[dict] | ||
| parse_ratios_file(path) -> list[dict] | ||
| ratios_placement(text, marker="#") -> tuple[first_ok, last_ok] | ||
| ratios_placement(text, marker="#") -> tuple[opening_ok, closing_ok] | ||
|
|
||
| This module has zero non-stdlib dependencies and is safe to copy | ||
| verbatim into any project that wants msdmd support. | ||
|
|
@@ -30,13 +33,39 @@ | |
| from pathlib import Path | ||
| from typing import Iterable | ||
|
|
||
| # extension → comment marker | ||
| _MARKERS: dict[str, str] = { | ||
| ".py": "#", ".rb": "#", ".ex": "#", ".exs": "#", ".sh": "#", | ||
| ".ts": "//", ".tsx": "//", ".js": "//", ".jsx": "//", ".mjs": "//", | ||
| ".rs": "//", ".go": "//", ".java": "//", ".c": "//", ".cpp": "//", | ||
| ".cc": "//", ".h": "//", ".hpp": "//", ".swift": "//", ".kt": "//", | ||
| # extension → line-comment marker. Keep this registry entry-for-entry equivalent | ||
| # to universal.ts; tests fail if either parser gains or loses an extension alone. | ||
| COMMENT_MARKERS: dict[str, str] = { | ||
| ".py": "#", ".pyw": "#", ".pyi": "#", | ||
| ".rb": "#", ".rake": "#", ".gemspec": "#", | ||
| ".ex": "#", ".exs": "#", | ||
| ".sh": "#", ".bash": "#", ".zsh": "#", ".fish": "#", | ||
| ".pl": "#", ".pm": "#", ".t": "#", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| ".r": "#", ".jl": "#", | ||
| ".ps1": "#", ".psm1": "#", ".tcl": "#", | ||
| ".raku": "#", ".rakumod": "#", | ||
| ".ts": "//", ".tsx": "//", ".mts": "//", ".cts": "//", | ||
| ".js": "//", ".jsx": "//", ".mjs": "//", ".cjs": "//", | ||
| ".rs": "//", ".go": "//", ".java": "//", | ||
| ".c": "//", ".cc": "//", ".cp": "//", ".cpp": "//", | ||
| ".cxx": "//", ".c+": "//", ".c++": "//", | ||
| ".h": "//", ".hh": "//", ".hp": "//", ".hpp": "//", | ||
| ".hxx": "//", ".h+": "//", ".h++": "//", | ||
| ".tcc": "//", ".ipp": "//", ".inl": "//", | ||
| ".swift": "//", ".kt": "//", ".kts": "//", ".cs": "//", | ||
| ".mm": "//", ".scala": "//", ".dart": "//", ".zig": "//", | ||
| ".groovy": "//", ".gradle": "//", ".php": "//", | ||
| ".sql": "--", ".lua": "--", ".hs": "--", | ||
| ".adb": "--", ".ads": "--", ".vhd": "--", ".vhdl": "--", | ||
| ".lean": "--", | ||
| ".erl": "%", ".hrl": "%", ".prolog": "%", | ||
| ".clj": ";", ".cljs": ";", ".cljc": ";", ".bb": ";", | ||
| ".lisp": ";", ".lsp": ";", ".cl": ";", | ||
| ".scm": ";", ".ss": ";", ".rkt": ";", | ||
| ".f": "!", ".for": "!", ".f90": "!", ".f95": "!", | ||
| ".f03": "!", ".f08": "!", | ||
| ".vb": "'", ".vbs": "'", | ||
| ".cob": "*>", ".cbl": "*>", | ||
| } | ||
|
|
||
| _DEFAULT_SKIP = ( | ||
|
|
@@ -48,7 +77,7 @@ | |
|
|
||
| def marker_for(path: Path) -> str | None: | ||
| """Return the comment marker for a file path, or None if unsupported.""" | ||
| return _MARKERS.get(path.suffix.lower()) | ||
| return COMMENT_MARKERS.get(path.suffix.lower()) | ||
|
|
||
|
|
||
| def _block_regex(block_name: str, marker: str) -> re.Pattern[str]: | ||
|
|
@@ -124,7 +153,7 @@ def walk_tree( | |
| ext_set = ( | ||
| set(e.lower() if e.startswith(".") else "." + e.lower() for e in extensions) | ||
| if extensions is not None | ||
| else set(_MARKERS.keys()) | ||
| else set(COMMENT_MARKERS.keys()) | ||
| ) | ||
|
|
||
| def iter_source_files(path: Path) -> Iterable[Path]: | ||
|
|
@@ -155,8 +184,9 @@ def iter_source_files(path: Path) -> Iterable[Path]: | |
|
|
||
| # --- RATIOS single-line declaration (msdmd extension) -------------------- | ||
| # Unlike every other declaration, RATIOS is not fenced. It is a single | ||
| # comment line carrying the three canonical ratios, placed on the file's | ||
| # first and last non-blank lines: | ||
| # comment line carrying the three canonical ratios at the opening source | ||
| # boundary and last non-blank line. A valid line-1 shebang moves the opening | ||
| # boundary to literal line 2: | ||
| # <marker> ratios: loc_comments=N:M imports_exports=N:M calls_definitions=N:M | ||
| RATIO_IDS = ("loc_comments", "imports_exports", "calls_definitions") | ||
| _RATIOS_TOKEN_RE = re.compile(r"(?P<key>[a-z_]+)=(?P<val>\S+)") | ||
|
|
@@ -171,9 +201,9 @@ def parse_ratios(text: str, marker: str = "#") -> list[dict]: | |
|
|
||
| RATIOS is not a fenced block: it is one comment line of the form | ||
| ``<marker> ratios: loc_comments=N:M imports_exports=N:M calls_definitions=N:M`` | ||
| placed on the file's first and last non-blank lines. Returns one flat | ||
| ``{"id", "value"}`` dict per (declaration line x ratio token) so a drift | ||
| gate can verify every occurrence. | ||
| placed at the file's opening and closing source boundaries. Returns one | ||
| flat ``{"id", "value"}`` dict per (declaration line x ratio token) so a | ||
| drift gate can verify every occurrence. | ||
| """ | ||
| line_re = _ratios_line_re(marker) | ||
| out: list[dict] = [] | ||
|
|
@@ -198,17 +228,29 @@ def parse_ratios_file(path: Path) -> list[dict]: | |
|
|
||
|
|
||
| def ratios_placement(text: str, marker: str = "#") -> tuple[bool, bool]: | ||
| """Return ``(first_line_has_ratios, last_non_blank_line_has_ratios)``.""" | ||
| """Return ``(opening_ratios_ok, closing_ratios_ok)``. | ||
|
|
||
| A non-empty ``#!`` interpreter directive may occupy literal line 1. It is | ||
| the only accepted preamble and RATIOS must immediately follow it. | ||
| """ | ||
| line_re = _ratios_line_re(marker) | ||
| lines = text.splitlines() | ||
| if not lines: | ||
| return (False, False) | ||
| first_ok = bool(line_re.match(lines[0].rstrip())) | ||
| has_shebang = lines[0].startswith("#!") and bool(lines[0][2:].strip()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a supported Rust file beginning with a standard inner attribute such as Useful? React with 👍 / 👎. |
||
| opening_index = 1 if has_shebang else 0 | ||
| opening_ok = ( | ||
| len(lines) > opening_index | ||
| and bool(line_re.match(lines[opening_index].rstrip())) | ||
| ) | ||
| if opening_index == 0 and len(lines) > 1: | ||
| displaced = lines[1].startswith("#!") and bool(lines[1][2:].strip()) | ||
| opening_ok = opening_ok and not displaced | ||
| last_ok = False | ||
| for raw in reversed(lines): | ||
| if raw.strip() == "": | ||
| continue | ||
| last_ok = bool(line_re.match(raw.rstrip())) | ||
| break | ||
| return (first_ok, last_ok) | ||
| # ratios: loc_comments=128:49 imports_exports=4:7 calls_definitions=51:10 | ||
| return (opening_ok, last_ok) | ||
| # ratios: loc_comments=161:57 imports_exports=4:7 calls_definitions=55:10 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this vendored snapshot,
../ratios/SKILL.mddoes not exist; a repo-wide search finds only this new reference, while the installed-skills list contains justmeta-module-build,msdmd, andtest-build. Readers therefore cannot access the promised complete seal contract, so vendor the RATIOS skill with this snapshot or make the required contract self-contained here.Useful? React with 👍 / 👎.