@neuroverseos/governance 0.9.0 → 0.10.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.
@@ -12549,8 +12549,8 @@ async function deriveCommand(args) {
12549
12549
  return;
12550
12550
  }
12551
12551
  const plan = result.plan;
12552
- const { mkdirSync: mkdirSync7 } = await import("fs");
12553
- mkdirSync7(outputDir, { recursive: true });
12552
+ const { mkdirSync: mkdirSync8 } = await import("fs");
12553
+ mkdirSync8(outputDir, { recursive: true });
12554
12554
  const worldJson = {
12555
12555
  world_id: `plan_${plan.plan_id}`,
12556
12556
  name: `Derived: ${plan.objective}`,
@@ -16901,13 +16901,13 @@ function generateWorld(state) {
16901
16901
  return { worldJson, stateSchema, guardsJson, rules, gatesJson, invariants, outcomes, metadata };
16902
16902
  }
16903
16903
  async function writeWorld(outputDir, world) {
16904
- const { mkdirSync: mkdirSync7, existsSync: existsSync17 } = await import("fs");
16904
+ const { mkdirSync: mkdirSync8, existsSync: existsSync17 } = await import("fs");
16905
16905
  const { writeFile: writeFile6 } = await import("fs/promises");
16906
16906
  const { join: join21 } = await import("path");
16907
16907
  const files = [];
16908
- if (!existsSync17(outputDir)) mkdirSync7(outputDir, { recursive: true });
16908
+ if (!existsSync17(outputDir)) mkdirSync8(outputDir, { recursive: true });
16909
16909
  const rulesDir = join21(outputDir, "rules");
16910
- if (!existsSync17(rulesDir)) mkdirSync7(rulesDir, { recursive: true });
16910
+ if (!existsSync17(rulesDir)) mkdirSync8(rulesDir, { recursive: true });
16911
16911
  const writeJson = async (name, data) => {
16912
16912
  const path = join21(outputDir, name);
16913
16913
  await writeFile6(path, JSON.stringify(data, null, 2) + "\n", "utf-8");
@@ -17155,7 +17155,7 @@ function previewLens(lens) {
17155
17155
  const DIM4 = "\x1B[2m";
17156
17156
  const CYAN3 = "\x1B[36m";
17157
17157
  const YELLOW4 = "\x1B[33m";
17158
- const GREEN3 = "\x1B[32m";
17158
+ const GREEN4 = "\x1B[32m";
17159
17159
  const RESET4 = "\x1B[0m";
17160
17160
  const lines = [];
17161
17161
  lines.push("");
@@ -17166,7 +17166,7 @@ function previewLens(lens) {
17166
17166
  if (d.example) {
17167
17167
  lines.push(` ${BOLD4}${d.id}${RESET4}`);
17168
17168
  lines.push(` ${YELLOW4}Without:${RESET4} ${DIM4}${d.example.without}${RESET4}`);
17169
- lines.push(` ${GREEN3}With:${RESET4} ${d.example.with}`);
17169
+ lines.push(` ${GREEN4}With:${RESET4} ${d.example.with}`);
17170
17170
  lines.push("");
17171
17171
  }
17172
17172
  }
@@ -21832,6 +21832,262 @@ var init_notion = __esm({
21832
21832
  }
21833
21833
  });
21834
21834
 
21835
+ // src/radiant/adapters/linear.ts
21836
+ async function fetchLinearActivity(apiKey, options = {}) {
21837
+ const windowDays = options.windowDays ?? 14;
21838
+ const maxIssues = options.maxIssues ?? 200;
21839
+ const since = new Date(Date.now() - windowDays * 24 * 60 * 60 * 1e3);
21840
+ const sinceIso = since.toISOString();
21841
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
21842
+ const teamFilter = options.teamIds && options.teamIds.length > 0 ? `team: { id: { in: [${options.teamIds.map((t) => JSON.stringify(t)).join(", ")}] } }` : "";
21843
+ const issuesQuery = `
21844
+ query RadiantIssues($since: DateTimeOrDuration!, $first: Int!) {
21845
+ issues(
21846
+ filter: {
21847
+ updatedAt: { gte: $since }
21848
+ ${teamFilter}
21849
+ }
21850
+ first: $first
21851
+ orderBy: updatedAt
21852
+ ) {
21853
+ nodes {
21854
+ id
21855
+ identifier
21856
+ title
21857
+ url
21858
+ createdAt
21859
+ updatedAt
21860
+ completedAt
21861
+ canceledAt
21862
+ state { name type }
21863
+ assignee { id name email }
21864
+ creator { id name }
21865
+ team { id name }
21866
+ project { id name }
21867
+ cycle { id number startsAt endsAt }
21868
+ comments(first: 20) {
21869
+ nodes { id body createdAt user { id name } }
21870
+ }
21871
+ }
21872
+ }
21873
+ }
21874
+ `;
21875
+ const cyclesQuery = `
21876
+ query RadiantCycles($since: DateTimeOrDuration!, $now: DateTimeOrDuration!) {
21877
+ cycles(
21878
+ filter: { endsAt: { gte: $since, lte: $now } }
21879
+ first: 20
21880
+ ) {
21881
+ nodes {
21882
+ id
21883
+ number
21884
+ startsAt
21885
+ endsAt
21886
+ issueCountHistory
21887
+ completedIssueCountHistory
21888
+ team { id name }
21889
+ }
21890
+ }
21891
+ }
21892
+ `;
21893
+ const [issuesResponse, cyclesResponse] = await Promise.all([
21894
+ fetchLinearGraphQL(apiKey, issuesQuery, {
21895
+ since: sinceIso,
21896
+ first: maxIssues
21897
+ }),
21898
+ fetchLinearGraphQL(apiKey, cyclesQuery, {
21899
+ since: sinceIso,
21900
+ now: nowIso
21901
+ })
21902
+ ]);
21903
+ const rawIssues = issuesResponse.issues?.nodes ?? [];
21904
+ const rawCycles = cyclesResponse.cycles?.nodes ?? [];
21905
+ const events = [];
21906
+ const assignees = /* @__PURE__ */ new Set();
21907
+ const projects = /* @__PURE__ */ new Map();
21908
+ let issuesCreated = 0;
21909
+ let issuesCompleted = 0;
21910
+ let issuesOpen = 0;
21911
+ let issuesStalled = 0;
21912
+ let commentsTotal = 0;
21913
+ const now = Date.now();
21914
+ const stallThresholdMs = 14 * 24 * 60 * 60 * 1e3;
21915
+ for (const issue of rawIssues) {
21916
+ const created = new Date(issue.createdAt);
21917
+ const updated = new Date(issue.updatedAt);
21918
+ const completed = issue.completedAt ? new Date(issue.completedAt) : null;
21919
+ const assigneeId = issue.assignee?.id ?? "unassigned";
21920
+ if (assigneeId !== "unassigned") assignees.add(assigneeId);
21921
+ if (issue.project) {
21922
+ projects.set(issue.project.name, (projects.get(issue.project.name) ?? 0) + 1);
21923
+ }
21924
+ const actor = {
21925
+ id: assigneeId,
21926
+ kind: "human",
21927
+ name: issue.assignee?.name ?? "unassigned"
21928
+ };
21929
+ if (created >= since) {
21930
+ issuesCreated++;
21931
+ events.push({
21932
+ id: `linear-created-${issue.id}`,
21933
+ timestamp: issue.createdAt,
21934
+ actor: {
21935
+ id: issue.creator?.id ?? "unknown",
21936
+ kind: "human",
21937
+ name: issue.creator?.name ?? "unknown"
21938
+ },
21939
+ kind: "issue_created",
21940
+ content: `[${issue.identifier}] ${issue.title}`,
21941
+ metadata: {
21942
+ issueId: issue.id,
21943
+ url: issue.url,
21944
+ team: issue.team?.name,
21945
+ project: issue.project?.name,
21946
+ state: issue.state?.name
21947
+ }
21948
+ });
21949
+ }
21950
+ if (completed && completed >= since) {
21951
+ issuesCompleted++;
21952
+ events.push({
21953
+ id: `linear-completed-${issue.id}`,
21954
+ timestamp: issue.completedAt,
21955
+ actor,
21956
+ kind: "issue_completed",
21957
+ content: `[${issue.identifier}] ${issue.title}`,
21958
+ metadata: {
21959
+ issueId: issue.id,
21960
+ url: issue.url,
21961
+ team: issue.team?.name,
21962
+ project: issue.project?.name,
21963
+ cycleDays: issue.cycle?.startsAt && issue.completedAt ? Math.round(
21964
+ (new Date(issue.completedAt).getTime() - new Date(issue.cycle.startsAt).getTime()) / (24 * 60 * 60 * 1e3)
21965
+ ) : null
21966
+ }
21967
+ });
21968
+ }
21969
+ if (!completed && !issue.canceledAt) {
21970
+ issuesOpen++;
21971
+ const isInProgress = issue.state?.type === "started";
21972
+ const idleMs = now - updated.getTime();
21973
+ if (isInProgress && idleMs > stallThresholdMs) issuesStalled++;
21974
+ }
21975
+ for (const comment of issue.comments?.nodes ?? []) {
21976
+ const commentedAt = new Date(comment.createdAt);
21977
+ if (commentedAt < since) continue;
21978
+ commentsTotal++;
21979
+ events.push({
21980
+ id: `linear-comment-${comment.id}`,
21981
+ timestamp: comment.createdAt,
21982
+ actor: {
21983
+ id: comment.user?.id ?? "unknown",
21984
+ kind: "human",
21985
+ name: comment.user?.name ?? "unknown"
21986
+ },
21987
+ kind: "issue_comment",
21988
+ content: comment.body.slice(0, 280),
21989
+ metadata: {
21990
+ issueId: issue.id,
21991
+ issueIdentifier: issue.identifier,
21992
+ url: issue.url
21993
+ }
21994
+ });
21995
+ }
21996
+ }
21997
+ let cycleCompletionRate = null;
21998
+ if (rawCycles.length > 0) {
21999
+ const rates = [];
22000
+ for (const cycle of rawCycles) {
22001
+ const committed = cycle.issueCountHistory?.at(0) ?? 0;
22002
+ const completed = cycle.completedIssueCountHistory?.at(-1) ?? 0;
22003
+ if (committed > 0) rates.push(completed / committed);
22004
+ }
22005
+ if (rates.length > 0) {
22006
+ cycleCompletionRate = Math.round(rates.reduce((a, b) => a + b, 0) / rates.length * 100) / 100;
22007
+ }
22008
+ }
22009
+ const topProjects = [...projects.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5).map(([name]) => name);
22010
+ const signals = {
22011
+ issuesCreated,
22012
+ issuesCompleted,
22013
+ issuesOpen,
22014
+ issuesStalled,
22015
+ cycleCompletionRate,
22016
+ uniqueAssignees: assignees.size,
22017
+ commentsTotal,
22018
+ topProjects
22019
+ };
22020
+ events.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp));
22021
+ return { events, signals };
22022
+ }
22023
+ function formatLinearSignalsForPrompt(signals) {
22024
+ if (signals.issuesCreated === 0 && signals.issuesCompleted === 0 && signals.issuesOpen === 0) {
22025
+ return "";
22026
+ }
22027
+ const lines = [
22028
+ "## Linear Activity (planned work vs. shipped outcome)",
22029
+ "",
22030
+ `${signals.issuesCreated} issues created, ${signals.issuesCompleted} completed in window.`,
22031
+ `${signals.issuesOpen} issues still open.`
22032
+ ];
22033
+ if (signals.issuesStalled > 0) {
22034
+ lines.push(
22035
+ `${signals.issuesStalled} in-progress issues haven't moved in 14+ days (stalled).`
22036
+ );
22037
+ }
22038
+ if (signals.cycleCompletionRate !== null) {
22039
+ const pct = Math.round(signals.cycleCompletionRate * 100);
22040
+ lines.push(`Cycles ended in window completed ${pct}% of what was committed.`);
22041
+ }
22042
+ if (signals.uniqueAssignees > 0) {
22043
+ lines.push(`${signals.uniqueAssignees} unique assignees active.`);
22044
+ }
22045
+ if (signals.commentsTotal > 0) {
22046
+ lines.push(`${signals.commentsTotal} comments across issues in window.`);
22047
+ }
22048
+ if (signals.topProjects.length > 0) {
22049
+ lines.push(`Most active projects: ${signals.topProjects.join(", ")}.`);
22050
+ }
22051
+ lines.push("");
22052
+ lines.push("Linear is where the team states what it will build.");
22053
+ lines.push("GitHub is where the team reveals what actually got built.");
22054
+ lines.push("Low completion rate + high creation rate = planning faster than shipping.");
22055
+ lines.push("High stalled count = commitments made but not honored.");
22056
+ lines.push("Compare Linear signals against GitHub to find the stated-vs-shipped gap.");
22057
+ return lines.join("\n");
22058
+ }
22059
+ async function fetchLinearGraphQL(apiKey, query, variables) {
22060
+ const res = await fetch("https://api.linear.app/graphql", {
22061
+ method: "POST",
22062
+ headers: {
22063
+ // Linear accepts the raw API key in Authorization with no "Bearer" prefix.
22064
+ Authorization: apiKey,
22065
+ "Content-Type": "application/json"
22066
+ },
22067
+ body: JSON.stringify({ query, variables })
22068
+ });
22069
+ if (!res.ok) {
22070
+ throw new Error(
22071
+ `Linear API error ${res.status}: ${(await res.text()).slice(0, 300)}`
22072
+ );
22073
+ }
22074
+ const json = await res.json();
22075
+ if (json.errors && json.errors.length > 0) {
22076
+ throw new Error(
22077
+ `Linear GraphQL errors: ${json.errors.map((e) => e.message).join("; ")}`
22078
+ );
22079
+ }
22080
+ if (!json.data) {
22081
+ throw new Error("Linear API returned no data");
22082
+ }
22083
+ return json.data;
22084
+ }
22085
+ var init_linear = __esm({
22086
+ "src/radiant/adapters/linear.ts"() {
22087
+ "use strict";
22088
+ }
22089
+ });
22090
+
21835
22091
  // src/radiant/core/git-remote.ts
21836
22092
  function resolveGitConfigPath(repoDir) {
21837
22093
  const dotGit = (0, import_path14.join)(repoDir, ".git");
@@ -22761,6 +23017,144 @@ var init_signals = __esm({
22761
23017
  }
22762
23018
  });
22763
23019
 
23020
+ // src/radiant/core/vocabulary.ts
23021
+ function extractDeclaredVocabulary(worldmodelContent) {
23022
+ const aligned = extractSection(worldmodelContent, "Aligned Behaviors").map(
23023
+ (b) => parseBehavior(b, "aligned")
23024
+ );
23025
+ const drift = extractSection(worldmodelContent, "Drift Behaviors").map(
23026
+ (b) => parseBehavior(b, "drift")
23027
+ );
23028
+ const allNames = [...aligned, ...drift].map((p) => p.name);
23029
+ return { aligned, drift, allNames };
23030
+ }
23031
+ function extractSection(content, header) {
23032
+ const escaped = header.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23033
+ const pattern = new RegExp(
23034
+ `##\\s+${escaped}\\s*\\n([\\s\\S]*?)(?=\\n##\\s|$)`,
23035
+ "i"
23036
+ );
23037
+ const match = content.match(pattern);
23038
+ if (!match) return [];
23039
+ const body = match[1];
23040
+ const bullets = body.match(/^[-*]\s+.+$/gm);
23041
+ if (!bullets) return [];
23042
+ return bullets.map((b) => b.replace(/^[-*]\s+/, "").trim()).filter((b) => b.length > 0 && !b.startsWith("<!--"));
23043
+ }
23044
+ function parseBehavior(bullet, kind) {
23045
+ const explicit = bullet.match(
23046
+ /^`?([a-z][a-z0-9_]*)`?\s+[—\u2014-]\s+(.+)$/i
23047
+ );
23048
+ if (explicit && isSnakeCase(explicit[1])) {
23049
+ return {
23050
+ name: explicit[1].toLowerCase(),
23051
+ prose: explicit[2].trim(),
23052
+ kind
23053
+ };
23054
+ }
23055
+ return { name: snakeCaseName(bullet), prose: bullet, kind };
23056
+ }
23057
+ function isSnakeCase(s) {
23058
+ return /^[a-z][a-z0-9_]*$/.test(s);
23059
+ }
23060
+ function snakeCaseName(s) {
23061
+ const base = s.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
23062
+ if (base.length <= 60) return base;
23063
+ const truncated = base.slice(0, 60);
23064
+ const lastUnderscore = truncated.lastIndexOf("_");
23065
+ return lastUnderscore > 20 ? truncated.slice(0, lastUnderscore) : truncated;
23066
+ }
23067
+ function matchDeclaredPattern(candidateName, candidateDescription, vocabulary) {
23068
+ const candidateText = `${candidateName.replace(/_/g, " ")} ${candidateDescription}`;
23069
+ const candidateWords = contentWords(candidateText);
23070
+ if (candidateWords.size === 0) return null;
23071
+ let best = null;
23072
+ for (const pattern of [...vocabulary.aligned, ...vocabulary.drift]) {
23073
+ const proseWords = contentWords(pattern.prose);
23074
+ if (proseWords.size === 0) continue;
23075
+ let shared = 0;
23076
+ for (const w of proseWords) {
23077
+ if (candidateWords.has(w)) shared++;
23078
+ }
23079
+ const coverage = shared / proseWords.size;
23080
+ if (shared >= 2 && coverage >= 0.3) {
23081
+ if (!best || coverage > best.score) {
23082
+ best = { pattern, score: coverage };
23083
+ }
23084
+ }
23085
+ }
23086
+ return best?.pattern ?? null;
23087
+ }
23088
+ function contentWords(text) {
23089
+ const words = text.toLowerCase().match(/[a-z][a-z0-9_]+/g) ?? [];
23090
+ return new Set(words.filter((w) => w.length > 3 && !STOPWORDS.has(w)));
23091
+ }
23092
+ var STOPWORDS;
23093
+ var init_vocabulary = __esm({
23094
+ "src/radiant/core/vocabulary.ts"() {
23095
+ "use strict";
23096
+ STOPWORDS = /* @__PURE__ */ new Set([
23097
+ "about",
23098
+ "after",
23099
+ "against",
23100
+ "among",
23101
+ "around",
23102
+ "because",
23103
+ "been",
23104
+ "before",
23105
+ "being",
23106
+ "between",
23107
+ "both",
23108
+ "could",
23109
+ "does",
23110
+ "doing",
23111
+ "during",
23112
+ "each",
23113
+ "from",
23114
+ "further",
23115
+ "have",
23116
+ "having",
23117
+ "into",
23118
+ "itself",
23119
+ "most",
23120
+ "nor",
23121
+ "only",
23122
+ "other",
23123
+ "over",
23124
+ "same",
23125
+ "should",
23126
+ "some",
23127
+ "such",
23128
+ "than",
23129
+ "that",
23130
+ "their",
23131
+ "them",
23132
+ "then",
23133
+ "there",
23134
+ "these",
23135
+ "they",
23136
+ "this",
23137
+ "those",
23138
+ "through",
23139
+ "under",
23140
+ "until",
23141
+ "very",
23142
+ "were",
23143
+ "what",
23144
+ "when",
23145
+ "where",
23146
+ "which",
23147
+ "while",
23148
+ "will",
23149
+ "with",
23150
+ "without",
23151
+ "would",
23152
+ "your",
23153
+ "yours"
23154
+ ]);
23155
+ }
23156
+ });
23157
+
22764
23158
  // src/radiant/types.ts
22765
23159
  function isScored(s) {
22766
23160
  return typeof s === "number";
@@ -22812,7 +23206,11 @@ var init_math = __esm({
22812
23206
  async function interpretPatterns(input) {
22813
23207
  const prompt = buildInterpretationPrompt(input);
22814
23208
  const raw = await input.ai.complete(prompt, "Analyze the activity and produce the read.");
22815
- const parsed = parseInterpretation(raw, input.canonicalPatterns ?? []);
23209
+ const canonicalNames = [
23210
+ ...input.canonicalPatterns ?? [],
23211
+ ...input.declaredVocabulary?.allNames ?? []
23212
+ ];
23213
+ const parsed = parseInterpretation(raw, canonicalNames, input.declaredVocabulary);
22816
23214
  return {
22817
23215
  patterns: parsed.patterns,
22818
23216
  meaning: parsed.meaning,
@@ -22823,8 +23221,10 @@ async function interpretPatterns(input) {
22823
23221
  function buildInterpretationPrompt(input) {
22824
23222
  const signalSummary = formatSignalSummary(input.signals);
22825
23223
  const eventSample = formatEventSample(input.events, 30);
22826
- const canonicalList = (input.canonicalPatterns ?? []).length > 0 ? `Patterns the organization has already named (use these names if you see them):
22827
- ${input.canonicalPatterns.map((p) => `- ${p}`).join("\n")}` : "No patterns have been named yet. Everything you observe is new.";
23224
+ const canonicalList = formatDeclaredVocabulary(
23225
+ input.declaredVocabulary,
23226
+ input.canonicalPatterns ?? []
23227
+ );
22828
23228
  const compressedWorld = compressWorldmodel(input.worldmodelContent);
22829
23229
  const cl = compressLens(input.lens);
22830
23230
  const frame = input.lens.primary_frame;
@@ -22935,6 +23335,44 @@ Only recommend a move when the evidence actually calls for one.
22935
23335
  Do NOT use these phrases anywhere in your output:
22936
23336
  ${forbiddenList}`;
22937
23337
  }
23338
+ function formatDeclaredVocabulary(vocabulary, extraNames) {
23339
+ const aligned = vocabulary?.aligned ?? [];
23340
+ const drift = vocabulary?.drift ?? [];
23341
+ if (aligned.length === 0 && drift.length === 0 && extraNames.length === 0) {
23342
+ return 'No patterns have been named yet. Everything you observe is new \u2014 mark it type: "candidate".';
23343
+ }
23344
+ const parts = [];
23345
+ parts.push("## Declared vocabulary (use these names when you see matching evidence)");
23346
+ parts.push("");
23347
+ parts.push(
23348
+ 'The worldmodel declares the patterns below. If your observation matches one of these, use the EXACT snake_case name shown and mark type: "canonical" \u2014 do not invent a new name for something that already has one.'
23349
+ );
23350
+ parts.push("");
23351
+ if (aligned.length > 0) {
23352
+ parts.push("### Aligned behaviors (positive patterns)");
23353
+ for (const p of aligned) {
23354
+ parts.push(`- \`${p.name}\` \u2014 ${p.prose}`);
23355
+ }
23356
+ parts.push("");
23357
+ }
23358
+ if (drift.length > 0) {
23359
+ parts.push("### Drift behaviors (negative patterns)");
23360
+ for (const p of drift) {
23361
+ parts.push(`- \`${p.name}\` \u2014 ${p.prose}`);
23362
+ }
23363
+ parts.push("");
23364
+ }
23365
+ if (extraNames.length > 0) {
23366
+ parts.push(
23367
+ `Additional canonical names (from prior runs or caller): ${extraNames.join(", ")}`
23368
+ );
23369
+ parts.push("");
23370
+ }
23371
+ parts.push(
23372
+ 'If you observe something genuinely new that matches NO declared pattern, mark it type: "candidate" with a freshly-invented snake_case name.'
23373
+ );
23374
+ return parts.join("\n");
23375
+ }
22938
23376
  function formatSignalSummary(signals) {
22939
23377
  const lines = [];
22940
23378
  const domains = ["life", "cyber", "joint"];
@@ -22960,7 +23398,7 @@ function formatEventSample(events, maxEvents) {
22960
23398
  "${content}"`;
22961
23399
  }).join("\n");
22962
23400
  }
22963
- function parseInterpretation(raw, canonicalNames) {
23401
+ function parseInterpretation(raw, canonicalNames, vocabulary) {
22964
23402
  let meaning = "";
22965
23403
  let move = "";
22966
23404
  let patternsArray = [];
@@ -22990,14 +23428,23 @@ function parseInterpretation(raw, canonicalNames) {
22990
23428
  const patterns = [];
22991
23429
  for (const item of patternsArray) {
22992
23430
  if (!isPatternLike(item)) continue;
22993
- const nameStr = String(item.name ?? "unnamed");
23431
+ const rawName = String(item.name ?? "unnamed");
23432
+ const description = String(item.description ?? "");
22994
23433
  const ev = item.evidence;
22995
- const isCanonical = item.type === "canonical" || canonicalSet.has(nameStr.toLowerCase());
23434
+ let name = rawName;
23435
+ let isCanonical = item.type === "canonical" || canonicalSet.has(rawName.toLowerCase());
23436
+ if (!isCanonical && vocabulary) {
23437
+ const matched = matchDeclaredPattern(rawName, description, vocabulary);
23438
+ if (matched) {
23439
+ name = matched.name;
23440
+ isCanonical = true;
23441
+ }
23442
+ }
22996
23443
  patterns.push({
22997
- name: nameStr,
23444
+ name,
22998
23445
  type: isCanonical ? "canonical" : "candidate",
22999
- declaredAs: isCanonical ? nameStr : void 0,
23000
- description: String(item.description ?? ""),
23446
+ declaredAs: isCanonical ? name : void 0,
23447
+ description,
23001
23448
  evidence: {
23002
23449
  signals: Array.isArray(ev?.signals) ? ev.signals.map(String) : [],
23003
23450
  events: Array.isArray(ev?.events) ? ev.events.map(String) : [],
@@ -23015,6 +23462,7 @@ var init_patterns = __esm({
23015
23462
  "src/radiant/core/patterns.ts"() {
23016
23463
  "use strict";
23017
23464
  init_compress();
23465
+ init_vocabulary();
23018
23466
  }
23019
23467
  });
23020
23468
 
@@ -23333,10 +23781,24 @@ Compare stated intent against actual GitHub activity. Gaps = drift.`;
23333
23781
  } catch {
23334
23782
  }
23335
23783
  }
23784
+ const linearKey = process.env.LINEAR_API_KEY;
23785
+ if (linearKey) {
23786
+ try {
23787
+ const linear = await fetchLinearActivity(linearKey, { windowDays });
23788
+ events.push(...linear.events);
23789
+ adapterSignals += "\n\n" + formatLinearSignalsForPrompt(linear.signals);
23790
+ activeAdapters.push("linear");
23791
+ } catch {
23792
+ }
23793
+ }
23336
23794
  events.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp));
23795
+ if (input.personalUser) {
23796
+ events = filterEventsByUser(events, input.personalUser);
23797
+ }
23337
23798
  const classified = classifyEvents(events);
23338
23799
  const signals = extractSignals(classified);
23339
23800
  const scores = computeScores(signals, input.worldmodelContent !== "");
23801
+ const declaredVocabulary = extractDeclaredVocabulary(worldmodelContent);
23340
23802
  const { patterns, meaning, move } = await interpretPatterns({
23341
23803
  signals,
23342
23804
  events: classified,
@@ -23344,6 +23806,7 @@ Compare stated intent against actual GitHub activity. Gaps = drift.`;
23344
23806
  lens,
23345
23807
  ai: input.ai,
23346
23808
  canonicalPatterns: input.canonicalPatterns,
23809
+ declaredVocabulary,
23347
23810
  statedIntent: [statedIntent, adapterSignals, priorReadContext].filter(Boolean).join("\n\n") || void 0
23348
23811
  });
23349
23812
  const rewrittenPatterns = patterns.map((p) => lens.rewrite(p));
@@ -23398,6 +23861,10 @@ Compare stated intent against actual GitHub activity. Gaps = drift.`;
23398
23861
  worldStack
23399
23862
  };
23400
23863
  }
23864
+ function filterEventsByUser(events, username) {
23865
+ const target = username.toLowerCase();
23866
+ return events.filter((e) => e.actor.id.toLowerCase() === target);
23867
+ }
23401
23868
  function computeScores(signals, worldmodelLoaded) {
23402
23869
  const gate = DEFAULT_EVIDENCE_GATE;
23403
23870
  const lifeSignals = signals.filter((s) => s.domain === "life");
@@ -23453,12 +23920,14 @@ var init_emergent = __esm({
23453
23920
  init_discord();
23454
23921
  init_slack();
23455
23922
  init_notion();
23923
+ init_linear();
23456
23924
  init_discovery();
23457
23925
  init_exocortex();
23458
23926
  init_palace();
23459
23927
  init_compress();
23460
23928
  init_governance();
23461
23929
  init_signals();
23930
+ init_vocabulary();
23462
23931
  init_math();
23463
23932
  init_patterns();
23464
23933
  init_renderer();
@@ -23780,7 +24249,9 @@ var init_server = __esm({
23780
24249
  // src/cli/radiant.ts
23781
24250
  var radiant_exports = {};
23782
24251
  __export(radiant_exports, {
23783
- main: () => main34
24252
+ checkScopeConsent: () => checkScopeConsent,
24253
+ main: () => main34,
24254
+ parseArgs: () => parseArgs27
23784
24255
  });
23785
24256
  function parseArgs27(argv) {
23786
24257
  const result = {
@@ -23792,8 +24263,12 @@ function parseArgs27(argv) {
23792
24263
  exocortex: void 0,
23793
24264
  teamExocortex: void 0,
23794
24265
  view: void 0,
24266
+ user: void 0,
24267
+ personal: false,
24268
+ entireOrg: false,
23795
24269
  json: false,
23796
24270
  help: false,
24271
+ force: false,
23797
24272
  rest: []
23798
24273
  };
23799
24274
  let i = 0;
@@ -23825,9 +24300,22 @@ function parseArgs27(argv) {
23825
24300
  case "--view":
23826
24301
  result.view = argv[++i];
23827
24302
  break;
24303
+ case "--user":
24304
+ result.user = argv[++i];
24305
+ break;
24306
+ case "--personal":
24307
+ result.personal = true;
24308
+ break;
24309
+ case "--entire-org":
24310
+ result.entireOrg = true;
24311
+ break;
23828
24312
  case "--json":
23829
24313
  result.json = true;
23830
24314
  break;
24315
+ case "--force":
24316
+ case "-f":
24317
+ result.force = true;
24318
+ break;
23831
24319
  case "--help":
23832
24320
  case "-h":
23833
24321
  result.help = true;
@@ -23985,6 +24473,15 @@ ${DIM3}Model: ${model ?? "claude-sonnet-4-20250514 (default)"}${RESET3}
23985
24473
  process.exit(2);
23986
24474
  }
23987
24475
  }
24476
+ function checkScopeConsent(input) {
24477
+ if (input.personal && !input.resolvedUser) {
24478
+ return { ok: false, reason: "personal_requires_user" };
24479
+ }
24480
+ if (input.scope.type === "org" && !input.entireOrg && !input.personal) {
24481
+ return { ok: false, reason: "org_requires_opt_in" };
24482
+ }
24483
+ return { ok: true };
24484
+ }
23988
24485
  async function cmdEmergent(args) {
23989
24486
  const scopeStr = args.rest[0];
23990
24487
  if (!scopeStr) {
@@ -23995,6 +24492,43 @@ async function cmdEmergent(args) {
23995
24492
  process.exit(1);
23996
24493
  }
23997
24494
  const scope = parseScope(scopeStr);
24495
+ const personalUser = args.user ?? process.env.RADIANT_USER;
24496
+ const consent = checkScopeConsent({
24497
+ scope,
24498
+ personal: args.personal,
24499
+ entireOrg: args.entireOrg,
24500
+ resolvedUser: personalUser
24501
+ });
24502
+ if (!consent.ok) {
24503
+ if (consent.reason === "personal_requires_user") {
24504
+ process.stderr.write(
24505
+ `${RED2}Error:${RESET3} --personal requires a GitHub username.
24506
+ ${DIM3}Pass --user <login> or set RADIANT_USER. Radiant will read
24507
+ only that user's activity \u2014 no one else is observed.${RESET3}
24508
+ `
24509
+ );
24510
+ } else {
24511
+ process.stderr.write(
24512
+ `${YELLOW3}\u26A0${RESET3} ${BOLD3}"${scope.owner}" is an org-wide scope.${RESET3}
24513
+
24514
+ ${DIM3}This reads activity across ALL repos in the org \u2014 a global-observer
24515
+ pattern that some teams consider offside with decentralization and
24516
+ cognitive-liberty principles. It's opt-in for that reason.${RESET3}
24517
+
24518
+ Three ways forward:
24519
+ ${GREEN3}1.${RESET3} Scope to a single repo (recommended default):
24520
+ radiant emergent ${scope.owner}/<repo>
24521
+
24522
+ ${GREEN3}2.${RESET3} Read only your own activity (personal mode):
24523
+ radiant emergent ${scope.owner}/ --personal --user <your-login>
24524
+
24525
+ ${GREEN3}3.${RESET3} Explicitly opt in to org-wide observation:
24526
+ radiant emergent ${scope.owner}/ --entire-org
24527
+ `
24528
+ );
24529
+ }
24530
+ process.exit(1);
24531
+ }
23998
24532
  const lensId = args.lens ?? process.env.RADIANT_LENS;
23999
24533
  if (!lensId) {
24000
24534
  process.stderr.write(
@@ -24043,8 +24577,11 @@ ${DIM3}Set it to a GitHub PAT with repo read access.${RESET3}
24043
24577
  const ctx = readExocortex(exocortexPath);
24044
24578
  exocortexStatus = summarizeExocortex(ctx);
24045
24579
  }
24580
+ const scopeLabel = scope.type === "org" ? scope.owner + " (entire org)" : scope.owner + "/" + scope.repo;
24581
+ const modeLabel = args.personal ? `personal \u2014 only ${personalUser}'s activity` : "team \u2014 all contributors";
24046
24582
  process.stderr.write(
24047
- `${DIM3}Scope: ${scope.type === "org" ? scope.owner + " (entire org)" : scope.owner + "/" + scope.repo}${RESET3}
24583
+ `${DIM3}Scope: ${scopeLabel}${RESET3}
24584
+ ${DIM3}Mode: ${modeLabel}${RESET3}
24048
24585
  ${DIM3}View: ${view}${RESET3}
24049
24586
  ${DIM3}Lens: ${lensId}${RESET3}
24050
24587
  ${DIM3}Model: ${model ?? "claude-sonnet-4-20250514 (default)"}${RESET3}
@@ -24060,7 +24597,8 @@ ${DIM3}Fetching activity...${RESET3}
24060
24597
  lensId,
24061
24598
  ai,
24062
24599
  windowDays: 14,
24063
- exocortexPath: exocortexPath || void 0
24600
+ exocortexPath: exocortexPath || void 0,
24601
+ personalUser: args.personal ? personalUser : void 0
24064
24602
  });
24065
24603
  if (!result.voiceClean) {
24066
24604
  process.stderr.write(
@@ -24162,6 +24700,43 @@ ${DIM3}Use: lenses list | lenses describe <id>${RESET3}
24162
24700
  );
24163
24701
  process.exit(1);
24164
24702
  }
24703
+ async function cmdInit2(args) {
24704
+ const targetDir = (0, import_path20.resolve)(args.rest[0] ?? "./mind-palace");
24705
+ const existed = (0, import_fs19.existsSync)(targetDir);
24706
+ if (existed && !args.force) {
24707
+ const entries = (0, import_fs19.readdirSync)(targetDir);
24708
+ if (entries.length > 0) {
24709
+ process.stderr.write(
24710
+ `${RED2}Error:${RESET3} ${targetDir} already exists and is not empty.
24711
+ ${DIM3}Use --force to write into it anyway (existing files will be overwritten).${RESET3}
24712
+ `
24713
+ );
24714
+ process.exit(1);
24715
+ }
24716
+ }
24717
+ (0, import_fs19.mkdirSync)(targetDir, { recursive: true });
24718
+ (0, import_fs19.mkdirSync)((0, import_path20.join)(targetDir, "reads"), { recursive: true });
24719
+ (0, import_fs19.mkdirSync)((0, import_path20.join)(targetDir, "worldmodels"), { recursive: true });
24720
+ for (const [relPath, content] of Object.entries(MIND_PALACE_FILES)) {
24721
+ const fullPath = (0, import_path20.join)(targetDir, relPath);
24722
+ (0, import_fs19.mkdirSync)((0, import_path20.resolve)(fullPath, ".."), { recursive: true });
24723
+ (0, import_fs19.writeFileSync)(fullPath, content, "utf-8");
24724
+ }
24725
+ process.stdout.write(
24726
+ `${GREEN3}\u2713${RESET3} Mind Palace scaffolded at ${BOLD3}${targetDir}${RESET3}
24727
+
24728
+ ${DIM3}Next steps:${RESET3}
24729
+ 1. Edit ${targetDir}/attention.md \u2014 what you're focused on right now
24730
+ 2. Edit ${targetDir}/worldmodels/starter.worldmodel.md \u2014 add a few
24731
+ aligned and drift behaviors
24732
+ 3. Run: neuroverse radiant emergent <owner/repo> \\
24733
+ --worlds ${targetDir}/worldmodels \\
24734
+ --exocortex ${targetDir}
24735
+
24736
+ ${DIM3}Files are yours. Edit freely.${RESET3}
24737
+ `
24738
+ );
24739
+ }
24165
24740
  async function main34(argv) {
24166
24741
  const args = parseArgs27(argv);
24167
24742
  if (args.help || !args.subcommand) {
@@ -24169,6 +24744,8 @@ async function main34(argv) {
24169
24744
  return;
24170
24745
  }
24171
24746
  switch (args.subcommand) {
24747
+ case "init":
24748
+ return cmdInit2(args);
24172
24749
  case "think":
24173
24750
  return cmdThink(args);
24174
24751
  case "lenses":
@@ -24199,7 +24776,7 @@ async function main34(argv) {
24199
24776
  process.exit(1);
24200
24777
  }
24201
24778
  }
24202
- var import_fs19, import_path20, RED2, DIM3, BOLD3, YELLOW3, RESET3, USAGE10;
24779
+ var import_fs19, import_path20, RED2, GREEN3, DIM3, BOLD3, YELLOW3, RESET3, USAGE10, MIND_PALACE_FILES;
24203
24780
  var init_radiant = __esm({
24204
24781
  "src/cli/radiant.ts"() {
24205
24782
  "use strict";
@@ -24213,6 +24790,7 @@ var init_radiant = __esm({
24213
24790
  init_lenses();
24214
24791
  init_discovery();
24215
24792
  RED2 = "\x1B[31m";
24793
+ GREEN3 = "\x1B[32m";
24216
24794
  DIM3 = "\x1B[2m";
24217
24795
  BOLD3 = "\x1B[1m";
24218
24796
  YELLOW3 = "\x1B[33m";
@@ -24220,6 +24798,9 @@ var init_radiant = __esm({
24220
24798
  USAGE10 = `
24221
24799
  ${BOLD3}neuroverse radiant${RESET3} \u2014 behavioral intelligence for collaboration systems
24222
24800
 
24801
+ ${BOLD3}Setup:${RESET3}
24802
+ init Scaffold a Mind Palace in the current directory
24803
+
24223
24804
  ${BOLD3}Stage A (voice layer):${RESET3}
24224
24805
  think Send a query through the worldmodel + lens \u2192 AI-framed response
24225
24806
 
@@ -24230,13 +24811,27 @@ ${BOLD3}Stage B (behavioral analysis, coming soon):${RESET3}
24230
24811
  lenses List or describe available rendering lenses
24231
24812
 
24232
24813
  ${BOLD3}Usage:${RESET3}
24814
+ neuroverse radiant init (scaffolds ./mind-palace/)
24815
+ neuroverse radiant init ./my-palace (custom path)
24233
24816
  neuroverse radiant think --lens auki-builder --worlds ./worlds/ --query "What is our biggest risk?"
24234
24817
  neuroverse radiant think --lens auki-builder --worlds ./worlds/ < prompt.txt
24235
24818
  neuroverse radiant emergent aukiverse/posemesh --lens auki-builder --worlds ./worlds/
24236
24819
  neuroverse radiant emergent aukiverse/posemesh --lens auki-builder --worlds ./worlds/ --exocortex ~/exocortex/
24820
+ neuroverse radiant emergent aukilabs/posemesh --personal --user alice
24821
+ neuroverse radiant emergent aukilabs/ --entire-org --lens auki-builder --worlds ./worlds/
24237
24822
  neuroverse radiant lenses list
24238
24823
  neuroverse radiant lenses describe auki-builder
24239
24824
 
24825
+ ${BOLD3}Read modes:${RESET3}
24826
+ ${BOLD3}Default (team):${RESET3} reads all contributors in the given scope.
24827
+ ${BOLD3}--personal --user <login>:${RESET3} reads ONLY that user's activity.
24828
+ A local, private facilitator \u2014 no one else is observed. Works against
24829
+ any scope; an org scope with --personal is fine.
24830
+ ${BOLD3}--entire-org (gated):${RESET3} org-wide scope observes every contributor
24831
+ across every repo. This is a global-observer stance and is opt-in.
24832
+ \`radiant emergent <org>/\` without --entire-org will refuse and show
24833
+ you the three choices (single repo, --personal, or explicit opt-in).
24834
+
24240
24835
  ${BOLD3}Auto-discovery:${RESET3}
24241
24836
  You do not need to clone the target repo.
24242
24837
 
@@ -24255,7 +24850,169 @@ ${BOLD3}Environment:${RESET3}
24255
24850
  RADIANT_LENS Default lens id (overridden by --lens)
24256
24851
  RADIANT_MODEL AI model override (default: claude-sonnet-4-20250514)
24257
24852
  RADIANT_EXOCORTEX Default exocortex directory (overridden by --exocortex)
24853
+ RADIANT_USER Default personal-mode user (overridden by --user)
24258
24854
  `.trim();
24855
+ MIND_PALACE_FILES = {
24856
+ "README.md": `# Mind Palace
24857
+
24858
+ This is your Mind Palace \u2014 structured external memory that gives Radiant
24859
+ (and any agent you wire into it) persistent context about who you are,
24860
+ what you're working on, and what "on track" means for you.
24861
+
24862
+ Radiant reads these files before every run and writes each read back into
24863
+ \`reads/\`. Over time, \`knowledge.md\` accumulates what's persisted and what
24864
+ hasn't \u2014 the feedback loop that turns raw activity into named behavior.
24865
+
24866
+ ## Files
24867
+
24868
+ - \`attention.md\` \u2014 what you're focused on **right now**
24869
+ - \`goals.md\` \u2014 what you're working toward
24870
+ - \`sprint.md\` \u2014 this week's focus
24871
+ - \`identity.md\` \u2014 who you are, what you value
24872
+ - \`worldmodels/\` \u2014 your thinking constitutions (drift + aligned behaviors)
24873
+ - \`reads/\` \u2014 dated Radiant reads (written by \`radiant emergent\`)
24874
+ - \`knowledge.md\` \u2014 accumulated pattern persistence across reads
24875
+
24876
+ ## How to use
24877
+
24878
+ 1. Fill in \`attention.md\`, \`goals.md\`, \`sprint.md\`, \`identity.md\` with
24879
+ your own words. A sentence each is enough to start \u2014 the files grow
24880
+ with you.
24881
+ 2. Edit \`worldmodels/starter.worldmodel.md\`: add a few aligned behaviors
24882
+ (what on-track looks like) and drift behaviors (what off-track looks
24883
+ like). The sharper these are, the sharper Radiant's reads.
24884
+ 3. Run \`neuroverse radiant emergent <owner/repo> --mind-palace .\` against
24885
+ the repo you want read. Radiant compares your stated intent (these
24886
+ files) to your observed activity (GitHub) and names the gap.
24887
+
24888
+ Edit freely. These files are yours.
24889
+ `,
24890
+ "attention.md": `# Attention
24891
+
24892
+ <!--
24893
+ What are you focused on RIGHT NOW? One paragraph. Updated as you shift.
24894
+ This is the file an AI agent reads at the start of a session to know
24895
+ what to help with today.
24896
+ -->
24897
+
24898
+ `,
24899
+ "goals.md": `# Goals
24900
+
24901
+ <!--
24902
+ What are you working toward? Bullet points welcome.
24903
+ Longer horizon than attention \u2014 months, not days.
24904
+ -->
24905
+
24906
+ -
24907
+ `,
24908
+ "sprint.md": `# Sprint
24909
+
24910
+ <!--
24911
+ This week's focus. What do you want to ship or finish?
24912
+ Keep it short \u2014 five bullets max.
24913
+ -->
24914
+
24915
+ -
24916
+ `,
24917
+ "identity.md": `# Identity
24918
+
24919
+ <!--
24920
+ Who are you, what do you value, how do you work?
24921
+ This is the context an agent needs to not treat you like a stranger
24922
+ every time. Write it in your own voice.
24923
+ -->
24924
+
24925
+ `,
24926
+ "knowledge.md": `# Knowledge
24927
+
24928
+ <!--
24929
+ Radiant writes accumulated pattern persistence here across reads.
24930
+ Leave this file empty on day one \u2014 it fills up as \`radiant emergent\`
24931
+ runs accumulate.
24932
+ -->
24933
+
24934
+ `,
24935
+ "reads/.gitkeep": "",
24936
+ "worldmodels/starter.worldmodel.md": `# Starter Worldmodel
24937
+
24938
+ <!--
24939
+ Your thinking constitution. Radiant reads this to understand what
24940
+ "aligned" and "drift" mean for your work.
24941
+
24942
+ The sharper the Aligned/Drift Behaviors, the sharper Radiant's reads.
24943
+ When Radiant detects something matching a drift behavior below, it
24944
+ labels it with THAT name \u2014 it doesn't invent new ones.
24945
+ -->
24946
+
24947
+ ## Mission
24948
+
24949
+ <!-- One sentence. What are you doing in the world? -->
24950
+
24951
+
24952
+ ## Invariants
24953
+
24954
+ <!--
24955
+ Non-negotiable rules. If a decision violates one, it's blocked.
24956
+ Keep this list short \u2014 3 to 6 items. Each should be a hard no.
24957
+ -->
24958
+
24959
+ -
24960
+
24961
+ ## Aligned Behaviors
24962
+
24963
+ <!--
24964
+ What "on track" looks like. One per line, phrased as a behavior.
24965
+ Radiant will use these as canonical pattern names when it sees
24966
+ matching evidence in your activity.
24967
+
24968
+ Example:
24969
+ - ships partial-but-working features rather than waiting for the full stack
24970
+ - writes decisions down before acting on them
24971
+ -->
24972
+
24973
+ -
24974
+
24975
+ ## Drift Behaviors
24976
+
24977
+ <!--
24978
+ What "off track" looks like. Same format as Aligned.
24979
+ When Radiant detects drift, it will label it with these names \u2014 not
24980
+ make up new ones.
24981
+
24982
+ Example:
24983
+ - shipping pace outruns strategic decision-making
24984
+ - architecture decisions surface without context about why
24985
+ -->
24986
+
24987
+ -
24988
+
24989
+ ## Signals
24990
+
24991
+ <!--
24992
+ Observable quantities you care about. Radiant scores activity
24993
+ against these \u2014 5 to 7 is the sweet spot.
24994
+
24995
+ Example:
24996
+ - shipping_velocity
24997
+ - decision_ownership
24998
+ - storytelling_cadence
24999
+ -->
25000
+
25001
+ -
25002
+
25003
+ ## Decision Priorities
25004
+
25005
+ <!--
25006
+ When tradeoffs appear, these resolve them. Format: "A > B".
25007
+
25008
+ Example:
25009
+ - correctness > speed
25010
+ - clarity > cleverness
25011
+ -->
25012
+
25013
+ -
25014
+ `
25015
+ };
24259
25016
  }
24260
25017
  });
24261
25018