@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.
@@ -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",
@@ -117609,19 +117609,19 @@ __export(exports_generate, {
117609
117609
  executeGenerateCommand: () => executeGenerateCommand,
117610
117610
  ProfileNotFoundError: () => ProfileNotFoundError
117611
117611
  });
117612
- import { existsSync as existsSync68, readFileSync as readFileSync53, realpathSync as realpathSync10 } from "fs";
117613
- import { dirname as dirname28, isAbsolute as isAbsolute6, join as join72, resolve as resolve16 } from "path";
117612
+ import { existsSync as existsSync69, readFileSync as readFileSync54, realpathSync as realpathSync10 } from "fs";
117613
+ import { dirname as dirname28, isAbsolute as isAbsolute6, join as join74, resolve as resolve16 } from "path";
117614
117614
  function profilesDirFor(opts) {
117615
117615
  if (opts.profilesDir)
117616
117616
  return opts.profilesDir;
117617
117617
  if (opts.cwd)
117618
- return join72(opts.cwd, PROFILES_RELATIVE);
117619
- return join72(REPO_ROOT, PROFILES_RELATIVE);
117618
+ return join74(opts.cwd, PROFILES_RELATIVE);
117619
+ return join74(REPO_ROOT, PROFILES_RELATIVE);
117620
117620
  }
