@kl-c/matrixos 0.1.4 → 0.1.6

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