@antelopejs/interface-core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ # Configuration
2
+
3
+ ## Overview
4
+
5
+ The `@antelopejs/interface-core/config` module exports TypeScript types and the `defineConfig` helper for defining AntelopeJS project configurations. These types describe module sources, logging settings, environment overrides, and test configurations.
6
+
7
+ ## Import
8
+
9
+ ```ts
10
+ import { defineConfig } from "@antelopejs/interface-core/config";
11
+ import type {
12
+ AntelopeConfig,
13
+ AntelopeModuleConfig,
14
+ AntelopeLogging,
15
+ ModuleSource,
16
+ ModuleSourceLocal,
17
+ ModuleSourceGit,
18
+ ModuleSourcePackage,
19
+ ModuleSourceLocalFolder,
20
+ } from "@antelopejs/interface-core/config";
21
+ ```
22
+
23
+ ## `defineConfig`
24
+
25
+ The `defineConfig` function provides type-safe configuration definition. It accepts either a static configuration object or a function that receives a context and returns a configuration.
26
+
27
+ ```ts
28
+ import { defineConfig } from "@antelopejs/interface-core/config";
29
+
30
+ // Static configuration
31
+ export default defineConfig({
32
+ name: "my-project",
33
+ modules: {
34
+ database: "@antelopejs/database",
35
+ auth: {
36
+ version: "1.0.0",
37
+ source: { type: "package", package: "@antelopejs/auth", version: "1.0.0" },
38
+ config: { secret: "my-secret" },
39
+ },
40
+ },
41
+ });
42
+ ```
43
+
44
+ ```ts
45
+ // Dynamic configuration based on environment
46
+ export default defineConfig((ctx) => {
47
+ return {
48
+ name: "my-project",
49
+ modules: {
50
+ database: {
51
+ source: { type: "package", package: "@antelopejs/database", version: "1.0.0" },
52
+ config: {
53
+ host: ctx.env === "production" ? "db.prod.internal" : "localhost",
54
+ },
55
+ },
56
+ },
57
+ };
58
+ });
59
+ ```
60
+
61
+ ## `AntelopeConfig`
62
+
63
+ The root configuration object for an AntelopeJS project.
64
+
65
+ | Property | Type | Description |
66
+ | ---------------- | ----------------------------------------------- | ------------------------------------------- |
67
+ | `name` | `string` | Project name |
68
+ | `cacheFolder` | `string` | Optional custom cache directory |
69
+ | `modules` | `Record<string, string \| AntelopeModuleConfig>` | Module definitions (shorthand or full) |
70
+ | `logging` | `AntelopeLogging` | Optional logging configuration |
71
+ | `envOverrides` | `Record<string, string \| string[]>` | Optional environment variable overrides |
72
+ | `environments` | `Record<string, Partial<AntelopeConfig>>` | Optional per-environment config overrides |
73
+ | `test` | `AntelopeTestConfig` | Optional test configuration |
74
+
75
+ ## Module sources
76
+
77
+ Each module source type specifies how to locate and load the module code.
78
+
79
+ ### Local source
80
+
81
+ Load a module from a local file path:
82
+
83
+ ```ts
84
+ const config: AntelopeModuleConfig = {
85
+ source: {
86
+ type: "local",
87
+ path: "./modules/my-module",
88
+ main: "index.ts",
89
+ watchDir: "src",
90
+ installCommand: "pnpm install",
91
+ reloadCommand: "pnpm build",
92
+ },
93
+ };
94
+ ```
95
+
96
+ The optional `reloadCommand` runs instead of `installCommand` on hot reload, letting you configure a faster command chain (for example, skipping `pnpm install`).
97
+
98
+ ### Git source
99
+
100
+ Load a module from a Git repository:
101
+
102
+ ```ts
103
+ const config: AntelopeModuleConfig = {
104
+ source: {
105
+ type: "git",
106
+ remote: "https://github.com/org/module.git",
107
+ branch: "main",
108
+ installCommand: "pnpm install",
109
+ },
110
+ };
111
+ ```
112
+
113
+ ### Package source
114
+
115
+ Load a module from an npm package:
116
+
117
+ ```ts
118
+ const config: AntelopeModuleConfig = {
119
+ source: {
120
+ type: "package",
121
+ package: "@antelopejs/database",
122
+ version: "1.0.0",
123
+ },
124
+ };
125
+ ```
126
+
127
+ ### Local folder source
128
+
129
+ Load a module from a local folder with optional file watching:
130
+
131
+ ```ts
132
+ const config: AntelopeModuleConfig = {
133
+ source: {
134
+ type: "local-folder",
135
+ path: "./packages/shared",
136
+ watchDir: ["src", "lib"],
137
+ installCommand: ["pnpm install", "pnpm build"],
138
+ reloadCommand: "pnpm build",
139
+ },
140
+ };
141
+ ```
142
+
143
+ Like the local source, `local-folder` also accepts an optional `reloadCommand` that runs in place of `installCommand` on hot reload.
144
+
145
+ ## `AntelopeModuleConfig`
146
+
147
+ Full module configuration within the project config.
148
+
149
+ | Property | Type | Description |
150
+ | ----------------- | ------------------------------------------------- | ---------------------------------------- |
151
+ | `version` | `string` | Optional version constraint |
152
+ | `source` | `ModuleSource*` | Source definition (local, git, package, local-folder) |
153
+ | `config` | `unknown` | Optional runtime configuration |
154
+ | `importOverrides` | `ImportOverride[] \| Record<string, string>` | Optional import path redirections |
155
+ | `disabledExports` | `string[]` | Optional list of exports to disable |
156
+
157
+ ## `AntelopeLogging`
158
+
159
+ Logging configuration within the project config.
160
+
161
+ | Property | Type | Description |
162
+ | ----------------- | --------------------------------- | ------------------------------------------ |
163
+ | `enabled` | `boolean` | Enable or disable logging |
164
+ | `moduleTracking` | `object` | Track module-level logging with includes/excludes |
165
+ | `channelFilter` | `Record<string, number \| string>` | Filter log output by channel and level |
166
+ | `formatter` | `Record<string, string>` | Custom formatters per channel |
167
+ | `dateFormat` | `string` | Date format string for log timestamps |
168
+
169
+ ## `AntelopeTestConfig`
170
+
171
+ Test configuration for the project.
172
+
173
+ | Property | Type | Description |
174
+ | --------- | ------------ | --------------------------------------------------- |
175
+ | `folder` | `string` | Optional test folder path |
176
+ | `setup` | `Function` | Optional async setup function returning partial config |
177
+ | `cleanup` | `Function` | Optional async cleanup function |
178
+
179
+ ## Next steps
180
+
181
+ - [Introduction](./1.introduction.md) - Return to the overview
182
+ - [Modules](./5.modules.md) - Module lifecycle management
@@ -0,0 +1,60 @@
1
+ # Runtime
2
+
3
+ ## Overview
4
+
5
+ The `@antelopejs/interface-core/runtime` module exposes information about the runtime environment of the running project and a registry for development servers. The implementation is provided by the AntelopeJS core: `ajs project dev` reports development mode, while `ajs project start` and `ajs project run` report production mode.
6
+
7
+ ## Import
8
+
9
+ ```ts
10
+ import {
11
+ GetRuntimeInfo,
12
+ RegisterDevServer,
13
+ DEV_REGISTRY_PATH,
14
+ } from "@antelopejs/interface-core/runtime";
15
+ ```
16
+
17
+ ## `GetRuntimeInfo`
18
+
19
+ Retrieves information about the runtime environment of the running project.
20
+
21
+ ```ts
22
+ const info = await GetRuntimeInfo();
23
+ // { dev: true, projectPath: "/path/to/project", env: "default" }
24
+ ```
25
+
26
+ | Field | Description |
27
+ | ------------- | ----------------------------------------------------------------- |
28
+ | `dev` | `true` when running under `ajs project dev`, `false` otherwise |
29
+ | `projectPath` | Absolute path to the root of the running project |
30
+ | `env` | Name of the active configuration environment |
31
+
32
+ ## `RegisterDevServer`
33
+
34
+ Registers a development server and the endpoints it is listening on. Modules that bind network ports (such as an HTTP API) call this after a successful `listen()` so external tooling can discover the actual endpoints.
35
+
36
+ ```ts
37
+ await RegisterDevServer("api", [
38
+ { protocol: "http", host: "localhost", port: 5011 },
39
+ ]);
40
+ ```
41
+
42
+ In development mode, the core merges the registration into the dev registry file and removes the file on shutdown. Outside development mode, the call is a no-op.
43
+
44
+ ## Dev registry file
45
+
46
+ The dev registry file lives at `DEV_REGISTRY_PATH` (`.antelope/dev.json`) relative to the project root. Its shape is described by the `DevServerRegistry` type:
47
+
48
+ ```json
49
+ {
50
+ "pid": 12345,
51
+ "startedAt": "2026-06-12T10:00:00Z",
52
+ "servers": {
53
+ "api": {
54
+ "endpoints": [{ "protocol": "http", "host": "localhost", "port": 5011 }]
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ The file is only valid while the process identified by `pid` exists. If that process is gone, the file is orphaned and must be ignored or overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/interface-core",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "AntelopeJS core interface primitives - proxies, decorators, interface functions, and logging",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -16,7 +16,9 @@
16
16
  "main": "dist/index.js",
17
17
  "types": "dist/index.d.ts",
18
18
  "files": [
19
- "dist"
19
+ "dist",
20
+ "docs",
21
+ "skills"
20
22
  ],
21
23
  "exports": {
22
24
  ".": {
@@ -79,7 +81,10 @@
79
81
  "test": "pnpm run build && ajs module test ."
80
82
  },
81
83
  "antelopeJs": {
82
- "test": "src/antelope.test.ts"
84
+ "test": "src/antelope.test.ts",
85
+ "skills": [
86
+ "./skills"
87
+ ]
83
88
  },
84
89
  "dependencies": {
85
90
  "reflect-metadata": "^0.2.2"
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: core-interface
3
+ description: Provides the AntelopeJS core interface primitives - AsyncProxy/EventProxy/RegisteringProxy, InterfaceFunction, ImplementInterface, GetMetadata, decorator factories, module lifecycle events, structured Logging, and defineConfig. Use when importing from "@antelopejs/interface-core" (or its /decorators, /modules, /proxies, /runtime, /config, /logging subpaths), when declaring or implementing an AntelopeJS interface, wiring cross-module calls or events, building custom decorators, subscribing to ModuleStarted/ModuleDestroyed, writing logs via Logging.Info/Error, or authoring antelope.config with defineConfig.
4
+ category: antelopejs-interface
5
+ tags: [antelopejs, interface, proxy, decorators, logging]
6
+ ---
7
+
8
+ # @antelopejs/interface-core
9
+
10
+ Foundational primitives of the AntelopeJS interface system. An interface is a plain module of proxy
11
+ objects (the declaration); a provider attaches concrete behavior with `ImplementInterface`; consumers
12
+ call the declaration directly. All proxy calls cross module boundaries: they queue while no
13
+ implementation is attached and auto-detach when the providing module is unloaded. Decorator
14
+ factories, `GetMetadata`, and config types are ordinary consumer-side helpers (no proxy crossing).
15
+
16
+ ## Import paths
17
+
18
+ ```ts
19
+ import { InterfaceFunction, ImplementInterface, GetMetadata, GetInterfaceInstances, GetInterfaceInstance, AsyncProxy, EventProxy, RegisteringProxy, GetResponsibleModule } from "@antelopejs/interface-core";
20
+ import { MakeClassDecorator, MakeMethodDecorator, MakePropertyDecorator, MakeParameterDecorator } from "@antelopejs/interface-core/decorators"; // + many combined variants
21
+ import { Events, ListModules, GetModuleInfo, LoadModule, StartModule, StopModule, DestroyModule, ReloadModule } from "@antelopejs/interface-core/modules";
22
+ import { AsyncProxy, EventProxy, RegisteringProxy } from "@antelopejs/interface-core/proxies"; // same classes the root entry re-exports; pick one import site
23
+ import { GetRuntimeInfo, RegisterDevServer, DEV_REGISTRY_PATH } from "@antelopejs/interface-core/runtime";
24
+ import { defineConfig, type AntelopeConfig, type AntelopeModuleConfig } from "@antelopejs/interface-core/config";
25
+ import { Logging } from "@antelopejs/interface-core/logging";
26
+ ```
27
+
28
+ ## Declaring and implementing an interface
29
+
30
+ ```ts
31
+ // declaration.ts - the interface contract
32
+ import { InterfaceFunction, EventProxy } from "@antelopejs/interface-core";
33
+
34
+ export const GetUser = InterfaceFunction<(id: string) => { name: string }>();
35
+ export const OnUserCreated = new EventProxy<(userId: string) => void>();
36
+ ```
37
+
38
+ ```ts
39
+ // provider module - attach the implementation
40
+ import { ImplementInterface } from "@antelopejs/interface-core";
41
+ import * as UserInterface from "./declaration";
42
+
43
+ ImplementInterface(UserInterface, {
44
+ GetUser(id) {
45
+ return { name: "Alice" };
46
+ },
47
+ });
48
+ ```
49
+
50
+ ```ts
51
+ // consumer - call the declaration; always returns a Promise
52
+ import { Logging } from "@antelopejs/interface-core/logging";
53
+ import { GetUser, OnUserCreated } from "./declaration";
54
+
55
+ const user = await GetUser("42");
56
+ OnUserCreated.register((userId) => Logging.Info("created", userId));
57
+ ```
58
+
59
+ For a `RegisteringProxy` field, the implementation entry is an object:
60
+ `{ register: (id, ...args) => void, unregister: (id) => void }`. `EventProxy` fields are never
61
+ implemented; providers `emit` on them, consumers `register`/`unregister` handlers.
62
+
63
+ ## Logging
64
+
65
+ ```ts
66
+ import { Logging } from "@antelopejs/interface-core/logging";
67
+
68
+ Logging.Info("hello"); // main channel; also Error/Warn/Debug/Trace
69
+ const ch = new Logging.Channel("database"); // named channel
70
+ ch.Debug("query", { ms: 12 });
71
+ ```
72
+
73
+ ## Gotchas
74
+
75
+ - `InterfaceFunction` calls always return a `Promise`, even for sync implementations. Unimplemented
76
+ calls queue indefinitely (no timeout); an `await` before any provider attaches simply waits. In
77
+ `ajs module test` stub mode they reject instead with "Interface function called without
78
+ implementation in test environment. Ensure the required module is loaded in your test config.".
79
+ - Prefer the synchronous `ImplementInterface(decl, impl)`; the Promise-accepting overload is
80
+ deprecated. Implementations may be partial - unmatched keys keep queuing.
81
+ - Module attribution (`GetResponsibleModule`) works by call-stack analysis. Attach implementations
82
+ and register handlers synchronously during module load; doing it from a setTimeout/setInterval
83
+ callback logs "this will break hot reloading!", and other async contexts break attribution
84
+ silently - both defeat automatic cleanup on module unload.
85
+ - `RegisteringProxy` replays existing registrations to a newly attached provider (hot reload safe);
86
+ `EventProxy.register` deduplicates by function identity; both auto-clean handlers of destroyed
87
+ modules via `Events.ModuleDestroyed`.
88
+ - `GetMetadata` needs a metadata class with a static `key: symbol`; it inherits from the prototype
89
+ chain by default (pass `inherit = false` to disable). `reflect-metadata` is loaded by the main
90
+ entry point.
91
+ - Decorator factory callbacks split their arguments: decorator targets first (class / target+key /
92
+ target+key+descriptor), then the factory's own parameters.
93
+
94
+ ## Deeper reference
95
+
96
+ See the shipped `.d.ts` files under `dist/` for exact signatures, and this package's `docs/`
97
+ chapters — Introduction, Proxies, Decorators, Metadata, Modules, Logging, Configuration,
98
+ Runtime — for the prose guides. Do not duplicate them here.