@neuroverseos/governance 0.8.0 → 0.9.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.
@@ -112,7 +112,7 @@ async function cmdInit(argv) {
112
112
  const args = parseArgs(argv);
113
113
  if (args.help) {
114
114
  process.stdout.write(
115
- 'neuroverse worldmodel init \u2014 Scaffold a new .worldmodel.md template\n\nOptions:\n --name <name> Model name (default: "My Behavioral Model")\n --output <path> Output path (default: ./model.worldmodel.md)\n'
115
+ 'neuroverse worldmodel init \u2014 Create a new behavioral model\n\nWith ANTHROPIC_API_KEY set:\n Interactive \u2014 answers questions, AI structures your worldmodel.\n Your natural process: talk \u2192 structure \u2192 refine.\n\nWithout ANTHROPIC_API_KEY:\n Template \u2014 generates a scaffold you fill in manually.\n\nOptions:\n --name <name> Model name (default: "My Behavioral Model")\n --output <path> Output path (default: ./model.worldmodel.md)\n --template Force template mode even with API key set\n'
116
116
  );
117
117
  return;
118
118
  }
@@ -126,6 +126,121 @@ async function cmdInit(argv) {
126
126
  process.stderr.write("Use --output to specify a different path.\n");
127
127
  process.exit(1);
128
128
  }
129
+ const apiKey = process.env.ANTHROPIC_API_KEY;
130
+ const forceTemplate = argv.includes("--template");
131
+ if (apiKey && !forceTemplate && process.stdin.isTTY) {
132
+ const { askQuestions, structureWorldmodel, saveWorldmodel } = await import("../worldmodel-create-5SWHVNMQ.js");
133
+ process.stderr.write(`
134
+ `);
135
+ const answers = await askQuestions();
136
+ process.stderr.write(`${DIM}Structuring your worldmodel...${RESET}
137
+ `);
138
+ try {
139
+ const content = await structureWorldmodel(answers, apiKey);
140
+ const dir2 = dirname(outputPath);
141
+ if (!existsSync(dir2)) {
142
+ await mkdir(dir2, { recursive: true });
143
+ }
144
+ saveWorldmodel(content, outputPath);
145
+ process.stderr.write(`
146
+ ${GREEN}Created${RESET} ${outputPath}
147
+ `);
148
+ process.stderr.write(
149
+ `${DIM}Review the file, then run: neuroverse worldmodel validate ${basename(outputPath)}${RESET}
150
+ `
151
+ );
152
+ try {
153
+ const validateResult = parseWorldModel(content);
154
+ if (validateResult.model) {
155
+ const m = validateResult.model;
156
+ process.stderr.write(
157
+ `${DIM} Domains: ${m.geometry.domains.length} Overlaps: ${m.geometry.overlapEffects.length} Signals: ${m.evolution.signals.length}${RESET}
158
+ `
159
+ );
160
+ }
161
+ const errors = validateResult.issues.filter((i) => i.severity === "error");
162
+ if (errors.length > 0) {
163
+ process.stderr.write(
164
+ `
165
+ ${YELLOW}Validation found ${errors.length} issue${errors.length > 1 ? "s" : ""} \u2014 review and fix:${RESET}
166
+ `
167
+ );
168
+ for (const issue of errors) {
169
+ process.stderr.write(` ${formatIssue(issue)}
170
+ `);
171
+ }
172
+ } else {
173
+ process.stderr.write(`${GREEN}Validates cleanly!${RESET}
174
+ `);
175
+ try {
176
+ if (!validateResult.model) throw new Error("no model");
177
+ const { compileWorldModel: compileWorldModel2 } = await import("../engine/worldmodel-compiler.js");
178
+ const compiled = compileWorldModel2(validateResult.model);
179
+ const outDir = dirname(outputPath);
180
+ const baseName = basename(outputPath).replace(/\.worldmodel\.md$/, "");
181
+ const worldPath = join(outDir, `${baseName}.nv-world.md`);
182
+ await writeFile(worldPath, compiled.worldMarkdown, "utf-8");
183
+ const signalsPath = join(outDir, "signals.json");
184
+ await writeFile(signalsPath, JSON.stringify(compiled.signalSchema, null, 2), "utf-8");
185
+ const overlapsPath = join(outDir, "overlaps.json");
186
+ await writeFile(overlapsPath, JSON.stringify(compiled.overlapMap, null, 2), "utf-8");
187
+ const contextsPath = join(outDir, "contexts.json");
188
+ await writeFile(contextsPath, JSON.stringify(compiled.contextsConfig, null, 2), "utf-8");
189
+ const lensesPath = join(outDir, "lenses.json");
190
+ await writeFile(lensesPath, JSON.stringify(compiled.lensSuggestions, null, 2), "utf-8");
191
+ process.stderr.write(`
192
+ ${GREEN}Compiled!${RESET} Token-optimized artifacts:
193
+ `);
194
+ process.stderr.write(`${DIM} ${worldPath}${RESET}
195
+ `);
196
+ process.stderr.write(`${DIM} ${signalsPath}${RESET}
197
+ `);
198
+ process.stderr.write(`${DIM} ${overlapsPath}${RESET}
199
+ `);
200
+ process.stderr.write(`${DIM} ${contextsPath}${RESET}
201
+ `);
202
+ process.stderr.write(`${DIM} ${lensesPath}${RESET}
203
+ `);
204
+ process.stderr.write(`
205
+ ${DIM}Source: ${outputPath} (readable, editable)${RESET}
206
+ `);
207
+ process.stderr.write(`${DIM}Compiled: ready for Radiant \u2014 token-optimized, no prose overhead.${RESET}
208
+ `);
209
+ } catch {
210
+ process.stderr.write(
211
+ `${DIM}Auto-compile skipped \u2014 run 'neuroverse worldmodel build ${basename(outputPath)}' manually.${RESET}
212
+ `
213
+ );
214
+ }
215
+ }
216
+ } catch {
217
+ }
218
+ } catch (err) {
219
+ process.stderr.write(`${RED}Error:${RESET} ${err}
220
+ `);
221
+ process.stderr.write(
222
+ `${DIM}Falling back to template mode.${RESET}
223
+
224
+ `
225
+ );
226
+ const template2 = generateScaffold(modelName);
227
+ const dir2 = dirname(outputPath);
228
+ if (!existsSync(dir2)) {
229
+ await mkdir(dir2, { recursive: true });
230
+ }
231
+ await writeFile(outputPath, template2, "utf-8");
232
+ process.stderr.write(`${GREEN}Created${RESET} ${outputPath} (template)
233
+ `);
234
+ }
235
+ return;
236
+ }
237
+ if (!apiKey && !forceTemplate) {
238
+ process.stderr.write(
239
+ `${DIM}Tip: Set ANTHROPIC_API_KEY for the guided experience \u2014 AI asks you questions and creates your worldmodel.${RESET}
240
+
241
+ `
242
+ );
243
+ }
129
244
  const template = generateScaffold(modelName);
130
245
  const dir = dirname(outputPath);
131
246
  if (!existsSync(dir)) {
@@ -2,12 +2,14 @@ import {
2
2
  LENSES,
3
3
  aukiBuilderLens,
4
4
  getLens,
5
- listLenses
6
- } from "./chunk-VGFDMPVB.js";
5
+ listLenses,
6
+ sovereignConduitLens
7
+ } from "./chunk-TCGGED4G.js";
7
8
  import "./chunk-QWGCMQQD.js";
8
9
  export {
9
10
  LENSES,
10
11
  aukiBuilderLens,
11
12
  getLens,
12
- listLenses
13
+ listLenses,
14
+ sovereignConduitLens
13
15
  };