Hoc collect ctors

From openreachtech/hora-skills-ort-core · View interactive version

Hoc collect ctors is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. How a set of classes, one per member, is collected into the one place callers ask: a barrel file, or a folder loaded once at startup, chosen by how an addition reaches its users. Use when variants are modelled as classes, when about to list them in an array or a keyed object, or when adding a barrel

How to use this skill

Skill file

Collect Ctors

A set whose members differ — the days of a week, the fingers of a hand, the currency pairs an

application trades, the expressions a query builder accepts — is held as one class per member,

and the classes are collected into one place that callers ask. How they are collected is

decided by one question: how does an addition to the set reach the people who use it?

One class per member

key in an object literal. What sets one member apart from the others lives in its class, and a

member that has to behave differently overrides only what differs.

Choose by how an addition reaches its users

| The set | How an addition reaches its users | Collected through |

| :-- | :-- | :-- |

| Closed: the number of members is fixed by the domain | It never does; no member is added | A barrel file |

| Grows inside a published package | Through a release, once a user raises the version | A barrel file, updated as part of the publish |

| Grows inside an application | A file placed in the folder takes effect at the next start | A folder, loaded once at startup |

Whether the set will grow is not the question. A package's expressions grow too, and still

take a barrel: nothing added to a package reaches anyone until it is published, so the barrel is

updated as part of the release work that has to happen anyway. What asks for a folder is an

addition that takes effect without passing through any release.

A barrel file

A barrel imports every class of the set and exports them together. Every member stands in

it as one import line, it is resolved statically, and nothing is loaded at run time — so a reader

sees the whole set without running anything.

// fingers/index.js — a closed set: five members, and no sixth will come
import ThumbFinger from './ThumbFinger.js'
import IndexFinger from './IndexFinger.js'
// ... the remaining three

export default [
  ThumbFinger,
  IndexFinger,
  // ...
]

package offers, and adding a member to it is one step of the release that publishes the member.

the barrel, an existing file, which is the cost the folder exists to remove.

A folder loaded once at startup

**Where an addition takes effect without a release, it is made by adding a class file to a fixed

folder, and by nothing else.** No list, no barrel and no existing file is edited to admit it.

asynchronous factory method loads every class under the folder through DeepCtorsLoader, and

holds them as its one property. The constructor only receives what the factory loaded, as

/hoc-classes-constructor requires.

the package @openreachtech/mentsu-deep-loader, installed from the public npm registry

(registry.npmjs.org); no .npmrc line points its scope at another registry. It walks a folder

recursively and keeps only the classes that are, or extend, the base class it is bound to. How it is called is that

package's README; a loader of the same job written by hand is a second copy of it, and one

carrying its name is mistaken for it.

changes, so nothing has to guard the set against callers: the set is the folder.

and it turns a static import into a load at run time for nothing.

Asking the collection

exists, which class it is, and what the members are.

static member each class answers through. The classes are held in an Array, and no dictionary

keyed by a string is built beside it: classes defined in the source code are never so many that

find() over them is slow — see /hoc-prohibit-native-features.

reaches the collection.

replace it — see /hoc-wire-dependencies.

Where this stops

class belongs to /hoc-git-commit.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.