chainlesschain 0.37.10 → 0.37.12
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/README.md +166 -10
- package/package.json +1 -1
- package/src/commands/a2a.js +374 -0
- package/src/commands/bi.js +240 -0
- package/src/commands/cowork.js +317 -0
- package/src/commands/economy.js +375 -0
- package/src/commands/evolution.js +398 -0
- package/src/commands/hmemory.js +273 -0
- package/src/commands/hook.js +260 -0
- package/src/commands/init.js +184 -0
- package/src/commands/lowcode.js +320 -0
- package/src/commands/plugin.js +55 -2
- package/src/commands/sandbox.js +366 -0
- package/src/commands/skill.js +254 -201
- package/src/commands/workflow.js +359 -0
- package/src/commands/zkp.js +277 -0
- package/src/index.js +44 -0
- package/src/lib/a2a-protocol.js +371 -0
- package/src/lib/agent-coordinator.js +273 -0
- package/src/lib/agent-economy.js +369 -0
- package/src/lib/app-builder.js +377 -0
- package/src/lib/bi-engine.js +299 -0
- package/src/lib/cowork/ab-comparator-cli.js +180 -0
- package/src/lib/cowork/code-knowledge-graph-cli.js +232 -0
- package/src/lib/cowork/debate-review-cli.js +144 -0
- package/src/lib/cowork/decision-kb-cli.js +153 -0
- package/src/lib/cowork/project-style-analyzer-cli.js +168 -0
- package/src/lib/cowork-adapter.js +106 -0
- package/src/lib/evolution-system.js +508 -0
- package/src/lib/hierarchical-memory.js +471 -0
- package/src/lib/hook-manager.js +387 -0
- package/src/lib/plugin-manager.js +118 -0
- package/src/lib/project-detector.js +53 -0
- package/src/lib/sandbox-v2.js +503 -0
- package/src/lib/service-container.js +183 -0
- package/src/lib/skill-loader.js +274 -0
- package/src/lib/workflow-engine.js +503 -0
- package/src/lib/zkp-engine.js +241 -0
- package/src/repl/agent-repl.js +117 -112
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow engine commands
|
|
3
|
+
* chainlesschain workflow create|list|run|status|pause|resume|rollback|templates|delete
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { logger } from "../lib/logger.js";
|
|
8
|
+
import { bootstrap, shutdown } from "../runtime/bootstrap.js";
|
|
9
|
+
import {
|
|
10
|
+
createWorkflow,
|
|
11
|
+
listWorkflows,
|
|
12
|
+
executeWorkflow,
|
|
13
|
+
getExecutionLog,
|
|
14
|
+
pauseExecution,
|
|
15
|
+
resumeExecution,
|
|
16
|
+
rollbackExecution,
|
|
17
|
+
getTemplates,
|
|
18
|
+
deleteWorkflow,
|
|
19
|
+
} from "../lib/workflow-engine.js";
|
|
20
|
+
|
|
21
|
+
export function registerWorkflowCommand(program) {
|
|
22
|
+
const workflow = program
|
|
23
|
+
.command("workflow")
|
|
24
|
+
.description(
|
|
25
|
+
"Workflow engine — create, run, and manage DAG-based workflows",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// workflow create <name>
|
|
29
|
+
workflow
|
|
30
|
+
.command("create <name>")
|
|
31
|
+
.description("Create a new workflow")
|
|
32
|
+
.option("-d, --description <desc>", "Workflow description")
|
|
33
|
+
.option("-t, --template <id>", "Use a built-in template")
|
|
34
|
+
.option("-s, --stages <json>", "Stages as JSON array")
|
|
35
|
+
.option("--json", "Output as JSON")
|
|
36
|
+
.action(async (name, options) => {
|
|
37
|
+
try {
|
|
38
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
39
|
+
if (!ctx.db) {
|
|
40
|
+
logger.error("Database not available");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
const db = ctx.db.getDatabase();
|
|
44
|
+
|
|
45
|
+
let stages;
|
|
46
|
+
if (options.template) {
|
|
47
|
+
const templates = getTemplates();
|
|
48
|
+
const tpl = templates.find((t) => t.id === options.template);
|
|
49
|
+
if (!tpl) {
|
|
50
|
+
logger.error(
|
|
51
|
+
`Template not found: ${options.template}. Use "workflow templates" to list.`,
|
|
52
|
+
);
|
|
53
|
+
await shutdown();
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
stages = tpl.stages;
|
|
57
|
+
} else if (options.stages) {
|
|
58
|
+
try {
|
|
59
|
+
stages = JSON.parse(options.stages);
|
|
60
|
+
} catch (_err) {
|
|
61
|
+
logger.error("Invalid JSON for --stages");
|
|
62
|
+
await shutdown();
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
logger.error("Provide --template <id> or --stages <json>");
|
|
67
|
+
await shutdown();
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const result = createWorkflow(db, {
|
|
72
|
+
name,
|
|
73
|
+
description: options.description,
|
|
74
|
+
stages,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (options.json) {
|
|
78
|
+
console.log(JSON.stringify(result, null, 2));
|
|
79
|
+
} else {
|
|
80
|
+
logger.log(chalk.green(`Workflow created: ${result.id}`));
|
|
81
|
+
logger.log(` Name: ${chalk.cyan(name)}`);
|
|
82
|
+
logger.log(` Stages: ${result.stages.length}`);
|
|
83
|
+
logger.log(` Status: ${result.status}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
await shutdown();
|
|
87
|
+
} catch (err) {
|
|
88
|
+
logger.error(`Failed: ${err.message}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// workflow list
|
|
94
|
+
workflow
|
|
95
|
+
.command("list")
|
|
96
|
+
.description("List all workflows")
|
|
97
|
+
.option("--json", "Output as JSON")
|
|
98
|
+
.action(async (options) => {
|
|
99
|
+
try {
|
|
100
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
101
|
+
if (!ctx.db) {
|
|
102
|
+
logger.error("Database not available");
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
const db = ctx.db.getDatabase();
|
|
106
|
+
const workflows = listWorkflows(db);
|
|
107
|
+
|
|
108
|
+
if (options.json) {
|
|
109
|
+
console.log(
|
|
110
|
+
JSON.stringify(
|
|
111
|
+
workflows.map((w) => ({
|
|
112
|
+
id: w.id,
|
|
113
|
+
name: w.name,
|
|
114
|
+
description: w.description,
|
|
115
|
+
status: w.status,
|
|
116
|
+
stages: w.dag.length,
|
|
117
|
+
created_at: w.created_at,
|
|
118
|
+
})),
|
|
119
|
+
null,
|
|
120
|
+
2,
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
} else if (workflows.length === 0) {
|
|
124
|
+
logger.info(
|
|
125
|
+
'No workflows found. Create one with "chainlesschain workflow create"',
|
|
126
|
+
);
|
|
127
|
+
} else {
|
|
128
|
+
logger.log(chalk.bold(`Workflows (${workflows.length}):\n`));
|
|
129
|
+
for (const w of workflows) {
|
|
130
|
+
logger.log(
|
|
131
|
+
` ${chalk.cyan(w.id)} — ${w.name} [${chalk.green(w.status)}]`,
|
|
132
|
+
);
|
|
133
|
+
if (w.description) logger.log(` ${chalk.gray(w.description)}`);
|
|
134
|
+
logger.log(` Stages: ${w.dag.length}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
await shutdown();
|
|
139
|
+
} catch (err) {
|
|
140
|
+
logger.error(`Failed: ${err.message}`);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// workflow run <id>
|
|
146
|
+
workflow
|
|
147
|
+
.command("run <id>")
|
|
148
|
+
.description("Execute a workflow")
|
|
149
|
+
.option("-i, --input <json>", "Input data as JSON")
|
|
150
|
+
.option("--json", "Output as JSON")
|
|
151
|
+
.action(async (id, options) => {
|
|
152
|
+
try {
|
|
153
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
154
|
+
if (!ctx.db) {
|
|
155
|
+
logger.error("Database not available");
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
const db = ctx.db.getDatabase();
|
|
159
|
+
|
|
160
|
+
let input = {};
|
|
161
|
+
if (options.input) {
|
|
162
|
+
try {
|
|
163
|
+
input = JSON.parse(options.input);
|
|
164
|
+
} catch (_err) {
|
|
165
|
+
logger.error("Invalid JSON for --input");
|
|
166
|
+
await shutdown();
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const result = executeWorkflow(db, id, input);
|
|
172
|
+
|
|
173
|
+
if (options.json) {
|
|
174
|
+
console.log(JSON.stringify(result, null, 2));
|
|
175
|
+
} else {
|
|
176
|
+
logger.log(chalk.green(`Workflow executed: ${result.id}`));
|
|
177
|
+
logger.log(` Status: ${result.status}`);
|
|
178
|
+
logger.log(` Steps completed: ${result.log.length}`);
|
|
179
|
+
for (const entry of result.log) {
|
|
180
|
+
logger.log(
|
|
181
|
+
` ${chalk.gray("•")} ${entry.stageName} [${entry.type}] — ${chalk.green(entry.status)}`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
await shutdown();
|
|
187
|
+
} catch (err) {
|
|
188
|
+
logger.error(`Failed: ${err.message}`);
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// workflow status <exec-id>
|
|
194
|
+
workflow
|
|
195
|
+
.command("status <exec-id>")
|
|
196
|
+
.description("Show execution status and log")
|
|
197
|
+
.option("--json", "Output as JSON")
|
|
198
|
+
.action(async (execId, options) => {
|
|
199
|
+
try {
|
|
200
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
201
|
+
if (!ctx.db) {
|
|
202
|
+
logger.error("Database not available");
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
const db = ctx.db.getDatabase();
|
|
206
|
+
const result = getExecutionLog(db, execId);
|
|
207
|
+
|
|
208
|
+
if (options.json) {
|
|
209
|
+
console.log(JSON.stringify(result, null, 2));
|
|
210
|
+
} else {
|
|
211
|
+
logger.log(chalk.bold(`Execution: ${result.id}`));
|
|
212
|
+
logger.log(` Workflow: ${result.workflowId}`);
|
|
213
|
+
logger.log(` Status: ${chalk.cyan(result.status)}`);
|
|
214
|
+
logger.log(` Started: ${result.startedAt || "N/A"}`);
|
|
215
|
+
logger.log(` Completed: ${result.completedAt || "N/A"}`);
|
|
216
|
+
if (result.log.length > 0) {
|
|
217
|
+
logger.log(` Log:`);
|
|
218
|
+
for (const entry of result.log) {
|
|
219
|
+
if (entry.stageName) {
|
|
220
|
+
logger.log(
|
|
221
|
+
` ${chalk.gray("•")} ${entry.stageName} — ${entry.status}`,
|
|
222
|
+
);
|
|
223
|
+
} else if (entry.action) {
|
|
224
|
+
logger.log(
|
|
225
|
+
` ${chalk.gray("•")} ${entry.action} at ${entry.timestamp}`,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
await shutdown();
|
|
233
|
+
} catch (err) {
|
|
234
|
+
logger.error(`Failed: ${err.message}`);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// workflow pause <exec-id>
|
|
240
|
+
workflow
|
|
241
|
+
.command("pause <exec-id>")
|
|
242
|
+
.description("Pause a running execution")
|
|
243
|
+
.action(async (execId) => {
|
|
244
|
+
try {
|
|
245
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
246
|
+
if (!ctx.db) {
|
|
247
|
+
logger.error("Database not available");
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
const db = ctx.db.getDatabase();
|
|
251
|
+
const result = pauseExecution(db, execId);
|
|
252
|
+
logger.log(chalk.yellow(`Execution paused: ${result.id}`));
|
|
253
|
+
|
|
254
|
+
await shutdown();
|
|
255
|
+
} catch (err) {
|
|
256
|
+
logger.error(`Failed: ${err.message}`);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// workflow resume <exec-id>
|
|
262
|
+
workflow
|
|
263
|
+
.command("resume <exec-id>")
|
|
264
|
+
.description("Resume a paused execution")
|
|
265
|
+
.action(async (execId) => {
|
|
266
|
+
try {
|
|
267
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
268
|
+
if (!ctx.db) {
|
|
269
|
+
logger.error("Database not available");
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
const db = ctx.db.getDatabase();
|
|
273
|
+
const result = resumeExecution(db, execId);
|
|
274
|
+
logger.log(chalk.green(`Execution resumed: ${result.id}`));
|
|
275
|
+
|
|
276
|
+
await shutdown();
|
|
277
|
+
} catch (err) {
|
|
278
|
+
logger.error(`Failed: ${err.message}`);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// workflow rollback <exec-id>
|
|
284
|
+
workflow
|
|
285
|
+
.command("rollback <exec-id>")
|
|
286
|
+
.description("Rollback an execution")
|
|
287
|
+
.action(async (execId) => {
|
|
288
|
+
try {
|
|
289
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
290
|
+
if (!ctx.db) {
|
|
291
|
+
logger.error("Database not available");
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
const db = ctx.db.getDatabase();
|
|
295
|
+
const result = rollbackExecution(db, execId);
|
|
296
|
+
logger.log(chalk.red(`Execution rolled back: ${result.id}`));
|
|
297
|
+
|
|
298
|
+
await shutdown();
|
|
299
|
+
} catch (err) {
|
|
300
|
+
logger.error(`Failed: ${err.message}`);
|
|
301
|
+
process.exit(1);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// workflow templates
|
|
306
|
+
workflow
|
|
307
|
+
.command("templates")
|
|
308
|
+
.description("List built-in workflow templates")
|
|
309
|
+
.option("--json", "Output as JSON")
|
|
310
|
+
.action(async (options) => {
|
|
311
|
+
try {
|
|
312
|
+
const templates = getTemplates();
|
|
313
|
+
|
|
314
|
+
if (options.json) {
|
|
315
|
+
console.log(JSON.stringify(templates, null, 2));
|
|
316
|
+
} else {
|
|
317
|
+
logger.log(chalk.bold(`Workflow Templates (${templates.length}):\n`));
|
|
318
|
+
for (const tpl of templates) {
|
|
319
|
+
logger.log(` ${chalk.cyan(tpl.id)} — ${tpl.name}`);
|
|
320
|
+
logger.log(` ${chalk.gray(tpl.description)}`);
|
|
321
|
+
logger.log(
|
|
322
|
+
` Stages: ${tpl.stages.map((s) => s.name).join(" → ")}`,
|
|
323
|
+
);
|
|
324
|
+
logger.log("");
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
} catch (err) {
|
|
328
|
+
logger.error(`Failed: ${err.message}`);
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// workflow delete <id>
|
|
334
|
+
workflow
|
|
335
|
+
.command("delete <id>")
|
|
336
|
+
.description("Delete a workflow")
|
|
337
|
+
.action(async (id) => {
|
|
338
|
+
try {
|
|
339
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
340
|
+
if (!ctx.db) {
|
|
341
|
+
logger.error("Database not available");
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
const db = ctx.db.getDatabase();
|
|
345
|
+
const result = deleteWorkflow(db, id);
|
|
346
|
+
|
|
347
|
+
if (result.deleted) {
|
|
348
|
+
logger.log(chalk.green(`Workflow deleted: ${id}`));
|
|
349
|
+
} else {
|
|
350
|
+
logger.warn(`Workflow not found: ${id}`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
await shutdown();
|
|
354
|
+
} catch (err) {
|
|
355
|
+
logger.error(`Failed: ${err.message}`);
|
|
356
|
+
process.exit(1);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZKP commands
|
|
3
|
+
* chainlesschain zkp compile|prove|verify|identity|stats|circuits|proofs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { logger } from "../lib/logger.js";
|
|
8
|
+
import { bootstrap, shutdown } from "../runtime/bootstrap.js";
|
|
9
|
+
import {
|
|
10
|
+
ensureZKPTables,
|
|
11
|
+
compileCircuit,
|
|
12
|
+
generateProof,
|
|
13
|
+
verifyProof,
|
|
14
|
+
createIdentityProof,
|
|
15
|
+
getZKPStats,
|
|
16
|
+
listCircuits,
|
|
17
|
+
listProofs,
|
|
18
|
+
} from "../lib/zkp-engine.js";
|
|
19
|
+
|
|
20
|
+
export function registerZkpCommand(program) {
|
|
21
|
+
const zkp = program
|
|
22
|
+
.command("zkp")
|
|
23
|
+
.description("Zero-knowledge proof engine — circuits, proofs, identity");
|
|
24
|
+
|
|
25
|
+
// zkp compile
|
|
26
|
+
zkp
|
|
27
|
+
.command("compile <name>")
|
|
28
|
+
.description("Compile a ZKP circuit")
|
|
29
|
+
.option("--definition <json>", "Circuit definition as JSON")
|
|
30
|
+
.action(async (name, options) => {
|
|
31
|
+
try {
|
|
32
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
33
|
+
if (!ctx.db) {
|
|
34
|
+
logger.error("Database not available");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const db = ctx.db.getDatabase();
|
|
38
|
+
ensureZKPTables(db);
|
|
39
|
+
|
|
40
|
+
const def = options.definition || "{}";
|
|
41
|
+
const circuit = compileCircuit(db, name, def);
|
|
42
|
+
logger.success(`Circuit compiled: ${chalk.cyan(name)}`);
|
|
43
|
+
logger.log(
|
|
44
|
+
` ${chalk.bold("ID:")} ${chalk.cyan(circuit.id)}`,
|
|
45
|
+
);
|
|
46
|
+
logger.log(` ${chalk.bold("Constraints:")} ${circuit.constraints}`);
|
|
47
|
+
logger.log(
|
|
48
|
+
` ${chalk.bold("VK:")} ${circuit.verificationKey.slice(0, 16)}...`,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
await shutdown();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
logger.error(`Failed: ${err.message}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// zkp prove
|
|
59
|
+
zkp
|
|
60
|
+
.command("prove <circuit-id>")
|
|
61
|
+
.description("Generate a zero-knowledge proof")
|
|
62
|
+
.option("--private <json>", "Private inputs as JSON")
|
|
63
|
+
.option("--public <json>", "Public inputs as JSON")
|
|
64
|
+
.option("--json", "Output as JSON")
|
|
65
|
+
.action(async (circuitId, options) => {
|
|
66
|
+
try {
|
|
67
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
68
|
+
if (!ctx.db) {
|
|
69
|
+
logger.error("Database not available");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
const db = ctx.db.getDatabase();
|
|
73
|
+
ensureZKPTables(db);
|
|
74
|
+
|
|
75
|
+
const privateInputs = options.private
|
|
76
|
+
? JSON.parse(options.private)
|
|
77
|
+
: {};
|
|
78
|
+
const publicInputs = options.public ? JSON.parse(options.public) : [];
|
|
79
|
+
const proof = generateProof(db, circuitId, privateInputs, publicInputs);
|
|
80
|
+
|
|
81
|
+
if (options.json) {
|
|
82
|
+
console.log(JSON.stringify(proof, null, 2));
|
|
83
|
+
} else {
|
|
84
|
+
logger.success("Proof generated");
|
|
85
|
+
logger.log(` ${chalk.bold("ID:")} ${chalk.cyan(proof.id)}`);
|
|
86
|
+
logger.log(` ${chalk.bold("Scheme:")} ${proof.scheme}`);
|
|
87
|
+
logger.log(` ${chalk.bold("Circuit:")} ${proof.circuitId}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await shutdown();
|
|
91
|
+
} catch (err) {
|
|
92
|
+
logger.error(`Failed: ${err.message}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// zkp verify
|
|
98
|
+
zkp
|
|
99
|
+
.command("verify <proof-id>")
|
|
100
|
+
.description("Verify a zero-knowledge proof")
|
|
101
|
+
.option("--json", "Output as JSON")
|
|
102
|
+
.action(async (proofId, options) => {
|
|
103
|
+
try {
|
|
104
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
105
|
+
if (!ctx.db) {
|
|
106
|
+
logger.error("Database not available");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
const db = ctx.db.getDatabase();
|
|
110
|
+
ensureZKPTables(db);
|
|
111
|
+
|
|
112
|
+
const result = verifyProof(db, proofId);
|
|
113
|
+
if (options.json) {
|
|
114
|
+
console.log(JSON.stringify(result, null, 2));
|
|
115
|
+
} else {
|
|
116
|
+
const status = result.valid
|
|
117
|
+
? chalk.green("VALID")
|
|
118
|
+
: chalk.red("INVALID");
|
|
119
|
+
logger.log(
|
|
120
|
+
` ${chalk.bold("Proof:")} ${chalk.cyan(result.proofId)}`,
|
|
121
|
+
);
|
|
122
|
+
logger.log(` ${chalk.bold("Result:")} ${status}`);
|
|
123
|
+
logger.log(` ${chalk.bold("Scheme:")} ${result.scheme}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await shutdown();
|
|
127
|
+
} catch (err) {
|
|
128
|
+
logger.error(`Failed: ${err.message}`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// zkp identity
|
|
134
|
+
zkp
|
|
135
|
+
.command("identity")
|
|
136
|
+
.description("Create a selective-disclosure identity proof")
|
|
137
|
+
.option("--claims <json>", "Identity claims as JSON")
|
|
138
|
+
.option("--disclose <fields>", "Comma-separated fields to disclose")
|
|
139
|
+
.option("--json", "Output as JSON")
|
|
140
|
+
.action(async (options) => {
|
|
141
|
+
try {
|
|
142
|
+
const claims = options.claims ? JSON.parse(options.claims) : {};
|
|
143
|
+
const disclose = options.disclose
|
|
144
|
+
? options.disclose.split(",").map((s) => s.trim())
|
|
145
|
+
: [];
|
|
146
|
+
const result = createIdentityProof(claims, disclose);
|
|
147
|
+
|
|
148
|
+
if (options.json) {
|
|
149
|
+
console.log(JSON.stringify(result, null, 2));
|
|
150
|
+
} else {
|
|
151
|
+
logger.success("Identity proof created");
|
|
152
|
+
logger.log(` ${chalk.bold("ID:")} ${chalk.cyan(result.id)}`);
|
|
153
|
+
logger.log(` ${chalk.bold("Type:")} ${result.type}`);
|
|
154
|
+
logger.log(
|
|
155
|
+
` ${chalk.bold("Disclosed:")} ${JSON.stringify(result.disclosed)}`,
|
|
156
|
+
);
|
|
157
|
+
logger.log(
|
|
158
|
+
` ${chalk.bold("Hidden:")} ${result.hiddenCount} field(s)`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
logger.error(`Failed: ${err.message}`);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// zkp stats
|
|
168
|
+
zkp
|
|
169
|
+
.command("stats")
|
|
170
|
+
.description("Show ZKP engine statistics")
|
|
171
|
+
.option("--json", "Output as JSON")
|
|
172
|
+
.action(async (options) => {
|
|
173
|
+
try {
|
|
174
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
175
|
+
if (!ctx.db) {
|
|
176
|
+
logger.error("Database not available");
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
const db = ctx.db.getDatabase();
|
|
180
|
+
ensureZKPTables(db);
|
|
181
|
+
|
|
182
|
+
const stats = getZKPStats();
|
|
183
|
+
if (options.json) {
|
|
184
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
185
|
+
} else {
|
|
186
|
+
logger.log(` ${chalk.bold("Circuits:")} ${stats.circuits}`);
|
|
187
|
+
logger.log(` ${chalk.bold("Proofs:")} ${stats.proofs}`);
|
|
188
|
+
logger.log(
|
|
189
|
+
` ${chalk.bold("Verified:")} ${stats.verifiedProofs}`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await shutdown();
|
|
194
|
+
} catch (err) {
|
|
195
|
+
logger.error(`Failed: ${err.message}`);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// zkp circuits
|
|
201
|
+
zkp
|
|
202
|
+
.command("circuits")
|
|
203
|
+
.description("List all compiled circuits")
|
|
204
|
+
.option("--json", "Output as JSON")
|
|
205
|
+
.action(async (options) => {
|
|
206
|
+
try {
|
|
207
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
208
|
+
if (!ctx.db) {
|
|
209
|
+
logger.error("Database not available");
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
const db = ctx.db.getDatabase();
|
|
213
|
+
ensureZKPTables(db);
|
|
214
|
+
|
|
215
|
+
const circuits = listCircuits(db);
|
|
216
|
+
if (options.json) {
|
|
217
|
+
console.log(JSON.stringify(circuits, null, 2));
|
|
218
|
+
} else {
|
|
219
|
+
if (circuits.length === 0) {
|
|
220
|
+
logger.log("No circuits compiled");
|
|
221
|
+
} else {
|
|
222
|
+
for (const c of circuits) {
|
|
223
|
+
logger.log(
|
|
224
|
+
` ${chalk.cyan(c.id.slice(0, 8))} ${chalk.bold(c.name)} — ${c.constraints} constraint(s)`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
await shutdown();
|
|
231
|
+
} catch (err) {
|
|
232
|
+
logger.error(`Failed: ${err.message}`);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// zkp proofs
|
|
238
|
+
zkp
|
|
239
|
+
.command("proofs")
|
|
240
|
+
.description("List proofs")
|
|
241
|
+
.option("--circuit <id>", "Filter by circuit ID")
|
|
242
|
+
.option("--json", "Output as JSON")
|
|
243
|
+
.action(async (options) => {
|
|
244
|
+
try {
|
|
245
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
246
|
+
if (!ctx.db) {
|
|
247
|
+
logger.error("Database not available");
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
const db = ctx.db.getDatabase();
|
|
251
|
+
ensureZKPTables(db);
|
|
252
|
+
|
|
253
|
+
const proofs = listProofs(db, { circuitId: options.circuit });
|
|
254
|
+
if (options.json) {
|
|
255
|
+
console.log(JSON.stringify(proofs, null, 2));
|
|
256
|
+
} else {
|
|
257
|
+
if (proofs.length === 0) {
|
|
258
|
+
logger.log("No proofs generated");
|
|
259
|
+
} else {
|
|
260
|
+
for (const p of proofs) {
|
|
261
|
+
const status = p.verified
|
|
262
|
+
? chalk.green("verified")
|
|
263
|
+
: chalk.yellow("unverified");
|
|
264
|
+
logger.log(
|
|
265
|
+
` ${chalk.cyan(p.id.slice(0, 8))} ${p.scheme} [${status}]`,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
await shutdown();
|
|
272
|
+
} catch (err) {
|
|
273
|
+
logger.error(`Failed: ${err.message}`);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,26 @@ import { registerSyncCommand } from "./commands/sync.js";
|
|
|
34
34
|
import { registerWalletCommand } from "./commands/wallet.js";
|
|
35
35
|
import { registerOrgCommand } from "./commands/org.js";
|
|
36
36
|
import { registerPluginCommand } from "./commands/plugin.js";
|
|
37
|
+
import { registerInitCommand } from "./commands/init.js";
|
|
38
|
+
import { registerCoworkCommand } from "./commands/cowork.js";
|
|
39
|
+
|
|
40
|
+
// Phase 6: Advanced AI & Hooks
|
|
41
|
+
import { registerHookCommand } from "./commands/hook.js";
|
|
42
|
+
import { registerWorkflowCommand } from "./commands/workflow.js";
|
|
43
|
+
import { registerHmemoryCommand } from "./commands/hmemory.js";
|
|
44
|
+
import { registerA2aCommand } from "./commands/a2a.js";
|
|
45
|
+
|
|
46
|
+
// Phase 7: Security & Evolution
|
|
47
|
+
import { registerSandboxCommand } from "./commands/sandbox.js";
|
|
48
|
+
import { registerEvolutionCommand } from "./commands/evolution.js";
|
|
49
|
+
|
|
50
|
+
// Phase 8: Blockchain & Enterprise
|
|
51
|
+
import { registerEconomyCommand } from "./commands/economy.js";
|
|
52
|
+
import { registerZkpCommand } from "./commands/zkp.js";
|
|
53
|
+
import { registerBiCommand } from "./commands/bi.js";
|
|
54
|
+
|
|
55
|
+
// Phase 9: Low-Code & Multi-Agent
|
|
56
|
+
import { registerLowcodeCommand } from "./commands/lowcode.js";
|
|
37
57
|
|
|
38
58
|
export function createProgram() {
|
|
39
59
|
const program = new Command();
|
|
@@ -47,6 +67,9 @@ export function createProgram() {
|
|
|
47
67
|
.option("--verbose", "Enable verbose output")
|
|
48
68
|
.option("--quiet", "Suppress non-essential output");
|
|
49
69
|
|
|
70
|
+
// Project initialization
|
|
71
|
+
registerInitCommand(program);
|
|
72
|
+
|
|
50
73
|
// Existing commands
|
|
51
74
|
registerSetupCommand(program);
|
|
52
75
|
registerStartCommand(program);
|
|
@@ -95,5 +118,26 @@ export function createProgram() {
|
|
|
95
118
|
registerOrgCommand(program);
|
|
96
119
|
registerPluginCommand(program);
|
|
97
120
|
|
|
121
|
+
// Multi-agent collaboration
|
|
122
|
+
registerCoworkCommand(program);
|
|
123
|
+
|
|
124
|
+
// Phase 6: Advanced AI & Hooks
|
|
125
|
+
registerHookCommand(program);
|
|
126
|
+
registerWorkflowCommand(program);
|
|
127
|
+
registerHmemoryCommand(program);
|
|
128
|
+
registerA2aCommand(program);
|
|
129
|
+
|
|
130
|
+
// Phase 7: Security & Evolution
|
|
131
|
+
registerSandboxCommand(program);
|
|
132
|
+
registerEvolutionCommand(program);
|
|
133
|
+
|
|
134
|
+
// Phase 8: Blockchain & Enterprise
|
|
135
|
+
registerEconomyCommand(program);
|
|
136
|
+
registerZkpCommand(program);
|
|
137
|
+
registerBiCommand(program);
|
|
138
|
+
|
|
139
|
+
// Phase 9: Low-Code & Multi-Agent
|
|
140
|
+
registerLowcodeCommand(program);
|
|
141
|
+
|
|
98
142
|
return program;
|
|
99
143
|
}
|