Catalogue / periplus-rutter
periplus-rutter
Apache-2.0SignedWrites or changes a Periplus rutter, the pack of data that tells Periplus how to find one stack's things in real files. Use when the user says the map misses something, add a rule, support this framework, or map this stack, to start a rutter for a new stack, or to make a custom rutter in a project's…--- name: periplus-rutter description: Writes or changes a Periplus rutter, the pack of data that tells Periplus how to find one stack's things in real files. Use when the user says the map misses something, add a rule, support this framework, or map this stack, to start a rutter for a new stack, or to make a custom rutter in a project's .periplus/packs that extends a bundled one. Each task ends with periplus validate and periplus map. ---
Writing a Periplus rutter
Standing rules
- Rules are small and add to each other: one rule solves one case, and several cases are several rules. Split by rule file inside one rutter, never by adding rutters for one stack; a new rutter repeats the file types and folders the covering one already holds, and a small rule can be read, tested and removed alone. A case is not a literal: four files that differ only in a quoted key are one rule with an alternation.
- A rutter reads in passes by depth: order 1 is the structure, order 2 one layer inside each class as nodes at their lines, order 3 joins in the map with map rules. Each pass reads what the one before it found, so no rule has to look a thing up itself.
- There is no stack knowledge in the engine: a new stack is a rutter, never engine code, even where a request seems to ask for engine code. When rules cannot express a pattern, the engine gains a general ability that every rutter can use, so a third-party rutter can do all a built-in one does.
- Probe before saying a rutter cannot do something: write two formulations of the rule, run each, and quote the engine's message for each before you call it an engine gap. A guess about the format's limits has been wrong before; the message is the evidence. A text rule on a method call, written because a variable argument seemed to leave no row, is the misreading: a reference rule lists that call under
skipped. - A rutter meant for others never names the project it was built on, in its code, rules, examples or prose. The name leaks the project and ties the rule to one site.
Where the detail lives
This skill gives the steps. Each rule shape, and what the format cannot say, is in the rutter author guides; read the section the step names instead of guessing a key:
- Rutter author guide: the files of a rutter, one rule of each shape, how to check a rutter.
- Rutter author guide: text: text spans, nested regions of a text file, and a
root_namefor a project that is one unit at its root. - Rutter author guide: abilities: a call's class and method in one rule, id patterns, and
match.eachover every entry of a group in a docblock annotation. - Rutter author guide: references: reference rules on a parse tree, and the keys the engine does not run.
- Rutter author guide: imports: imports and bindings.
- Rutter author guide: map rules: map rules, which join what earlier passes found. Its follow steps are
edge,incoming_edge(an edge walked from its target back to its sources),ancestors,node,id_matches(a{name}in its pattern is filled with that capture as literal text),edge_attribute(a value a file rule wrote on the edge just walked, as a capture),place: edge(what the fire makes sits at the lines of the edge just walked, not at the matched node),in_table(the walk goes on only when a capture is a key of a table, and withvaluebrings the table's value in as a capture) andtry: the steps inside atryand after it run from the current node, and if they reach nothing the later steps run with the captures it had, so a lookup that may fail (a method on an ancestor the map does not hold) leaves the end toon_miss.match.unlessholds chains of the same steps, such asunless: [[{node: 'my_module.again::{name}'}]], each run from the matched node with the captures ofwhere; when any chain reaches a node, the rule makes nothing for that node.match.unless_matchedholds chains run from the nodefollowreached, with the capturesfollowmade, such asunless_matched: [[{node: 'my_module.stop::{class}'}]]; one that reaches a node blocks only that result. A chain sees only what the map held when the pass began. A map rule may emit one node withresolution: runtimebeside it, to mark a place the code decides at run time; such a rule runs in one last pass. - Rutter author guide: Drupal: the PHP and Drupal rutters, read as worked examples.
Bundled rutters lists every rutter that ships with Periplus.
The README section "Write a rutter" and CONTRIBUTING give the loop: write the rutter in the project's own .periplus/packs first, and map that project until the map holds what the code holds.
Write a rule
- Find the rutter that already covers the stack. Put the new rule in a rule file of that rutter,
not in a new rutter: a new rule file inside the covering rutter adds to its rules and keeps one set of file types and folders.
- Write one rule for one case. When a request holds several cases, write several rules, even where
they emit the same type: in php_basic, find_declarations.yaml and find_runtime_calls.yaml each find php.call_site in their own way, and neither file's rules are stretched over the other's case.
- Declare each node type and edge kind the rule emits, in that rule file or in a pack the rutter
depends on. A rule may name only those types. Name a contributed-module type for its module, as drupal.webform_handler does, so a later drupal_basic type cannot collide. An edge end that names one type mints its id in that type's id namespace, not the kind's.
- Pick the shape from the guide: a whole-file rule, a text rule, a binding rule, a reference rule
or a map rule.
- Set the confidence. Confidence is declared on the rule, not decided at runtime. A rule firing on
an explicit declaration and a rule firing on a naming convention cannot emit the same confidence: the first is declared, the second inferred. A rule that links two things only because a name is written as text, such as a string equal to a known id, is mentioned.
Language-level knowledge lives in the language rutter, framework-level knowledge in the framework rutter, and the framework rutter shares into the language rutter's lists through tables. Each rule is small, covers one case, and adds to the others.
The example adds a rule file to python_text in a project that already holds the second-stack example rutters. A module-level name in capitals is a constant only by convention, so the rule is inferred:
<!-- example write-rule: .periplus/packs/python_text@0.1.0/rules/constants.yaml -->
node_types:
- name: python.constant
id_namespace: python.constant
rules:
- rule: constant
reads: file
in: [python]
match: {file: '**', filetype: python, text: '(?m)^(?<name>[A-Z][A-Z0-9_]*)[ \t]*='}
id: {template: '{module}.{name}'}
emits: [{node: {type: python.constant}}]
confidence: inferred<!-- example write-rule: shop/limits.py -->
RETRIES = 3
Check the rutter, then map the project; the map report's not_executed and problems should be empty:
<!-- nav-run -->
$ periplus validate python_text $ periplus map
Close a gap through an internal node
Most gaps close with two rules. A file rule writes an internal node where the code names a thing: a call site, a hub for a name, or a name guessed from how it is written. A map rule joins that node to the real target, and only when the map holds the target. A target the map lacks leaves a mark, an end with on_miss: unresolved or a referenced node: never silence, and never an invented target. An end that leaves the mapped code takes on_miss: unknown_boundary; a rule that knows what it reaches writes boundary: {into: {template, type}, kind} on the same end, into a type declared boundary: true. Mark the node's type internal: true, so the written map leaves it out; the detail is in Internal node types, and the pattern in Join an internal node to its real target.
Copy from the bundled rule files role/role_call.yaml of drupal_basic, a role-name hub joined to the role's configuration; member/member_call.yaml of js_basic, a member call joined to the member function its script declares; and edges/var_type_as_written.yaml of php_basic, a name kept as written and as resolved, joined to whichever the map holds.
No mark is removed unless the real target replaces it. No false edge is acceptable: narrow the rule instead.
Reach for an ability before a workaround
Each line is a shape, the old workaround it replaces, and the ability to write instead. None of them needs the engine.
These abilities remove copies. They do not replace small rules. One way of writing a thing is still one rule, and ten ways are ten rules that end at the same thing in the map. Keep two rules apart when they differ in what they match, in the walk they follow, in the edge they make or in what that edge means, even when their names look alike. A table row is right only for the same rule repeated with another name.
- The fact sits on one line inside a large node, such as a route at line 1 of its file. Do not
add an internal node only to carry the line. Add place: edge right after the step that walks the edge a file rule made at that line (Map rules).
- Several rules are copies of one rule: the same match, the same walk and the same edge, and
only a name, or the type that name reaches, differs. Do not write one rule per row. Put the rows in a table, and look the capture up with in_table: {table: <table>, capture: <name>, value: <new name>}; an end may then take types: ['{<new name>}']. Every table value must be a type the edge kind allows. The step sits outside any try, and such an end takes no boundary (Map rules).
- A join shows that the code names no target. Emit one node with
attribute: {name: resolution, template: runtime} beside it; such a rule runs in one last pass, so mark only what no later join could resolve (Map rules).
- A docblock annotation holds a group of entries. Do not write a rule per key or per position.
Use match.each: <group>.*, or <group>.*.* for every group, with {key}, {value}, {group} and {enclosing_type}; normalize on the id and the to end; a dotted annotation_key; and to: {from: {annotation_key: <key>}} for the id another key names
Preview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 28.3 kB | 9829ae400995 |
| SKILVAULT_SOURCE.json | 1.3 kB | b694a709b73b |
| THIRD_PARTY_NOTICES.md | 11.4 kB | e8c53edda826 |
| evals/evals.json | 1.6 kB | 26710ce5dbd4 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 0.1.0 Current | cfec2858bf2b | 2 Dec 2026 |
Locking a skill to one version needs Pro.