@fro.bot/systematic 2.11.0 → 2.12.1
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.
- package/dist/cli.js +1 -1
- package/dist/index-b4ht76qd.js +16104 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +47 -190
- package/dist/lib/agent-colors.d.ts +16 -0
- package/dist/lib/config-schema.d.ts +181 -0
- package/dist/schemas/systematic-config.schema.json +392 -0
- package/package.json +9 -4
- package/dist/index-mfy9dbdx.js +0 -1620
- package/dist/lib/plugin-singleton.d.ts +0 -60
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-process register-once guard for the Systematic plugin factory.
|
|
3
|
-
*
|
|
4
|
-
* OpenCode invokes the plugin factory more than once per process when the
|
|
5
|
-
* same plugin is referenced by multiple config sources (for example a
|
|
6
|
-
* user-level `~/.config/opencode/opencode.json` AND a project-level
|
|
7
|
-
* `opencode.json`). Each invocation evaluates the plugin module fresh —
|
|
8
|
-
* module-local variables reset between calls — so the guard state must
|
|
9
|
-
* live on `globalThis` to persist across module instances within the
|
|
10
|
-
* same process.
|
|
11
|
-
*
|
|
12
|
-
* On the first invocation `doInit` runs and the resulting hooks promise
|
|
13
|
-
* is cached on `globalThis`; the caller receives `{ isFirst: true, hooks }`.
|
|
14
|
-
* On every subsequent invocation in the same PID `doInit` is skipped and
|
|
15
|
-
* the cached resolved hooks are returned directly to every caller.
|
|
16
|
-
* Across PIDs the guard is treated as absent and init runs fresh —
|
|
17
|
-
* `globalThis` is per-process, but the explicit PID check adds defensive
|
|
18
|
-
* belt-and-suspenders against any state-leakage edge case.
|
|
19
|
-
*
|
|
20
|
-
* The singleton returns the same hooks reference to every caller within a
|
|
21
|
-
* process — first and duplicate alike. OpenCode may register the same hook
|
|
22
|
-
* surface once per configured plugin source; that is preferable to suppressing
|
|
23
|
-
* duplicates with an empty object because every source keeps the full tools,
|
|
24
|
-
* commands, skills, and hooks surface.
|
|
25
|
-
*
|
|
26
|
-
* **Known limitation — rejected init is sticky.** If `doInit()` rejects,
|
|
27
|
-
* the rejected promise is stored on `globalThis` and every subsequent
|
|
28
|
-
* invocation in the same PID returns the same rejection without retrying
|
|
29
|
-
* init. This is intentional: re-running heavy init on every call would
|
|
30
|
-
* defeat the guard's purpose. Recovery requires a process restart.
|
|
31
|
-
*/
|
|
32
|
-
export interface PlugInOnceOptions<T> {
|
|
33
|
-
/** Heavy init work that should run at most once per process. */
|
|
34
|
-
doInit: () => Promise<T>;
|
|
35
|
-
/** Test override; defaults to `process.pid`. */
|
|
36
|
-
pid?: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Result envelope for `plugInOnce(...)`.
|
|
40
|
-
*
|
|
41
|
-
* - `isFirst: true` — caller was the first invocation in this process.
|
|
42
|
-
* - `isFirst: false` — `doInit` was skipped; the cached result is returned.
|
|
43
|
-
*
|
|
44
|
-
* In both cases `hooks` is the real resolved value of `doInit()`. Callers
|
|
45
|
-
* return `result.hooks` unconditionally without inspecting `isFirst`.
|
|
46
|
-
*/
|
|
47
|
-
export interface PlugInOnceResult<T> {
|
|
48
|
-
isFirst: boolean;
|
|
49
|
-
hooks: T;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Run `doInit` at most once per process; on duplicate invocations return the
|
|
53
|
-
* cached real hook surface so every config source sees the same surface.
|
|
54
|
-
*/
|
|
55
|
-
export declare function plugInOnce<T>({ doInit, pid, }: PlugInOnceOptions<T>): Promise<PlugInOnceResult<T>>;
|
|
56
|
-
/**
|
|
57
|
-
* Test-only: clear the singleton state so the next invocation re-runs
|
|
58
|
-
* init. Must not be called in production code paths.
|
|
59
|
-
*/
|
|
60
|
-
export declare function _resetPluginSingleton(): void;
|