zigrix 0.1.0-alpha.0
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/LICENSE +184 -0
- package/README.md +128 -0
- package/dist/agents/registry.d.ts +28 -0
- package/dist/agents/registry.js +98 -0
- package/dist/config/defaults.d.ts +66 -0
- package/dist/config/defaults.js +58 -0
- package/dist/config/load.d.ts +13 -0
- package/dist/config/load.js +96 -0
- package/dist/config/mutate.d.ts +10 -0
- package/dist/config/mutate.js +61 -0
- package/dist/config/schema.d.ts +132 -0
- package/dist/config/schema.js +123 -0
- package/dist/configure.d.ts +24 -0
- package/dist/configure.js +164 -0
- package/dist/doctor.d.ts +4 -0
- package/dist/doctor.js +99 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +791 -0
- package/dist/onboard.d.ts +99 -0
- package/dist/onboard.js +490 -0
- package/dist/orchestration/dispatch.d.ts +9 -0
- package/dist/orchestration/dispatch.js +146 -0
- package/dist/orchestration/evidence.d.ts +19 -0
- package/dist/orchestration/evidence.js +97 -0
- package/dist/orchestration/finalize.d.ts +7 -0
- package/dist/orchestration/finalize.js +136 -0
- package/dist/orchestration/pipeline.d.ts +11 -0
- package/dist/orchestration/pipeline.js +26 -0
- package/dist/orchestration/report.d.ts +5 -0
- package/dist/orchestration/report.js +92 -0
- package/dist/orchestration/worker.d.ts +34 -0
- package/dist/orchestration/worker.js +132 -0
- package/dist/rules/templates.d.ts +24 -0
- package/dist/rules/templates.js +73 -0
- package/dist/runner/run.d.ts +10 -0
- package/dist/runner/run.js +91 -0
- package/dist/runner/schema.d.ts +33 -0
- package/dist/runner/schema.js +10 -0
- package/dist/runner/store.d.ts +5 -0
- package/dist/runner/store.js +19 -0
- package/dist/state/events.d.ts +3 -0
- package/dist/state/events.js +53 -0
- package/dist/state/paths.d.ts +15 -0
- package/dist/state/paths.js +23 -0
- package/dist/state/tasks.d.ts +61 -0
- package/dist/state/tasks.js +247 -0
- package/dist/state/verify.d.ts +2 -0
- package/dist/state/verify.js +65 -0
- package/examples/hello-workflow.json +13 -0
- package/package.json +44 -0
- package/skills/zigrix-doctor/SKILL.md +20 -0
- package/skills/zigrix-evidence/SKILL.md +21 -0
- package/skills/zigrix-init/SKILL.md +23 -0
- package/skills/zigrix-report/SKILL.md +20 -0
- package/skills/zigrix-shared/SKILL.md +31 -0
- package/skills/zigrix-task-create/SKILL.md +34 -0
- package/skills/zigrix-task-status/SKILL.md +27 -0
- package/skills/zigrix-worker/SKILL.md +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and
|
|
27
|
+
configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object
|
|
31
|
+
code, generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
46
|
+
version of the Work and any modifications or additions to that Work or
|
|
47
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
48
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
49
|
+
Entity authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal, or
|
|
51
|
+
written communication sent to the Licensor or its representatives, including
|
|
52
|
+
but not limited to communication on electronic mailing lists, source code
|
|
53
|
+
control systems, and issue tracking systems that are managed by, or on behalf
|
|
54
|
+
of, the Licensor for the purpose of discussing and improving the Work, but
|
|
55
|
+
excluding communication that is conspicuously marked or otherwise designated in
|
|
56
|
+
writing by the copyright owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sub-license, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
70
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
71
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
72
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
73
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
74
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
75
|
+
their Contribution(s) alone or by combination of their Contribution(s) with the
|
|
76
|
+
Work to which such Contribution(s) was submitted. If You institute patent
|
|
77
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
78
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
80
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
81
|
+
the date such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
88
|
+
of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
95
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
96
|
+
part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents
|
|
106
|
+
of the NOTICE file are for informational purposes only and do not modify the
|
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
|
110
|
+
modifying the License.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
113
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
114
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
115
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
116
|
+
complies with the conditions stated in this License.
|
|
117
|
+
|
|
118
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
119
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
120
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
121
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
122
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
123
|
+
executed with Licensor regarding such Contributions.
|
|
124
|
+
|
|
125
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
126
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
127
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
128
|
+
reproducing the content of the NOTICE file.
|
|
129
|
+
|
|
130
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
131
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
132
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
133
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
134
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
137
|
+
associated with Your exercise of permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
140
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
141
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
142
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
143
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
144
|
+
character arising as a result of this License or out of the use or inability to
|
|
145
|
+
use the Work (including but not limited to damages for loss of goodwill, work
|
|
146
|
+
stoppage, computer failure or malfunction, or any and all other commercial
|
|
147
|
+
damages or losses), even if such Contributor has been advised of the
|
|
148
|
+
possibility of such damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
151
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
152
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
153
|
+
and/or rights consistent with this License. However, in accepting such
|
|
154
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
156
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
|
161
|
+
|
|
162
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
163
|
+
|
|
164
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
165
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
166
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
167
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
168
|
+
recommend that a file or class name and description of purpose be included on
|
|
169
|
+
the same "printed page" as the copyright notice for easier identification
|
|
170
|
+
within third-party archives.
|
|
171
|
+
|
|
172
|
+
Copyright [yyyy] [name of copyright owner]
|
|
173
|
+
|
|
174
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
175
|
+
you may not use this file except in compliance with the License.
|
|
176
|
+
You may obtain a copy of the License at
|
|
177
|
+
|
|
178
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
179
|
+
|
|
180
|
+
Unless required by applicable law or agreed to in writing, software
|
|
181
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
182
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
183
|
+
See the License for the specific language governing permissions and
|
|
184
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Zigrix
|
|
2
|
+
|
|
3
|
+
Zigrix is a **multi-project parallel task orchestration CLI** for agent-assisted development workflows.
|
|
4
|
+
|
|
5
|
+
It turns ad-hoc delegation into a file-backed, inspectable flow with:
|
|
6
|
+
- global runtime state (`~/.zigrix/`) — tasks are not project-bound
|
|
7
|
+
- task dispatch and finalization with full orchestration metadata
|
|
8
|
+
- agent registry + participation control
|
|
9
|
+
- rule/template validation and recovery
|
|
10
|
+
- evidence merge + final report rendering
|
|
11
|
+
- OpenClaw integration (skill registration + PATH stabilization)
|
|
12
|
+
- release-friendly Node/TypeScript packaging
|
|
13
|
+
|
|
14
|
+
## Current status
|
|
15
|
+
- Stage: **alpha, productization in progress**
|
|
16
|
+
- Main implementation: **Node/TypeScript at repository root**
|
|
17
|
+
- Legacy reference: **Python prototype under `legacy-python/`**
|
|
18
|
+
- Supported first: **macOS, Linux**
|
|
19
|
+
- Packaging path: **GitHub Releases + install.sh**, npm publish prepared for manual follow-up
|
|
20
|
+
|
|
21
|
+
## Intended user model
|
|
22
|
+
- **Human operator:** install Zigrix, run `zigrix onboard`, and stop there unless recovery or advanced maintenance is needed.
|
|
23
|
+
- **OpenClaw agents:** use the operational Zigrix commands (`task`, `worker`, `evidence`, `report`, `pipeline`, and low-level config surfaces) after onboarding.
|
|
24
|
+
- **Advanced maintenance:** `zigrix configure` for reconfiguration, `zigrix reset` for recovery.
|
|
25
|
+
|
|
26
|
+
See `docs/onboarding-ownership-model.md` for the product-direction source of truth.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install and onboard (one-time human setup)
|
|
32
|
+
./install.sh
|
|
33
|
+
zigrix onboard
|
|
34
|
+
|
|
35
|
+
# Verify readiness
|
|
36
|
+
zigrix doctor
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`zigrix onboard` will:
|
|
40
|
+
1. Create `~/.zigrix/` with default config
|
|
41
|
+
2. Detect OpenClaw and import agents from `openclaw.json`
|
|
42
|
+
3. Seed rule files from `orchestration/rules/`
|
|
43
|
+
4. Ensure `zigrix` is reachable from PATH (creates symlink if needed)
|
|
44
|
+
5. Register zigrix skill packs into OpenClaw's `~/.openclaw/skills/`
|
|
45
|
+
|
|
46
|
+
## What Zigrix can do today
|
|
47
|
+
- **dispatch** tasks with full orchestration metadata (replaces `dev_dispatch.py`)
|
|
48
|
+
- **finalize** tasks with evidence merge and execution unit checks (replaces `dev_finalize.py`)
|
|
49
|
+
- validate, inspect, change, diff, and reset config
|
|
50
|
+
- manage agent registry and orchestration membership
|
|
51
|
+
- validate, render, edit, diff, and reset rules/templates
|
|
52
|
+
- create and track tasks with append-only event history
|
|
53
|
+
- manage worker/evidence/report lifecycle
|
|
54
|
+
- detect stale tasks, verify state consistency, and recover state
|
|
55
|
+
- **configure** agents, rules, PATH, skills, and workspace after initial setup
|
|
56
|
+
|
|
57
|
+
## Recovery-first operations
|
|
58
|
+
Reset one broken template:
|
|
59
|
+
```bash
|
|
60
|
+
zigrix template reset workerPrompt --yes
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Reset all config back to defaults:
|
|
64
|
+
```bash
|
|
65
|
+
zigrix reset config --yes
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Reset runtime state only:
|
|
69
|
+
```bash
|
|
70
|
+
zigrix reset state --yes
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Documentation map
|
|
74
|
+
- `docs/quickstart.md`
|
|
75
|
+
- `docs/onboarding-ownership-model.md`
|
|
76
|
+
- `docs/product-decisions.md`
|
|
77
|
+
- `docs/cli-spec.md`
|
|
78
|
+
- `docs/openclaw-integration.md`
|
|
79
|
+
- `docs/concepts.md`
|
|
80
|
+
- `docs/runtime-flow.md`
|
|
81
|
+
- `docs/state-layout.md`
|
|
82
|
+
- `docs/troubleshooting.md`
|
|
83
|
+
- `docs/v1-scope.md`
|
|
84
|
+
- `docs/non-goals.md`
|
|
85
|
+
- `docs/install.md`
|
|
86
|
+
- `docs/release-process.md`
|
|
87
|
+
- `docs/versioning.md`
|
|
88
|
+
- `docs/known-limitations.md`
|
|
89
|
+
- `docs/npm-publish-manual.md`
|
|
90
|
+
|
|
91
|
+
## Repository layout
|
|
92
|
+
```text
|
|
93
|
+
zigrix/
|
|
94
|
+
├─ src/ # Node/TS main implementation
|
|
95
|
+
├─ tests/ # test coverage
|
|
96
|
+
├─ skills/ # OpenClaw skill packs
|
|
97
|
+
├─ examples/ # example workflows
|
|
98
|
+
├─ scripts/ # smoke / release helpers
|
|
99
|
+
├─ docs/ # product + architecture docs
|
|
100
|
+
├─ legacy-python/ # reference prototype only
|
|
101
|
+
└─ .github/ # CI + issue/PR templates
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Product stance
|
|
105
|
+
- local-first
|
|
106
|
+
- config-first
|
|
107
|
+
- recoverable by default
|
|
108
|
+
- OpenClaw-friendly, not OpenClaw-dependent in the core
|
|
109
|
+
- stability before speculative expansion
|
|
110
|
+
|
|
111
|
+
## Non-goals right now
|
|
112
|
+
- hosted control plane
|
|
113
|
+
- GUI/TUI product surface
|
|
114
|
+
- generalized plugin SDK
|
|
115
|
+
- automatic npm publish execution
|
|
116
|
+
- Windows-first support
|
|
117
|
+
|
|
118
|
+
## Contributing
|
|
119
|
+
See `CONTRIBUTING.md`.
|
|
120
|
+
|
|
121
|
+
## Support
|
|
122
|
+
See `SUPPORT.md`.
|
|
123
|
+
|
|
124
|
+
## Security
|
|
125
|
+
See `SECURITY.md`.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
Apache-2.0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ZigrixConfig } from '../config/schema.js';
|
|
2
|
+
export type AgentMutationResult = {
|
|
3
|
+
config: ZigrixConfig;
|
|
4
|
+
changed: boolean;
|
|
5
|
+
agentId: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function listAgents(config: ZigrixConfig): Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
role: string;
|
|
11
|
+
runtime: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
participant: boolean;
|
|
14
|
+
excluded: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function addAgent(config: ZigrixConfig, params: {
|
|
17
|
+
id: string;
|
|
18
|
+
role: string;
|
|
19
|
+
runtime: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
include?: boolean;
|
|
23
|
+
}): AgentMutationResult;
|
|
24
|
+
export declare function removeAgent(config: ZigrixConfig, agentId: string): AgentMutationResult;
|
|
25
|
+
export declare function includeAgent(config: ZigrixConfig, agentId: string): AgentMutationResult;
|
|
26
|
+
export declare function excludeAgent(config: ZigrixConfig, agentId: string): AgentMutationResult;
|
|
27
|
+
export declare function setAgentEnabled(config: ZigrixConfig, agentId: string, enabled: boolean): AgentMutationResult;
|
|
28
|
+
export declare function setAgentRole(config: ZigrixConfig, agentId: string, role: string): AgentMutationResult;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { zigrixConfigSchema } from '../config/schema.js';
|
|
2
|
+
function assertAgentExists(config, agentId) {
|
|
3
|
+
if (!config.agents.registry[agentId]) {
|
|
4
|
+
throw new Error(`agent not found: ${agentId}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function unique(items) {
|
|
8
|
+
return [...new Set(items)];
|
|
9
|
+
}
|
|
10
|
+
export function listAgents(config) {
|
|
11
|
+
return Object.entries(config.agents.registry)
|
|
12
|
+
.map(([id, agent]) => ({
|
|
13
|
+
id,
|
|
14
|
+
label: agent.label,
|
|
15
|
+
role: agent.role,
|
|
16
|
+
runtime: agent.runtime,
|
|
17
|
+
enabled: agent.enabled,
|
|
18
|
+
participant: config.agents.orchestration.participants.includes(id),
|
|
19
|
+
excluded: config.agents.orchestration.excluded.includes(id),
|
|
20
|
+
}))
|
|
21
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
22
|
+
}
|
|
23
|
+
export function addAgent(config, params) {
|
|
24
|
+
if (config.agents.registry[params.id]) {
|
|
25
|
+
throw new Error(`agent already exists: ${params.id}`);
|
|
26
|
+
}
|
|
27
|
+
const next = structuredClone(config);
|
|
28
|
+
next.agents.registry[params.id] = {
|
|
29
|
+
label: params.label ?? params.id,
|
|
30
|
+
role: params.role,
|
|
31
|
+
runtime: params.runtime,
|
|
32
|
+
enabled: params.enabled ?? true,
|
|
33
|
+
metadata: {},
|
|
34
|
+
};
|
|
35
|
+
if (params.include) {
|
|
36
|
+
next.agents.orchestration.participants = unique([...next.agents.orchestration.participants, params.id]);
|
|
37
|
+
next.agents.orchestration.excluded = next.agents.orchestration.excluded.filter((item) => item !== params.id);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
config: zigrixConfigSchema.parse(next),
|
|
41
|
+
changed: true,
|
|
42
|
+
agentId: params.id,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function removeAgent(config, agentId) {
|
|
46
|
+
assertAgentExists(config, agentId);
|
|
47
|
+
const next = structuredClone(config);
|
|
48
|
+
delete next.agents.registry[agentId];
|
|
49
|
+
next.agents.orchestration.participants = next.agents.orchestration.participants.filter((item) => item !== agentId);
|
|
50
|
+
next.agents.orchestration.excluded = next.agents.orchestration.excluded.filter((item) => item !== agentId);
|
|
51
|
+
return {
|
|
52
|
+
config: zigrixConfigSchema.parse(next),
|
|
53
|
+
changed: true,
|
|
54
|
+
agentId,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function includeAgent(config, agentId) {
|
|
58
|
+
assertAgentExists(config, agentId);
|
|
59
|
+
const next = structuredClone(config);
|
|
60
|
+
next.agents.orchestration.participants = unique([...next.agents.orchestration.participants, agentId]);
|
|
61
|
+
next.agents.orchestration.excluded = next.agents.orchestration.excluded.filter((item) => item !== agentId);
|
|
62
|
+
return {
|
|
63
|
+
config: zigrixConfigSchema.parse(next),
|
|
64
|
+
changed: true,
|
|
65
|
+
agentId,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function excludeAgent(config, agentId) {
|
|
69
|
+
assertAgentExists(config, agentId);
|
|
70
|
+
const next = structuredClone(config);
|
|
71
|
+
next.agents.orchestration.excluded = unique([...next.agents.orchestration.excluded, agentId]);
|
|
72
|
+
next.agents.orchestration.participants = next.agents.orchestration.participants.filter((item) => item !== agentId);
|
|
73
|
+
return {
|
|
74
|
+
config: zigrixConfigSchema.parse(next),
|
|
75
|
+
changed: true,
|
|
76
|
+
agentId,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function setAgentEnabled(config, agentId, enabled) {
|
|
80
|
+
assertAgentExists(config, agentId);
|
|
81
|
+
const next = structuredClone(config);
|
|
82
|
+
next.agents.registry[agentId].enabled = enabled;
|
|
83
|
+
return {
|
|
84
|
+
config: zigrixConfigSchema.parse(next),
|
|
85
|
+
changed: true,
|
|
86
|
+
agentId,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function setAgentRole(config, agentId, role) {
|
|
90
|
+
assertAgentExists(config, agentId);
|
|
91
|
+
const next = structuredClone(config);
|
|
92
|
+
next.agents.registry[agentId].role = role;
|
|
93
|
+
return {
|
|
94
|
+
config: zigrixConfigSchema.parse(next),
|
|
95
|
+
changed: true,
|
|
96
|
+
agentId,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare const ZIGRIX_HOME: string;
|
|
2
|
+
export declare const defaultConfig: {
|
|
3
|
+
readonly paths: {
|
|
4
|
+
readonly baseDir: string;
|
|
5
|
+
readonly tasksDir: string;
|
|
6
|
+
readonly evidenceDir: string;
|
|
7
|
+
readonly promptsDir: string;
|
|
8
|
+
readonly eventsFile: string;
|
|
9
|
+
readonly indexFile: string;
|
|
10
|
+
readonly runsDir: string;
|
|
11
|
+
readonly rulesDir: string;
|
|
12
|
+
};
|
|
13
|
+
readonly workspace: {
|
|
14
|
+
readonly projectsBaseDir: "";
|
|
15
|
+
};
|
|
16
|
+
readonly agents: {
|
|
17
|
+
readonly registry: {};
|
|
18
|
+
readonly orchestration: {
|
|
19
|
+
readonly participants: readonly [];
|
|
20
|
+
readonly excluded: readonly [];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly rules: {
|
|
24
|
+
readonly scales: {
|
|
25
|
+
readonly simple: {
|
|
26
|
+
readonly requiredRoles: readonly ["orchestrator"];
|
|
27
|
+
readonly optionalRoles: readonly ["qa"];
|
|
28
|
+
};
|
|
29
|
+
readonly normal: {
|
|
30
|
+
readonly requiredRoles: readonly ["orchestrator", "qa"];
|
|
31
|
+
readonly optionalRoles: readonly ["frontend", "backend"];
|
|
32
|
+
};
|
|
33
|
+
readonly risky: {
|
|
34
|
+
readonly requiredRoles: readonly ["orchestrator", "qa", "security"];
|
|
35
|
+
readonly optionalRoles: readonly ["frontend", "backend", "infra"];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly completion: {
|
|
39
|
+
readonly requireQa: true;
|
|
40
|
+
readonly requireEvidence: true;
|
|
41
|
+
readonly requireUserReport: true;
|
|
42
|
+
};
|
|
43
|
+
readonly stale: {
|
|
44
|
+
readonly defaultHours: 24;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly templates: {
|
|
48
|
+
readonly workerPrompt: {
|
|
49
|
+
readonly format: "markdown";
|
|
50
|
+
readonly version: 1;
|
|
51
|
+
readonly placeholders: readonly ["taskId", "title", "scale", "agentId", "description"];
|
|
52
|
+
readonly body: "## Worker Assignment: {{taskId}}\n- title: {{title}}\n- scale: {{scale}}\n- agent: {{agentId}}\n- description: {{description}}";
|
|
53
|
+
};
|
|
54
|
+
readonly finalReport: {
|
|
55
|
+
readonly format: "markdown";
|
|
56
|
+
readonly version: 1;
|
|
57
|
+
readonly placeholders: readonly ["taskId", "title", "status", "summary"];
|
|
58
|
+
readonly body: "## Final Report: {{taskId}}\n- title: {{title}}\n- status: {{status}}\n- summary: {{summary}}";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly runtime: {
|
|
62
|
+
readonly outputMode: "text";
|
|
63
|
+
readonly jsonIndent: 2;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type DefaultConfig = typeof defaultConfig;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
export const ZIGRIX_HOME = process.env.ZIGRIX_HOME ?? path.join(os.homedir(), '.zigrix');
|
|
4
|
+
export const defaultConfig = {
|
|
5
|
+
paths: {
|
|
6
|
+
baseDir: ZIGRIX_HOME,
|
|
7
|
+
tasksDir: path.join(ZIGRIX_HOME, 'tasks'),
|
|
8
|
+
evidenceDir: path.join(ZIGRIX_HOME, 'evidence'),
|
|
9
|
+
promptsDir: path.join(ZIGRIX_HOME, 'prompts'),
|
|
10
|
+
eventsFile: path.join(ZIGRIX_HOME, 'tasks.jsonl'),
|
|
11
|
+
indexFile: path.join(ZIGRIX_HOME, 'index.json'),
|
|
12
|
+
runsDir: path.join(ZIGRIX_HOME, 'runs'),
|
|
13
|
+
rulesDir: path.join(ZIGRIX_HOME, 'rules'),
|
|
14
|
+
},
|
|
15
|
+
workspace: {
|
|
16
|
+
projectsBaseDir: '',
|
|
17
|
+
},
|
|
18
|
+
agents: {
|
|
19
|
+
registry: {},
|
|
20
|
+
orchestration: {
|
|
21
|
+
participants: [],
|
|
22
|
+
excluded: [],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
scales: {
|
|
27
|
+
simple: { requiredRoles: ['orchestrator'], optionalRoles: ['qa'] },
|
|
28
|
+
normal: { requiredRoles: ['orchestrator', 'qa'], optionalRoles: ['frontend', 'backend'] },
|
|
29
|
+
risky: { requiredRoles: ['orchestrator', 'qa', 'security'], optionalRoles: ['frontend', 'backend', 'infra'] },
|
|
30
|
+
},
|
|
31
|
+
completion: {
|
|
32
|
+
requireQa: true,
|
|
33
|
+
requireEvidence: true,
|
|
34
|
+
requireUserReport: true,
|
|
35
|
+
},
|
|
36
|
+
stale: {
|
|
37
|
+
defaultHours: 24,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
templates: {
|
|
41
|
+
workerPrompt: {
|
|
42
|
+
format: 'markdown',
|
|
43
|
+
version: 1,
|
|
44
|
+
placeholders: ['taskId', 'title', 'scale', 'agentId', 'description'],
|
|
45
|
+
body: '## Worker Assignment: {{taskId}}\n- title: {{title}}\n- scale: {{scale}}\n- agent: {{agentId}}\n- description: {{description}}',
|
|
46
|
+
},
|
|
47
|
+
finalReport: {
|
|
48
|
+
format: 'markdown',
|
|
49
|
+
version: 1,
|
|
50
|
+
placeholders: ['taskId', 'title', 'status', 'summary'],
|
|
51
|
+
body: '## Final Report: {{taskId}}\n- title: {{title}}\n- status: {{status}}\n- summary: {{summary}}',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
runtime: {
|
|
55
|
+
outputMode: 'text',
|
|
56
|
+
jsonIndent: 2,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ZigrixConfig } from './schema.js';
|
|
2
|
+
export type LoadedConfig = {
|
|
3
|
+
config: ZigrixConfig;
|
|
4
|
+
configPath: string | null;
|
|
5
|
+
baseDir: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function loadConfig(options?: {
|
|
8
|
+
baseDir?: string;
|
|
9
|
+
configPath?: string;
|
|
10
|
+
}): LoadedConfig;
|
|
11
|
+
export declare function writeConfigFile(targetPath: string, config: ZigrixConfig): string;
|
|
12
|
+
export declare function writeDefaultConfig(baseDir?: string, force?: boolean): string;
|
|
13
|
+
export declare function getConfigValue(config: ZigrixConfig, dottedPath?: string): unknown;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import YAML from 'yaml';
|
|
5
|
+
import { defaultConfig, ZIGRIX_HOME } from './defaults.js';
|
|
6
|
+
import { zigrixConfigSchema } from './schema.js';
|
|
7
|
+
const CONFIG_CANDIDATES = [
|
|
8
|
+
'zigrix.config.json',
|
|
9
|
+
'zigrix.config.yaml',
|
|
10
|
+
'zigrix.config.yml',
|
|
11
|
+
];
|
|
12
|
+
function isObject(value) {
|
|
13
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
function deepMerge(base, override) {
|
|
16
|
+
if (!isObject(base) || !isObject(override)) {
|
|
17
|
+
return override ?? base;
|
|
18
|
+
}
|
|
19
|
+
const merged = { ...base };
|
|
20
|
+
for (const [key, value] of Object.entries(override)) {
|
|
21
|
+
const current = merged[key];
|
|
22
|
+
if (isObject(current) && isObject(value)) {
|
|
23
|
+
merged[key] = deepMerge(current, value);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
merged[key] = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
}
|
|
31
|
+
function parseConfigFile(filePath) {
|
|
32
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
33
|
+
if (filePath.endsWith('.yaml') || filePath.endsWith('.yml')) {
|
|
34
|
+
return YAML.parse(raw);
|
|
35
|
+
}
|
|
36
|
+
return JSON.parse(raw);
|
|
37
|
+
}
|
|
38
|
+
function resolveConfigPath(baseDir, explicitPath) {
|
|
39
|
+
if (explicitPath) {
|
|
40
|
+
return path.resolve(explicitPath);
|
|
41
|
+
}
|
|
42
|
+
for (const candidate of CONFIG_CANDIDATES) {
|
|
43
|
+
const fullPath = path.join(baseDir, candidate);
|
|
44
|
+
if (fs.existsSync(fullPath)) {
|
|
45
|
+
return fullPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
function applyEnvOverrides(config) {
|
|
51
|
+
const copy = structuredClone(config);
|
|
52
|
+
if (process.env.ZIGRIX_OUTPUT_MODE === 'text' || process.env.ZIGRIX_OUTPUT_MODE === 'json') {
|
|
53
|
+
copy.runtime.outputMode = process.env.ZIGRIX_OUTPUT_MODE;
|
|
54
|
+
}
|
|
55
|
+
if (process.env.ZIGRIX_JSON_INDENT) {
|
|
56
|
+
const indent = Number(process.env.ZIGRIX_JSON_INDENT);
|
|
57
|
+
if (!Number.isNaN(indent)) {
|
|
58
|
+
copy.runtime.jsonIndent = indent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return copy;
|
|
62
|
+
}
|
|
63
|
+
export function loadConfig(options) {
|
|
64
|
+
const baseDir = path.resolve(options?.baseDir ?? ZIGRIX_HOME);
|
|
65
|
+
const configPath = resolveConfigPath(baseDir, options?.configPath);
|
|
66
|
+
const parsed = configPath ? parseConfigFile(configPath) : {};
|
|
67
|
+
const merged = deepMerge(structuredClone(defaultConfig), parsed);
|
|
68
|
+
const withEnv = applyEnvOverrides(merged);
|
|
69
|
+
const result = zigrixConfigSchema.parse(withEnv);
|
|
70
|
+
return { config: result, configPath, baseDir };
|
|
71
|
+
}
|
|
72
|
+
export function writeConfigFile(targetPath, config) {
|
|
73
|
+
const resolvedPath = path.resolve(targetPath);
|
|
74
|
+
fs.mkdirSync(path.dirname(resolvedPath), { recursive: true });
|
|
75
|
+
fs.writeFileSync(resolvedPath, `${JSON.stringify(zigrixConfigSchema.parse(config), null, 2)}\n`, 'utf8');
|
|
76
|
+
return resolvedPath;
|
|
77
|
+
}
|
|
78
|
+
export function writeDefaultConfig(baseDir, force = false) {
|
|
79
|
+
const resolvedBase = path.resolve(baseDir ?? ZIGRIX_HOME);
|
|
80
|
+
const targetPath = path.join(resolvedBase, 'zigrix.config.json');
|
|
81
|
+
if (fs.existsSync(targetPath) && !force) {
|
|
82
|
+
throw new Error(`config already exists: ${targetPath}`);
|
|
83
|
+
}
|
|
84
|
+
fs.mkdirSync(resolvedBase, { recursive: true });
|
|
85
|
+
return writeConfigFile(targetPath, structuredClone(defaultConfig));
|
|
86
|
+
}
|
|
87
|
+
export function getConfigValue(config, dottedPath) {
|
|
88
|
+
if (!dottedPath)
|
|
89
|
+
return config;
|
|
90
|
+
return dottedPath.split('.').reduce((acc, key) => {
|
|
91
|
+
if (acc && typeof acc === 'object' && key in acc) {
|
|
92
|
+
return acc[key];
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}, config);
|
|
96
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ZigrixConfig } from './schema.js';
|
|
2
|
+
export declare function parseConfigInput(raw: string): unknown;
|
|
3
|
+
export declare function getValueAtPath(value: unknown, dottedPath?: string): unknown;
|
|
4
|
+
export declare function setValueAtPath<T extends Record<string, unknown>>(target: T, dottedPath: string, nextValue: unknown): T;
|
|
5
|
+
export declare function resetValueAtPath(config: ZigrixConfig, dottedPath?: string): ZigrixConfig;
|
|
6
|
+
export declare function diffValues(current: unknown, baseline: unknown): {
|
|
7
|
+
changed: boolean;
|
|
8
|
+
current: unknown;
|
|
9
|
+
baseline: unknown;
|
|
10
|
+
};
|