117621
117621
  function loadProfile(name2, options = {}) {
117622
117622
  const fs21 = options.fs ?? defaultFS2;
117623
117623
  const dir = profilesDirFor(options);
117624
- const path27 = join72(dir, `${name2}.json`);
117624
+ const path27 = join74(dir, `${name2}.json`);
117625
117625
  if (!fs21.existsSync(path27)) {
117626
117626
  throw new ProfileNotFoundError(name2);
117627
117627
  }
@@ -117634,7 +117634,7 @@ function listProfiles(options = {}) {
117634
117634
  const known = options.knownNames ?? ["trader", "plumber"];
117635
117635
  const out = [];
117636
117636
  for (const name2 of known) {
117637
- const path27 = join72(dir, `${name2}.json`);
117637
+ const path27 = join74(dir, `${name2}.json`);
117638
117638
  if (fs21.existsSync(path27)) {
117639
117639
  try {
117640
117640
  const raw = JSON.parse(fs21.readFileSync(path27, "utf-8"));
@@ -117707,7 +117707,7 @@ var init_generate = __esm(() => {
117707
117707
  init_src4();
117708
117708
  init_src4();
117709
117709
  REPO_ROOT = resolve16(dirname28(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
117710
- defaultFS2 = { existsSync: existsSync68, readFileSync: readFileSync53, realpathSync: realpathSync10 };
117710
+ defaultFS2 = { existsSync: existsSync69, readFileSync: readFileSync54, realpathSync: realpathSync10 };
117711
117711
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
117712
117712
  profileName;
117713
117713
  constructor(profileName) {
@@ -117724,12 +117724,12 @@ __export(exports_cost_report, {
117724
117724
  executeCostReportCommand: () => executeCostReportCommand
117725
117725
  });
117726
117726
  import { Database as Database6 } from "bun:sqlite";
117727
- import { existsSync as existsSync69 } from "fs";
117727
+ import { existsSync as existsSync70 } from "fs";
117728
117728
  import * as path27 from "path";
117729
117729
  import * as os13 from "os";
117730
117730
  function executeCostReportCommand(args) {
117731
117731
  const dbPath = path27.join(os13.homedir(), ".matrixos", "cost.db");
117732
- if (!existsSync69(dbPath)) {
117732
+ if (!existsSync70(dbPath)) {
117733
117733
  return { exitCode: 1, stdout: `No cost data available
117734
117734
  ` };
117735
117735
  }
@@ -117859,8 +117859,8 @@ var exports_profile_resolve = {};
117859
117859
  __export(exports_profile_resolve, {
117860
117860
  executeProfileResolveCommand: () => executeProfileResolveCommand
117861
117861
  });
117862
- import { existsSync as existsSync70, readdirSync as readdirSync15, readFileSync as readFileSync54 } from "fs";
117863
- import { join as join74, resolve as resolve17, dirname as dirname29 } from "path";
117862
+ import { existsSync as existsSync71, readdirSync as readdirSync15, readFileSync as readFileSync55 } from "fs";
117863
+ import { join as join76, resolve as resolve17, dirname as dirname29 } from "path";
117864
117864
  function executeProfileResolveCommand(args) {
117865
117865
  if (args.options.help) {
117866
117866
  return {
@@ -117885,8 +117885,8 @@ function executeProfileResolveCommand(args) {
117885
117885
  ` };
117886
117886
  }
117887
117887
  const name2 = nameRaw.endsWith(".json") ? nameRaw.slice(0, -5) : nameRaw;
117888
- const profilesDir = join74(REPO_ROOT2, PROFILES_RELATIVE2);
117889
- if (!existsSync70(profilesDir)) {
117888
+ const profilesDir = join76(REPO_ROOT2, PROFILES_RELATIVE2);
117889
+ if (!existsSync71(profilesDir)) {
117890
117890
  return { exitCode: 1, stdout: `error: profiles directory not found at ${profilesDir}
117891
117891
  ` };
117892
117892
  }
@@ -117905,8 +117905,8 @@ function executeProfileResolveCommand(args) {
117905
117905
  const registry2 = {};
117906
117906
  for (const file3 of profileFiles) {
117907
117907
  try {
117908
- const filePath = join74(profilesDir, file3);
117909
- const raw = JSON.parse(readFileSync54(filePath, "utf-8"));
117908
+ const filePath = join76(profilesDir, file3);
117909
+ const raw = JSON.parse(readFileSync55(filePath, "utf-8"));
117910
117910
  const profile2 = ProfileSchema.parse(raw);
117911
117911
  registry2[profile2.name] = profile2;
117912
117912
  } catch {}
@@ -117968,8 +117968,8 @@ __export(exports_export, {
117968
117968
  getShell: () => getShell,
117969
117969
  executeExportCommand: () => executeExportCommand
117970
117970
  });
117971
- import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync23, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync24 } from "fs";
117972
- import { isAbsolute as isAbsolute7, join as join75, resolve as resolve18, dirname as dirname30 } from "path";
117971
+ import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync24, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync25 } from "fs";
117972
+ import { isAbsolute as isAbsolute7, join as join77, resolve as resolve18, dirname as dirname30 } from "path";
117973
117973
  import { spawnSync as spawnSync3 } from "child_process";
117974
117974
  function setShell(shell) {
117975
117975
  activeShell = shell;
@@ -118010,7 +118010,7 @@ function executeExportCommand(args) {
118010
118010
  return { exitCode: 1, stdout: `error: generate failed: ${message}
118011
118011
  ` };
118012
118012
  }
118013
- const pkgPath = join75(absoluteTargetDir, "package.json");
118013
+ const pkgPath = join77(absoluteTargetDir, "package.json");
118014
118014
  let pkg;
118015
118015
  try {
118016
118016
  pkg = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
@@ -118050,7 +118050,7 @@ ${packResult.stdout}
118050
118050
  return { exitCode: 1, stdout: `error: npm pack produced no tarball name in output
118051
118051
  ` };
118052
118052
  }
118053
- let tgzPath = join75(absoluteTargetDir, tgzName);
118053
+ let tgzPath = join77(absoluteTargetDir, tgzName);
118054
118054
  if (args.options.output) {
118055
118055
  const outputPath = args.options.output;
118056
118056
  const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
@@ -118091,12 +118091,12 @@ var init_export = __esm(() => {
118091
118091
  };
118092
118092
  activeShell = defaultShell;
118093
118093
  defaultExportFS = {
118094
- existsSync: existsSync71,
118095
- readFileSync: readFileSync55,
118096
- writeFileSync: writeFileSync23,
118094
+ existsSync: existsSync72,
118095
+ readFileSync: readFileSync56,
118096
+ writeFileSync: writeFileSync24,
118097
118097
  copyFileSync: copyFileSync7,
118098
118098
  realpathSync: realpathSync11,
118099
- mkdirSync: mkdirSync24
118099
+ mkdirSync: mkdirSync25
118100
118100
  };
118101
118101
  });
118102
118102
 
@@ -122416,6 +122416,7 @@ init_zod();
122416
122416
  var WatchdogConfigSchema = object({
122417
122417
  enabled: boolean2().default(true),
122418
122418
  doomLoopThreshold: number2().int().positive().max(20).default(3),
122419
+ softDoomLoopThreshold: number2().int().positive().max(20).default(5),
122419
122420
  stuckTimeoutSec: number2().int().positive().max(600).default(90),
122420
122421
  auditLogPath: string2().optional(),
122421
122422
  recoveryStrategy: _enum2(["nudge", "fallback", "restart", "notify", "safe"]).default("nudge"),
@@ -135343,6 +135344,63 @@ function formatSearchResults(result) {
135343
135344
  `);
135344
135345
  }
135345
135346
 
135347
+ // packages/learning-loop/src/improvement.ts
135348
+ import { existsSync as existsSync57, mkdirSync as mkdirSync16, readFileSync as readFileSync45, writeFileSync as writeFileSync14 } from "fs";
135349
+ import { join as join52, basename as basename10 } from "path";
135350
+ function createImprovementStore(improvementsDir) {
135351
+ if (!existsSync57(improvementsDir)) {
135352
+ mkdirSync16(improvementsDir, { recursive: true });
135353
+ }
135354
+ function save(improvement) {
135355
+ const filePath = join52(improvementsDir, `${improvement.id}.json`);
135356
+ writeFileSync14(filePath, JSON.stringify(improvement, null, 2), "utf-8");
135357
+ }
135358
+ function list() {
135359
+ const files = [];
135360
+ try {
135361
+ const entries = readdirSyncSafe(improvementsDir) ?? [];
135362
+ for (const entry of entries) {
135363
+ if (entry.endsWith(".json"))
135364
+ files.push(entry);
135365
+ }
135366
+ } catch {
135367
+ return [];
135368
+ }
135369
+ files.sort().reverse();
135370
+ return files.map((f2) => get(basename10(f2, ".json"))).filter((i3) => i3 !== null);
135371
+ }
135372
+ function get(id) {
135373
+ const filePath = join52(improvementsDir, `${id}.json`);
135374
+ try {
135375
+ const raw = readFileSync45(filePath, "utf-8");
135376
+ return JSON.parse(raw);
135377
+ } catch {
135378
+ return null;
135379
+ }
135380
+ }
135381
+ function updateStatus(id, status2, metadata) {
135382
+ const existing = get(id);
135383
+ if (!existing)
135384
+ return null;
135385
+ const updated = {
135386
+ ...existing,
135387
+ ...metadata,
135388
+ status: status2
135389
+ };
135390
+ save(updated);
135391
+ return updated;
135392
+ }
135393
+ return { save, list, get, updateStatus };
135394
+ }
135395
+ function readdirSyncSafe(dir) {
135396
+ try {
135397
+ const { readdirSync: readdirSync10 } = __require("fs");
135398
+ return readdirSync10(dir);
135399
+ } catch {
135400
+ return;
135401
+ }
135402
+ }
135403
+
135346
135404
  // packages/omo-opencode/src/cli/apply-learnings.ts
135347
135405
  import * as nodeFs2 from "fs";
135348
135406
  import * as nodePath from "path";
@@ -135385,7 +135443,7 @@ async function applyLearningsCli(options = {}) {
135385
135443
  }
135386
135444
 
135387
135445
  // packages/omo-opencode/src/cli/boulder/boulder.ts
135388
- import { existsSync as existsSync58 } from "fs";
135446
+ import { existsSync as existsSync59 } from "fs";
135389
135447
 
135390
135448
  // packages/omo-opencode/src/cli/boulder/formatter.ts
135391
135449
  var import_picocolors22 = __toESM(require_picocolors(), 1);
@@ -135522,10 +135580,10 @@ async function boulder(options) {
135522
135580
  const boulderFilePath = getBoulderFilePath(directory);
135523
135581
  const state2 = readBoulderState(directory);
135524
135582
  if (!state2) {
135525
- const message = existsSync58(boulderFilePath) ? formatReadErrorMessage(options.json) : formatNoBoulderMessage(options.json);
135583
+ const message = existsSync59(boulderFilePath) ? formatReadErrorMessage(options.json) : formatNoBoulderMessage(options.json);
135526
135584
  process.stderr.write(`${message}
135527
135585
  `);
135528
- return existsSync58(boulderFilePath) ? 2 : 1;
135586
+ return existsSync59(boulderFilePath) ? 2 : 1;
135529
135587
  }
135530
135588
  const works = getBoulderWorks(state2);
135531
135589
  const filteredWorks = options.workId ? works.filter((work) => work.work_id === options.workId) : works;
@@ -136452,25 +136510,25 @@ async function refreshModelCapabilities(options, deps = {}) {
136452
136510
  }
136453
136511
  // packages/skills-loader-core/src/features/opencode-skill-loader/loader.ts
136454
136512
  init_src();
136455
- import { join as join60 } from "path";
136513
+ import { join as join61 } from "path";
136456
136514
 
136457
136515
  // packages/skills-loader-core/src/shared/claude-config-dir.ts
136458
136516
  init_src();
136459
- import { join as join54 } from "path";
136517
+ import { join as join55 } from "path";
136460
136518
  function getClaudeConfigDir() {
136461
136519
  const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
136462
136520
  if (envConfigDir) {
136463
136521
  return envConfigDir;
136464
136522
  }
136465
- return join54(getHomeDirectory(), ".claude");
136523
+ return join55(getHomeDirectory(), ".claude");
136466
136524
  }
136467
136525
  // packages/skills-loader-core/src/shared/opencode-command-dirs.ts
136468
- import { basename as basename10, dirname as dirname22, join as join56 } from "path";
136526
+ import { basename as basename11, dirname as dirname22, join as join57 } from "path";
136469
136527
 
136470
136528
  // packages/skills-loader-core/src/shared/opencode-config-dir.ts
136471
- import { existsSync as existsSync60, realpathSync as realpathSync8 } from "fs";
136529
+ import { existsSync as existsSync61, realpathSync as realpathSync8 } from "fs";
136472
136530
  import { homedir as homedir20 } from "os";
136473
- import { join as join55, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
136531
+ import { join as join56, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
136474
136532
 
136475
136533
  // packages/skills-loader-core/src/shared/plugin-identity.ts
136476
136534
  init_src();
@@ -136503,15 +136561,15 @@ function getTauriConfigDir2(identifier) {
136503
136561
  const platform2 = process.platform;
136504
136562
  switch (platform2) {
136505
136563
  case "darwin":
136506
- return join55(homedir20(), "Library", "Application Support", identifier);
136564
+ return join56(homedir20(), "Library", "Application Support", identifier);
136507
136565
  case "win32": {
136508
- const appData = process.env.APPDATA || join55(homedir20(), "AppData", "Roaming");
136566
+ const appData = process.env.APPDATA || join56(homedir20(), "AppData", "Roaming");
136509
136567
  return win325.join(appData, identifier);
136510
136568
  }
136511
136569
  case "linux":
136512
136570
  default: {
136513
- const xdgConfig = process.env.XDG_CONFIG_HOME || join55(homedir20(), ".config");
136514
- return join55(xdgConfig, identifier);
136571
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join56(homedir20(), ".config");
136572
+ return join56(xdgConfig, identifier);
136515
136573
  }
136516
136574
  }
136517
136575
  }
@@ -136520,7 +136578,7 @@ function resolveConfigPath3(pathValue) {
136520
136578
  return posix5.normalize(pathValue);
136521
136579
  }
136522
136580
  const resolvedPath = resolve12(pathValue);
136523
- if (!existsSync60(resolvedPath))
136581
+ if (!existsSync61(resolvedPath))
136524
136582
  return resolvedPath;
136525
136583
  try {
136526
136584
  return realpathSync8(resolvedPath);
@@ -136554,8 +136612,8 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
136554
136612
  function getCliDefaultConfigDir2() {
136555
136613
  const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
136556
136614
  const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
136557
- const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join55(homedir20(), ".config");
136558
- const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join55(xdgConfig, "opencode");
136615
+ const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join56(homedir20(), ".config");
136616
+ const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join56(xdgConfig, "opencode");
136559
136617
  return resolveConfigPath3(configDir);
136560
136618
  }
136561
136619
  function getCliCustomConfigDir2() {
@@ -136588,9 +136646,9 @@ function getOpenCodeConfigDir2(options) {
136588
136646
  const tauriDir = process.platform === "win32" ? win325.isAbsolute(tauriDirBase) ? win325.normalize(tauriDirBase) : win325.resolve(tauriDirBase) : resolveConfigPath3(tauriDirBase);
136589
136647
  if (checkExisting) {
136590
136648
  const legacyDir = getCliConfigDir2();
136591
- const legacyConfig = join55(legacyDir, "opencode.json");
136592
- const legacyConfigC = join55(legacyDir, "opencode.jsonc");
136593
- if (existsSync60(legacyConfig) || existsSync60(legacyConfigC)) {
136649
+ const legacyConfig = join56(legacyDir, "opencode.json");
136650
+ const legacyConfigC = join56(legacyDir, "opencode.jsonc");
136651
+ if (existsSync61(legacyConfig) || existsSync61(legacyConfigC)) {
136594
136652
  return legacyDir;
136595
136653
  }
136596
136654
  }
@@ -136600,7 +136658,7 @@ function getOpenCodeConfigDir2(options) {
136600
136658
  // packages/skills-loader-core/src/shared/opencode-command-dirs.ts
136601
136659
  function getParentOpencodeConfigDir(configDir) {
136602
136660
  const parentDir = dirname22(configDir);
136603
- if (basename10(parentDir) !== "profiles") {
136661
+ if (basename11(parentDir) !== "profiles") {
136604
136662
  return null;
136605
136663
  }
136606
136664
  return dirname22(parentDir);
@@ -136611,21 +136669,21 @@ function getOpenCodeSkillDirs(options) {
136611
136669
  ...configDirs.flatMap((configDir) => {
136612
136670
  const parentConfigDir = getParentOpencodeConfigDir(configDir);
136613
136671
  return [
136614
- join56(configDir, "skills"),
136615
- join56(configDir, "skill"),
136616
- ...parentConfigDir ? [join56(parentConfigDir, "skills"), join56(parentConfigDir, "skill")] : []
136672
+ join57(configDir, "skills"),
136673
+ join57(configDir, "skill"),
136674
+ ...parentConfigDir ? [join57(parentConfigDir, "skills"), join57(parentConfigDir, "skill")] : []
136617
136675
  ];
136618
136676
  })
136619
136677
  ]));
136620
136678
  }
136621
136679
  // packages/skills-loader-core/src/shared/project-discovery-dirs.ts
136622
136680
  import { execFileSync as execFileSync2 } from "child_process";
136623
- import { existsSync as existsSync61, realpathSync as realpathSync9 } from "fs";
136624
- import { dirname as dirname23, join as join57, resolve as resolve13, win32 as win326 } from "path";
136681
+ import { existsSync as existsSync62, realpathSync as realpathSync9 } from "fs";
136682
+ import { dirname as dirname23, join as join58, resolve as resolve13, win32 as win326 } from "path";
136625
136683
  var worktreePathCache2 = new Map;
136626
136684
  function normalizePath2(path18) {
136627
136685
  const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve13(path18);
136628
- if (!existsSync61(resolvedPath)) {
136686
+ if (!existsSync62(resolvedPath)) {
136629
136687
  return resolvedPath;
136630
136688
  }
136631
136689
  try {
@@ -136656,8 +136714,8 @@ function findAncestorDirectories(startDirectory, targetPaths, stopDirectory) {
136656
136714
  const stopDirectoryKey = resolvedStopDirectory ? pathKey2(resolvedStopDirectory) : undefined;
136657
136715
  while (true) {
136658
136716
  for (const targetPath of targetPaths) {
136659
- const candidateDirectory = join57(currentDirectory, ...targetPath);
136660
- if (!existsSync61(candidateDirectory)) {
136717
+ const candidateDirectory = join58(currentDirectory, ...targetPath);
136718
+ if (!existsSync62(candidateDirectory)) {
136661
136719
  continue;
136662
136720
  }
136663
136721
  const normalizedCandidateDirectory = normalizePath2(candidateDirectory);
@@ -136739,13 +136797,13 @@ function deduplicateSkillsByName(skills2) {
136739
136797
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-directory-loader.ts
136740
136798
  init_src();
136741
136799
  import * as fs19 from "fs/promises";
136742
- import { join as join59 } from "path";
136800
+ import { join as join60 } from "path";
136743
136801
 
136744
136802
  // packages/skills-loader-core/src/features/opencode-skill-loader/loaded-skill-from-path.ts
136745
136803
  init_src();
136746
136804
  init_src2();
136747
136805
  import * as fs18 from "fs/promises";
136748
- import { basename as basename11 } from "path";
136806
+ import { basename as basename12 } from "path";
136749
136807
 
136750
136808
  // packages/skills-loader-core/src/features/opencode-skill-loader/allowed-tools-parser.ts
136751
136809
  function parseAllowedTools(allowedTools) {
@@ -136760,7 +136818,7 @@ function parseAllowedTools(allowedTools) {
136760
136818
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-mcp-config.ts
136761
136819
  init_js_yaml();
136762
136820
  import * as fs17 from "fs/promises";
136763
- import { join as join58 } from "path";
136821
+ import { join as join59 } from "path";
136764
136822
  function parseSkillMcpConfigFromFrontmatter(content) {
136765
136823
  const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
136766
136824
  if (!frontmatterMatch)
@@ -136779,7 +136837,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
136779
136837
  return;
136780
136838
  }
136781
136839
  async function loadMcpJsonFromDir(skillDir) {
136782
- const mcpJsonPath = join58(skillDir, "mcp.json");
136840
+ const mcpJsonPath = join59(skillDir, "mcp.json");
136783
136841
  try {
136784
136842
  const content = await fs17.readFile(mcpJsonPath, "utf-8");
136785
136843
  const parsed = JSON.parse(content);
@@ -136861,7 +136919,7 @@ $ARGUMENTS
136861
136919
  }
136862
136920
  }
136863
136921
  function inferSkillNameFromFileName(filePath) {
136864
- return basename11(filePath, ".md");
136922
+ return basename12(filePath, ".md");
136865
136923
  }
136866
136924
 
136867
136925
  // packages/skills-loader-core/src/features/opencode-skill-loader/skill-directory-loader.ts
@@ -136895,10 +136953,10 @@ async function loadSkillsFromDir(options) {
136895
136953
  const directories = entries.filter((entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink()));
136896
136954
  const files = entries.filter((entry) => !entry.name.startsWith(".") && !entry.isDirectory() && !entry.isSymbolicLink() && isMarkdownFile(entry));
136897
136955
  for (const entry of directories) {
136898
- const entryPath = join59(options.skillsDir, entry.name);
136956
+ const entryPath = join60(options.skillsDir, entry.name);
136899
136957
  const resolvedPath = await resolveSymlinkAsync(entryPath);
136900
136958
  const dirName = entry.name;
136901
- const skillMdPath = join59(resolvedPath, "SKILL.md");
136959
+ const skillMdPath = join60(resolvedPath, "SKILL.md");
136902
136960
  if (await canAccessFile(skillMdPath)) {
136903
136961
  const skill = await loadSkillFromPath({
136904
136962
  skillPath: skillMdPath,
@@ -136912,7 +136970,7 @@ async function loadSkillsFromDir(options) {
136912
136970
  }
136913
136971
  continue;
136914
136972
  }
136915
- const namedSkillMdPath = join59(resolvedPath, `${dirName}.md`);
136973
+ const namedSkillMdPath = join60(resolvedPath, `${dirName}.md`);
136916
136974
  if (await canAccessFile(namedSkillMdPath)) {
136917
136975
  const skill = await loadSkillFromPath({
136918
136976
  skillPath: namedSkillMdPath,
@@ -136943,7 +137001,7 @@ async function loadSkillsFromDir(options) {
136943
137001
  }
136944
137002
  }
136945
137003
  for (const entry of files) {
136946
- const entryPath = join59(options.skillsDir, entry.name);
137004
+ const entryPath = join60(options.skillsDir, entry.name);
136947
137005
  const baseName = inferSkillNameFromFileName(entryPath);
136948
137006
  const skill = await loadSkillFromPath({
136949
137007
  skillPath: entryPath,
@@ -136995,7 +137053,7 @@ async function discoverAllSkills(directory) {
136995
137053
  ]);
136996
137054
  }
136997
137055
  async function discoverUserClaudeSkills() {
136998
- const userSkillsDir = join60(getClaudeConfigDir(), "skills");
137056
+ const userSkillsDir = join61(getClaudeConfigDir(), "skills");
136999
137057
  return loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
137000
137058
  }
137001
137059
  async function discoverProjectClaudeSkills(directory) {
@@ -137022,7 +137080,7 @@ async function discoverProjectAgentsSkills(directory) {
137022
137080
  return deduplicateSkillsByName(allSkills.flat());
137023
137081
  }
137024
137082
  async function discoverGlobalAgentsSkills(homeDirectory = getHomeDirectory()) {
137025
- const agentsGlobalDir = join60(homeDirectory, ".agents", "skills");
137083
+ const agentsGlobalDir = join61(homeDirectory, ".agents", "skills");
137026
137084
  return loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
137027
137085
  }
137028
137086
  // packages/skills-loader-core/src/features/builtin-skills/agent-browser/SKILL.md
@@ -137768,17 +137826,17 @@ playwright-cli close
137768
137826
  allowedTools: ["Bash(playwright-cli:*)"]
137769
137827
  };
137770
137828
  // packages/skills-loader-core/src/features/builtin-skills/skill-file-loader.ts
137771
- import { readFileSync as readFileSync47 } from "fs";
137772
- import { join as join61 } from "path";
137829
+ import { readFileSync as readFileSync48 } from "fs";
137830
+ import { join as join62 } from "path";
137773
137831
  init_src();
137774
- function createSharedSkillTemplateLoader(readFile3 = readFileSync47, skillsRootPath = sharedSkillsRootPath()) {
137832
+ function createSharedSkillTemplateLoader(readFile3 = readFileSync48, skillsRootPath = sharedSkillsRootPath()) {
137775
137833
  const cache = new Map;
137776
137834
  return (skillName) => {
137777
137835
  const cached2 = cache.get(skillName);
137778
137836
  if (cached2 !== undefined)
137779
137837
  return cached2;
137780
137838
  try {
137781
- const { body } = parseFrontmatter(readFile3(join61(skillsRootPath, skillName, "SKILL.md"), "utf8"));
137839
+ const { body } = parseFrontmatter(readFile3(join62(skillsRootPath, skillName, "SKILL.md"), "utf8"));
137782
137840
  cache.set(skillName, body);
137783
137841
  return body;
137784
137842
  } catch (error51) {
@@ -138915,7 +138973,7 @@ var gitMasterSkill = {
138915
138973
  template: GIT_MASTER_TEMPLATE
138916
138974
  };
138917
138975
  // packages/skills-loader-core/src/features/builtin-skills/skills/dev-browser.ts
138918
- import { dirname as dirname24, join as join62 } from "path";
138976
+ import { dirname as dirname24, join as join63 } from "path";
138919
138977
  import { fileURLToPath as fileURLToPath8 } from "url";
138920
138978
  var CURRENT_DIR = dirname24(fileURLToPath8(import.meta.url));
138921
138979
  var devBrowserSkill = {
@@ -139135,7 +139193,7 @@ console.log({
139135
139193
  await client.disconnect();
139136
139194
  EOF
139137
139195
  \`\`\``,
139138
- resolvedPath: join62(CURRENT_DIR, "..", "dev-browser")
139196
+ resolvedPath: join63(CURRENT_DIR, "..", "dev-browser")
139139
139197
  };
139140
139198
  // packages/skills-loader-core/src/features/builtin-skills/skills/review-work.ts
139141
139199
  var reviewWorkSkill = {
@@ -140128,11 +140186,11 @@ function applySnapshotRetention(options) {
140128
140186
  // packages/omo-opencode/src/cli/snapshot/snapshot.ts
140129
140187
  import { Database as Database3 } from "bun:sqlite";
140130
140188
  import {
140131
- existsSync as existsSync63,
140132
- mkdirSync as mkdirSync18,
140189
+ existsSync as existsSync64,
140190
+ mkdirSync as mkdirSync19,
140133
140191
  copyFileSync as copyFileSync3,
140134
- readFileSync as readFileSync48,
140135
- writeFileSync as writeFileSync16,
140192
+ readFileSync as readFileSync49,
140193
+ writeFileSync as writeFileSync17,
140136
140194
  readdirSync as readdirSync10,
140137
140195
  statSync as statSync8,
140138
140196
  rmSync as rmSync4
@@ -140144,12 +140202,12 @@ async function snapshotCli(options = {}) {
140144
140202
  const homeDir = os7.homedir();
140145
140203
  const snapshotDir = options.snapshotDir ?? path18.join(homeDir, ".matrixos", "snapshots");
140146
140204
  const allPaths = getAllSnapshotPaths(homeDir);
140147
- const files = allPaths.files.filter((f2) => existsSync63(f2.sourcePath));
140205
+ const files = allPaths.files.filter((f2) => existsSync64(f2.sourcePath));
140148
140206
  const realFs = {
140149
- existsSync: existsSync63,
140150
- mkdirSync: mkdirSync18,
140151
- readFileSync: readFileSync48,
140152
- writeFileSync: writeFileSync16,
140207
+ existsSync: existsSync64,
140208
+ mkdirSync: mkdirSync19,
140209
+ readFileSync: readFileSync49,
140210
+ writeFileSync: writeFileSync17,
140153
140211
  copyFileSync: copyFileSync3,
140154
140212
  readdirSync: readdirSync10,
140155
140213
  statSync: statSync8,
@@ -140211,11 +140269,11 @@ async function snapshotCli(options = {}) {
140211
140269
 
140212
140270
  // packages/omo-opencode/src/cli/snapshot/restore.ts
140213
140271
  import {
140214
- existsSync as existsSync64,
140215
- mkdirSync as mkdirSync19,
140272
+ existsSync as existsSync65,
140273
+ mkdirSync as mkdirSync20,
140216
140274
  copyFileSync as copyFileSync4,
140217
- readFileSync as readFileSync49,
140218
- writeFileSync as writeFileSync17,
140275
+ readFileSync as readFileSync50,
140276
+ writeFileSync as writeFileSync18,
140219
140277
  readdirSync as readdirSync11,
140220
140278
  statSync as statSync9,
140221
140279
  rmSync as rmSync5
@@ -140225,10 +140283,10 @@ import * as os8 from "os";
140225
140283
  async function restoreCli(options) {
140226
140284
  const snapshotDir = options.snapshotDir ?? path19.join(os8.homedir(), ".matrixos", "snapshots");
140227
140285
  const realFs = {
140228
- existsSync: existsSync64,
140229
- mkdirSync: mkdirSync19,
140230
- readFileSync: readFileSync49,
140231
- writeFileSync: writeFileSync17,
140286
+ existsSync: existsSync65,
140287
+ mkdirSync: mkdirSync20,
140288
+ readFileSync: readFileSync50,
140289
+ writeFileSync: writeFileSync18,
140232
140290
  copyFileSync: copyFileSync4,
140233
140291
  readdirSync: readdirSync11,
140234
140292
  statSync: statSync9,
@@ -140242,7 +140300,7 @@ async function restoreCli(options) {
140242
140300
  try {
140243
140301
  restoreSnapshot(options.state, { snapshotDir, fs: realFs });
140244
140302
  const manifestPath = path19.join(snapshotDir, options.state, "manifest.json");
140245
- const raw = readFileSync49(manifestPath).toString("utf-8");
140303
+ const raw = readFileSync50(manifestPath).toString("utf-8");
140246
140304
  const parsed = JSON.parse(raw);
140247
140305
  const fileCount = typeof parsed === "object" && parsed !== null && "files" in parsed && Array.isArray(parsed.files) ? parsed.files.length : 0;
140248
140306
  if (options.json) {
@@ -140263,11 +140321,11 @@ async function restoreCli(options) {
140263
140321
 
140264
140322
  // packages/omo-opencode/src/cli/snapshot/list.ts
140265
140323
  import {
140266
- existsSync as existsSync65,
140267
- mkdirSync as mkdirSync20,
140324
+ existsSync as existsSync66,
140325
+ mkdirSync as mkdirSync21,
140268
140326
  copyFileSync as copyFileSync5,
140269
- readFileSync as readFileSync50,
140270
- writeFileSync as writeFileSync18,
140327
+ readFileSync as readFileSync51,
140328
+ writeFileSync as writeFileSync19,
140271
140329
  readdirSync as readdirSync12,
140272
140330
  statSync as statSync10,
140273
140331
  rmSync as rmSync6
@@ -140287,10 +140345,10 @@ function formatBytes(bytes) {
140287
140345
  async function snapshotListCli(options) {
140288
140346
  const snapshotDir = options.snapshotDir ?? path20.join(os9.homedir(), ".matrixos", "snapshots");
140289
140347
  const realFs = {
140290
- existsSync: existsSync65,
140291
- mkdirSync: mkdirSync20,
140292
- readFileSync: readFileSync50,
140293
- writeFileSync: writeFileSync18,
140348
+ existsSync: existsSync66,
140349
+ mkdirSync: mkdirSync21,
140350
+ readFileSync: readFileSync51,
140351
+ writeFileSync: writeFileSync19,
140294
140352
  copyFileSync: copyFileSync5,
140295
140353
  readdirSync: readdirSync12,
140296
140354
  statSync: statSync10,
@@ -140317,11 +140375,11 @@ async function snapshotListCli(options) {
140317
140375
 
140318
140376
  // packages/omo-opencode/src/cli/snapshot/prune.ts
140319
140377
  import {
140320
- existsSync as existsSync66,
140321
- mkdirSync as mkdirSync21,
140378
+ existsSync as existsSync67,
140379
+ mkdirSync as mkdirSync22,
140322
140380
  copyFileSync as copyFileSync6,
140323
- readFileSync as readFileSync51,
140324
- writeFileSync as writeFileSync19,
140381
+ readFileSync as readFileSync52,
140382
+ writeFileSync as writeFileSync20,
140325
140383
  readdirSync as readdirSync13,
140326
140384
  statSync as statSync11,
140327
140385
  rmSync as rmSync7
@@ -140331,10 +140389,10 @@ import * as os10 from "os";
140331
140389
  async function snapshotPruneCli(options = {}) {
140332
140390
  const snapshotDir = options.snapshotDir ?? path21.join(os10.homedir(), ".matrixos", "snapshots");
140333
140391
  const realFs = {
140334
- existsSync: existsSync66,
140335
- mkdirSync: mkdirSync21,
140336
- readFileSync: readFileSync51,
140337
- writeFileSync: writeFileSync19,
140392
+ existsSync: existsSync67,
140393
+ mkdirSync: mkdirSync22,
140394
+ readFileSync: readFileSync52,
140395
+ writeFileSync: writeFileSync20,
140338
140396
  copyFileSync: copyFileSync6,
140339
140397
  readdirSync: readdirSync13,
140340
140398
  statSync: statSync11,
@@ -140381,8 +140439,8 @@ function codebaseCli(rootProgram) {
140381
140439
  try {
140382
140440
  const dimension = Number.parseInt(options.dimension, 10) || 384;
140383
140441
  const dbDir = path22.dirname(options.db);
140384
- const { mkdirSync: mkdirSync22 } = await import("fs");
140385
- mkdirSync22(dbDir, { recursive: true });
140442
+ const { mkdirSync: mkdirSync23 } = await import("fs");
140443
+ mkdirSync23(dbDir, { recursive: true });
140386
140444
  const store4 = createSqliteVectorStore({ path: options.db, dimension });
140387
140445
  if (options.reset) {
140388
140446
  store4.clear();
@@ -140619,7 +140677,7 @@ function printHumanReadable2(r2) {
140619
140677
  // packages/omo-opencode/src/cli/trace.ts
140620
140678
  init_data_path();
140621
140679
  import * as path23 from "path";
140622
- import { writeFileSync as writeFileSync20 } from "fs";
140680
+ import { writeFileSync as writeFileSync21 } from "fs";
140623
140681
  import { Database as Database4 } from "bun:sqlite";
140624
140682
  function defaultDbPath() {
140625
140683
  return path23.join(getDataDir(), "opencode", "opencode.db");
@@ -140823,7 +140881,7 @@ function renderMermaid(result, outPath) {
140823
140881
  const content = lines.join(`
140824
140882
  `);
140825
140883
  if (outPath && outPath !== "-") {
140826
- writeFileSync20(outPath, content + `
140884
+ writeFileSync21(outPath, content + `
140827
140885
  `);
140828
140886
  }
140829
140887
  return content;
@@ -141411,6 +141469,117 @@ async function dashboardCli(options) {
141411
141469
  }
141412
141470
  }
141413
141471
 
141472
+ // packages/omo-opencode/src/cli/architect.ts
141473
+ import { join as join72 } from "path";
141474
+ var IMPROVEMENTS_DIR = ".matrixos/improvements";
141475
+ function getStore(directory) {
141476
+ const baseDir = directory ?? process.cwd();
141477
+ return createImprovementStore(join72(baseDir, IMPROVEMENTS_DIR));
141478
+ }
141479
+ async function architectReview(options) {
141480
+ const store4 = getStore(options.directory);
141481
+ if (options.id) {
141482
+ const improvement = store4.get(options.id);
141483
+ if (!improvement) {
141484
+ console.error(`Improvement not found: ${options.id}`);
141485
+ return 1;
141486
+ }
141487
+ if (options.approve) {
141488
+ store4.updateStatus(improvement.id, "approved", {
141489
+ approvedAt: new Date().toISOString(),
141490
+ reviewedBy: "cli"
141491
+ });
141492
+ console.log(`\u2705 Approved: ${improvement.title} (${improvement.id})`);
141493
+ return 0;
141494
+ }
141495
+ if (options.reject) {
141496
+ store4.updateStatus(improvement.id, "rejected", {
141497
+ rejectedAt: new Date().toISOString(),
141498
+ reviewedBy: "cli"
141499
+ });
141500
+ console.log(`\u274C Rejected: ${improvement.title} (${improvement.id})`);
141501
+ return 0;
141502
+ }
141503
+ if (options.json) {
141504
+ console.log(JSON.stringify(improvement, null, 2));
141505
+ return 0;
141506
+ }
141507
+ console.log(`
141508
+ === ${improvement.title} ===`);
141509
+ console.log(`ID: ${improvement.id}`);
141510
+ console.log(`Status: ${improvement.status}`);
141511
+ console.log(`Risk: ${improvement.risk}`);
141512
+ console.log(`
141513
+ ${improvement.description}`);
141514
+ console.log(`
141515
+ Rationale: ${improvement.rationale}`);
141516
+ console.log(`
141517
+ Changes:`);
141518
+ for (const change of improvement.changes) {
141519
+ console.log(` ${change.action} ${change.target}: ${change.path}`);
141520
+ }
141521
+ if (improvement.rollbackPlan)
141522
+ console.log(`
141523
+ Rollback: ${improvement.rollbackPlan}`);
141524
+ if (improvement.testPlan)
141525
+ console.log(`Test plan: ${improvement.testPlan}`);
141526
+ return 0;
141527
+ }
141528
+ const all = store4.list();
141529
+ const proposals = all.filter((i3) => i3.status === "proposed");
141530
+ const applied = all.filter((i3) => i3.status === "applied");
141531
+ if (options.json) {
141532
+ console.log(JSON.stringify({ proposals, applied, total: all.length }, null, 2));
141533
+ return 0;
141534
+ }
141535
+ console.log(`
141536
+ Architect \u2014 Improvement Proposals
141537
+ `);
141538
+ console.log(`Proposed: ${proposals.length} | Applied: ${applied.length} | Total: ${all.length}
141539
+ `);
141540
+ if (proposals.length > 0) {
141541
+ console.log("--- Pending Review ---");
141542
+ for (const p2 of proposals) {
141543
+ console.log(` [${p2.risk}] ${p2.title} (${p2.id})`);
141544
+ }
141545
+ console.log(`
141546
+ Review: bunx matrixos architect review --id <id>`);
141547
+ console.log(`Approve: bunx matrixos architect review --id <id> --approve`);
141548
+ console.log(`Reject: bunx matrixos architect review --id <id> --reject`);
141549
+ }
141550
+ if (applied.length > 0) {
141551
+ console.log(`
141552
+ --- Applied ---`);
141553
+ for (const a2 of applied) {
141554
+ console.log(` ${a2.title} (${a2.id}) \u2014 ${a2.appliedAt ?? "?"}`);
141555
+ }
141556
+ }
141557
+ return 0;
141558
+ }
141559
+ async function architectRollback(options) {
141560
+ const store4 = getStore(options.directory);
141561
+ const improvement = store4.get(options.id);
141562
+ if (!improvement) {
141563
+ console.error(`Improvement not found: ${options.id}`);
141564
+ return 1;
141565
+ }
141566
+ if (improvement.status !== "applied") {
141567
+ console.error(`Improvement is not applied (status: ${improvement.status}). Cannot rollback.`);
141568
+ return 1;
141569
+ }
141570
+ store4.updateStatus(improvement.id, "rolled_back", {
141571
+ rollbackPlan: `Rolled back via CLI at ${new Date().toISOString()}. See beforeSnapshot for original state.`
141572
+ });
141573
+ console.log(`\u21A9\uFE0F Rolled back: ${improvement.title} (${improvement.id})`);
141574
+ if (improvement.beforeSnapshot) {
141575
+ console.log(` Before-snapshot available for manual restore.`);
141576
+ }
141577
+ if (options.json) {
141578
+ console.log(JSON.stringify({ rolledBack: improvement.id, title: improvement.title }, null, 2));
141579
+ }
141580
+ return 0;
141581
+ }
141582
+
141414
141583
  // packages/omo-opencode/src/cli/runtime-commands.ts
141415
141584
  init_data_path();
141416
141585
  init_shared();
@@ -141581,6 +141750,15 @@ function configureRuntimeCommands(program2) {
141581
141750
  });
141582
141751
  process.exit(exitCode);
141583
141752
  });
141753
+ const architectCmd = program2.command("architect").description("Self-improvement workflow \u2014 review improvement proposals and roll back applied changes");
141754
+ 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) => {
141755
+ const exitCode = await architectReview(options);
141756
+ process.exit(exitCode);
141757
+ });
141758
+ 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) => {
141759
+ const exitCode = await architectRollback({ ...options, id });
141760
+ process.exit(exitCode);
141761
+ });
141584
141762
  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) => {
141585
141763
  const exitCode = await dashboardCli({
141586
141764
  port: parseInt(options.port ?? "9123", 10),