@baselineos/cli 0.1.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/.baseline/govern/audit-trail.json +61 -0
- package/.turbo/turbo-build.log +23 -0
- package/.turbo/turbo-test.log +80 -0
- package/LICENSE +17 -0
- package/README.md +19 -0
- package/dist/chunk-CCIHFLKI.js +1792 -0
- package/dist/cli.cjs +2290 -0
- package/dist/cli.d.cts +8 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +470 -0
- package/dist/index.cjs +3488 -0
- package/dist/index.d.cts +616 -0
- package/dist/index.d.ts +616 -0
- package/dist/index.js +1664 -0
- package/in/.baseline/govern/audit-trail.json +61 -0
- package/package.json +45 -0
- package/src/__tests__/badge.test.ts +93 -0
- package/src/__tests__/cli.test.ts +22 -0
- package/src/__tests__/commands.test.ts +178 -0
- package/src/__tests__/schema.test.ts +114 -0
- package/src/__tests__/smoke.test.ts +15 -0
- package/src/__tests__/verify.test.ts +135 -0
- package/src/badge.ts +88 -0
- package/src/cli.ts +314 -0
- package/src/commands.ts +2228 -0
- package/src/config/megagem-config.json +266 -0
- package/src/index.ts +19 -0
- package/src/megagem.ts +1800 -0
- package/src/verify.ts +254 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,1792 @@
|
|
|
1
|
+
// src/commands.ts
|
|
2
|
+
import { BaselineExperienceSystem } from "@baselineos/experience";
|
|
3
|
+
import { BaselineGovernSystem } from "@baselineos/govern";
|
|
4
|
+
import { mkdir, readFile, writeFile, readdir, stat } from "fs/promises";
|
|
5
|
+
import path from "path";
|
|
6
|
+
var BaselineCommandSystem = class {
|
|
7
|
+
state;
|
|
8
|
+
megagem;
|
|
9
|
+
contextEngine;
|
|
10
|
+
baselineLang;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.state = {
|
|
13
|
+
customContextFolder: null,
|
|
14
|
+
baselineMode: false,
|
|
15
|
+
commandQueue: [],
|
|
16
|
+
executionHistory: [],
|
|
17
|
+
currentWorkflow: null
|
|
18
|
+
};
|
|
19
|
+
this.megagem = null;
|
|
20
|
+
this.contextEngine = null;
|
|
21
|
+
this.baselineLang = {
|
|
22
|
+
lexicon: this.initializeBaselineLexicon(),
|
|
23
|
+
syntax: this.initializeBaselineSyntax(),
|
|
24
|
+
commands: this.initializeBaselineCommands()
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the Baseline lexicon with all recognized flags and their
|
|
29
|
+
* descriptions, usage patterns, categories, and examples.
|
|
30
|
+
*/
|
|
31
|
+
initializeBaselineLexicon() {
|
|
32
|
+
return {
|
|
33
|
+
"--onboard": {
|
|
34
|
+
description: "Guided 20-minute onboarding flow to set up a team and run Baseline",
|
|
35
|
+
usage: "--onboard [--name <full-name>] [--role <role>] [--email <email>] [--company <name>] [--team <name>] [--project <name>] [--language <code>] [--learning-style <style>] [--pace <speed>] [--focus <focus>] [--learning-path <path>] [--context <path>] [--mode <mode>] [--skip-workflow] [--fresh] [--interactive]",
|
|
36
|
+
category: "onboarding",
|
|
37
|
+
examples: [
|
|
38
|
+
'--onboard --team "Acme Corp" --project "AI Governance"',
|
|
39
|
+
'--onboard --name "Amani" --role "Platform Lead" --team "GTCX Protocol"',
|
|
40
|
+
"--onboard --language en --learning-style visual --pace fast --focus practical --learning-path standard",
|
|
41
|
+
"--onboard --context ./my-project --mode production",
|
|
42
|
+
"--onboard --skip-workflow",
|
|
43
|
+
"--onboard --fresh",
|
|
44
|
+
"--onboard --interactive"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"--experience": {
|
|
48
|
+
description: "Run an immersive experience sequence based on learning path",
|
|
49
|
+
usage: "--experience [--learning-path <path>] [--experiences <id,id>] [--context <path>] [--fresh]",
|
|
50
|
+
category: "onboarding",
|
|
51
|
+
examples: [
|
|
52
|
+
"--experience --learning-path standard",
|
|
53
|
+
"--experience --learning-path accelerated",
|
|
54
|
+
"--experience --experiences welcome-journey,ai-collaboration",
|
|
55
|
+
"--experience --fresh"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"--config": {
|
|
59
|
+
description: "Configure Baseline preferences and settings",
|
|
60
|
+
usage: "--config <section> [--set <value>] [--region <value>] [--standards <csv>] [--enable <csv>] [--context <path>]",
|
|
61
|
+
category: "setup",
|
|
62
|
+
examples: [
|
|
63
|
+
"--config show",
|
|
64
|
+
"--config language --set en",
|
|
65
|
+
"--config culture --region latin-america --business-style relationship-focused",
|
|
66
|
+
"--config compliance --region eu --standards gdpr,iso27001",
|
|
67
|
+
"--config accessibility --screen-reader --high-contrast"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"--index": {
|
|
71
|
+
description: "Index docs or context for retrieval",
|
|
72
|
+
usage: "--index [--paths <csv>] [--context <path>] [--max <n>]",
|
|
73
|
+
category: "setup",
|
|
74
|
+
examples: ["--index", "--index --paths docs,README.md", "--index --max 500"]
|
|
75
|
+
},
|
|
76
|
+
"--serve": {
|
|
77
|
+
description: "Start the Baseline MCP server (stdio) and optional API server",
|
|
78
|
+
usage: "--serve [--api] [--port <n>] [--context <path>] [--once]",
|
|
79
|
+
category: "setup",
|
|
80
|
+
examples: ["--serve", "--serve --api --port 3141", "--serve --once"]
|
|
81
|
+
},
|
|
82
|
+
"--agents": {
|
|
83
|
+
description: "Show agent registry status",
|
|
84
|
+
usage: "--agents [--context <path>]",
|
|
85
|
+
category: "info",
|
|
86
|
+
examples: ["--agents", "--agents --context ./project"]
|
|
87
|
+
},
|
|
88
|
+
"--doctor": {
|
|
89
|
+
description: "Run diagnostics for Baseline configuration and readiness",
|
|
90
|
+
usage: "--doctor [--context <path>]",
|
|
91
|
+
category: "diagnostics",
|
|
92
|
+
examples: ["--doctor", "--doctor --context ./project"]
|
|
93
|
+
},
|
|
94
|
+
"--baseline": {
|
|
95
|
+
description: "Execute the full Baseline Protocol workflow across all layers",
|
|
96
|
+
usage: "--baseline [options]",
|
|
97
|
+
category: "core",
|
|
98
|
+
examples: [
|
|
99
|
+
"--baseline",
|
|
100
|
+
"--baseline --context ./my-project",
|
|
101
|
+
"--baseline --mode production"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"--run": {
|
|
105
|
+
description: "Run the full Baseline workflow (alias for --baseline)",
|
|
106
|
+
usage: "--run [--context <path>] [--mode <mode>]",
|
|
107
|
+
category: "core",
|
|
108
|
+
examples: ["--run", "--run --context ./project --mode development"]
|
|
109
|
+
},
|
|
110
|
+
"--init": {
|
|
111
|
+
description: "Initialize Baseline and optionally write config",
|
|
112
|
+
usage: "--init [--context <path>] [--mode <mode>] [--write-config]",
|
|
113
|
+
category: "setup",
|
|
114
|
+
examples: ["--init", "--init --write-config", "--init --context ./project"]
|
|
115
|
+
},
|
|
116
|
+
"--baseline-lang": {
|
|
117
|
+
description: "Execute the Baseline language processing layer",
|
|
118
|
+
usage: "--baseline-lang [options]",
|
|
119
|
+
category: "layer",
|
|
120
|
+
examples: [
|
|
121
|
+
"--baseline-lang",
|
|
122
|
+
"--baseline-lang --parse",
|
|
123
|
+
"--baseline-lang --validate"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"--baseline-frame": {
|
|
127
|
+
description: "Execute the Baseline framework orchestration layer",
|
|
128
|
+
usage: "--baseline-frame [options]",
|
|
129
|
+
category: "layer",
|
|
130
|
+
examples: [
|
|
131
|
+
"--baseline-frame",
|
|
132
|
+
"--baseline-frame --scaffold",
|
|
133
|
+
"--baseline-frame --compose"
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
"--baseline-studio": {
|
|
137
|
+
description: "Execute the Baseline studio design and rendering layer",
|
|
138
|
+
usage: "--baseline-studio [options]",
|
|
139
|
+
category: "layer",
|
|
140
|
+
examples: [
|
|
141
|
+
"--baseline-studio",
|
|
142
|
+
"--baseline-studio --render",
|
|
143
|
+
"--baseline-studio --preview"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
"--baseline-govern": {
|
|
147
|
+
description: "Execute the Baseline governance and compliance layer",
|
|
148
|
+
usage: "--baseline-govern [options]",
|
|
149
|
+
category: "layer",
|
|
150
|
+
examples: [
|
|
151
|
+
"--baseline-govern",
|
|
152
|
+
"--baseline-govern --audit",
|
|
153
|
+
"--baseline-govern --policy"
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Initialize syntax patterns for the command system, defining parameter
|
|
160
|
+
* schemas and usage examples for each pattern.
|
|
161
|
+
*/
|
|
162
|
+
initializeBaselineSyntax() {
|
|
163
|
+
return {
|
|
164
|
+
onboarding: {
|
|
165
|
+
pattern: "--onboard [--name <full-name>] [--role <role>] [--email <email>] [--company <name>] [--team <name>] [--project <name>] [--language <code>] [--learning-style <style>] [--pace <speed>] [--focus <focus>] [--learning-path <path>] [--context <path>] [--mode <mode>] [--skip-workflow] [--fresh] [--interactive]",
|
|
166
|
+
parameters: {
|
|
167
|
+
name: "Your name for onboarding personalization",
|
|
168
|
+
role: "Your role (optional)",
|
|
169
|
+
email: "Your email (optional)",
|
|
170
|
+
company: "Company name for the onboarding profile",
|
|
171
|
+
team: "Team name to onboard (optional)",
|
|
172
|
+
project: "Project name to initialize (optional)",
|
|
173
|
+
language: "Preferred language (en, es, fr, de, ja, zh, ko, ar, hi, pt)",
|
|
174
|
+
"learning-style": "Learning style (visual, auditory, kinesthetic, reading)",
|
|
175
|
+
pace: "Learning pace (slow, moderate, fast, lightning)",
|
|
176
|
+
focus: "Learning focus (practical, theoretical, mixed)",
|
|
177
|
+
"learning-path": "Learning path (standard, accelerated, hands-on, theoretical)",
|
|
178
|
+
context: "Path to the project context folder",
|
|
179
|
+
mode: "Execution mode: development | staging | production",
|
|
180
|
+
"skip-workflow": "Skip running the Baseline workflow after onboarding",
|
|
181
|
+
fresh: "Start onboarding from scratch and overwrite any saved profile",
|
|
182
|
+
interactive: "Prompt for onboarding inputs"
|
|
183
|
+
},
|
|
184
|
+
examples: [
|
|
185
|
+
'--onboard --team "Acme" --project "AI Governance"',
|
|
186
|
+
'--onboard --name "Amani" --role "Engineering" --company "GTCX Dev"',
|
|
187
|
+
"--onboard --language en --learning-style visual --learning-path standard",
|
|
188
|
+
"--onboard --context ./project --mode development",
|
|
189
|
+
"--onboard --skip-workflow",
|
|
190
|
+
"--onboard --fresh",
|
|
191
|
+
"--onboard --interactive"
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
experience: {
|
|
195
|
+
pattern: "--experience [--learning-path <path>] [--experiences <id,id>] [--context <path>] [--fresh]",
|
|
196
|
+
parameters: {
|
|
197
|
+
"learning-path": "Learning path (standard, accelerated, hands-on, theoretical)",
|
|
198
|
+
experiences: "Comma-separated experience ids to run",
|
|
199
|
+
context: "Path to the project context folder",
|
|
200
|
+
fresh: "Reset onboarding profile before running experiences"
|
|
201
|
+
},
|
|
202
|
+
examples: [
|
|
203
|
+
"--experience --learning-path standard",
|
|
204
|
+
"--experience --learning-path accelerated",
|
|
205
|
+
"--experience --experiences welcome-journey,ai-collaboration",
|
|
206
|
+
"--experience --fresh"
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
config: {
|
|
210
|
+
pattern: "--config <section> [--set <value>] [--region <value>] [--standards <csv>] [--enable <csv>] [--context <path>]",
|
|
211
|
+
parameters: {
|
|
212
|
+
section: "Config section: show | language | culture | compliance | accessibility",
|
|
213
|
+
set: "Set a value for a given section",
|
|
214
|
+
region: "Set a region for culture/compliance",
|
|
215
|
+
standards: "Comma-separated standards list for compliance",
|
|
216
|
+
enable: "Comma-separated accessibility features to enable",
|
|
217
|
+
context: "Path to the project context folder"
|
|
218
|
+
},
|
|
219
|
+
examples: [
|
|
220
|
+
"--config show",
|
|
221
|
+
"--config language --set en",
|
|
222
|
+
"--config culture --region latin-america --business-style relationship-focused",
|
|
223
|
+
"--config compliance --region eu --standards gdpr,iso27001",
|
|
224
|
+
"--config accessibility --screen-reader --high-contrast"
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
index: {
|
|
228
|
+
pattern: "--index [--paths <csv>] [--context <path>] [--max <n>]",
|
|
229
|
+
parameters: {
|
|
230
|
+
paths: "Comma-separated list of paths to index",
|
|
231
|
+
context: "Context path to resolve relative paths",
|
|
232
|
+
max: "Maximum number of entries to index"
|
|
233
|
+
},
|
|
234
|
+
examples: ["--index", "--index --paths docs,README.md", "--index --max 500"]
|
|
235
|
+
},
|
|
236
|
+
serve: {
|
|
237
|
+
pattern: "--serve [--api] [--port <n>] [--context <path>] [--once]",
|
|
238
|
+
parameters: {
|
|
239
|
+
api: "Start the HTTP/WebSocket API server alongside MCP",
|
|
240
|
+
port: "Port for the API server (default: 3141)",
|
|
241
|
+
context: "Path to the project context folder",
|
|
242
|
+
once: "Start then return immediately (for scripting)"
|
|
243
|
+
},
|
|
244
|
+
examples: ["--serve", "--serve --api --port 3141", "--serve --once"]
|
|
245
|
+
},
|
|
246
|
+
agents: {
|
|
247
|
+
pattern: "--agents [--context <path>]",
|
|
248
|
+
parameters: {
|
|
249
|
+
context: "Path to the project context folder"
|
|
250
|
+
},
|
|
251
|
+
examples: ["--agents", "--agents --context ./project"]
|
|
252
|
+
},
|
|
253
|
+
doctor: {
|
|
254
|
+
pattern: "--doctor [--context <path>]",
|
|
255
|
+
parameters: {
|
|
256
|
+
context: "Path to the project context folder"
|
|
257
|
+
},
|
|
258
|
+
examples: ["--doctor", "--doctor --context ./project"]
|
|
259
|
+
},
|
|
260
|
+
workflow: {
|
|
261
|
+
pattern: "--baseline [--context <path>] [--mode <mode>] [--verbose]",
|
|
262
|
+
parameters: {
|
|
263
|
+
context: "Path to the project context folder",
|
|
264
|
+
mode: "Execution mode: development | staging | production",
|
|
265
|
+
verbose: "Enable verbose logging output"
|
|
266
|
+
},
|
|
267
|
+
examples: [
|
|
268
|
+
"--baseline --context ./project --mode development",
|
|
269
|
+
"--baseline --mode production --verbose"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
run: {
|
|
273
|
+
pattern: "--run [--context <path>] [--mode <mode>]",
|
|
274
|
+
parameters: {
|
|
275
|
+
context: "Path to the project context folder",
|
|
276
|
+
mode: "Execution mode: development | staging | production"
|
|
277
|
+
},
|
|
278
|
+
examples: ["--run", "--run --context ./project --mode development"]
|
|
279
|
+
},
|
|
280
|
+
init: {
|
|
281
|
+
pattern: "--init [--context <path>] [--mode <mode>] [--write-config]",
|
|
282
|
+
parameters: {
|
|
283
|
+
context: "Path to the project context folder",
|
|
284
|
+
mode: "Execution mode: development | staging | production",
|
|
285
|
+
"write-config": "Persist baseline.config.json into .baseline/"
|
|
286
|
+
},
|
|
287
|
+
examples: ["--init --write-config", "--init --context ./project"]
|
|
288
|
+
},
|
|
289
|
+
layer: {
|
|
290
|
+
pattern: "--baseline-<layer> [--input <path>] [--output <path>] [--config <path>]",
|
|
291
|
+
parameters: {
|
|
292
|
+
layer: "Target layer: lang | frame | studio | govern",
|
|
293
|
+
input: "Input file or directory path",
|
|
294
|
+
output: "Output file or directory path",
|
|
295
|
+
config: "Layer-specific configuration file path"
|
|
296
|
+
},
|
|
297
|
+
examples: [
|
|
298
|
+
"--baseline-lang --input ./src --output ./dist",
|
|
299
|
+
"--baseline-frame --config ./baseline.config.json"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
chain: {
|
|
303
|
+
pattern: '--baseline-chain "<cmd1> | <cmd2> | <cmd3>"',
|
|
304
|
+
parameters: {
|
|
305
|
+
commands: "Pipe-delimited list of commands to execute sequentially"
|
|
306
|
+
},
|
|
307
|
+
examples: [
|
|
308
|
+
'--baseline-chain "--baseline-lang | --baseline-frame | --baseline-studio"',
|
|
309
|
+
'--baseline-chain "--init | --baseline"'
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
queue: {
|
|
313
|
+
pattern: "--baseline-queue <add|run|clear|status>",
|
|
314
|
+
parameters: {
|
|
315
|
+
action: "Queue action to perform",
|
|
316
|
+
command: "Command to add (when using add)"
|
|
317
|
+
},
|
|
318
|
+
examples: [
|
|
319
|
+
"--baseline-queue add --baseline-lang",
|
|
320
|
+
"--baseline-queue run",
|
|
321
|
+
"--baseline-queue status"
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Initialize the built-in command registry with descriptions and action
|
|
328
|
+
* identifiers for each recognized command.
|
|
329
|
+
*/
|
|
330
|
+
initializeBaselineCommands() {
|
|
331
|
+
return {
|
|
332
|
+
"--onboard": {
|
|
333
|
+
description: "Run a guided onboarding flow (team, project, system, workflow)",
|
|
334
|
+
action: "onboard",
|
|
335
|
+
category: "onboarding"
|
|
336
|
+
},
|
|
337
|
+
"--experience": {
|
|
338
|
+
description: "Run an immersive experience sequence based on learning path",
|
|
339
|
+
action: "experience",
|
|
340
|
+
category: "onboarding"
|
|
341
|
+
},
|
|
342
|
+
"--config": {
|
|
343
|
+
description: "Configure Baseline preferences and settings",
|
|
344
|
+
action: "config",
|
|
345
|
+
category: "setup"
|
|
346
|
+
},
|
|
347
|
+
"--index": {
|
|
348
|
+
description: "Index docs or context for retrieval",
|
|
349
|
+
action: "index",
|
|
350
|
+
category: "setup"
|
|
351
|
+
},
|
|
352
|
+
"--serve": {
|
|
353
|
+
description: "Start the Baseline server or MCP daemon (placeholder)",
|
|
354
|
+
action: "serve",
|
|
355
|
+
category: "setup"
|
|
356
|
+
},
|
|
357
|
+
"--persona": {
|
|
358
|
+
description: "Show persona status and available roles",
|
|
359
|
+
action: "persona",
|
|
360
|
+
category: "info"
|
|
361
|
+
},
|
|
362
|
+
"--agents": {
|
|
363
|
+
description: "Show agent registry status (placeholder)",
|
|
364
|
+
action: "agents",
|
|
365
|
+
category: "info"
|
|
366
|
+
},
|
|
367
|
+
"--doctor": {
|
|
368
|
+
description: "Run diagnostics for Baseline configuration and readiness",
|
|
369
|
+
action: "doctor",
|
|
370
|
+
category: "diagnostics"
|
|
371
|
+
},
|
|
372
|
+
"--init": {
|
|
373
|
+
description: "Initialize a new Baseline project in the current directory",
|
|
374
|
+
action: "initialize",
|
|
375
|
+
category: "setup"
|
|
376
|
+
},
|
|
377
|
+
"--run": {
|
|
378
|
+
description: "Run the full Baseline workflow with default settings",
|
|
379
|
+
action: "run",
|
|
380
|
+
category: "execution"
|
|
381
|
+
},
|
|
382
|
+
"--status": {
|
|
383
|
+
description: "Display the current status of the Baseline system and active workflows",
|
|
384
|
+
action: "status",
|
|
385
|
+
category: "info"
|
|
386
|
+
},
|
|
387
|
+
"--help": {
|
|
388
|
+
description: "Display help information for all available commands",
|
|
389
|
+
action: "help",
|
|
390
|
+
category: "info"
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Execute the full Baseline Protocol workflow across all five layers:
|
|
396
|
+
* init -> lang -> frame -> studio -> govern
|
|
397
|
+
*/
|
|
398
|
+
async executeBaselineWorkflow(options = {}) {
|
|
399
|
+
const workflowId = `wf-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
400
|
+
const workflow = {
|
|
401
|
+
id: workflowId,
|
|
402
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
403
|
+
options,
|
|
404
|
+
status: "running"
|
|
405
|
+
};
|
|
406
|
+
this.state.currentWorkflow = workflow;
|
|
407
|
+
this.state.baselineMode = true;
|
|
408
|
+
console.log(`[Baseline] Starting workflow ${workflowId}`);
|
|
409
|
+
console.log(`[Baseline] Options: ${JSON.stringify(options)}`);
|
|
410
|
+
try {
|
|
411
|
+
console.log("[Baseline] Step 1/5: Initializing baseline environment...");
|
|
412
|
+
const initResult = await this.initializeBaseline(options);
|
|
413
|
+
if (!initResult.success) {
|
|
414
|
+
throw new Error(`Initialization failed: ${initResult.error || "unknown error"}`);
|
|
415
|
+
}
|
|
416
|
+
console.log("[Baseline] Step 1/5: Initialization complete.");
|
|
417
|
+
console.log("[Baseline] Step 2/5: Processing language layer...");
|
|
418
|
+
const langResult = await this.executeBaselineLang(options);
|
|
419
|
+
if (!langResult.success) {
|
|
420
|
+
throw new Error(`Language layer failed: ${langResult.error || "unknown error"}`);
|
|
421
|
+
}
|
|
422
|
+
console.log("[Baseline] Step 2/5: Language layer complete.");
|
|
423
|
+
console.log("[Baseline] Step 3/5: Processing frame layer...");
|
|
424
|
+
const frameResult = await this.executeBaselineFrame(options);
|
|
425
|
+
if (!frameResult.success) {
|
|
426
|
+
throw new Error(`Frame layer failed: ${frameResult.error || "unknown error"}`);
|
|
427
|
+
}
|
|
428
|
+
console.log("[Baseline] Step 3/5: Frame layer complete.");
|
|
429
|
+
console.log("[Baseline] Step 4/5: Processing studio layer...");
|
|
430
|
+
const studioResult = await this.executeBaselineStudio(options);
|
|
431
|
+
if (!studioResult.success) {
|
|
432
|
+
throw new Error(`Studio layer failed: ${studioResult.error || "unknown error"}`);
|
|
433
|
+
}
|
|
434
|
+
console.log("[Baseline] Step 4/5: Studio layer complete.");
|
|
435
|
+
console.log("[Baseline] Step 5/5: Processing governance layer...");
|
|
436
|
+
const governResult = await this.executeBaselineGovern(options);
|
|
437
|
+
if (!governResult.success) {
|
|
438
|
+
throw new Error(`Governance layer failed: ${governResult.error || "unknown error"}`);
|
|
439
|
+
}
|
|
440
|
+
console.log("[Baseline] Step 5/5: Governance layer complete.");
|
|
441
|
+
workflow.endTime = /* @__PURE__ */ new Date();
|
|
442
|
+
workflow.duration = workflow.endTime.getTime() - workflow.startTime.getTime();
|
|
443
|
+
workflow.status = "completed";
|
|
444
|
+
this.state.executionHistory.push(workflow);
|
|
445
|
+
this.state.currentWorkflow = null;
|
|
446
|
+
console.log(`[Baseline] Workflow ${workflowId} completed in ${workflow.duration}ms`);
|
|
447
|
+
return {
|
|
448
|
+
success: true,
|
|
449
|
+
workflow,
|
|
450
|
+
results: {
|
|
451
|
+
init: initResult,
|
|
452
|
+
lang: langResult,
|
|
453
|
+
frame: frameResult,
|
|
454
|
+
studio: studioResult,
|
|
455
|
+
govern: governResult
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
} catch (error) {
|
|
459
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
460
|
+
workflow.endTime = /* @__PURE__ */ new Date();
|
|
461
|
+
workflow.duration = workflow.endTime.getTime() - workflow.startTime.getTime();
|
|
462
|
+
workflow.status = "failed";
|
|
463
|
+
workflow.error = errorMessage;
|
|
464
|
+
this.state.executionHistory.push(workflow);
|
|
465
|
+
this.state.currentWorkflow = null;
|
|
466
|
+
console.log(`[Baseline] Workflow ${workflowId} failed: ${errorMessage}`);
|
|
467
|
+
return {
|
|
468
|
+
success: false,
|
|
469
|
+
error: errorMessage,
|
|
470
|
+
workflow
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
normalizeString(value) {
|
|
475
|
+
if (typeof value === "string") {
|
|
476
|
+
const trimmed = value.trim();
|
|
477
|
+
return trimmed.length ? trimmed : void 0;
|
|
478
|
+
}
|
|
479
|
+
if (value === null || value === void 0) {
|
|
480
|
+
return void 0;
|
|
481
|
+
}
|
|
482
|
+
const text = String(value).trim();
|
|
483
|
+
return text.length ? text : void 0;
|
|
484
|
+
}
|
|
485
|
+
normalizeBoolean(value) {
|
|
486
|
+
if (typeof value === "boolean") return value;
|
|
487
|
+
if (typeof value === "string") {
|
|
488
|
+
return ["true", "1", "yes", "y"].includes(value.toLowerCase());
|
|
489
|
+
}
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
resolveContext(value, fallback) {
|
|
493
|
+
const resolved = this.normalizeString(value) || fallback || process.cwd();
|
|
494
|
+
return path.resolve(resolved);
|
|
495
|
+
}
|
|
496
|
+
async loadOnboardingProfile(context) {
|
|
497
|
+
const directory = path.join(context, ".baseline");
|
|
498
|
+
const filePath = path.join(directory, "onboarding.json");
|
|
499
|
+
try {
|
|
500
|
+
const raw = await readFile(filePath, "utf8");
|
|
501
|
+
const parsed = JSON.parse(raw);
|
|
502
|
+
return { path: filePath, profile: parsed, exists: true };
|
|
503
|
+
} catch (err) {
|
|
504
|
+
const error = err;
|
|
505
|
+
if (error.code === "ENOENT") {
|
|
506
|
+
return { path: filePath, profile: null, exists: false };
|
|
507
|
+
}
|
|
508
|
+
return { path: filePath, profile: null, exists: false, error: error.message };
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
async saveOnboardingProfile(filePath, profile) {
|
|
512
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
513
|
+
await writeFile(filePath, JSON.stringify(profile, null, 2), "utf8");
|
|
514
|
+
}
|
|
515
|
+
async loadBaselineConfig(context) {
|
|
516
|
+
const directory = path.join(context, ".baseline");
|
|
517
|
+
const filePath = path.join(directory, "baseline.config.json");
|
|
518
|
+
try {
|
|
519
|
+
const raw = await readFile(filePath, "utf8");
|
|
520
|
+
const parsed = JSON.parse(raw);
|
|
521
|
+
return { path: filePath, config: parsed, exists: true };
|
|
522
|
+
} catch (err) {
|
|
523
|
+
const error = err;
|
|
524
|
+
if (error.code === "ENOENT") {
|
|
525
|
+
return { path: filePath, config: null, exists: false };
|
|
526
|
+
}
|
|
527
|
+
return { path: filePath, config: null, exists: false, error: error.message };
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
async saveBaselineConfig(filePath, config) {
|
|
531
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
532
|
+
await writeFile(filePath, JSON.stringify(config, null, 2), "utf8");
|
|
533
|
+
}
|
|
534
|
+
async fileExists(filePath) {
|
|
535
|
+
try {
|
|
536
|
+
const result = await stat(filePath);
|
|
537
|
+
return result.isFile() || result.isDirectory();
|
|
538
|
+
} catch {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
buildDefaultConfig(context, profile) {
|
|
543
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
544
|
+
return {
|
|
545
|
+
version: 1,
|
|
546
|
+
context,
|
|
547
|
+
createdAt: now,
|
|
548
|
+
updatedAt: now,
|
|
549
|
+
language: profile?.preferences?.language || "en",
|
|
550
|
+
preferences: {
|
|
551
|
+
learningStyle: profile?.preferences?.learningStyle,
|
|
552
|
+
pace: profile?.preferences?.pace,
|
|
553
|
+
focus: profile?.preferences?.focus,
|
|
554
|
+
learningPath: profile?.preferences?.learningPath
|
|
555
|
+
},
|
|
556
|
+
culture: {},
|
|
557
|
+
compliance: {},
|
|
558
|
+
accessibility: {}
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
getExperienceCatalog() {
|
|
562
|
+
return {
|
|
563
|
+
"welcome-journey": {
|
|
564
|
+
id: "welcome-journey",
|
|
565
|
+
name: "Welcome Journey",
|
|
566
|
+
description: "Interactive introduction to Baseline and AI-native development.",
|
|
567
|
+
duration: "5-10 minutes",
|
|
568
|
+
difficulty: "beginner",
|
|
569
|
+
type: "story",
|
|
570
|
+
tags: ["onboarding", "introduction", "story"]
|
|
571
|
+
},
|
|
572
|
+
"acceleration-discovery": {
|
|
573
|
+
id: "acceleration-discovery",
|
|
574
|
+
name: "Acceleration Discovery",
|
|
575
|
+
description: "Experience the jump from 300x to 1,000,000x acceleration.",
|
|
576
|
+
duration: "10-15 minutes",
|
|
577
|
+
difficulty: "beginner",
|
|
578
|
+
type: "interactive",
|
|
579
|
+
tags: ["acceleration", "demo", "interactive"]
|
|
580
|
+
},
|
|
581
|
+
"ai-collaboration": {
|
|
582
|
+
id: "ai-collaboration",
|
|
583
|
+
name: "AI Collaboration Workshop",
|
|
584
|
+
description: "Learn to coordinate with autonomous AI systems.",
|
|
585
|
+
duration: "15-20 minutes",
|
|
586
|
+
difficulty: "intermediate",
|
|
587
|
+
type: "workshop",
|
|
588
|
+
tags: ["workshop", "ai", "collaboration"]
|
|
589
|
+
},
|
|
590
|
+
"quantum-leap": {
|
|
591
|
+
id: "quantum-leap",
|
|
592
|
+
name: "Quantum Leap Challenge",
|
|
593
|
+
description: "Tackle advanced challenges with quantum-level acceleration.",
|
|
594
|
+
duration: "20-30 minutes",
|
|
595
|
+
difficulty: "advanced",
|
|
596
|
+
type: "challenge",
|
|
597
|
+
tags: ["challenge", "quantum", "advanced"]
|
|
598
|
+
},
|
|
599
|
+
"singularity-mastery": {
|
|
600
|
+
id: "singularity-mastery",
|
|
601
|
+
name: "Singularity Mastery",
|
|
602
|
+
description: "Master the highest tiers of AI-native execution.",
|
|
603
|
+
duration: "30-45 minutes",
|
|
604
|
+
difficulty: "expert",
|
|
605
|
+
type: "mastery",
|
|
606
|
+
tags: ["mastery", "singularity", "expert"]
|
|
607
|
+
},
|
|
608
|
+
"concept-exploration": {
|
|
609
|
+
id: "concept-exploration",
|
|
610
|
+
name: "Concept Exploration",
|
|
611
|
+
description: "Deep dive into AI-native development concepts.",
|
|
612
|
+
duration: "15-20 minutes",
|
|
613
|
+
difficulty: "intermediate",
|
|
614
|
+
type: "theoretical",
|
|
615
|
+
tags: ["theoretical", "concepts", "learning"]
|
|
616
|
+
},
|
|
617
|
+
"theory-workshop": {
|
|
618
|
+
id: "theory-workshop",
|
|
619
|
+
name: "Theory Workshop",
|
|
620
|
+
description: "Explore the principles behind Baseline OS.",
|
|
621
|
+
duration: "25-35 minutes",
|
|
622
|
+
difficulty: "advanced",
|
|
623
|
+
type: "workshop",
|
|
624
|
+
tags: ["workshop", "theory", "principles"]
|
|
625
|
+
},
|
|
626
|
+
"advanced-concepts": {
|
|
627
|
+
id: "advanced-concepts",
|
|
628
|
+
name: "Advanced Concepts",
|
|
629
|
+
description: "Master advanced AI-native concepts and patterns.",
|
|
630
|
+
duration: "30-40 minutes",
|
|
631
|
+
difficulty: "expert",
|
|
632
|
+
type: "theoretical",
|
|
633
|
+
tags: ["theoretical", "advanced", "mastery"]
|
|
634
|
+
},
|
|
635
|
+
"workshop-series": {
|
|
636
|
+
id: "workshop-series",
|
|
637
|
+
name: "Workshop Series",
|
|
638
|
+
description: "Hands-on applied learning series.",
|
|
639
|
+
duration: "45-60 minutes",
|
|
640
|
+
difficulty: "intermediate",
|
|
641
|
+
type: "workshop",
|
|
642
|
+
tags: ["workshop", "series", "hands-on"]
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
getLearningPaths() {
|
|
647
|
+
return {
|
|
648
|
+
standard: {
|
|
649
|
+
name: "Standard Path",
|
|
650
|
+
experiences: ["welcome-journey", "acceleration-discovery", "ai-collaboration"]
|
|
651
|
+
},
|
|
652
|
+
accelerated: {
|
|
653
|
+
name: "Accelerated Path",
|
|
654
|
+
experiences: ["acceleration-discovery", "quantum-leap", "singularity-mastery"]
|
|
655
|
+
},
|
|
656
|
+
"hands-on": {
|
|
657
|
+
name: "Hands-On Path",
|
|
658
|
+
experiences: ["ai-collaboration", "quantum-leap", "workshop-series"]
|
|
659
|
+
},
|
|
660
|
+
theoretical: {
|
|
661
|
+
name: "Theoretical Path",
|
|
662
|
+
experiences: ["concept-exploration", "theory-workshop", "advanced-concepts"]
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Execute a guided onboarding flow (team, project, system) and optionally
|
|
668
|
+
* run the full Baseline workflow. Designed for a 20-minute quickstart.
|
|
669
|
+
*/
|
|
670
|
+
async executeOnboarding(options = {}) {
|
|
671
|
+
const startedAt = Date.now();
|
|
672
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
673
|
+
const forceFresh = this.normalizeBoolean(options.fresh) || this.normalizeBoolean(options.reset);
|
|
674
|
+
const existingProfile = forceFresh ? null : await this.loadOnboardingProfile(context);
|
|
675
|
+
const prior = existingProfile?.profile ?? null;
|
|
676
|
+
const name = this.normalizeString(options.name) || prior?.user?.name || "User";
|
|
677
|
+
const role = this.normalizeString(options.role) || prior?.user?.role || "Operator";
|
|
678
|
+
const email = this.normalizeString(options.email) || prior?.user?.email;
|
|
679
|
+
const company = this.normalizeString(options.company) || prior?.company || "Acme Corp";
|
|
680
|
+
const team = this.normalizeString(options.team) || prior?.team;
|
|
681
|
+
const project = this.normalizeString(options.project) || prior?.project;
|
|
682
|
+
const mode = this.normalizeString(options.mode) || prior?.mode || "development";
|
|
683
|
+
const language = this.normalizeString(options.language) || prior?.preferences?.language || "en";
|
|
684
|
+
const learningStyle = this.normalizeString(options["learning-style"]) || prior?.preferences?.learningStyle || "visual";
|
|
685
|
+
const pace = this.normalizeString(options.pace) || prior?.preferences?.pace || "moderate";
|
|
686
|
+
const focus = this.normalizeString(options.focus) || prior?.preferences?.focus || "practical";
|
|
687
|
+
const learningPath = this.normalizeString(options["learning-path"]) || prior?.preferences?.learningPath || "standard";
|
|
688
|
+
const skipWorkflow = this.normalizeBoolean(options["skip-workflow"]);
|
|
689
|
+
console.log("[Baseline:Onboarding] Starting 20-minute onboarding flow");
|
|
690
|
+
console.log(`[Baseline:Onboarding] Welcome: ${name} (${role})`);
|
|
691
|
+
console.log(`[Baseline:Onboarding] Language: ${language}`);
|
|
692
|
+
console.log(
|
|
693
|
+
`[Baseline:Onboarding] Learning path: ${learningPath} (${learningStyle}, ${pace}, ${focus})`
|
|
694
|
+
);
|
|
695
|
+
if (team) {
|
|
696
|
+
console.log(`[Baseline:Onboarding] Team: ${team}`);
|
|
697
|
+
}
|
|
698
|
+
console.log(`[Baseline:Onboarding] Company: ${company}`);
|
|
699
|
+
if (project) {
|
|
700
|
+
console.log(`[Baseline:Onboarding] Project: ${project}`);
|
|
701
|
+
}
|
|
702
|
+
console.log(`[Baseline:Onboarding] Context: ${context}`);
|
|
703
|
+
console.log(`[Baseline:Onboarding] Mode: ${mode}`);
|
|
704
|
+
if (existingProfile?.exists && !forceFresh) {
|
|
705
|
+
console.log("[Baseline:Onboarding] Resuming from saved onboarding profile");
|
|
706
|
+
}
|
|
707
|
+
if (skipWorkflow) {
|
|
708
|
+
console.log("[Baseline:Onboarding] Workflow execution skipped by flag");
|
|
709
|
+
}
|
|
710
|
+
const experience = new BaselineExperienceSystem();
|
|
711
|
+
const systemResult = await experience.onboarding.system.initialize();
|
|
712
|
+
const systemId = systemResult.systemId || `system-${Date.now()}`;
|
|
713
|
+
const systemConfig = await experience.onboarding.system.configure(systemId, {
|
|
714
|
+
user: { name, role, email },
|
|
715
|
+
company,
|
|
716
|
+
team,
|
|
717
|
+
project,
|
|
718
|
+
context,
|
|
719
|
+
mode,
|
|
720
|
+
preferences: { language, learningStyle, pace, focus, learningPath }
|
|
721
|
+
});
|
|
722
|
+
let teamResult;
|
|
723
|
+
let teamConfig;
|
|
724
|
+
let teamId;
|
|
725
|
+
if (team) {
|
|
726
|
+
teamResult = await experience.onboarding.team.start(company);
|
|
727
|
+
teamId = teamResult.teamId ?? `team-${Date.now()}`;
|
|
728
|
+
teamConfig = await experience.onboarding.team.configure(teamId, {
|
|
729
|
+
user: { name, role, email },
|
|
730
|
+
team,
|
|
731
|
+
company,
|
|
732
|
+
mode
|
|
733
|
+
});
|
|
734
|
+
} else {
|
|
735
|
+
teamResult = { success: true, skipped: true, reason: "team not provided" };
|
|
736
|
+
teamConfig = { success: true, skipped: true, reason: "team not provided" };
|
|
737
|
+
}
|
|
738
|
+
let projectResult;
|
|
739
|
+
let projectConfig;
|
|
740
|
+
let projectId;
|
|
741
|
+
if (project) {
|
|
742
|
+
projectResult = await experience.onboarding.project.setup(project);
|
|
743
|
+
projectId = projectResult.projectId ?? `project-${Date.now()}`;
|
|
744
|
+
projectConfig = await experience.onboarding.project.configure(projectId, {
|
|
745
|
+
teamId,
|
|
746
|
+
context
|
|
747
|
+
});
|
|
748
|
+
} else {
|
|
749
|
+
projectResult = { success: true, skipped: true, reason: "project not provided" };
|
|
750
|
+
projectConfig = { success: true, skipped: true, reason: "project not provided" };
|
|
751
|
+
}
|
|
752
|
+
let workflow = null;
|
|
753
|
+
if (!skipWorkflow) {
|
|
754
|
+
workflow = await this.executeBaselineWorkflow({ context, mode });
|
|
755
|
+
}
|
|
756
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
757
|
+
const completedSteps = ["identity", "preferences", "workspace"];
|
|
758
|
+
if (!skipWorkflow) {
|
|
759
|
+
completedSteps.push("workflow");
|
|
760
|
+
}
|
|
761
|
+
const profile = {
|
|
762
|
+
version: 2,
|
|
763
|
+
createdAt: prior?.createdAt || now,
|
|
764
|
+
updatedAt: now,
|
|
765
|
+
user: { name, role, ...email ? { email } : {} },
|
|
766
|
+
company,
|
|
767
|
+
...team ? { team } : {},
|
|
768
|
+
...project ? { project } : {},
|
|
769
|
+
context,
|
|
770
|
+
mode,
|
|
771
|
+
preferences: { language, learningStyle, pace, focus, learningPath },
|
|
772
|
+
progress: {
|
|
773
|
+
completedSteps,
|
|
774
|
+
lastStep: completedSteps[completedSteps.length - 1],
|
|
775
|
+
lastCompletedAt: now
|
|
776
|
+
},
|
|
777
|
+
experiences: prior?.experiences ?? { completed: [] },
|
|
778
|
+
...workflow?.workflow?.id ? { workflow: { lastRunAt: now, lastWorkflowId: workflow.workflow.id } } : {}
|
|
779
|
+
};
|
|
780
|
+
const storage = existingProfile ?? {
|
|
781
|
+
path: path.join(context, ".baseline", "onboarding.json"),
|
|
782
|
+
exists: false,
|
|
783
|
+
profile: null
|
|
784
|
+
};
|
|
785
|
+
let storageSaved = false;
|
|
786
|
+
let storageError;
|
|
787
|
+
try {
|
|
788
|
+
await this.saveOnboardingProfile(storage.path, profile);
|
|
789
|
+
storageSaved = true;
|
|
790
|
+
} catch (err) {
|
|
791
|
+
storageError = err instanceof Error ? err.message : String(err);
|
|
792
|
+
console.log(`[Baseline:Onboarding] Failed to save profile: ${storageError}`);
|
|
793
|
+
}
|
|
794
|
+
const success = systemResult.success && systemConfig.success && teamResult.success && teamConfig.success && projectResult.success && projectConfig.success && (workflow ? workflow.success : true);
|
|
795
|
+
return {
|
|
796
|
+
success,
|
|
797
|
+
onboarding: {
|
|
798
|
+
system: systemResult,
|
|
799
|
+
systemConfig,
|
|
800
|
+
user: { name, role, email },
|
|
801
|
+
preferences: { language, learningStyle, pace, focus, learningPath },
|
|
802
|
+
profile,
|
|
803
|
+
storage: {
|
|
804
|
+
path: storage.path,
|
|
805
|
+
saved: storageSaved,
|
|
806
|
+
error: storageError
|
|
807
|
+
},
|
|
808
|
+
team: teamResult,
|
|
809
|
+
teamConfig,
|
|
810
|
+
project: projectResult,
|
|
811
|
+
projectConfig
|
|
812
|
+
},
|
|
813
|
+
workflow,
|
|
814
|
+
nextSteps: [
|
|
815
|
+
"Run `baseline status` to verify layer status.",
|
|
816
|
+
"Run `baseline --baseline` to execute the full workflow.",
|
|
817
|
+
"Follow docs/experience/baseline-20-min-onboarding.md for mastery path."
|
|
818
|
+
],
|
|
819
|
+
durationMs: Date.now() - startedAt
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Execute an immersive experience sequence based on the selected learning path.
|
|
824
|
+
* Uses onboarding profile data and persists progress.
|
|
825
|
+
*/
|
|
826
|
+
async executeExperience(options = {}) {
|
|
827
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
828
|
+
const forceFresh = this.normalizeBoolean(options.fresh) || this.normalizeBoolean(options.reset);
|
|
829
|
+
const storage = forceFresh ? null : await this.loadOnboardingProfile(context);
|
|
830
|
+
let profile = storage?.profile ?? null;
|
|
831
|
+
if (!profile) {
|
|
832
|
+
console.log("[Baseline:Experience] No onboarding profile found. Bootstrapping profile...");
|
|
833
|
+
const onboardingResult = await this.executeOnboarding({
|
|
834
|
+
...options,
|
|
835
|
+
context,
|
|
836
|
+
"skip-workflow": true,
|
|
837
|
+
fresh: forceFresh
|
|
838
|
+
});
|
|
839
|
+
profile = onboardingResult.onboarding?.profile ?? null;
|
|
840
|
+
}
|
|
841
|
+
if (!profile) {
|
|
842
|
+
return { success: false, error: "Unable to load or create onboarding profile." };
|
|
843
|
+
}
|
|
844
|
+
const catalog = this.getExperienceCatalog();
|
|
845
|
+
const paths = this.getLearningPaths();
|
|
846
|
+
const learningPath = this.normalizeString(options["learning-path"]) || profile.preferences.learningPath || "standard";
|
|
847
|
+
const explicitList = this.normalizeString(options.experiences);
|
|
848
|
+
const requested = explicitList ? explicitList.split(",").map((entry) => entry.trim()).filter((entry) => entry.length) : paths[learningPath]?.experiences || paths.standard.experiences;
|
|
849
|
+
const experiences = requested.filter((id) => !!catalog[id]);
|
|
850
|
+
if (experiences.length === 0) {
|
|
851
|
+
return {
|
|
852
|
+
success: false,
|
|
853
|
+
error: "No valid experiences found. Provide --learning-path or --experiences."
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
console.log("[Baseline:Experience] Starting experience sequence");
|
|
857
|
+
console.log(`[Baseline:Experience] Path: ${learningPath}`);
|
|
858
|
+
experiences.forEach((experienceId, index) => {
|
|
859
|
+
const experience = catalog[experienceId];
|
|
860
|
+
console.log(
|
|
861
|
+
`[Baseline:Experience] ${index + 1}/${experiences.length}: ${experience.name} (${experience.duration})`
|
|
862
|
+
);
|
|
863
|
+
console.log(` ${experience.description}`);
|
|
864
|
+
});
|
|
865
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
866
|
+
const completed = Array.from(
|
|
867
|
+
/* @__PURE__ */ new Set([...profile.experiences?.completed ?? [], ...experiences])
|
|
868
|
+
);
|
|
869
|
+
const updatedProfile = {
|
|
870
|
+
...profile,
|
|
871
|
+
updatedAt: now,
|
|
872
|
+
preferences: {
|
|
873
|
+
...profile.preferences,
|
|
874
|
+
learningPath
|
|
875
|
+
},
|
|
876
|
+
experiences: {
|
|
877
|
+
completed,
|
|
878
|
+
lastExperience: experiences[experiences.length - 1],
|
|
879
|
+
lastCompletedAt: now
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
const targetPath = storage?.path ?? path.join(context, ".baseline", "onboarding.json");
|
|
883
|
+
let storageSaved = false;
|
|
884
|
+
let storageError;
|
|
885
|
+
try {
|
|
886
|
+
await this.saveOnboardingProfile(targetPath, updatedProfile);
|
|
887
|
+
storageSaved = true;
|
|
888
|
+
} catch (err) {
|
|
889
|
+
storageError = err instanceof Error ? err.message : String(err);
|
|
890
|
+
console.log(`[Baseline:Experience] Failed to save profile: ${storageError}`);
|
|
891
|
+
}
|
|
892
|
+
return {
|
|
893
|
+
success: true,
|
|
894
|
+
experience: {
|
|
895
|
+
path: learningPath,
|
|
896
|
+
experiences: experiences.map((id) => catalog[id]),
|
|
897
|
+
completed
|
|
898
|
+
},
|
|
899
|
+
profile: updatedProfile,
|
|
900
|
+
storage: {
|
|
901
|
+
path: targetPath,
|
|
902
|
+
saved: storageSaved,
|
|
903
|
+
error: storageError
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Initialize Baseline and optionally persist config to disk.
|
|
909
|
+
*/
|
|
910
|
+
async executeInit(options = {}) {
|
|
911
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
912
|
+
const mode = this.normalizeString(options.mode) || "development";
|
|
913
|
+
const writeConfig = this.normalizeBoolean(options["write-config"]) || this.normalizeBoolean(options.persist) || this.normalizeBoolean(options.write);
|
|
914
|
+
const initResult = await this.initializeBaseline({ context, mode });
|
|
915
|
+
if (!initResult.success) {
|
|
916
|
+
return initResult;
|
|
917
|
+
}
|
|
918
|
+
if (!writeConfig) {
|
|
919
|
+
return {
|
|
920
|
+
...initResult,
|
|
921
|
+
message: "Initialization complete (config not written). Use --write-config to persist."
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
const profile = await this.loadOnboardingProfile(context);
|
|
925
|
+
const configRecord = await this.loadBaselineConfig(context);
|
|
926
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
927
|
+
const config = {
|
|
928
|
+
...configRecord.config ?? this.buildDefaultConfig(context, profile.profile),
|
|
929
|
+
context,
|
|
930
|
+
updatedAt: now
|
|
931
|
+
};
|
|
932
|
+
await this.saveBaselineConfig(configRecord.path, config);
|
|
933
|
+
return {
|
|
934
|
+
...initResult,
|
|
935
|
+
config,
|
|
936
|
+
configPath: configRecord.path,
|
|
937
|
+
message: "Initialization complete and config written."
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Update or show Baseline configuration.
|
|
942
|
+
*/
|
|
943
|
+
async executeConfig(options = {}) {
|
|
944
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
945
|
+
const positional = Array.isArray(options._) && options._.length ? options._ : [];
|
|
946
|
+
const section = this.normalizeString(options.config) || this.normalizeString(options.section) || (positional.length ? this.normalizeString(positional[0]) : void 0) || "show";
|
|
947
|
+
const showOnly = this.normalizeBoolean(options.show) || section === "show" || !options.set && !options.region && !options.standards && !options.enable;
|
|
948
|
+
const onboarding = await this.loadOnboardingProfile(context);
|
|
949
|
+
const existing = await this.loadBaselineConfig(context);
|
|
950
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
951
|
+
const config = existing.config ?? this.buildDefaultConfig(context, onboarding.profile);
|
|
952
|
+
if (showOnly) {
|
|
953
|
+
return {
|
|
954
|
+
success: true,
|
|
955
|
+
config,
|
|
956
|
+
configPath: existing.path
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
if (section === "language") {
|
|
960
|
+
const value = this.normalizeString(options.set);
|
|
961
|
+
if (!value) {
|
|
962
|
+
return { success: false, error: "Missing --set <language-code>" };
|
|
963
|
+
}
|
|
964
|
+
config.language = value;
|
|
965
|
+
if (onboarding.profile) {
|
|
966
|
+
onboarding.profile.preferences.language = value;
|
|
967
|
+
onboarding.profile.updatedAt = now;
|
|
968
|
+
await this.saveOnboardingProfile(onboarding.path, onboarding.profile);
|
|
969
|
+
}
|
|
970
|
+
} else if (section === "culture") {
|
|
971
|
+
const region = this.normalizeString(options.region);
|
|
972
|
+
const businessStyle = this.normalizeString(options["business-style"]) || this.normalizeString(options.business);
|
|
973
|
+
config.culture = {
|
|
974
|
+
...config.culture,
|
|
975
|
+
...region ? { region } : {},
|
|
976
|
+
...businessStyle ? { businessStyle } : {}
|
|
977
|
+
};
|
|
978
|
+
} else if (section === "compliance") {
|
|
979
|
+
const region = this.normalizeString(options.region);
|
|
980
|
+
const standardsRaw = this.normalizeString(options.standards);
|
|
981
|
+
const standards = standardsRaw ? standardsRaw.split(",").map((entry) => entry.trim()).filter(Boolean) : void 0;
|
|
982
|
+
config.compliance = {
|
|
983
|
+
...config.compliance,
|
|
984
|
+
...region ? { region } : {},
|
|
985
|
+
...standards ? { standards } : {}
|
|
986
|
+
};
|
|
987
|
+
} else if (section === "accessibility") {
|
|
988
|
+
const enabledRaw = this.normalizeString(options.enable);
|
|
989
|
+
const enabled = enabledRaw ? enabledRaw.split(",").map((entry) => entry.trim()).filter(Boolean) : [];
|
|
990
|
+
config.accessibility = {
|
|
991
|
+
...config.accessibility,
|
|
992
|
+
...enabled.length ? { enabled } : {},
|
|
993
|
+
...this.normalizeBoolean(options["screen-reader"]) ? { screenReader: true } : {},
|
|
994
|
+
...this.normalizeBoolean(options["high-contrast"]) ? { highContrast: true } : {},
|
|
995
|
+
...this.normalizeBoolean(options["voice-control"]) ? { voiceControl: true } : {}
|
|
996
|
+
};
|
|
997
|
+
} else {
|
|
998
|
+
return { success: false, error: `Unknown config section: ${section}` };
|
|
999
|
+
}
|
|
1000
|
+
config.updatedAt = now;
|
|
1001
|
+
await this.saveBaselineConfig(existing.path, config);
|
|
1002
|
+
return {
|
|
1003
|
+
success: true,
|
|
1004
|
+
config,
|
|
1005
|
+
configPath: existing.path
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
async collectIndexEntries(root, maxEntries) {
|
|
1009
|
+
const entries = [];
|
|
1010
|
+
const queue = [root];
|
|
1011
|
+
const ignore = /* @__PURE__ */ new Set([".git", "node_modules", ".baseline", "dist", ".next", "build"]);
|
|
1012
|
+
while (queue.length && entries.length < maxEntries) {
|
|
1013
|
+
const current = queue.shift();
|
|
1014
|
+
if (!current) continue;
|
|
1015
|
+
let currentStat;
|
|
1016
|
+
try {
|
|
1017
|
+
currentStat = await stat(current);
|
|
1018
|
+
} catch {
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
if (currentStat.isFile()) {
|
|
1022
|
+
entries.push(current);
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
if (!currentStat.isDirectory()) continue;
|
|
1026
|
+
const name = path.basename(current);
|
|
1027
|
+
if (ignore.has(name)) continue;
|
|
1028
|
+
let children = [];
|
|
1029
|
+
try {
|
|
1030
|
+
children = await readdir(current);
|
|
1031
|
+
} catch {
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
for (const child of children) {
|
|
1035
|
+
if (entries.length >= maxEntries) break;
|
|
1036
|
+
queue.push(path.join(current, child));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return entries;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Index documentation/context files for retrieval.
|
|
1043
|
+
*/
|
|
1044
|
+
async executeIndex(options = {}) {
|
|
1045
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
1046
|
+
const positional = Array.isArray(options._) && options._.length ? options._ : [];
|
|
1047
|
+
const pathsRaw = this.normalizeString(options.paths) || this.normalizeString(options.path) || (positional.length ? positional.join(",") : void 0);
|
|
1048
|
+
const defaultCandidates = ["docs", "README.md"].map((entry) => path.join(context, entry)).filter((entry) => entry !== "");
|
|
1049
|
+
const targets = pathsRaw ? pathsRaw.split(",").map((entry) => entry.trim()).filter(Boolean).map((entry) => path.resolve(context, entry)) : defaultCandidates;
|
|
1050
|
+
const maxEntries = Number(options.max) > 0 ? Number(options.max) : 2e3;
|
|
1051
|
+
console.log(`[Baseline:Index] Scanning ${targets.length} target(s) in ${context}`);
|
|
1052
|
+
const files = [];
|
|
1053
|
+
for (const target of targets) {
|
|
1054
|
+
const before = files.length;
|
|
1055
|
+
const collected = await this.collectIndexEntries(target, maxEntries - files.length);
|
|
1056
|
+
files.push(...collected);
|
|
1057
|
+
const added = files.length - before;
|
|
1058
|
+
if (added > 0) console.log(`[Baseline:Index] ${path.relative(context, target) || target} \u2192 ${added} file(s)`);
|
|
1059
|
+
if (files.length >= maxEntries) break;
|
|
1060
|
+
}
|
|
1061
|
+
console.log(`[Baseline:Index] Total: ${files.length} document(s) indexed`);
|
|
1062
|
+
const index = files.map((filePath) => ({
|
|
1063
|
+
path: filePath,
|
|
1064
|
+
relativePath: path.relative(context, filePath)
|
|
1065
|
+
}));
|
|
1066
|
+
const indexPath = path.join(context, ".baseline", "index.json");
|
|
1067
|
+
await mkdir(path.dirname(indexPath), { recursive: true });
|
|
1068
|
+
await writeFile(
|
|
1069
|
+
indexPath,
|
|
1070
|
+
JSON.stringify(
|
|
1071
|
+
{
|
|
1072
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1073
|
+
context,
|
|
1074
|
+
total: index.length,
|
|
1075
|
+
entries: index
|
|
1076
|
+
},
|
|
1077
|
+
null,
|
|
1078
|
+
2
|
|
1079
|
+
),
|
|
1080
|
+
"utf8"
|
|
1081
|
+
);
|
|
1082
|
+
return {
|
|
1083
|
+
success: true,
|
|
1084
|
+
indexed: index.length,
|
|
1085
|
+
indexPath,
|
|
1086
|
+
targets
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Placeholder for MCP server/daemon execution.
|
|
1091
|
+
*/
|
|
1092
|
+
async executeServe(options = {}) {
|
|
1093
|
+
return this.executeServeWithOptions(options);
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Placeholder for agent status and management.
|
|
1097
|
+
*/
|
|
1098
|
+
executePersona(_options = {}) {
|
|
1099
|
+
const personas = [
|
|
1100
|
+
{ id: "developer", name: "Developer", focus: "Code governance, CI/CD integration, deployment validation" },
|
|
1101
|
+
{ id: "compliance-officer", name: "Compliance Officer", focus: "Policy enforcement, evidence export, regulatory alignment" },
|
|
1102
|
+
{ id: "platform-engineer", name: "Platform Engineer", focus: "System health, agent management, infrastructure monitoring" },
|
|
1103
|
+
{ id: "dfi-partner", name: "DFI Partner / Auditor", focus: "Evidence review, compliance verification, audit trails" },
|
|
1104
|
+
{ id: "trade-finance", name: "Trade Finance Officer", focus: "AfCFTA compliance, trade governance, DFI evidence" }
|
|
1105
|
+
];
|
|
1106
|
+
console.log("[Baseline:Persona]");
|
|
1107
|
+
console.log(" Available personas:");
|
|
1108
|
+
console.log("");
|
|
1109
|
+
for (const persona of personas) {
|
|
1110
|
+
console.log(` ${persona.id.padEnd(22)} ${persona.name}`);
|
|
1111
|
+
console.log(` ${"".padEnd(22)} ${persona.focus}`);
|
|
1112
|
+
console.log("");
|
|
1113
|
+
}
|
|
1114
|
+
console.log(" Set persona in Settings or baseline.config.ts");
|
|
1115
|
+
return { success: true, personas };
|
|
1116
|
+
}
|
|
1117
|
+
async executeAgents(options = {}) {
|
|
1118
|
+
return this.executeAgentsWithOptions(options);
|
|
1119
|
+
}
|
|
1120
|
+
async buildBaselineOS(context) {
|
|
1121
|
+
const { Baseline } = await import("baselineos");
|
|
1122
|
+
const knowledge = [
|
|
1123
|
+
path.join(context, "docs"),
|
|
1124
|
+
path.join(context, "README.md")
|
|
1125
|
+
];
|
|
1126
|
+
return new Baseline({
|
|
1127
|
+
projectRoot: context,
|
|
1128
|
+
knowledge,
|
|
1129
|
+
paths: {
|
|
1130
|
+
data: path.join(context, ".baseline"),
|
|
1131
|
+
index: path.join(context, ".baseline", "index"),
|
|
1132
|
+
checkpoints: path.join(context, ".baseline", "checkpoints")
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
async executeServeWithOptions(options) {
|
|
1137
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
1138
|
+
const withApi = this.normalizeBoolean(options.api);
|
|
1139
|
+
const portRaw = this.normalizeString(options.port);
|
|
1140
|
+
const port = portRaw && Number(portRaw) > 0 ? Number(portRaw) : 3141;
|
|
1141
|
+
const once = this.normalizeBoolean(options.once);
|
|
1142
|
+
const baseline = await this.buildBaselineOS(context);
|
|
1143
|
+
await baseline.init();
|
|
1144
|
+
const mcpServer = await baseline.startMCPServer();
|
|
1145
|
+
let apiServer = null;
|
|
1146
|
+
if (withApi) {
|
|
1147
|
+
apiServer = await baseline.startAPIServer(port);
|
|
1148
|
+
}
|
|
1149
|
+
console.error(
|
|
1150
|
+
`[Baseline:Serve] MCP server started (stdio)${withApi ? ` + API:${port}` : ""}`
|
|
1151
|
+
);
|
|
1152
|
+
if (once) {
|
|
1153
|
+
return {
|
|
1154
|
+
success: true,
|
|
1155
|
+
status: "running",
|
|
1156
|
+
mode: "stdio",
|
|
1157
|
+
api: withApi ? { port } : null,
|
|
1158
|
+
message: "Server started (once mode)."
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
await new Promise((resolve) => {
|
|
1162
|
+
const handle = async () => {
|
|
1163
|
+
try {
|
|
1164
|
+
await mcpServer.stop();
|
|
1165
|
+
} catch {
|
|
1166
|
+
}
|
|
1167
|
+
if (apiServer && typeof apiServer === "object" && "stop" in apiServer) {
|
|
1168
|
+
await apiServer.stop();
|
|
1169
|
+
}
|
|
1170
|
+
await baseline.shutdown();
|
|
1171
|
+
resolve();
|
|
1172
|
+
};
|
|
1173
|
+
process.on("SIGINT", handle);
|
|
1174
|
+
process.on("SIGTERM", handle);
|
|
1175
|
+
});
|
|
1176
|
+
return {
|
|
1177
|
+
success: true,
|
|
1178
|
+
status: "stopped"
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
async executeAgentsWithOptions(options) {
|
|
1182
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
1183
|
+
const baseline = await this.buildBaselineOS(context);
|
|
1184
|
+
await baseline.init();
|
|
1185
|
+
const agents = baseline.listAgents();
|
|
1186
|
+
return {
|
|
1187
|
+
success: true,
|
|
1188
|
+
context,
|
|
1189
|
+
total: agents.length,
|
|
1190
|
+
agents
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Run diagnostics for configuration and readiness.
|
|
1195
|
+
*/
|
|
1196
|
+
async executeDoctor(options = {}) {
|
|
1197
|
+
const context = this.resolveContext(options.context, process.cwd());
|
|
1198
|
+
const checks = [
|
|
1199
|
+
{
|
|
1200
|
+
id: "config",
|
|
1201
|
+
description: "Baseline config exists",
|
|
1202
|
+
path: path.join(context, ".baseline", "baseline.config.json")
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
id: "onboarding",
|
|
1206
|
+
description: "Onboarding profile exists",
|
|
1207
|
+
path: path.join(context, ".baseline", "onboarding.json")
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
id: "index",
|
|
1211
|
+
description: "Index exists",
|
|
1212
|
+
path: path.join(context, ".baseline", "index.json")
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
id: "roadmap",
|
|
1216
|
+
description: "Roadmap exists",
|
|
1217
|
+
path: path.join(context, "docs", "strategy", "roadmap.md")
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
id: "ga-release",
|
|
1221
|
+
description: "GA release checklist exists",
|
|
1222
|
+
path: path.join(context, "docs", "strategy", "ga-release.md")
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
id: "package-json",
|
|
1226
|
+
description: "package.json exists",
|
|
1227
|
+
path: path.join(context, "package.json")
|
|
1228
|
+
}
|
|
1229
|
+
];
|
|
1230
|
+
const results = await Promise.all(
|
|
1231
|
+
checks.map(async (check) => ({
|
|
1232
|
+
...check,
|
|
1233
|
+
ok: await this.fileExists(check.path)
|
|
1234
|
+
}))
|
|
1235
|
+
);
|
|
1236
|
+
const total = results.length;
|
|
1237
|
+
const passed = results.filter((check) => check.ok).length;
|
|
1238
|
+
const score = Math.round(passed / total * 100);
|
|
1239
|
+
const missing = results.filter((check) => !check.ok).map((check) => check.id);
|
|
1240
|
+
return {
|
|
1241
|
+
success: true,
|
|
1242
|
+
context,
|
|
1243
|
+
score,
|
|
1244
|
+
passed,
|
|
1245
|
+
total,
|
|
1246
|
+
missing,
|
|
1247
|
+
checks: results
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Initialize the Baseline environment, setting up context folder,
|
|
1252
|
+
* configuration, and mode.
|
|
1253
|
+
*/
|
|
1254
|
+
async initializeBaseline(options = {}) {
|
|
1255
|
+
try {
|
|
1256
|
+
const contextPath = options.context || process.cwd();
|
|
1257
|
+
const mode = options.mode || "development";
|
|
1258
|
+
this.state.customContextFolder = contextPath;
|
|
1259
|
+
this.state.baselineMode = true;
|
|
1260
|
+
console.log(`[Baseline:Init] Context path: ${contextPath}`);
|
|
1261
|
+
console.log(`[Baseline:Init] Mode: ${mode}`);
|
|
1262
|
+
const contextValid = typeof contextPath === "string" && contextPath.length > 0;
|
|
1263
|
+
if (!contextValid) {
|
|
1264
|
+
return {
|
|
1265
|
+
success: false,
|
|
1266
|
+
error: "Invalid context path provided"
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
const config = {
|
|
1270
|
+
contextPath,
|
|
1271
|
+
mode,
|
|
1272
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1273
|
+
version: "0.1.0"
|
|
1274
|
+
};
|
|
1275
|
+
const detected = {};
|
|
1276
|
+
try {
|
|
1277
|
+
const { existsSync, readFileSync } = await import("fs");
|
|
1278
|
+
const { join } = await import("path");
|
|
1279
|
+
const pkgPath = join(contextPath, "package.json");
|
|
1280
|
+
if (existsSync(pkgPath)) {
|
|
1281
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
1282
|
+
const allDeps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
1283
|
+
if (allDeps["@anthropic-ai/sdk"]) detected.provider = "anthropic";
|
|
1284
|
+
else if (allDeps["openai"]) detected.provider = "openai";
|
|
1285
|
+
if (allDeps["langchain"] || allDeps["@langchain/core"]) detected.framework = "langchain";
|
|
1286
|
+
if (allDeps["@modelcontextprotocol/sdk"]) detected.mcp = true;
|
|
1287
|
+
if (allDeps["bullmq"] || allDeps["@temporalio/client"]) detected.orchestration = true;
|
|
1288
|
+
detected.runtime = "node";
|
|
1289
|
+
detected.name = pkg.name;
|
|
1290
|
+
}
|
|
1291
|
+
const pyReq = join(contextPath, "requirements.txt");
|
|
1292
|
+
if (existsSync(pyReq)) {
|
|
1293
|
+
const reqs = readFileSync(pyReq, "utf8");
|
|
1294
|
+
if (reqs.includes("anthropic")) detected.provider = "anthropic";
|
|
1295
|
+
else if (reqs.includes("openai")) detected.provider = "openai";
|
|
1296
|
+
if (reqs.includes("langchain")) detected.framework = "langchain";
|
|
1297
|
+
detected.runtime = "python";
|
|
1298
|
+
}
|
|
1299
|
+
if (Object.keys(detected).length > 0) {
|
|
1300
|
+
console.log(`[Baseline:Init] Detected: ${JSON.stringify(detected)}`);
|
|
1301
|
+
}
|
|
1302
|
+
} catch {
|
|
1303
|
+
}
|
|
1304
|
+
console.log("[Baseline:Init] Environment initialized successfully");
|
|
1305
|
+
return {
|
|
1306
|
+
success: true,
|
|
1307
|
+
config: { ...config, detected },
|
|
1308
|
+
contextPath,
|
|
1309
|
+
mode,
|
|
1310
|
+
detected
|
|
1311
|
+
};
|
|
1312
|
+
} catch (error) {
|
|
1313
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1314
|
+
return {
|
|
1315
|
+
success: false,
|
|
1316
|
+
error: errorMessage
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Execute the Baseline Language layer -- parsing, validation,
|
|
1322
|
+
* and semantic analysis of the project context.
|
|
1323
|
+
*/
|
|
1324
|
+
async executeBaselineLang(options = {}) {
|
|
1325
|
+
try {
|
|
1326
|
+
const inputPath = options.input || this.state.customContextFolder || process.cwd();
|
|
1327
|
+
const outputPath = options.output || inputPath;
|
|
1328
|
+
console.log(`[Baseline:Lang] Processing language layer...`);
|
|
1329
|
+
console.log(`[Baseline:Lang] Input: ${inputPath}`);
|
|
1330
|
+
console.log(`[Baseline:Lang] Output: ${outputPath}`);
|
|
1331
|
+
const lexiconKeys = Object.keys(this.baselineLang.lexicon);
|
|
1332
|
+
console.log(`[Baseline:Lang] Lexicon entries loaded: ${lexiconKeys.length}`);
|
|
1333
|
+
const syntaxKeys = Object.keys(this.baselineLang.syntax);
|
|
1334
|
+
console.log(`[Baseline:Lang] Syntax patterns loaded: ${syntaxKeys.length}`);
|
|
1335
|
+
const analysisResult = {
|
|
1336
|
+
lexiconEntries: lexiconKeys.length,
|
|
1337
|
+
syntaxPatterns: syntaxKeys.length,
|
|
1338
|
+
validationPassed: true,
|
|
1339
|
+
semanticScore: 1,
|
|
1340
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1341
|
+
};
|
|
1342
|
+
console.log("[Baseline:Lang] Language layer processing complete");
|
|
1343
|
+
return {
|
|
1344
|
+
success: true,
|
|
1345
|
+
inputPath,
|
|
1346
|
+
outputPath,
|
|
1347
|
+
analysis: analysisResult
|
|
1348
|
+
};
|
|
1349
|
+
} catch (error) {
|
|
1350
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1351
|
+
return {
|
|
1352
|
+
success: false,
|
|
1353
|
+
error: errorMessage
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Execute the Baseline Frame layer -- scaffolding, composition,
|
|
1359
|
+
* and framework orchestration.
|
|
1360
|
+
*/
|
|
1361
|
+
async executeBaselineFrame(options = {}) {
|
|
1362
|
+
try {
|
|
1363
|
+
const inputPath = options.input || this.state.customContextFolder || process.cwd();
|
|
1364
|
+
const configPath = options.config || null;
|
|
1365
|
+
console.log(`[Baseline:Frame] Processing frame layer...`);
|
|
1366
|
+
console.log(`[Baseline:Frame] Input: ${inputPath}`);
|
|
1367
|
+
if (configPath) {
|
|
1368
|
+
console.log(`[Baseline:Frame] Config: ${configPath}`);
|
|
1369
|
+
}
|
|
1370
|
+
const scaffoldResult = {
|
|
1371
|
+
components: [],
|
|
1372
|
+
templates: [],
|
|
1373
|
+
structure: "hierarchical"
|
|
1374
|
+
};
|
|
1375
|
+
const compositionResult = {
|
|
1376
|
+
composed: true,
|
|
1377
|
+
layers: ["lang", "frame", "studio", "govern"],
|
|
1378
|
+
dependencies: []
|
|
1379
|
+
};
|
|
1380
|
+
const orchestrationResult = {
|
|
1381
|
+
orchestrated: true,
|
|
1382
|
+
pipelineStages: 4,
|
|
1383
|
+
parallelism: 1
|
|
1384
|
+
};
|
|
1385
|
+
console.log("[Baseline:Frame] Frame layer processing complete");
|
|
1386
|
+
return {
|
|
1387
|
+
success: true,
|
|
1388
|
+
scaffold: scaffoldResult,
|
|
1389
|
+
composition: compositionResult,
|
|
1390
|
+
orchestration: orchestrationResult
|
|
1391
|
+
};
|
|
1392
|
+
} catch (error) {
|
|
1393
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1394
|
+
return {
|
|
1395
|
+
success: false,
|
|
1396
|
+
error: errorMessage
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Execute the Baseline Studio layer -- design rendering,
|
|
1402
|
+
* preview generation, and visual asset processing.
|
|
1403
|
+
*/
|
|
1404
|
+
async executeBaselineStudio(options = {}) {
|
|
1405
|
+
try {
|
|
1406
|
+
const inputPath = options.input || this.state.customContextFolder || process.cwd();
|
|
1407
|
+
const renderMode = options.render || "standard";
|
|
1408
|
+
console.log(`[Baseline:Studio] Processing studio layer...`);
|
|
1409
|
+
console.log(`[Baseline:Studio] Input: ${inputPath}`);
|
|
1410
|
+
console.log(`[Baseline:Studio] Render mode: ${renderMode}`);
|
|
1411
|
+
const designResult = {
|
|
1412
|
+
designSystem: "baseline-default",
|
|
1413
|
+
components: 0,
|
|
1414
|
+
tokens: {},
|
|
1415
|
+
themes: ["light", "dark"]
|
|
1416
|
+
};
|
|
1417
|
+
const renderResult = {
|
|
1418
|
+
rendered: true,
|
|
1419
|
+
mode: renderMode,
|
|
1420
|
+
outputFormat: "html",
|
|
1421
|
+
assets: []
|
|
1422
|
+
};
|
|
1423
|
+
const previewResult = {
|
|
1424
|
+
previewAvailable: false,
|
|
1425
|
+
previewUrl: null
|
|
1426
|
+
};
|
|
1427
|
+
console.log("[Baseline:Studio] Studio layer processing complete");
|
|
1428
|
+
return {
|
|
1429
|
+
success: true,
|
|
1430
|
+
design: designResult,
|
|
1431
|
+
render: renderResult,
|
|
1432
|
+
preview: previewResult
|
|
1433
|
+
};
|
|
1434
|
+
} catch (error) {
|
|
1435
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1436
|
+
return {
|
|
1437
|
+
success: false,
|
|
1438
|
+
error: errorMessage
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Execute the Baseline Govern layer -- audit, policy enforcement,
|
|
1444
|
+
* compliance checking, and governance controls.
|
|
1445
|
+
*/
|
|
1446
|
+
async executeBaselineGovern(options = {}) {
|
|
1447
|
+
try {
|
|
1448
|
+
const inputPath = options.input || this.state.customContextFolder || process.cwd();
|
|
1449
|
+
const policyPath = options.policy || null;
|
|
1450
|
+
const auditPath = path.join(inputPath, ".baseline", "govern", "audit-trail.json");
|
|
1451
|
+
console.log(`[Baseline:Govern] Processing governance layer...`);
|
|
1452
|
+
console.log(`[Baseline:Govern] Input: ${inputPath}`);
|
|
1453
|
+
if (policyPath) {
|
|
1454
|
+
console.log(`[Baseline:Govern] Policy: ${policyPath}`);
|
|
1455
|
+
}
|
|
1456
|
+
let policyContent = "Default governance policy";
|
|
1457
|
+
if (policyPath) {
|
|
1458
|
+
try {
|
|
1459
|
+
policyContent = await readFile(policyPath, "utf8");
|
|
1460
|
+
} catch (error) {
|
|
1461
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1462
|
+
console.log(`[Baseline:Govern] Unable to read policy file, using default policy (${message})`);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
const govern = new BaselineGovernSystem({ persistPath: auditPath });
|
|
1466
|
+
const createdPolicy = await govern.policies.create("baseline-default", policyContent, {
|
|
1467
|
+
severity: "high",
|
|
1468
|
+
enforcement: "block",
|
|
1469
|
+
requireApproval: Boolean(options.requireApproval),
|
|
1470
|
+
requiredApprovers: Array.isArray(options.requiredApprovers) ? options.requiredApprovers : ["govern-approver"],
|
|
1471
|
+
rules: [
|
|
1472
|
+
{
|
|
1473
|
+
id: "restricted-sensitivity",
|
|
1474
|
+
name: "Restricted sensitivity requires approval",
|
|
1475
|
+
severity: "high",
|
|
1476
|
+
enforcement: "block",
|
|
1477
|
+
condition: { field: "sensitivity", equals: "restricted" },
|
|
1478
|
+
message: "Restricted workloads must pass approval before enforcement."
|
|
1479
|
+
}
|
|
1480
|
+
]
|
|
1481
|
+
});
|
|
1482
|
+
if (!createdPolicy.success || !createdPolicy.policy) {
|
|
1483
|
+
throw new Error(createdPolicy.error || "Failed to create governance policy");
|
|
1484
|
+
}
|
|
1485
|
+
const policyId = createdPolicy.policy.id;
|
|
1486
|
+
const approvedPolicy = await govern.policies.approve(policyId, String(options.approver || "baseline-cli"));
|
|
1487
|
+
if (!approvedPolicy.success) {
|
|
1488
|
+
throw new Error(approvedPolicy.error || "Failed to approve governance policy");
|
|
1489
|
+
}
|
|
1490
|
+
const enforcement = await govern.policies.enforce(policyId, {
|
|
1491
|
+
resourceId: String(options.resourceId || inputPath),
|
|
1492
|
+
requestedBy: String(options.requestedBy || "baseline-cli"),
|
|
1493
|
+
sensitivity: String(options.sensitivity || "standard"),
|
|
1494
|
+
mode: String(options.mode || this.state.customContextFolder || "development")
|
|
1495
|
+
});
|
|
1496
|
+
const compliance = await govern.compliance.check("ISO27001", {
|
|
1497
|
+
documentation: options.documentation || "complete",
|
|
1498
|
+
process: options.process || "complete"
|
|
1499
|
+
});
|
|
1500
|
+
const evidence = govern.getEvidenceBundle(policyId, String(options.resourceId || inputPath));
|
|
1501
|
+
const violations = enforcement.evaluation?.violations ?? [];
|
|
1502
|
+
const policyResult = {
|
|
1503
|
+
policiesEvaluated: 1,
|
|
1504
|
+
policiesPassed: enforcement.success ? 1 : 0,
|
|
1505
|
+
policiesFailed: enforcement.success ? 0 : 1,
|
|
1506
|
+
violations,
|
|
1507
|
+
enforcementAction: enforcement.evaluation?.enforcementAction ?? "allow",
|
|
1508
|
+
requiresApproval: enforcement.evaluation?.requiresApproval ?? false
|
|
1509
|
+
};
|
|
1510
|
+
const auditResult = {
|
|
1511
|
+
auditId: `audit-${Date.now()}`,
|
|
1512
|
+
passed: enforcement.success,
|
|
1513
|
+
findings: violations.map((violation) => violation.message),
|
|
1514
|
+
severity: violations.length > 0 ? "high" : "none",
|
|
1515
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1516
|
+
events: evidence.auditTrail.length
|
|
1517
|
+
};
|
|
1518
|
+
const complianceResult = {
|
|
1519
|
+
compliant: compliance.compliance?.compliant ?? false,
|
|
1520
|
+
standards: ["ISO27001"],
|
|
1521
|
+
certifications: [],
|
|
1522
|
+
gaps: compliance.compliance?.violations ?? []
|
|
1523
|
+
};
|
|
1524
|
+
console.log("[Baseline:Govern] Governance layer processing complete");
|
|
1525
|
+
return {
|
|
1526
|
+
success: enforcement.success,
|
|
1527
|
+
audit: auditResult,
|
|
1528
|
+
policy: policyResult,
|
|
1529
|
+
compliance: complianceResult,
|
|
1530
|
+
evaluation: enforcement.evaluation,
|
|
1531
|
+
approval: enforcement.approval,
|
|
1532
|
+
evidence
|
|
1533
|
+
};
|
|
1534
|
+
} catch (error) {
|
|
1535
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1536
|
+
return {
|
|
1537
|
+
success: false,
|
|
1538
|
+
error: errorMessage
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Execute a chain of commands sequentially. Each command in the array
|
|
1544
|
+
* is executed in order. If any command fails, the chain halts.
|
|
1545
|
+
*/
|
|
1546
|
+
async executeChainedCommands(commands) {
|
|
1547
|
+
console.log(`[Baseline:Chain] Executing ${commands.length} chained commands...`);
|
|
1548
|
+
const results = {};
|
|
1549
|
+
let overallSuccess = true;
|
|
1550
|
+
for (let i = 0; i < commands.length; i++) {
|
|
1551
|
+
const command = commands[i].trim();
|
|
1552
|
+
console.log(`[Baseline:Chain] Command ${i + 1}/${commands.length}: ${command}`);
|
|
1553
|
+
try {
|
|
1554
|
+
const result = await this.executeCommand(command);
|
|
1555
|
+
results[`step_${i + 1}`] = result;
|
|
1556
|
+
if (!result.success) {
|
|
1557
|
+
overallSuccess = false;
|
|
1558
|
+
console.log(`[Baseline:Chain] Command ${i + 1} failed: ${result.error || "unknown error"}`);
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
console.log(`[Baseline:Chain] Command ${i + 1} completed successfully`);
|
|
1562
|
+
} catch (error) {
|
|
1563
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1564
|
+
overallSuccess = false;
|
|
1565
|
+
results[`step_${i + 1}`] = { success: false, error: errorMessage };
|
|
1566
|
+
console.log(`[Baseline:Chain] Command ${i + 1} threw error: ${errorMessage}`);
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
console.log(`[Baseline:Chain] Chain execution ${overallSuccess ? "completed" : "failed"}`);
|
|
1571
|
+
return {
|
|
1572
|
+
success: overallSuccess,
|
|
1573
|
+
results,
|
|
1574
|
+
commandsExecuted: Object.keys(results).length,
|
|
1575
|
+
totalCommands: commands.length
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Add a command to the execution queue for deferred execution.
|
|
1580
|
+
*/
|
|
1581
|
+
queueCommand(command) {
|
|
1582
|
+
this.state.commandQueue.push(command);
|
|
1583
|
+
console.log(`[Baseline:Queue] Command queued: ${command} (queue size: ${this.state.commandQueue.length})`);
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Execute all commands currently in the queue, in FIFO order,
|
|
1587
|
+
* then clear the queue.
|
|
1588
|
+
*/
|
|
1589
|
+
async executeQueue() {
|
|
1590
|
+
const queueLength = this.state.commandQueue.length;
|
|
1591
|
+
if (queueLength === 0) {
|
|
1592
|
+
console.log("[Baseline:Queue] Queue is empty, nothing to execute");
|
|
1593
|
+
return { success: true, message: "Queue is empty" };
|
|
1594
|
+
}
|
|
1595
|
+
console.log(`[Baseline:Queue] Executing ${queueLength} queued commands...`);
|
|
1596
|
+
const commands = [...this.state.commandQueue];
|
|
1597
|
+
this.state.commandQueue = [];
|
|
1598
|
+
const result = await this.executeChainedCommands(commands);
|
|
1599
|
+
console.log(`[Baseline:Queue] Queue execution complete`);
|
|
1600
|
+
return result;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Execute a single command string by dispatching to the appropriate
|
|
1604
|
+
* handler based on the command flag.
|
|
1605
|
+
*/
|
|
1606
|
+
async executeCommand(command) {
|
|
1607
|
+
const trimmed = command.trim();
|
|
1608
|
+
console.log(`[Baseline:Command] Executing: ${trimmed}`);
|
|
1609
|
+
const parts = trimmed.split(/\s+/);
|
|
1610
|
+
const mainCommand = parts[0];
|
|
1611
|
+
const options = {};
|
|
1612
|
+
const positionals = [];
|
|
1613
|
+
for (let i = 1; i < parts.length; i++) {
|
|
1614
|
+
if (parts[i].startsWith("--")) {
|
|
1615
|
+
const key = parts[i].replace(/^--/, "");
|
|
1616
|
+
const value = parts[i + 1] && !parts[i + 1].startsWith("--") ? parts[++i] : "true";
|
|
1617
|
+
options[key] = value;
|
|
1618
|
+
} else {
|
|
1619
|
+
positionals.push(parts[i]);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
options._ = positionals;
|
|
1623
|
+
switch (mainCommand) {
|
|
1624
|
+
case "--onboard":
|
|
1625
|
+
return await this.executeOnboarding(options);
|
|
1626
|
+
case "--experience":
|
|
1627
|
+
return await this.executeExperience(options);
|
|
1628
|
+
case "--config":
|
|
1629
|
+
return await this.executeConfig(options);
|
|
1630
|
+
case "--index":
|
|
1631
|
+
return await this.executeIndex(options);
|
|
1632
|
+
case "--serve":
|
|
1633
|
+
return await this.executeServe(options);
|
|
1634
|
+
case "--persona":
|
|
1635
|
+
return this.executePersona(options);
|
|
1636
|
+
case "--agents":
|
|
1637
|
+
return await this.executeAgents(options);
|
|
1638
|
+
case "--doctor":
|
|
1639
|
+
return await this.executeDoctor(options);
|
|
1640
|
+
case "--baseline":
|
|
1641
|
+
return await this.executeBaselineWorkflow(options);
|
|
1642
|
+
case "--baseline-lang":
|
|
1643
|
+
return await this.executeBaselineLang(options);
|
|
1644
|
+
case "--baseline-frame":
|
|
1645
|
+
return await this.executeBaselineFrame(options);
|
|
1646
|
+
case "--baseline-studio":
|
|
1647
|
+
return await this.executeBaselineStudio(options);
|
|
1648
|
+
case "--baseline-govern":
|
|
1649
|
+
return await this.executeBaselineGovern(options);
|
|
1650
|
+
case "--init":
|
|
1651
|
+
return await this.executeInit(options);
|
|
1652
|
+
case "--run":
|
|
1653
|
+
return await this.executeBaselineWorkflow(options);
|
|
1654
|
+
case "--status": {
|
|
1655
|
+
const status = this.getStatus();
|
|
1656
|
+
return { success: true, ...status };
|
|
1657
|
+
}
|
|
1658
|
+
case "--help":
|
|
1659
|
+
this.showHelp();
|
|
1660
|
+
return { success: true };
|
|
1661
|
+
default:
|
|
1662
|
+
console.log(`[Baseline:Command] Unknown command: ${mainCommand}`);
|
|
1663
|
+
return {
|
|
1664
|
+
success: false,
|
|
1665
|
+
error: `Unknown command: ${mainCommand}. Use --help for available commands.`
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Return the current status of the Baseline system, including
|
|
1671
|
+
* state, execution history, and queue contents.
|
|
1672
|
+
*/
|
|
1673
|
+
getStatus() {
|
|
1674
|
+
const status = {
|
|
1675
|
+
baselineMode: this.state.baselineMode,
|
|
1676
|
+
customContextFolder: this.state.customContextFolder,
|
|
1677
|
+
queueLength: this.state.commandQueue.length,
|
|
1678
|
+
queuedCommands: [...this.state.commandQueue],
|
|
1679
|
+
executionHistoryCount: this.state.executionHistory.length,
|
|
1680
|
+
currentWorkflow: this.state.currentWorkflow ? {
|
|
1681
|
+
id: this.state.currentWorkflow.id,
|
|
1682
|
+
status: this.state.currentWorkflow.status,
|
|
1683
|
+
startTime: this.state.currentWorkflow.startTime.toISOString()
|
|
1684
|
+
} : null,
|
|
1685
|
+
recentExecutions: this.state.executionHistory.slice(-5).map(
|
|
1686
|
+
(execution) => ({
|
|
1687
|
+
id: execution.id,
|
|
1688
|
+
status: execution.status,
|
|
1689
|
+
duration: execution.duration,
|
|
1690
|
+
startTime: execution.startTime.toISOString(),
|
|
1691
|
+
error: execution.error || null
|
|
1692
|
+
})
|
|
1693
|
+
),
|
|
1694
|
+
megagemConnected: this.megagem !== null,
|
|
1695
|
+
contextEngineConnected: this.contextEngine !== null,
|
|
1696
|
+
lexiconEntries: Object.keys(this.baselineLang.lexicon).length,
|
|
1697
|
+
syntaxPatterns: Object.keys(this.baselineLang.syntax).length,
|
|
1698
|
+
commands: Object.keys(this.baselineLang.commands).length
|
|
1699
|
+
};
|
|
1700
|
+
const layers = ["lang", "frame", "studio", "govern", "experience", "autonomy", "persona"];
|
|
1701
|
+
const layerStatus = layers.map((id) => {
|
|
1702
|
+
const lastExec = this.state.executionHistory.filter((e) => e.status === "completed").slice(-1)[0];
|
|
1703
|
+
return { id, status: "armed", lastCheck: lastExec ? "passed" : "none" };
|
|
1704
|
+
});
|
|
1705
|
+
status.layers = layerStatus;
|
|
1706
|
+
console.log("[Baseline:Status]");
|
|
1707
|
+
console.log(` Mode: ${status.baselineMode ? "active" : "inactive"}`);
|
|
1708
|
+
console.log(` Context: ${status.customContextFolder || "none"}`);
|
|
1709
|
+
console.log(` Queue: ${status.queueLength} commands`);
|
|
1710
|
+
console.log(` History: ${status.executionHistoryCount} executions`);
|
|
1711
|
+
console.log(` MEGAGEM: ${status.megagemConnected ? "connected" : "disconnected"}`);
|
|
1712
|
+
console.log(` Context Engine: ${status.contextEngineConnected ? "connected" : "disconnected"}`);
|
|
1713
|
+
console.log("");
|
|
1714
|
+
console.log(" Governance Layers:");
|
|
1715
|
+
for (const layer of layerStatus) {
|
|
1716
|
+
const dot = layer.lastCheck === "passed" ? "\u25CF" : layer.lastCheck === "failed" ? "\u25CB" : "\u25CC";
|
|
1717
|
+
console.log(` ${dot} ${layer.id.padEnd(12)} ${layer.status.padEnd(8)} last check: ${layer.lastCheck}`);
|
|
1718
|
+
}
|
|
1719
|
+
return status;
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Display help information for all available commands, flags,
|
|
1723
|
+
* and syntax patterns.
|
|
1724
|
+
*/
|
|
1725
|
+
showHelp() {
|
|
1726
|
+
console.log("");
|
|
1727
|
+
console.log("=== Baseline Protocol CLI ===");
|
|
1728
|
+
console.log("");
|
|
1729
|
+
console.log("COMMANDS:");
|
|
1730
|
+
console.log("");
|
|
1731
|
+
for (const [flag, entry] of Object.entries(this.baselineLang.commands)) {
|
|
1732
|
+
console.log(` ${flag.padEnd(20)} ${entry.description}`);
|
|
1733
|
+
}
|
|
1734
|
+
console.log("");
|
|
1735
|
+
console.log("LAYER FLAGS:");
|
|
1736
|
+
console.log("");
|
|
1737
|
+
for (const [flag, entry] of Object.entries(this.baselineLang.lexicon)) {
|
|
1738
|
+
console.log(` ${flag.padEnd(24)} ${entry.description}`);
|
|
1739
|
+
console.log(` ${"".padEnd(24)} Usage: ${entry.usage}`);
|
|
1740
|
+
console.log(` ${"".padEnd(24)} Category: ${entry.category}`);
|
|
1741
|
+
if (entry.examples.length > 0) {
|
|
1742
|
+
console.log(` ${"".padEnd(24)} Examples:`);
|
|
1743
|
+
for (const example of entry.examples) {
|
|
1744
|
+
console.log(` ${"".padEnd(28)} ${example}`);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
console.log("");
|
|
1748
|
+
}
|
|
1749
|
+
console.log("SYNTAX PATTERNS:");
|
|
1750
|
+
console.log("");
|
|
1751
|
+
for (const [name, entry] of Object.entries(this.baselineLang.syntax)) {
|
|
1752
|
+
console.log(` ${name}:`);
|
|
1753
|
+
console.log(` Pattern: ${entry.pattern}`);
|
|
1754
|
+
console.log(" Parameters:");
|
|
1755
|
+
for (const [param, desc] of Object.entries(entry.parameters)) {
|
|
1756
|
+
console.log(` --${param.padEnd(16)} ${desc}`);
|
|
1757
|
+
}
|
|
1758
|
+
if (entry.examples.length > 0) {
|
|
1759
|
+
console.log(" Examples:");
|
|
1760
|
+
for (const example of entry.examples) {
|
|
1761
|
+
console.log(` ${example}`);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
console.log("");
|
|
1765
|
+
}
|
|
1766
|
+
console.log("USAGE:");
|
|
1767
|
+
console.log(" baseline --init Initialize a new project");
|
|
1768
|
+
console.log(" baseline --run Run the full workflow");
|
|
1769
|
+
console.log(" baseline --baseline --mode production Run in production mode");
|
|
1770
|
+
console.log(" baseline --status Check system status");
|
|
1771
|
+
console.log(" baseline --help Show this help");
|
|
1772
|
+
console.log("");
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Set the MEGAGEM integration instance for autonomous operations.
|
|
1776
|
+
*/
|
|
1777
|
+
setMegagem(megagem) {
|
|
1778
|
+
this.megagem = megagem;
|
|
1779
|
+
console.log("[Baseline] MEGAGEM integration connected");
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Set the Context Engine integration instance for context management.
|
|
1783
|
+
*/
|
|
1784
|
+
setContextEngine(contextEngine) {
|
|
1785
|
+
this.contextEngine = contextEngine;
|
|
1786
|
+
console.log("[Baseline] Context Engine integration connected");
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1790
|
+
export {
|
|
1791
|
+
BaselineCommandSystem
|
|
1792
|
+
};
|