@kl-c/matrixos 0.1.5 → 0.1.7

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/dist/cli/index.js CHANGED
@@ -2145,7 +2145,7 @@ var package_default;
2145
2145
  var init_package = __esm(() => {
2146
2146
  package_default = {
2147
2147
  name: "@kl-c/matrixos",
2148
- version: "0.1.5",
2148
+ version: "0.1.7",
2149
2149
  description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
2150
2150
  main: "./dist/index.js",
2151
2151
  types: "dist/index.d.ts",
@@ -117554,19 +117554,19 @@ __export(exports_generate, {
117554
117554
  executeGenerateCommand: () => executeGenerateCommand,
117555
117555
  ProfileNotFoundError: () => ProfileNotFoundError
117556
117556
  });
117557
- import { existsSync as existsSync68, readFileSync as readFileSync53, realpathSync as realpathSync10 } from "fs";
117558
- import { dirname as dirname28, isAbsolute as isAbsolute6, join as join72, resolve as resolve16 } from "path";
117557
+ import { existsSync as existsSync69, readFileSync as readFileSync54, realpathSync as realpathSync10 } from "fs";
117558
+ import { dirname as dirname28, isAbsolute as isAbsolute6, join as join74, resolve as resolve16 } from "path";
117559
117559
  function profilesDirFor(opts) {
117560
117560
  if (opts.profilesDir)
117561
117561
  return opts.profilesDir;
117562
117562
  if (opts.cwd)
117563
- return join72(opts.cwd, PROFILES_RELATIVE);
117564
- return join72(REPO_ROOT, PROFILES_RELATIVE);
117563
+ return join74(opts.cwd, PROFILES_RELATIVE);
117564
+ return join74(REPO_ROOT, PROFILES_RELATIVE);
117565
117565
  }
117566
117566
  function loadProfile(name2, options = {}) {
117567
117567
  const fs21 = options.fs ?? defaultFS2;
117568
117568
  const dir = profilesDirFor(options);
117569
- const path27 = join72(dir, `${name2}.json`);
117569
+ const path27 = join74(dir, `${name2}.json`);
117570
117570
  if (!fs21.existsSync(path27)) {
117571
117571
  throw new ProfileNotFoundError(name2);
117572
117572
  }
@@ -117579,7 +117579,7 @@ function listProfiles(options = {}) {
117579
117579
  const known = options.knownNames ?? ["trader", "plumber"];
117580
117580
  const out = [];
117581
117581
  for (const name2 of known) {
117582
- const path27 = join72(dir, `${name2}.json`);
117582
+ const path27 = join74(dir, `${name2}.json`);
117583
117583
  if (fs21.existsSync(path27)) {
117584
117584
  try {
117585
117585
  const raw = JSON.parse(fs21.readFileSync(path27, "utf-8"));
@@ -117652,7 +117652,7 @@ var init_generate = __esm(() => {
117652
117652
  init_src4();
117653
117653
  init_src4();
117654
117654
  REPO_ROOT = resolve16(dirname28(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
117655
- defaultFS2 = { existsSync: existsSync68, readFileSync: readFileSync53, realpathSync: realpathSync10 };
117655
+ defaultFS2 = { existsSync: existsSync69, readFileSync: readFileSync54, realpathSync: realpathSync10 };
117656
117656
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
117657
117657
  profileName;
117658
117658
  constructor(profileName) {
@@ -117669,12 +117669,12 @@ __export(exports_cost_report, {
117669
117669
  executeCostReportCommand: () => executeCostReportCommand
117670
117670
  });
117671
117671
  import { Database as Database6 } from "bun:sqlite";
117672
- import { existsSync as existsSync69 } from "fs";
117672
+ import { existsSync as existsSync70 } from "fs";
117673
117673
  import * as path27 from "path";
117674
117674
  import * as os13 from "os";
117675
117675
  function executeCostReportCommand(args) {
117676
117676
  const dbPath = path27.join(os13.homedir(), ".matrixos", "cost.db");
117677
- if (!existsSync69(dbPath)) {
117677
+ if (!existsSync70(dbPath)) {
117678
117678
  return { exitCode: 1, stdout: `No cost data available
117679
117679
  ` };
117680
117680
  }
@@ -117804,8 +117804,8 @@ var exports_profile_resolve = {};
117804
117804
  __export(exports_profile_resolve, {
117805
117805
  executeProfileResolveCommand: () => executeProfileResolveCommand
117806
117806
  });
117807
- import { existsSync as existsSync70, readdirSync as readdirSync15, readFileSync as readFileSync54 } from "fs";
117808
- import { join as join74, resolve as resolve17, dirname as dirname29 } from "path";
117807
+ import { existsSync as existsSync71, readdirSync as readdirSync15, readFileSync as readFileSync55 } from "fs";
117808
+ import { join as join76, resolve as resolve17, dirname as dirname29 } from "path";
117809
117809
  function executeProfileResolveCommand(args) {
117810
117810
  if (args.options.help) {
117811
117811
  return {
@@ -117830,8 +117830,8 @@ function executeProfileResolveCommand(args) {
117830
117830
  ` };
117831
117831
  }
117832
117832
  const name2 = nameRaw.endsWith(".json") ? nameRaw.slice(0, -5) : nameRaw;
117833
- const profilesDir = join74(REPO_ROOT2, PROFILES_RELATIVE2);
117834
- if (!existsSync70(profilesDir)) {
117833
+ const profilesDir = join76(REPO_ROOT2, PROFILES_RELATIVE2);
117834
+ if (!existsSync71(profilesDir)) {
117835
117835
  return { exitCode: 1, stdout: `error: profiles directory not found at ${profilesDir}
117836
117836
  ` };
117837
117837
  }
@@ -117850,8 +117850,8 @@ function executeProfileResolveCommand(args) {
117850
117850
  const registry2 = {};
117851
117851
  for (const file3 of profileFiles) {
117852
117852
  try {
117853
- const filePath = join74(profilesDir, file3);
117854
- const raw = JSON.parse(readFileSync54(filePath, "utf-8"));
117853
+ const filePath = join76(profilesDir, file3);
117854
+ const raw = JSON.parse(readFileSync55(filePath, "utf-8"));
117855
117855
  const profile2 = ProfileSchema.parse(raw);
117856
117856
  registry2[profile2.name] = profile2;
117857
117857
  } catch {}
@@ -117913,8 +117913,8 @@ __export(exports_export, {
117913
117913
  getShell: () => getShell,
117914
117914
  executeExportCommand: () => executeExportCommand
117915
117915
  });
117916
- import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync23, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync24 } from "fs";
117917
- import { isAbsolute as isAbsolute7, join as join75, resolve as resolve18, dirname as dirname30 } from "path";
117916
+ import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync24, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync25 } from "fs";
117917
+ import { isAbsolute as isAbsolute7, join as join77, resolve as resolve18, dirname as dirname30 } from "path";
117918
117918
  import { spawnSync as spawnSync3 } from "child_process";
117919
117919
  function setShell(shell) {
117920
117920
  activeShell = shell;
@@ -117955,7 +117955,7 @@ function executeExportCommand(args) {
117955
117955
  return { exitCode: 1, stdout: `error: generate failed: ${message}
117956
117956
  ` };
117957
117957
  }
117958
- const pkgPath = join75(absoluteTargetDir, "package.json");
117958
+ const pkgPath = join77(absoluteTargetDir, "package.json");
117959
117959
  let pkg;
117960
117960
  try {
117961
117961
  pkg = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
@@ -117995,7 +117995,7 @@ ${packResult.stdout}
117995
117995
  return { exitCode: 1, stdout: `error: npm pack produced no tarball name in output
117996
117996
  ` };
117997
117997
  }
117998
- let tgzPath = join75(absoluteTargetDir, tgzName);
117998
+ let tgzPath = join77(absoluteTargetDir, tgzName);
117999
117999
  if (args.options.output) {
118000
118000
  const outputPath = args.options.output;
118001
118001
  const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
@@ -118036,12 +118036,12 @@ var init_export = __esm(() => {
118036
118036
  };
118037
118037
  activeShell = defaultShell;
118038
118038
  defaultExportFS = {
118039
- existsSync: existsSync71,
118040
- readFileSync: readFileSync55,
118041
- writeFileSync: writeFileSync23,
118039
+ existsSync: existsSync72,
118040
+ readFileSync: readFileSync56,
118041
+ writeFileSync: writeFileSync24,
118042
118042
  copyFileSync: copyFileSync7,
118043
118043
  realpathSync: realpathSync11,
118044
- mkdirSync: mkdirSync24
118044
+ mkdirSync: mkdirSync25
118045
118045
  };
118046
118046
  });
118047
118047
 
@@ -122361,6 +122361,7 @@ init_zod();
122361
122361
  var WatchdogConfigSchema = object({
122362
122362
  enabled: boolean2().default(true),
122363
122363
  doomLoopThreshold: number2().int().positive().max(20).default(3),
122364
+ softDoomLoopThreshold: number2().int().positive().max(20).default(5),
122364
122365
  stuckTimeoutSec: number2().int().positive().max(600).default(90),
122365
122366
  auditLogPath: string2().optional(),
122366
122367
  recoveryStrategy: _enum2(["nudge", "fallback", "restart", "notify", "safe"]).default("nudge"),
@@ -135288,6 +135289,63 @@ function formatSearchResults(result) {
135288
135289
  `);
135289
135290
  }
135290
135291
 
135292
+ // packages/learning-loop/src/improvement.ts
135293
+ import { existsSync as existsSync57, mkdirSync as mkdirSync16, readFileSync as readFileSync45, writeFileSync as writeFileSync14 } from "fs";
135294
+ import { join as join52, basename as basename10 } from "path";
135295
+ function createImprovementStore(improvementsDir) {
135296
+ if (!existsSync57(improvementsDir)) {
135297
+ mkdirSync16(improvementsDir, { recursive: true });
135298
+ }
135299
+ function save(improvement) {
135300
+ const filePath = join52(improvementsDir, `${improvement.id}.json`);
135301
+ writeFileSync14(filePath, JSON.stringify(improvement, null, 2), "utf-8");
135302
+ }
135303
+ function list() {
135304
+ const files = [];
135305
+ try {
135306
+ const entries = readdirSyncSafe(improvementsDir) ?? [];
135307
+ for (const entry of entries) {
135308
+ if (entry.endsWith(".json"))
135309
+ files.push(entry);
135310
+ }
135311
+ } catch {
135312
+ return [];
135313
+ }
135314
+ files.sort().reverse();
135315
+ return files.map((f2) => get(basename10(f2, ".json"))).filter((i3) => i3 !== null);
135316
+ }
135317
+ function get(id) {
135318
+ const filePath = join52(improvementsDir, `${id}.json`);
135319
+ try {
135320
+ const raw = readFileSync45(filePath, "utf-8");
135321
+ return JSON.parse(raw);
135322
+ } catch {
135323
+ return null;
135324
+ }
135325
+ }
135326
+ function updateStatus(id, status2, metadata) {
135327
+ const existing = get(id);
135328
+ if (!existing)
135329
+ return null;
135330
+ const updated = {
135331
+ ...existing,
135332
+ ...metadata,
135333
+ status: status2
135334
+ };
135335
+ save(updated);
135336
+ return updated;
135337
+ }
135338
+ return { save, list, get, updateStatus };
135339
+ }
135340
+ function readdirSyncSafe(dir) {
135341
+ try {
135342
+ const { readdirSync: readdirSync10 } = __require("fs");
135343
+ return readdirSync10(dir);
135344
+ } catch {
135345
+ return;
135346
+ }
135347
+ }
135348
+
135291
135349
  // packages/omo-opencode/src/cli/apply-learnings.ts
135292
135350
  import * as nodeFs2 from "fs";
135293
135351
  import * as nodePath from "path";
@@ -135330,7 +135388,7 @@ async function applyLearningsCli(options = {}) {
135330
135388
  }
135331
135389
 
135332
135390
  // packages/omo-opencode/src/cli/boulder/boulder.ts
135333
- import { existsSync as existsSync58 } from "fs";
135391
+ import { existsSync as existsSync59 } from "fs";
135334
135392
 
135335
135393
  // packages/omo-opencode/src/cli/boulder/formatter.ts
135336
135394
  var import_picocolors22 = __toESM(require_picocolors(), 1);
@@ -135467,10 +135525,10 @@ async function boulder(options) {
135467
135525
  const boulderFilePath = getBoulderFilePath(directory);
135468
135526
  const state2 = readBoulderState(directory);
135469
135527
  if (!state2) {
135470
- const message = existsSync58(boulderFilePath) ? formatReadErrorMessage(options.json) : formatNoBoulderMessage(options.json);
135528
+ const message = existsSync59(boulderFilePath) ? formatReadErrorMessage(options.json) : formatNoBoulderMessage(options.json);
135471
135529
  process.stderr.write(`${message}
135472
135530
  `);
135473
- return existsSync58(boulderFilePath) ? 2 : 1;
135531
+ return existsSync59(boulderFilePath) ? 2 : 1;
135474
135532
  }
135475
135533
  const works = getBoulderWorks(state2);
135476
135534
  const filteredWorks = options.workId ? works.filter((work) => work.work_id === options.workId) : works;
@@ -136397,25 +136455,25 @@ async function refreshModelCapabilities(options, deps = {}) {
136397
136455
  }
136398
136456
  // packages/skills-loader-core/src/features/opencode-skill-loader/loader.ts
136399
136457
  init_src();
136400
- import { join as join60 } from "path";
136458
+ import { join as join61 } from "path";
136401
136459
 
136402
136460
  // packages/skills-loader-core/src/shared/claude-config-dir.ts
136403
136461
  init_src();
136404
- import { join as join54 } from "path";
136462
+ import { join as join55 } from "path";
136405
136463
  function getClaudeConfigDir() {
136406
136464
  const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
136407
136465
  if (envConfigDir) {
136408
136466
  return envConfigDir;
136409
136467
  }
136410
- return join54(getHomeDirectory(), ".claude");
136468
+ return join55(getHomeDirectory(), ".claude");
136411
136469
  }
136412
136470
  // packages/skills-loader-core/src/shared/opencode-command-dirs.ts
136413
- import { basename as basename10, dirname as dirname22, join as join56 } from "path";
136471
+ import { basename as basename11, dirname as dirname22, join as join57 } from "path";
136414
136472
 
136415
136473
  // packages/skills-loader-core/src/shared/opencode-config-dir.ts
136416
- import { existsSync as existsSync60, realpathSync as realpathSync8 } from "fs";
136474
+ import { existsSync as existsSync61, realpathSync as realpathSync8 } from "fs";
136417
136475
  import { homedir as homedir20 } from "os";
136418
- import { join as join55, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
136476
+ import { join as join56, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
136419
136477
 
136420
136478
  // packages/skills-loader-core/src/shared/plugin-identity.ts
136421
136479
  init_src();
@@ -136448,15 +136506,15 @@ function getTauriConfigDir2(identifier) {
136448
136506
  const platform2 = process.platform;
136449
136507
  switch (platform2) {
136450
136508
  case "darwin":
136451
- return join55(homedir20(), "Library", "Application Support", identifier);
136509
+ return join56(homedir20(), "Library", "Application Support", identifier);
136452
136510
  case "win32": {
136453
- const appData = process.env.APPDATA || join55(homedir20(), "AppData", "Roaming");
136511
+ const appData = process.env.APPDATA || join56(homedir20(), "AppData", "Roaming");
136454
136512
  return win325.join(appData, identifier);
136455
136513
  }
136456
136514
  case "linux":
136457
136515
  default: {
136458
- const xdgConfig = process.env.XDG_CONFIG_HOME || join55(homedir20(), ".config");
136459
- return join55(xdgConfig, identifier);
136516
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join56(homedir20(), ".config");
136517
+ return join56(xdgConfig, identifier);
136460
136518
  }
136461
136519
  }
136462
136520
  }
@@ -136465,7 +136523,7 @@ function resolveConfigPath3(pathValue) {
136465
136523
  return posix5.normalize(pathValue);
136466
136524
  }
136467
136525
  const resolvedPath = resolve12(pathValue);
136468
- if (!existsSync60(resolvedPath))
136526
+ if (!existsSync61(resolvedPath))
136469
136527
  return resolvedPath;
136470
136528
  try {
136471
136529
  return realpathSync8(resolvedPath);
@@ -136499,8 +136557,8 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
136499
136557
  function getCliDefaultConfigDir2() {
136500
136558
  const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
136501
136559
  const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
136502
- const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join55(homedir20(), ".config");
136503
- const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join55(xdgConfig, "opencode");
136560
+ const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join56(homedir20(), ".config");
136561
+ const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join56(xdgConfig, "opencode");
136504
136562
  return resolveConfigPath3(configDir);
136505
136563
  }
136506
136564
  function getCliCustomConfigDir2() {
@@ -136533,9 +136591,9 @@ function getOpenCodeConfigDir2(options) {
136533
136591
  const tauriDir = process.platform === "win32" ? win325.isAbsolute(tauriDirBase) ? win325.normalize(tauriDirBase) : win325.resolve(tauriDirBase) : resolveConfigPath3(tauriDirBase);
136534
136592
  if (checkExisting) {
136535
136593
  const legacyDir = getCliConfigDir2();
136536
- const legacyConfig = join55(legacyDir, "opencode.json");
136537
- const legacyConfigC = join55(legacyDir, "opencode.jsonc");
136538
- if (existsSync60(legacyConfig) || existsSync60(legacyConfigC)) {
136594
+ const legacyConfig = join56(legacyDir, "opencode.json");
136595
+ const legacyConfigC = join56(legacyDir, "opencode.jsonc");
136596
+ if (existsSync61(legacyConfig) || existsSync61(legacyConfigC)) {
136539
136597
  return legacyDir;
136540
136598
  }
136541
136599
  }
@@ -136545,7 +136603,7 @@ function getOpenCodeConfigDir2(options) {
136545
136603
  // packages/skills-loader-core/src/shared/opencode-command-dirs.ts
136546
136604
  function getParentOpencodeConfigDir(configDir) {
136547
136605
  const parentDir = dirname22(configDir);
136548
- if (basename10(parentDir) !== "profiles") {
136606
+ if (basename11(parentDir) !== "profiles") {
136549
136607
  return null;
136550
136608
  }
136551
136609
  return dirname22(parentDir);
@@ -136556,21 +136614,21 @@ function getOpenCodeSkillDirs(options) {
136556
136614
  ...configDirs.flatMap((configDir) => {
136557
136615
  const parentConfigDir = getParentOpencodeConfigDir(configDir);
136558
136616
  return [
136559
- join56(configDir, "skills"),
136560
- join56(configDir, "skill"),
136561
- ...parentConfigDir ? [join56(parentConfigDir, "skills"), join56(parentConfigDir, "skill")] : []
136617
+ join57(configDir, "skills"),
136618
+ join57(configDir, "skill"),
136619
+ ...parentConfigDir ? [join57(parentConfigDir, "skills"), join57(parentConfigDir, "skill")] : []
136562
136620
  ];
136563
136621
  })
136564
136622
  ]));
136565
136623
  }
136566
136624
  // packages/skills-loader-core/src/shared/project-discovery-dirs.ts
136567
136625
  import { execFileSync as execFileSync2 } from "child_process";
136568
- import { existsSync as existsSync61, realpathSync as realpathSync9 } from "fs";
136569
- import { dirname as dirname23, join as join57, resolve as resolve13, win32 as win326 } from "path";
136626
+ import { existsSync as existsSync62, realpathSync as realpathSync9 } from "fs";
136627
+ import { dirname as dirname23, join as join58, resolve as resolve13, win32 as win326 } from "path";
136570
136628
  var worktreePathCache2 = new Map;
136571
136629
  function normalizePath2(path18) {
136572
136630
  const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve13(path18);
136573
- if (!existsSync61(resolvedPath)) {
136631
+ if (!existsSync62(resolvedPath)) {
136574
136632
  return resolvedPath;
136575
136633
  }
136576
136634
  try {
@@ -136601,8 +136659,8 @@ function findAncestorDirectories(startDirectory, targetPaths, stopDirectory) {
136601
136659
  const stopDirectoryKey = resolvedStopDirectory ? pathKey2(resolvedStopDirectory) : undefined;
136602
136660
  while (true) {
136603
136661
  for (const targetPath of targetPaths) {
136604
- const candidateDirectory = join57(currentDirectory, ...targetPath);
136605
- if (!existsSync61(candidateDirectory)) {
136662
+ const candidateDirectory = join58(currentDirectory, ...targetPath);
136663
+ if (!existsSync62(candidateDirectory)) {
136606
136664
  continue;
136607
136665
  }
136608
136666
  const normalizedCandidateDirectory = normalizePath2(candidateDirectory);
@@ -136684,13 +136742,13 @@ function deduplicateSkillsByName(skills2) {
136684
136742
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-directory-loader.ts
136685
136743
  init_src();
136686
136744
  import * as fs19 from "fs/promises";
136687
- import { join as join59 } from "path";
136745
+ import { join as join60 } from "path";
136688
136746
 
136689
136747
  // packages/skills-loader-core/src/features/opencode-skill-loader/loaded-skill-from-path.ts
136690
136748
  init_src();
136691
136749
  init_src2();
136692
136750
  import * as fs18 from "fs/promises";
136693
- import { basename as basename11 } from "path";
136751
+ import { basename as basename12 } from "path";
136694
136752
 
136695
136753
  // packages/skills-loader-core/src/features/opencode-skill-loader/allowed-tools-parser.ts
136696
136754
  function parseAllowedTools(allowedTools) {
@@ -136705,7 +136763,7 @@ function parseAllowedTools(allowedTools) {
136705
136763
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-mcp-config.ts
136706
136764
  init_js_yaml();
136707
136765
  import * as fs17 from "fs/promises";
136708
- import { join as join58 } from "path";
136766
+ import { join as join59 } from "path";
136709
136767
  function parseSkillMcpConfigFromFrontmatter(content) {
136710
136768
  const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
136711
136769
  if (!frontmatterMatch)
@@ -136724,7 +136782,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
136724
136782
  return;
136725
136783
  }
136726
136784
  async function loadMcpJsonFromDir(skillDir) {
136727
- const mcpJsonPath = join58(skillDir, "mcp.json");
136785
+ const mcpJsonPath = join59(skillDir, "mcp.json");
136728
136786
  try {
136729
136787
  const content = await fs17.readFile(mcpJsonPath, "utf-8");
136730
136788
  const parsed = JSON.parse(content);
@@ -136806,7 +136864,7 @@ $ARGUMENTS
136806
136864
  }
136807
136865
  }
136808
136866
  function inferSkillNameFromFileName(filePath) {
136809
- return basename11(filePath, ".md");
136867
+ return basename12(filePath, ".md");
136810
136868
  }
136811
136869
 
136812
136870
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-directory-loader.ts
@@ -136840,10 +136898,10 @@ async function loadSkillsFromDir(options) {
136840
136898
  const directories = entries.filter((entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink()));
136841
136899
  const files = entries.filter((entry) => !entry.name.startsWith(".") && !entry.isDirectory() && !entry.isSymbolicLink() && isMarkdownFile(entry));
136842
136900
  for (const entry of directories) {
136843
- const entryPath = join59(options.skillsDir, entry.name);
136901
+ const entryPath = join60(options.skillsDir, entry.name);
136844
136902
  const resolvedPath = await resolveSymlinkAsync(entryPath);
136845
136903
  const dirName = entry.name;
136846
- const skillMdPath = join59(resolvedPath, "SKILL.md");
136904
+ const skillMdPath = join60(resolvedPath, "SKILL.md");
136847
136905
  if (await canAccessFile(skillMdPath)) {
136848
136906
  const skill = await loadSkillFromPath({
136849
136907
  skillPath: skillMdPath,
@@ -136857,7 +136915,7 @@ async function loadSkillsFromDir(options) {
136857
136915
  }
136858
136916
  continue;
136859
136917
  }
136860
- const namedSkillMdPath = join59(resolvedPath, `${dirName}.md`);
136918
+ const namedSkillMdPath = join60(resolvedPath, `${dirName}.md`);
136861
136919
  if (await canAccessFile(namedSkillMdPath)) {
136862
136920
  const skill = await loadSkillFromPath({
136863
136921
  skillPath: namedSkillMdPath,
@@ -136888,7 +136946,7 @@ async function loadSkillsFromDir(options) {
136888
136946
  }
136889
136947
  }
136890
136948
  for (const entry of files) {
136891
- const entryPath = join59(options.skillsDir, entry.name);
136949
+ const entryPath = join60(options.skillsDir, entry.name);
136892
136950
  const baseName = inferSkillNameFromFileName(entryPath);
136893
136951
  const skill = await loadSkillFromPath({
136894
136952
  skillPath: entryPath,
@@ -136940,7 +136998,7 @@ async function discoverAllSkills(directory) {
136940
136998
  ]);
136941
136999
  }
136942
137000
  async function discoverUserClaudeSkills() {
136943
- const userSkillsDir = join60(getClaudeConfigDir(), "skills");
137001
+ const userSkillsDir = join61(getClaudeConfigDir(), "skills");
136944
137002
  return loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
136945
137003
  }
136946
137004
  async function discoverProjectClaudeSkills(directory) {
@@ -136967,7 +137025,7 @@ async function discoverProjectAgentsSkills(directory) {
136967
137025
  return deduplicateSkillsByName(allSkills.flat());
136968
137026
  }
136969
137027
  async function discoverGlobalAgentsSkills(homeDirectory = getHomeDirectory()) {
136970
- const agentsGlobalDir = join60(homeDirectory, ".agents", "skills");
137028
+ const agentsGlobalDir = join61(homeDirectory, ".agents", "skills");
136971
137029
  return loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
136972
137030
  }
136973
137031
  // packages/skills-loader-core/src/features/builtin-skills/agent-browser/SKILL.md
@@ -137713,17 +137771,17 @@ playwright-cli close
137713
137771
  allowedTools: ["Bash(playwright-cli:*)"]
137714
137772
  };
137715
137773
  // packages/skills-loader-core/src/features/builtin-skills/skill-file-loader.ts
137716
- import { readFileSync as readFileSync47 } from "fs";
137717
- import { join as join61 } from "path";
137774
+ import { readFileSync as readFileSync48 } from "fs";
137775
+ import { join as join62 } from "path";
137718
137776
  init_src();
137719
- function createSharedSkillTemplateLoader(readFile3 = readFileSync47, skillsRootPath = sharedSkillsRootPath()) {
137777
+ function createSharedSkillTemplateLoader(readFile3 = readFileSync48, skillsRootPath = sharedSkillsRootPath()) {
137720
137778
  const cache = new Map;
137721
137779
  return (skillName) => {
137722
137780
  const cached2 = cache.get(skillName);
137723
137781
  if (cached2 !== undefined)
137724
137782
  return cached2;
137725
137783
  try {
137726
- const { body } = parseFrontmatter(readFile3(join61(skillsRootPath, skillName, "SKILL.md"), "utf8"));
137784
+ const { body } = parseFrontmatter(readFile3(join62(skillsRootPath, skillName, "SKILL.md"), "utf8"));
137727
137785
  cache.set(skillName, body);
137728
137786
  return body;
137729
137787
  } catch (error51) {
@@ -138860,7 +138918,7 @@ var gitMasterSkill = {
138860
138918
  template: GIT_MASTER_TEMPLATE
138861
138919
  };
138862
138920
  // packages/skills-loader-core/src/features/builtin-skills/skills/dev-browser.ts
138863
- import { dirname as dirname24, join as join62 } from "path";
138921
+ import { dirname as dirname24, join as join63 } from "path";
138864
138922
  import { fileURLToPath as fileURLToPath8 } from "url";
138865
138923
  var CURRENT_DIR = dirname24(fileURLToPath8(import.meta.url));
138866
138924
  var devBrowserSkill = {
@@ -139080,7 +139138,7 @@ console.log({
139080
139138
  await client.disconnect();
139081
139139
  EOF
139082
139140
  \`\`\``,
139083
- resolvedPath: join62(CURRENT_DIR, "..", "dev-browser")
139141
+ resolvedPath: join63(CURRENT_DIR, "..", "dev-browser")
139084
139142
  };
139085
139143
  // packages/skills-loader-core/src/features/builtin-skills/skills/review-work.ts
139086
139144
  var reviewWorkSkill = {
@@ -140073,11 +140131,11 @@ function applySnapshotRetention(options) {
140073
140131
  // packages/omo-opencode/src/cli/snapshot/snapshot.ts
140074
140132
  import { Database as Database3 } from "bun:sqlite";
140075
140133
  import {
140076
- existsSync as existsSync63,
140077
- mkdirSync as mkdirSync18,
140134
+ existsSync as existsSync64,
140135
+ mkdirSync as mkdirSync19,
140078
140136
  copyFileSync as copyFileSync3,
140079
- readFileSync as readFileSync48,
140080
- writeFileSync as writeFileSync16,
140137
+ readFileSync as readFileSync49,
140138
+ writeFileSync as writeFileSync17,
140081
140139
  readdirSync as readdirSync10,
140082
140140
  statSync as statSync8,
140083
140141
  rmSync as rmSync4
@@ -140089,12 +140147,12 @@ async function snapshotCli(options = {}) {
140089
140147
  const homeDir = os7.homedir();
140090
140148
  const snapshotDir = options.snapshotDir ?? path18.join(homeDir, ".matrixos", "snapshots");
140091
140149
  const allPaths = getAllSnapshotPaths(homeDir);
140092
- const files = allPaths.files.filter((f2) => existsSync63(f2.sourcePath));
140150
+ const files = allPaths.files.filter((f2) => existsSync64(f2.sourcePath));
140093
140151
  const realFs = {
140094
- existsSync: existsSync63,
140095
- mkdirSync: mkdirSync18,
140096
- readFileSync: readFileSync48,
140097
- writeFileSync: writeFileSync16,
140152
+ existsSync: existsSync64,
140153
+ mkdirSync: mkdirSync19,
140154
+ readFileSync: readFileSync49,
140155
+ writeFileSync: writeFileSync17,
140098
140156
  copyFileSync: copyFileSync3,
140099
140157
  readdirSync: readdirSync10,
140100
140158
  statSync: statSync8,
@@ -140156,11 +140214,11 @@ async function snapshotCli(options = {}) {
140156
140214
 
140157
140215
  // packages/omo-opencode/src/cli/snapshot/restore.ts
140158
140216
  import {
140159
- existsSync as existsSync64,
140160
- mkdirSync as mkdirSync19,
140217
+ existsSync as existsSync65,
140218
+ mkdirSync as mkdirSync20,
140161
140219
  copyFileSync as copyFileSync4,
140162
- readFileSync as readFileSync49,
140163
- writeFileSync as writeFileSync17,
140220
+ readFileSync as readFileSync50,
140221
+ writeFileSync as writeFileSync18,
140164
140222
  readdirSync as readdirSync11,
140165
140223
  statSync as statSync9,
140166
140224
  rmSync as rmSync5
@@ -140170,10 +140228,10 @@ import * as os8 from "os";
140170
140228
  async function restoreCli(options) {
140171
140229
  const snapshotDir = options.snapshotDir ?? path19.join(os8.homedir(), ".matrixos", "snapshots");
140172
140230
  const realFs = {
140173
- existsSync: existsSync64,
140174
- mkdirSync: mkdirSync19,
140175
- readFileSync: readFileSync49,
140176
- writeFileSync: writeFileSync17,
140231
+ existsSync: existsSync65,
140232
+ mkdirSync: mkdirSync20,
140233
+ readFileSync: readFileSync50,
140234
+ writeFileSync: writeFileSync18,
140177
140235
  copyFileSync: copyFileSync4,
140178
140236
  readdirSync: readdirSync11,
140179
140237
  statSync: statSync9,
@@ -140187,7 +140245,7 @@ async function restoreCli(options) {
140187
140245
  try {
140188
140246
  restoreSnapshot(options.state, { snapshotDir, fs: realFs });
140189
140247
  const manifestPath = path19.join(snapshotDir, options.state, "manifest.json");
140190
- const raw = readFileSync49(manifestPath).toString("utf-8");
140248
+ const raw = readFileSync50(manifestPath).toString("utf-8");
140191
140249
  const parsed = JSON.parse(raw);
140192
140250
  const fileCount = typeof parsed === "object" && parsed !== null && "files" in parsed && Array.isArray(parsed.files) ? parsed.files.length : 0;
140193
140251
  if (options.json) {
@@ -140208,11 +140266,11 @@ async function restoreCli(options) {
140208
140266
 
140209
140267
  // packages/omo-opencode/src/cli/snapshot/list.ts
140210
140268
  import {
140211
- existsSync as existsSync65,
140212
- mkdirSync as mkdirSync20,
140269
+ existsSync as existsSync66,
140270
+ mkdirSync as mkdirSync21,
140213
140271
  copyFileSync as copyFileSync5,
140214
- readFileSync as readFileSync50,
140215
- writeFileSync as writeFileSync18,
140272
+ readFileSync as readFileSync51,
140273
+ writeFileSync as writeFileSync19,
140216
140274
  readdirSync as readdirSync12,
140217
140275
  statSync as statSync10,
140218
140276
  rmSync as rmSync6
@@ -140232,10 +140290,10 @@ function formatBytes(bytes) {
140232
140290
  async function snapshotListCli(options) {
140233
140291
  const snapshotDir = options.snapshotDir ?? path20.join(os9.homedir(), ".matrixos", "snapshots");
140234
140292
  const realFs = {
140235
- existsSync: existsSync65,
140236
- mkdirSync: mkdirSync20,
140237
- readFileSync: readFileSync50,
140238
- writeFileSync: writeFileSync18,
140293
+ existsSync: existsSync66,
140294
+ mkdirSync: mkdirSync21,
140295
+ readFileSync: readFileSync51,
140296
+ writeFileSync: writeFileSync19,
140239
140297
  copyFileSync: copyFileSync5,
140240
140298
  readdirSync: readdirSync12,
140241
140299
  statSync: statSync10,
@@ -140262,11 +140320,11 @@ async function snapshotListCli(options) {
140262
140320
 
140263
140321
  // packages/omo-opencode/src/cli/snapshot/prune.ts
140264
140322
  import {
140265
- existsSync as existsSync66,
140266
- mkdirSync as mkdirSync21,
140323
+ existsSync as existsSync67,
140324
+ mkdirSync as mkdirSync22,
140267
140325
  copyFileSync as copyFileSync6,
140268
- readFileSync as readFileSync51,
140269
- writeFileSync as writeFileSync19,
140326
+ readFileSync as readFileSync52,
140327
+ writeFileSync as writeFileSync20,
140270
140328
  readdirSync as readdirSync13,
140271
140329
  statSync as statSync11,
140272
140330
  rmSync as rmSync7
@@ -140276,10 +140334,10 @@ import * as os10 from "os";
140276
140334
  async function snapshotPruneCli(options = {}) {
140277
140335
  const snapshotDir = options.snapshotDir ?? path21.join(os10.homedir(), ".matrixos", "snapshots");
140278
140336
  const realFs = {
140279
- existsSync: existsSync66,
140280
- mkdirSync: mkdirSync21,
140281
- readFileSync: readFileSync51,
140282
- writeFileSync: writeFileSync19,
140337
+ existsSync: existsSync67,
140338
+ mkdirSync: mkdirSync22,
140339
+ readFileSync: readFileSync52,
140340
+ writeFileSync: writeFileSync20,
140283
140341
  copyFileSync: copyFileSync6,
140284
140342
  readdirSync: readdirSync13,
140285
140343
  statSync: statSync11,
@@ -140326,8 +140384,8 @@ function codebaseCli(rootProgram) {
140326
140384
  try {
140327
140385
  const dimension = Number.parseInt(options.dimension, 10) || 384;
140328
140386
  const dbDir = path22.dirname(options.db);
140329
- const { mkdirSync: mkdirSync22 } = await import("fs");
140330
- mkdirSync22(dbDir, { recursive: true });
140387
+ const { mkdirSync: mkdirSync23 } = await import("fs");
140388
+ mkdirSync23(dbDir, { recursive: true });
140331
140389
  const store4 = createSqliteVectorStore({ path: options.db, dimension });
140332
140390
  if (options.reset) {
140333
140391
  store4.clear();
@@ -140564,7 +140622,7 @@ function printHumanReadable2(r2) {
140564
140622
  // packages/omo-opencode/src/cli/trace.ts
140565
140623
  init_data_path();
140566
140624
  import * as path23 from "path";
140567
- import { writeFileSync as writeFileSync20 } from "fs";
140625
+ import { writeFileSync as writeFileSync21 } from "fs";
140568
140626
  import { Database as Database4 } from "bun:sqlite";
140569
140627
  function defaultDbPath() {
140570
140628
  return path23.join(getDataDir(), "opencode", "opencode.db");
@@ -140768,7 +140826,7 @@ function renderMermaid(result, outPath) {
140768
140826
  const content = lines.join(`
140769
140827
  `);
140770
140828
  if (outPath && outPath !== "-") {
140771
- writeFileSync20(outPath, content + `
140829
+ writeFileSync21(outPath, content + `
140772
140830
  `);
140773
140831
  }
140774
140832
  return content;
@@ -141356,6 +141414,117 @@ async function dashboardCli(options) {
141356
141414
  }
141357
141415
  }
141358
141416
 
141417
+ // packages/omo-opencode/src/cli/architect.ts
141418
+ import { join as join72 } from "path";
141419
+ var IMPROVEMENTS_DIR = ".matrixos/improvements";
141420
+ function getStore(directory) {
141421
+ const baseDir = directory ?? process.cwd();
141422
+ return createImprovementStore(join72(baseDir, IMPROVEMENTS_DIR));
141423
+ }
141424
+ async function architectReview(options) {
141425
+ const store4 = getStore(options.directory);
141426
+ if (options.id) {
141427
+ const improvement = store4.get(options.id);
141428
+ if (!improvement) {
141429
+ console.error(`Improvement not found: ${options.id}`);
141430
+ return 1;
141431
+ }
141432
+ if (options.approve) {
141433
+ store4.updateStatus(improvement.id, "approved", {
141434
+ approvedAt: new Date().toISOString(),
141435
+ reviewedBy: "cli"
141436
+ });
141437
+ console.log(`\u2705 Approved: ${improvement.title} (${improvement.id})`);
141438
+ return 0;
141439
+ }
141440
+ if (options.reject) {
141441
+ store4.updateStatus(improvement.id, "rejected", {
141442
+ rejectedAt: new Date().toISOString(),
141443
+ reviewedBy: "cli"
141444
+ });
141445
+ console.log(`\u274C Rejected: ${improvement.title} (${improvement.id})`);
141446
+ return 0;
141447
+ }
141448
+ if (options.json) {
141449
+ console.log(JSON.stringify(improvement, null, 2));
141450
+ return 0;
141451
+ }
141452
+ console.log(`
141453
+ === ${improvement.title} ===`);
141454
+ console.log(`ID: ${improvement.id}`);
141455
+ console.log(`Status: ${improvement.status}`);
141456
+ console.log(`Risk: ${improvement.risk}`);
141457
+ console.log(`
141458
+ ${improvement.description}`);
141459
+ console.log(`
141460
+ Rationale: ${improvement.rationale}`);
141461
+ console.log(`
141462
+ Changes:`);
141463
+ for (const change of improvement.changes) {
141464
+ console.log(` ${change.action} ${change.target}: ${change.path}`);
141465
+ }
141466
+ if (improvement.rollbackPlan)
141467
+ console.log(`
141468
+ Rollback: ${improvement.rollbackPlan}`);
141469
+ if (improvement.testPlan)
141470
+ console.log(`Test plan: ${improvement.testPlan}`);
141471
+ return 0;
141472
+ }
141473
+ const all = store4.list();
141474
+ const proposals = all.filter((i3) => i3.status === "proposed");
141475
+ const applied = all.filter((i3) => i3.status === "applied");
141476
+ if (options.json) {
141477
+ console.log(JSON.stringify({ proposals, applied, total: all.length }, null, 2));
141478
+ return 0;
141479
+ }
141480
+ console.log(`
141481
+ Architect \u2014 Improvement Proposals
141482
+ `);
141483
+ console.log(`Proposed: ${proposals.length} | Applied: ${applied.length} | Total: ${all.length}
141484
+ `);
141485
+ if (proposals.length > 0) {
141486
+ console.log("--- Pending Review ---");
141487
+ for (const p2 of proposals) {
141488
+ console.log(` [${p2.risk}] ${p2.title} (${p2.id})`);
141489
+ }
141490
+ console.log(`
141491
+ Review: bunx matrixos architect review --id <id>`);
141492
+ console.log(`Approve: bunx matrixos architect review --id <id> --approve`);
141493
+ console.log(`Reject: bunx matrixos architect review --id <id> --reject`);
141494
+ }
141495
+ if (applied.length > 0) {
141496
+ console.log(`
141497
+ --- Applied ---`);
141498
+ for (const a2 of applied) {
141499
+ console.log(` ${a2.title} (${a2.id}) \u2014 ${a2.appliedAt ?? "?"}`);
141500
+ }
141501
+ }
141502
+ return 0;
141503
+ }
141504
+ async function architectRollback(options) {
141505
+ const store4 = getStore(options.directory);
141506
+ const improvement = store4.get(options.id);
141507
+ if (!improvement) {
141508
+ console.error(`Improvement not found: ${options.id}`);
141509
+ return 1;
141510
+ }
141511
+ if (improvement.status !== "applied") {
141512
+ console.error(`Improvement is not applied (status: ${improvement.status}). Cannot rollback.`);
141513
+ return 1;
141514
+ }
141515
+ store4.updateStatus(improvement.id, "rolled_back", {
141516
+ rollbackPlan: `Rolled back via CLI at ${new Date().toISOString()}. See beforeSnapshot for original state.`
141517
+ });
141518
+ console.log(`\u21A9\uFE0F Rolled back: ${improvement.title} (${improvement.id})`);
141519
+ if (improvement.beforeSnapshot) {
141520
+ console.log(` Before-snapshot available for manual restore.`);
141521
+ }
141522
+ if (options.json) {
141523
+ console.log(JSON.stringify({ rolledBack: improvement.id, title: improvement.title }, null, 2));
141524
+ }
141525
+ return 0;
141526
+ }
141527
+
141359
141528
  // packages/omo-opencode/src/cli/runtime-commands.ts
141360
141529
  init_data_path();
141361
141530
  init_shared();
@@ -141526,6 +141695,15 @@ function configureRuntimeCommands(program2) {
141526
141695
  });
141527
141696
  process.exit(exitCode);
141528
141697
  });
141698
+ const architectCmd = program2.command("architect").description("Self-improvement workflow \u2014 review improvement proposals and roll back applied changes");
141699
+ architectCmd.command("review").description("List improvement proposals or approve/reject a specific one").option("-d, --directory <path>", "Project directory").option("--id <id>", "Improvement ID to review").option("--approve", "Approve the improvement").option("--reject", "Reject the improvement").option("--json", "JSON output").action(async (options) => {
141700
+ const exitCode = await architectReview(options);
141701
+ process.exit(exitCode);
141702
+ });
141703
+ architectCmd.command("rollback").description("Roll back an applied improvement").argument("<id>", "Improvement ID to roll back").option("-d, --directory <path>", "Project directory").option("--json", "JSON output").action(async (id, options) => {
141704
+ const exitCode = await architectRollback({ ...options, id });
141705
+ process.exit(exitCode);
141706
+ });
141529
141707
  program2.command("dashboard").description("Start the MaTrixOS web dashboard (port 9123)").option("-p, --port <number>", "HTTP port", "9123").option("--host <addr>", "Bind address", "127.0.0.1").option("--daemon", "Run in background (no Ctrl+C)").action(async (options) => {
141530
141708
  const exitCode = await dashboardCli({
141531
141709
  port: parseInt(options.port ?? "9123", 10),