@kl-c/matrixos 0.2.1 → 0.2.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.
- package/dist/audit/self-audit.d.ts +53 -0
- package/dist/cli/index.js +1260 -346
- package/dist/cli/self-audit-command.d.ts +21 -0
- package/dist/cli-node/index.js +1260 -346
- package/dist/deployment/deploy-cli.d.ts +14 -0
- package/dist/deployment/deploy-static.d.ts +5 -0
- package/dist/deployment/deploy-vercel.d.ts +5 -0
- package/dist/deployment/deploy-vps.d.ts +5 -0
- package/dist/deployment/deployment-core.d.ts +38 -0
- package/dist/deployment/index.d.ts +10 -0
- package/dist/index.js +13 -2
- package/dist/project/project-context.d.ts +43 -0
- package/dist/project/project-memory.d.ts +35 -0
- package/package.json +1 -1
package/dist/cli-node/index.js
CHANGED
|
@@ -2163,7 +2163,7 @@ var package_default;
|
|
|
2163
2163
|
var init_package = __esm(() => {
|
|
2164
2164
|
package_default = {
|
|
2165
2165
|
name: "@kl-c/matrixos",
|
|
2166
|
-
version: "0.2.
|
|
2166
|
+
version: "0.2.6",
|
|
2167
2167
|
description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
|
|
2168
2168
|
main: "./dist/index.js",
|
|
2169
2169
|
types: "dist/index.d.ts",
|
|
@@ -90408,11 +90408,22 @@ class TelegramAdapter {
|
|
|
90408
90408
|
}
|
|
90409
90409
|
const text = envelope.content.text ?? "";
|
|
90410
90410
|
const result = await this.bot.api.sendMessage(chatId, text);
|
|
90411
|
-
|
|
90411
|
+
const messageId = String(result.message_id);
|
|
90412
|
+
if (envelope.metadata?.onMessageId && typeof envelope.metadata.onMessageId === "function") {
|
|
90413
|
+
envelope.metadata.onMessageId(messageId);
|
|
90414
|
+
}
|
|
90415
|
+
return messageId;
|
|
90412
90416
|
} catch (err) {
|
|
90413
90417
|
throw new TelegramSendError(`Failed to send Telegram message: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
90414
90418
|
}
|
|
90415
90419
|
}
|
|
90420
|
+
async editMessage(recipientId, messageId, text) {
|
|
90421
|
+
try {
|
|
90422
|
+
await this.bot.api.editMessageText(recipientId, Number(messageId), text);
|
|
90423
|
+
} catch (err) {
|
|
90424
|
+
console.warn(`[telegram] editMessage failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
90425
|
+
}
|
|
90426
|
+
}
|
|
90416
90427
|
onMessage(handler) {
|
|
90417
90428
|
this.messageHandler = handler;
|
|
90418
90429
|
}
|
|
@@ -164473,6 +164484,351 @@ var require_picomatch2 = __commonJS((exports2, module2) => {
|
|
|
164473
164484
|
module2.exports = picomatch;
|
|
164474
164485
|
});
|
|
164475
164486
|
|
|
164487
|
+
// packages/omo-opencode/src/features/cron/store.ts
|
|
164488
|
+
function createCronStore() {
|
|
164489
|
+
const jobs = new Map;
|
|
164490
|
+
let counter = 0;
|
|
164491
|
+
return {
|
|
164492
|
+
add(input) {
|
|
164493
|
+
counter += 1;
|
|
164494
|
+
const now = new Date().toISOString();
|
|
164495
|
+
const job = {
|
|
164496
|
+
id: `cron-${counter}`,
|
|
164497
|
+
name: input.name,
|
|
164498
|
+
schedule: input.schedule,
|
|
164499
|
+
command: input.command,
|
|
164500
|
+
channel: input.channel,
|
|
164501
|
+
recipient: input.recipient,
|
|
164502
|
+
enabled: input.enabled ?? true,
|
|
164503
|
+
createdAt: now,
|
|
164504
|
+
updatedAt: now
|
|
164505
|
+
};
|
|
164506
|
+
CronJobSchema.parse(job);
|
|
164507
|
+
jobs.set(job.id, job);
|
|
164508
|
+
return job;
|
|
164509
|
+
},
|
|
164510
|
+
get(id) {
|
|
164511
|
+
return jobs.get(id);
|
|
164512
|
+
},
|
|
164513
|
+
list(filter) {
|
|
164514
|
+
const all = Array.from(jobs.values());
|
|
164515
|
+
return all.filter((j) => {
|
|
164516
|
+
if (filter?.enabled !== undefined && j.enabled !== filter.enabled)
|
|
164517
|
+
return false;
|
|
164518
|
+
if (filter?.channel && j.channel !== filter.channel)
|
|
164519
|
+
return false;
|
|
164520
|
+
return true;
|
|
164521
|
+
});
|
|
164522
|
+
},
|
|
164523
|
+
remove(id) {
|
|
164524
|
+
return jobs.delete(id);
|
|
164525
|
+
},
|
|
164526
|
+
size() {
|
|
164527
|
+
return jobs.size;
|
|
164528
|
+
}
|
|
164529
|
+
};
|
|
164530
|
+
}
|
|
164531
|
+
var CronJobSchema;
|
|
164532
|
+
var init_store = __esm(() => {
|
|
164533
|
+
init_zod();
|
|
164534
|
+
CronJobSchema = object({
|
|
164535
|
+
id: string2().min(1),
|
|
164536
|
+
name: string2().min(1).max(100),
|
|
164537
|
+
schedule: string2().min(1).max(100),
|
|
164538
|
+
command: string2().min(1),
|
|
164539
|
+
channel: _enum2(["telegram", "discord", "whatsapp"]).optional(),
|
|
164540
|
+
recipient: string2().optional(),
|
|
164541
|
+
enabled: boolean2().default(true),
|
|
164542
|
+
createdAt: string2(),
|
|
164543
|
+
updatedAt: string2()
|
|
164544
|
+
}).strict();
|
|
164545
|
+
});
|
|
164546
|
+
|
|
164547
|
+
// packages/task-ledger-core/src/schema.ts
|
|
164548
|
+
var TaskSourceSchema, TaskStatusSchema, TaskPrioritySchema, TaskSchema, TaskInsertSchema, TaskPatchSchema, TaskFilterSchema;
|
|
164549
|
+
var init_schema2 = __esm(() => {
|
|
164550
|
+
init_zod();
|
|
164551
|
+
TaskSourceSchema = _enum2(["webhook", "cron", "user", "kanban"]);
|
|
164552
|
+
TaskStatusSchema = _enum2([
|
|
164553
|
+
"pending",
|
|
164554
|
+
"running",
|
|
164555
|
+
"done",
|
|
164556
|
+
"failed",
|
|
164557
|
+
"cancelled"
|
|
164558
|
+
]);
|
|
164559
|
+
TaskPrioritySchema = _enum2(["high", "medium", "low"]);
|
|
164560
|
+
TaskSchema = object({
|
|
164561
|
+
id: string2().min(1),
|
|
164562
|
+
source: TaskSourceSchema,
|
|
164563
|
+
context: string2().nullable(),
|
|
164564
|
+
status: TaskStatusSchema,
|
|
164565
|
+
priority: TaskPrioritySchema.nullable(),
|
|
164566
|
+
payload: string2(),
|
|
164567
|
+
agent_assigned: string2().nullable(),
|
|
164568
|
+
session_id: string2().nullable(),
|
|
164569
|
+
result: string2().nullable(),
|
|
164570
|
+
cost_tokens: number2().int().nonnegative().default(0),
|
|
164571
|
+
cost_usd: number2().nonnegative().default(0),
|
|
164572
|
+
created_at: number2().int(),
|
|
164573
|
+
started_at: number2().int().nullable(),
|
|
164574
|
+
completed_at: number2().int().nullable()
|
|
164575
|
+
}).strict();
|
|
164576
|
+
TaskInsertSchema = object({
|
|
164577
|
+
id: string2().min(1).optional(),
|
|
164578
|
+
source: TaskSourceSchema,
|
|
164579
|
+
context: string2().nullable().optional(),
|
|
164580
|
+
status: TaskStatusSchema.optional(),
|
|
164581
|
+
priority: TaskPrioritySchema.nullable().optional(),
|
|
164582
|
+
payload: string2(),
|
|
164583
|
+
agent_assigned: string2().nullable().optional(),
|
|
164584
|
+
session_id: string2().nullable().optional(),
|
|
164585
|
+
cost_tokens: number2().int().nonnegative().optional(),
|
|
164586
|
+
cost_usd: number2().nonnegative().optional()
|
|
164587
|
+
}).strict();
|
|
164588
|
+
TaskPatchSchema = object({
|
|
164589
|
+
status: TaskStatusSchema.optional(),
|
|
164590
|
+
priority: TaskPrioritySchema.nullable().optional(),
|
|
164591
|
+
agent_assigned: string2().nullable().optional(),
|
|
164592
|
+
session_id: string2().nullable().optional(),
|
|
164593
|
+
result: string2().nullable().optional(),
|
|
164594
|
+
cost_tokens: number2().int().nonnegative().optional(),
|
|
164595
|
+
cost_usd: number2().nonnegative().optional(),
|
|
164596
|
+
started_at: number2().int().nullable().optional(),
|
|
164597
|
+
completed_at: number2().int().nullable().optional()
|
|
164598
|
+
}).strict();
|
|
164599
|
+
TaskFilterSchema = object({
|
|
164600
|
+
source: TaskSourceSchema.optional(),
|
|
164601
|
+
context: string2().optional(),
|
|
164602
|
+
status: TaskStatusSchema.optional(),
|
|
164603
|
+
agent_assigned: string2().optional(),
|
|
164604
|
+
session_id: string2().optional(),
|
|
164605
|
+
priority: TaskPrioritySchema.optional()
|
|
164606
|
+
}).strict();
|
|
164607
|
+
});
|
|
164608
|
+
|
|
164609
|
+
// packages/task-ledger-core/src/ledger.ts
|
|
164610
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
164611
|
+
function rowToTask(row) {
|
|
164612
|
+
return {
|
|
164613
|
+
id: row.id,
|
|
164614
|
+
source: row.source,
|
|
164615
|
+
context: row.context,
|
|
164616
|
+
status: row.status,
|
|
164617
|
+
priority: row.priority,
|
|
164618
|
+
payload: row.payload,
|
|
164619
|
+
agent_assigned: row.agent_assigned,
|
|
164620
|
+
session_id: row.session_id,
|
|
164621
|
+
result: row.result,
|
|
164622
|
+
cost_tokens: row.cost_tokens,
|
|
164623
|
+
cost_usd: row.cost_usd,
|
|
164624
|
+
created_at: row.created_at,
|
|
164625
|
+
started_at: row.started_at,
|
|
164626
|
+
completed_at: row.completed_at
|
|
164627
|
+
};
|
|
164628
|
+
}
|
|
164629
|
+
function createTaskLedger(db) {
|
|
164630
|
+
db.exec(CREATE_TABLE_SQL);
|
|
164631
|
+
db.exec(CREATE_INDEX_STATUS);
|
|
164632
|
+
db.exec(CREATE_INDEX_CONTEXT);
|
|
164633
|
+
db.exec(CREATE_INDEX_SOURCE);
|
|
164634
|
+
return {
|
|
164635
|
+
insert(input) {
|
|
164636
|
+
const now = Date.now();
|
|
164637
|
+
const task2 = TaskSchema.parse({
|
|
164638
|
+
id: input.id ?? randomUUID2(),
|
|
164639
|
+
source: input.source,
|
|
164640
|
+
context: input.context ?? null,
|
|
164641
|
+
status: input.status ?? "pending",
|
|
164642
|
+
priority: input.priority ?? null,
|
|
164643
|
+
payload: input.payload,
|
|
164644
|
+
agent_assigned: input.agent_assigned ?? null,
|
|
164645
|
+
session_id: input.session_id ?? null,
|
|
164646
|
+
result: null,
|
|
164647
|
+
cost_tokens: input.cost_tokens ?? 0,
|
|
164648
|
+
cost_usd: input.cost_usd ?? 0,
|
|
164649
|
+
created_at: now,
|
|
164650
|
+
started_at: null,
|
|
164651
|
+
completed_at: null
|
|
164652
|
+
});
|
|
164653
|
+
db.exec(INSERT_SQL, {
|
|
164654
|
+
$id: task2.id,
|
|
164655
|
+
$source: task2.source,
|
|
164656
|
+
$context: task2.context,
|
|
164657
|
+
$status: task2.status,
|
|
164658
|
+
$priority: task2.priority,
|
|
164659
|
+
$payload: task2.payload,
|
|
164660
|
+
$agent_assigned: task2.agent_assigned,
|
|
164661
|
+
$session_id: task2.session_id,
|
|
164662
|
+
$result: task2.result,
|
|
164663
|
+
$cost_tokens: task2.cost_tokens,
|
|
164664
|
+
$cost_usd: task2.cost_usd,
|
|
164665
|
+
$created_at: task2.created_at,
|
|
164666
|
+
$started_at: task2.started_at,
|
|
164667
|
+
$completed_at: task2.completed_at
|
|
164668
|
+
});
|
|
164669
|
+
return task2;
|
|
164670
|
+
},
|
|
164671
|
+
get(id) {
|
|
164672
|
+
const rows = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
164673
|
+
if (rows.length === 0)
|
|
164674
|
+
return null;
|
|
164675
|
+
return rowToTask(rows[0]);
|
|
164676
|
+
},
|
|
164677
|
+
list(filter) {
|
|
164678
|
+
const conditions = [];
|
|
164679
|
+
const params = {};
|
|
164680
|
+
if (filter?.source) {
|
|
164681
|
+
conditions.push("source = $source");
|
|
164682
|
+
params.$source = filter.source;
|
|
164683
|
+
}
|
|
164684
|
+
if (filter?.context) {
|
|
164685
|
+
conditions.push("context = $context");
|
|
164686
|
+
params.$context = filter.context;
|
|
164687
|
+
}
|
|
164688
|
+
if (filter?.status) {
|
|
164689
|
+
conditions.push("status = $status");
|
|
164690
|
+
params.$status = filter.status;
|
|
164691
|
+
}
|
|
164692
|
+
if (filter?.agent_assigned) {
|
|
164693
|
+
conditions.push("agent_assigned = $agent_assigned");
|
|
164694
|
+
params.$agent_assigned = filter.agent_assigned;
|
|
164695
|
+
}
|
|
164696
|
+
if (filter?.session_id) {
|
|
164697
|
+
conditions.push("session_id = $session_id");
|
|
164698
|
+
params.$session_id = filter.session_id;
|
|
164699
|
+
}
|
|
164700
|
+
if (filter?.priority) {
|
|
164701
|
+
conditions.push("priority = $priority");
|
|
164702
|
+
params.$priority = filter.priority;
|
|
164703
|
+
}
|
|
164704
|
+
const where = conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : "";
|
|
164705
|
+
const sql = `SELECT * FROM tasks${where} ORDER BY created_at DESC`;
|
|
164706
|
+
const rows = db.query(sql, params);
|
|
164707
|
+
return rows.map(rowToTask);
|
|
164708
|
+
},
|
|
164709
|
+
update(id, patch) {
|
|
164710
|
+
const existing = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
164711
|
+
if (existing.length === 0)
|
|
164712
|
+
return null;
|
|
164713
|
+
const params = { $id: id };
|
|
164714
|
+
if (patch.status !== undefined)
|
|
164715
|
+
params.$status = patch.status;
|
|
164716
|
+
if (patch.priority !== undefined)
|
|
164717
|
+
params.$priority = patch.priority;
|
|
164718
|
+
if (patch.agent_assigned !== undefined)
|
|
164719
|
+
params.$agent_assigned = patch.agent_assigned;
|
|
164720
|
+
if (patch.session_id !== undefined)
|
|
164721
|
+
params.$session_id = patch.session_id;
|
|
164722
|
+
if (patch.result !== undefined)
|
|
164723
|
+
params.$result = patch.result;
|
|
164724
|
+
if (patch.cost_tokens !== undefined)
|
|
164725
|
+
params.$cost_tokens = patch.cost_tokens;
|
|
164726
|
+
if (patch.cost_usd !== undefined)
|
|
164727
|
+
params.$cost_usd = patch.cost_usd;
|
|
164728
|
+
if (patch.started_at !== undefined)
|
|
164729
|
+
params.$started_at = patch.started_at;
|
|
164730
|
+
if (patch.completed_at !== undefined)
|
|
164731
|
+
params.$completed_at = patch.completed_at;
|
|
164732
|
+
db.exec(UPDATE_SQL, params);
|
|
164733
|
+
return this.get(id);
|
|
164734
|
+
},
|
|
164735
|
+
remove(id) {
|
|
164736
|
+
const before = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
164737
|
+
if (before.length === 0)
|
|
164738
|
+
return false;
|
|
164739
|
+
db.exec(DELETE_BY_ID_SQL, { $id: id });
|
|
164740
|
+
return true;
|
|
164741
|
+
},
|
|
164742
|
+
listPending() {
|
|
164743
|
+
const rows = db.query(`SELECT * FROM tasks WHERE status = 'pending' ORDER BY created_at ASC`);
|
|
164744
|
+
return rows.map(rowToTask);
|
|
164745
|
+
},
|
|
164746
|
+
listFailed() {
|
|
164747
|
+
const rows = db.query(`SELECT * FROM tasks WHERE status = 'failed' ORDER BY created_at ASC`);
|
|
164748
|
+
return rows.map(rowToTask);
|
|
164749
|
+
},
|
|
164750
|
+
listByContext(context) {
|
|
164751
|
+
const rows = db.query(`SELECT * FROM tasks WHERE context = $context ORDER BY created_at DESC`, { $context: context });
|
|
164752
|
+
return rows.map(rowToTask);
|
|
164753
|
+
},
|
|
164754
|
+
close() {
|
|
164755
|
+
db.close();
|
|
164756
|
+
}
|
|
164757
|
+
};
|
|
164758
|
+
}
|
|
164759
|
+
var CREATE_TABLE_SQL = `
|
|
164760
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
164761
|
+
id TEXT PRIMARY KEY,
|
|
164762
|
+
source TEXT NOT NULL,
|
|
164763
|
+
context TEXT,
|
|
164764
|
+
status TEXT NOT NULL,
|
|
164765
|
+
priority TEXT,
|
|
164766
|
+
payload TEXT NOT NULL,
|
|
164767
|
+
agent_assigned TEXT,
|
|
164768
|
+
session_id TEXT,
|
|
164769
|
+
result TEXT,
|
|
164770
|
+
cost_tokens INTEGER DEFAULT 0,
|
|
164771
|
+
cost_usd REAL DEFAULT 0,
|
|
164772
|
+
created_at INTEGER NOT NULL,
|
|
164773
|
+
started_at INTEGER,
|
|
164774
|
+
completed_at INTEGER
|
|
164775
|
+
)
|
|
164776
|
+
`, CREATE_INDEX_STATUS = `CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status)`, CREATE_INDEX_CONTEXT = `CREATE INDEX IF NOT EXISTS idx_tasks_context ON tasks(context)`, CREATE_INDEX_SOURCE = `CREATE INDEX IF NOT EXISTS idx_tasks_source ON tasks(source)`, INSERT_SQL = `
|
|
164777
|
+
INSERT INTO tasks (id, source, context, status, priority, payload, agent_assigned, session_id, result, cost_tokens, cost_usd, created_at, started_at, completed_at)
|
|
164778
|
+
VALUES ($id, $source, $context, $status, $priority, $payload, $agent_assigned, $session_id, $result, $cost_tokens, $cost_usd, $created_at, $started_at, $completed_at)
|
|
164779
|
+
`, SELECT_BY_ID_SQL = `SELECT * FROM tasks WHERE id = $id`, DELETE_BY_ID_SQL = `DELETE FROM tasks WHERE id = $id`, UPDATE_SQL = `
|
|
164780
|
+
UPDATE tasks SET
|
|
164781
|
+
status = COALESCE($status, status),
|
|
164782
|
+
priority = COALESCE($priority, priority),
|
|
164783
|
+
agent_assigned = COALESCE($agent_assigned, agent_assigned),
|
|
164784
|
+
session_id = COALESCE($session_id, session_id),
|
|
164785
|
+
result = COALESCE($result, result),
|
|
164786
|
+
cost_tokens = COALESCE($cost_tokens, cost_tokens),
|
|
164787
|
+
cost_usd = COALESCE($cost_usd, cost_usd),
|
|
164788
|
+
started_at = COALESCE($started_at, started_at),
|
|
164789
|
+
completed_at = COALESCE($completed_at, completed_at)
|
|
164790
|
+
WHERE id = $id
|
|
164791
|
+
`;
|
|
164792
|
+
var init_ledger = __esm(() => {
|
|
164793
|
+
init_schema2();
|
|
164794
|
+
});
|
|
164795
|
+
|
|
164796
|
+
// packages/task-ledger-core/src/sqlite.ts
|
|
164797
|
+
import { Database as Database2 } from "bun:sqlite";
|
|
164798
|
+
function createSqliteDatabase(dbPath) {
|
|
164799
|
+
const db = new Database2(dbPath);
|
|
164800
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
164801
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
164802
|
+
return {
|
|
164803
|
+
exec(sql, ...params) {
|
|
164804
|
+
if (params.length === 0) {
|
|
164805
|
+
db.run(sql);
|
|
164806
|
+
} else {
|
|
164807
|
+
const named = params[0];
|
|
164808
|
+
db.run(sql, named);
|
|
164809
|
+
}
|
|
164810
|
+
},
|
|
164811
|
+
query(sql, ...params) {
|
|
164812
|
+
if (params.length === 0) {
|
|
164813
|
+
return db.prepare(sql).all();
|
|
164814
|
+
}
|
|
164815
|
+
const named = params[0];
|
|
164816
|
+
return db.prepare(sql).all(named);
|
|
164817
|
+
},
|
|
164818
|
+
close() {
|
|
164819
|
+
db.close();
|
|
164820
|
+
}
|
|
164821
|
+
};
|
|
164822
|
+
}
|
|
164823
|
+
var init_sqlite = () => {};
|
|
164824
|
+
|
|
164825
|
+
// packages/task-ledger-core/src/index.ts
|
|
164826
|
+
var init_src6 = __esm(() => {
|
|
164827
|
+
init_schema2();
|
|
164828
|
+
init_ledger();
|
|
164829
|
+
init_sqlite();
|
|
164830
|
+
});
|
|
164831
|
+
|
|
164476
164832
|
// packages/omo-opencode/src/cli/generate.ts
|
|
164477
164833
|
var exports_generate = {};
|
|
164478
164834
|
__export(exports_generate, {
|
|
@@ -165075,6 +165431,264 @@ var init_export = __esm(() => {
|
|
|
165075
165431
|
};
|
|
165076
165432
|
});
|
|
165077
165433
|
|
|
165434
|
+
// packages/omo-opencode/src/project/project-context.ts
|
|
165435
|
+
var exports_project_context = {};
|
|
165436
|
+
__export(exports_project_context, {
|
|
165437
|
+
unarchiveProject: () => unarchiveProject,
|
|
165438
|
+
switchProject: () => switchProject,
|
|
165439
|
+
saveState: () => saveState,
|
|
165440
|
+
saveProjectMeta: () => saveProjectMeta,
|
|
165441
|
+
loadState: () => loadState,
|
|
165442
|
+
loadProjectMeta: () => loadProjectMeta,
|
|
165443
|
+
listProjects: () => listProjects,
|
|
165444
|
+
initProjectFiles: () => initProjectFiles,
|
|
165445
|
+
getStatePath: () => getStatePath,
|
|
165446
|
+
getProjectsDir: () => getProjectsDir,
|
|
165447
|
+
getProjectDir: () => getProjectDir,
|
|
165448
|
+
getMatrixOsDir: () => getMatrixOsDir,
|
|
165449
|
+
getActiveProject: () => getActiveProject,
|
|
165450
|
+
deleteProject: () => deleteProject,
|
|
165451
|
+
createProject: () => createProject,
|
|
165452
|
+
archiveProject: () => archiveProject
|
|
165453
|
+
});
|
|
165454
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync27, readFileSync as readFileSync60, writeFileSync as writeFileSync27, rmSync as rmSync8 } from "fs";
|
|
165455
|
+
import { join as join81 } from "path";
|
|
165456
|
+
function getMatrixOsDir(cwd = process.cwd()) {
|
|
165457
|
+
return join81(cwd, ".matrixos");
|
|
165458
|
+
}
|
|
165459
|
+
function getProjectsDir(cwd) {
|
|
165460
|
+
return join81(getMatrixOsDir(cwd), "projects");
|
|
165461
|
+
}
|
|
165462
|
+
function getProjectDir(slug, cwd) {
|
|
165463
|
+
return join81(getProjectsDir(cwd), slug);
|
|
165464
|
+
}
|
|
165465
|
+
function getStatePath(cwd) {
|
|
165466
|
+
return join81(getMatrixOsDir(cwd), "state.json");
|
|
165467
|
+
}
|
|
165468
|
+
function loadState(cwd) {
|
|
165469
|
+
const path29 = getStatePath(cwd);
|
|
165470
|
+
if (!existsSync75(path29))
|
|
165471
|
+
return {};
|
|
165472
|
+
try {
|
|
165473
|
+
return JSON.parse(readFileSync60(path29, "utf-8"));
|
|
165474
|
+
} catch {
|
|
165475
|
+
return {};
|
|
165476
|
+
}
|
|
165477
|
+
}
|
|
165478
|
+
function saveState(state2, cwd) {
|
|
165479
|
+
const path29 = getStatePath(cwd);
|
|
165480
|
+
mkdirSync27(getMatrixOsDir(cwd), { recursive: true });
|
|
165481
|
+
writeFileSync27(path29, JSON.stringify(state2, null, 2) + `
|
|
165482
|
+
`);
|
|
165483
|
+
}
|
|
165484
|
+
function loadProjectMeta(slug, cwd) {
|
|
165485
|
+
const path29 = join81(getProjectDir(slug, cwd), "meta.json");
|
|
165486
|
+
if (!existsSync75(path29))
|
|
165487
|
+
return null;
|
|
165488
|
+
try {
|
|
165489
|
+
return JSON.parse(readFileSync60(path29, "utf-8"));
|
|
165490
|
+
} catch {
|
|
165491
|
+
return null;
|
|
165492
|
+
}
|
|
165493
|
+
}
|
|
165494
|
+
function saveProjectMeta(slug, meta3, cwd) {
|
|
165495
|
+
const dir = getProjectDir(slug, cwd);
|
|
165496
|
+
mkdirSync27(dir, { recursive: true });
|
|
165497
|
+
const path29 = join81(dir, "meta.json");
|
|
165498
|
+
writeFileSync27(path29, JSON.stringify(meta3, null, 2) + `
|
|
165499
|
+
`);
|
|
165500
|
+
}
|
|
165501
|
+
function initProjectFiles(slug, cwd) {
|
|
165502
|
+
const dir = getProjectDir(slug, cwd);
|
|
165503
|
+
mkdirSync27(join81(dir, "kb"), { recursive: true });
|
|
165504
|
+
const kanbanPath = join81(dir, "kanban.json");
|
|
165505
|
+
if (!existsSync75(kanbanPath)) {
|
|
165506
|
+
writeFileSync27(kanbanPath, JSON.stringify({ columns: ["todo", "in-progress", "review", "done"], tasks: [] }, null, 2) + `
|
|
165507
|
+
`);
|
|
165508
|
+
}
|
|
165509
|
+
}
|
|
165510
|
+
function createProject(slug, options = {}) {
|
|
165511
|
+
if (!/^[a-z0-9_-]+$/.test(slug)) {
|
|
165512
|
+
throw new Error(`Invalid project slug "${slug}": only lowercase letters, numbers, - and _ are allowed.`);
|
|
165513
|
+
}
|
|
165514
|
+
const dir = getProjectDir(slug, options.cwd);
|
|
165515
|
+
if (existsSync75(dir)) {
|
|
165516
|
+
throw new Error(`Project "${slug}" already exists.`);
|
|
165517
|
+
}
|
|
165518
|
+
const now = new Date().toISOString();
|
|
165519
|
+
const meta3 = {
|
|
165520
|
+
slug,
|
|
165521
|
+
name: options.name || slug,
|
|
165522
|
+
description: options.description,
|
|
165523
|
+
createdAt: now
|
|
165524
|
+
};
|
|
165525
|
+
saveProjectMeta(slug, meta3, options.cwd);
|
|
165526
|
+
initProjectFiles(slug, options.cwd);
|
|
165527
|
+
const state2 = loadState(options.cwd);
|
|
165528
|
+
if (!state2.activeProject) {
|
|
165529
|
+
saveState({ ...state2, activeProject: slug }, options.cwd);
|
|
165530
|
+
}
|
|
165531
|
+
return { slug, meta: meta3, active: state2.activeProject === slug || !state2.activeProject };
|
|
165532
|
+
}
|
|
165533
|
+
function listProjects(cwd) {
|
|
165534
|
+
const state2 = loadState(cwd);
|
|
165535
|
+
const root = getProjectsDir(cwd);
|
|
165536
|
+
if (!existsSync75(root))
|
|
165537
|
+
return [];
|
|
165538
|
+
const fs24 = __require("fs");
|
|
165539
|
+
const items = [];
|
|
165540
|
+
for (const slug of fs24.readdirSync(root, { withFileTypes: true })) {
|
|
165541
|
+
if (!slug.isDirectory())
|
|
165542
|
+
continue;
|
|
165543
|
+
const meta3 = loadProjectMeta(slug.name, cwd);
|
|
165544
|
+
if (!meta3)
|
|
165545
|
+
continue;
|
|
165546
|
+
items.push({ slug: slug.name, meta: meta3, active: state2.activeProject === slug.name });
|
|
165547
|
+
}
|
|
165548
|
+
return items.sort((a2, b2) => a2.slug.localeCompare(b2.slug));
|
|
165549
|
+
}
|
|
165550
|
+
function switchProject(slug, cwd) {
|
|
165551
|
+
const meta3 = loadProjectMeta(slug, cwd);
|
|
165552
|
+
if (!meta3)
|
|
165553
|
+
throw new Error(`Project "${slug}" does not exist.`);
|
|
165554
|
+
if (meta3.archived)
|
|
165555
|
+
throw new Error(`Project "${slug}" is archived. Unarchive it before switching.`);
|
|
165556
|
+
const state2 = loadState(cwd);
|
|
165557
|
+
saveState({ ...state2, activeProject: slug }, cwd);
|
|
165558
|
+
return { slug, meta: meta3, active: true };
|
|
165559
|
+
}
|
|
165560
|
+
function archiveProject(slug, cwd) {
|
|
165561
|
+
const meta3 = loadProjectMeta(slug, cwd);
|
|
165562
|
+
if (!meta3)
|
|
165563
|
+
throw new Error(`Project "${slug}" does not exist.`);
|
|
165564
|
+
const now = new Date().toISOString();
|
|
165565
|
+
const next = { ...meta3, archived: true, archivedAt: now };
|
|
165566
|
+
saveProjectMeta(slug, next, cwd);
|
|
165567
|
+
const state2 = loadState(cwd);
|
|
165568
|
+
if (state2.activeProject === slug) {
|
|
165569
|
+
saveState({ ...state2, activeProject: undefined }, cwd);
|
|
165570
|
+
}
|
|
165571
|
+
return { slug, meta: next, active: false };
|
|
165572
|
+
}
|
|
165573
|
+
function unarchiveProject(slug, cwd) {
|
|
165574
|
+
const meta3 = loadProjectMeta(slug, cwd);
|
|
165575
|
+
if (!meta3)
|
|
165576
|
+
throw new Error(`Project "${slug}" does not exist.`);
|
|
165577
|
+
const { archived: _a3, archivedAt: _b, ...rest } = meta3;
|
|
165578
|
+
const next = rest;
|
|
165579
|
+
saveProjectMeta(slug, next, cwd);
|
|
165580
|
+
return { slug, meta: next, active: loadState(cwd).activeProject === slug };
|
|
165581
|
+
}
|
|
165582
|
+
function deleteProject(slug, cwd) {
|
|
165583
|
+
const dir = getProjectDir(slug, cwd);
|
|
165584
|
+
if (!existsSync75(dir))
|
|
165585
|
+
throw new Error(`Project "${slug}" does not exist.`);
|
|
165586
|
+
rmSync8(dir, { recursive: true, force: true });
|
|
165587
|
+
const state2 = loadState(cwd);
|
|
165588
|
+
if (state2.activeProject === slug) {
|
|
165589
|
+
saveState({ ...state2, activeProject: undefined }, cwd);
|
|
165590
|
+
}
|
|
165591
|
+
}
|
|
165592
|
+
function getActiveProject(cwd) {
|
|
165593
|
+
const state2 = loadState(cwd);
|
|
165594
|
+
if (!state2.activeProject)
|
|
165595
|
+
return null;
|
|
165596
|
+
const meta3 = loadProjectMeta(state2.activeProject, cwd);
|
|
165597
|
+
if (!meta3) {
|
|
165598
|
+
saveState({ ...state2, activeProject: undefined }, cwd);
|
|
165599
|
+
return null;
|
|
165600
|
+
}
|
|
165601
|
+
return { slug: state2.activeProject, meta: meta3, active: true };
|
|
165602
|
+
}
|
|
165603
|
+
var init_project_context = () => {};
|
|
165604
|
+
|
|
165605
|
+
// packages/omo-opencode/src/project/project-memory.ts
|
|
165606
|
+
var exports_project_memory = {};
|
|
165607
|
+
__export(exports_project_memory, {
|
|
165608
|
+
tagWithProject: () => tagWithProject,
|
|
165609
|
+
searchProject: () => searchProject,
|
|
165610
|
+
searchKb: () => searchKb,
|
|
165611
|
+
listKbDocuments: () => listKbDocuments,
|
|
165612
|
+
isProjectEpisode: () => isProjectEpisode,
|
|
165613
|
+
addKbDocument: () => addKbDocument
|
|
165614
|
+
});
|
|
165615
|
+
import { existsSync as existsSync76, mkdirSync as mkdirSync28, readFileSync as readFileSync61, readdirSync as readdirSync16, writeFileSync as writeFileSync28 } from "fs";
|
|
165616
|
+
import { join as join82 } from "path";
|
|
165617
|
+
function tagWithProject(metadata = {}, projectSlug, cwd) {
|
|
165618
|
+
const active = projectSlug ?? getActiveProject(cwd)?.slug;
|
|
165619
|
+
if (!active)
|
|
165620
|
+
return metadata;
|
|
165621
|
+
return { ...metadata, project: active };
|
|
165622
|
+
}
|
|
165623
|
+
function isProjectEpisode(ep, projectSlug, cwd) {
|
|
165624
|
+
const target = projectSlug ?? getActiveProject(cwd)?.slug;
|
|
165625
|
+
if (!target)
|
|
165626
|
+
return true;
|
|
165627
|
+
return ep.metadata?.project === target;
|
|
165628
|
+
}
|
|
165629
|
+
function listKbDocuments(projectSlug, cwd) {
|
|
165630
|
+
const kbDir = join82(getProjectDir(projectSlug, cwd), "kb");
|
|
165631
|
+
if (!existsSync76(kbDir))
|
|
165632
|
+
return [];
|
|
165633
|
+
const docs = [];
|
|
165634
|
+
for (const entry of readdirSync16(kbDir, { withFileTypes: true })) {
|
|
165635
|
+
if (!entry.isFile())
|
|
165636
|
+
continue;
|
|
165637
|
+
const path29 = join82(kbDir, entry.name);
|
|
165638
|
+
try {
|
|
165639
|
+
docs.push({ path: path29, content: readFileSync61(path29, "utf-8") });
|
|
165640
|
+
} catch {}
|
|
165641
|
+
}
|
|
165642
|
+
return docs;
|
|
165643
|
+
}
|
|
165644
|
+
function searchKb(projectSlug, query, cwd) {
|
|
165645
|
+
const needle = query.toLowerCase();
|
|
165646
|
+
const docs = listKbDocuments(projectSlug, cwd);
|
|
165647
|
+
const results = [];
|
|
165648
|
+
for (const doc2 of docs) {
|
|
165649
|
+
const content = doc2.content.toLowerCase();
|
|
165650
|
+
const matches = content.split(needle).length - 1;
|
|
165651
|
+
if (matches > 0) {
|
|
165652
|
+
results.push({
|
|
165653
|
+
project: projectSlug,
|
|
165654
|
+
source: "kb",
|
|
165655
|
+
path: doc2.path,
|
|
165656
|
+
content: doc2.content.slice(0, 240),
|
|
165657
|
+
score: matches
|
|
165658
|
+
});
|
|
165659
|
+
}
|
|
165660
|
+
}
|
|
165661
|
+
return results.sort((a2, b2) => b2.score - a2.score);
|
|
165662
|
+
}
|
|
165663
|
+
async function searchProject(query, options = {}) {
|
|
165664
|
+
const projectSlug = options.projectSlug ?? getActiveProject(options.cwd)?.slug;
|
|
165665
|
+
if (!projectSlug)
|
|
165666
|
+
return [];
|
|
165667
|
+
const kbHits = searchKb(projectSlug, query, options.cwd);
|
|
165668
|
+
let memoryHits = [];
|
|
165669
|
+
if (options.memoryStore) {
|
|
165670
|
+
const episodes = options.memoryStore.searchEpisodes?.({ textContains: query, limit: 20 }) ?? [];
|
|
165671
|
+
memoryHits = episodes.filter((ep) => ep.metadata?.project === projectSlug).map((ep) => ({
|
|
165672
|
+
project: projectSlug,
|
|
165673
|
+
source: "episode",
|
|
165674
|
+
summary: ep.summary,
|
|
165675
|
+
score: 1
|
|
165676
|
+
}));
|
|
165677
|
+
}
|
|
165678
|
+
return [...kbHits, ...memoryHits].sort((a2, b2) => b2.score - a2.score);
|
|
165679
|
+
}
|
|
165680
|
+
function addKbDocument(projectSlug, filename, content, cwd) {
|
|
165681
|
+
const kbDir = join82(getProjectDir(projectSlug, cwd), "kb");
|
|
165682
|
+
mkdirSync28(kbDir, { recursive: true });
|
|
165683
|
+
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
165684
|
+
const path29 = join82(kbDir, safeName);
|
|
165685
|
+
writeFileSync28(path29, content, "utf-8");
|
|
165686
|
+
return path29;
|
|
165687
|
+
}
|
|
165688
|
+
var init_project_memory = __esm(() => {
|
|
165689
|
+
init_project_context();
|
|
165690
|
+
});
|
|
165691
|
+
|
|
165078
165692
|
// packages/omo-opencode/src/cli/adopt.ts
|
|
165079
165693
|
var exports_adopt = {};
|
|
165080
165694
|
__export(exports_adopt, {
|
|
@@ -165196,6 +165810,13 @@ async function runAdopt(options = {}) {
|
|
|
165196
165810
|
message: "Global adoption requires an interactive terminal. Run: matrixos adopt (no arguments)."
|
|
165197
165811
|
};
|
|
165198
165812
|
}
|
|
165813
|
+
if (!process.stdin.isTTY) {
|
|
165814
|
+
return {
|
|
165815
|
+
ok: false,
|
|
165816
|
+
message: `Cannot run interactive adoption: stdin is not a TTY.
|
|
165817
|
+
` + "Run in a terminal, or use: matrixos gateway adopt telegram --token <token>"
|
|
165818
|
+
};
|
|
165819
|
+
}
|
|
165199
165820
|
console.log(`
|
|
165200
165821
|
=== MaTrixOS Re-Adoption ===`);
|
|
165201
165822
|
console.log(`You can reconfigure providers, channels, and profile.
|
|
@@ -165402,12 +166023,12 @@ __export(exports_gateway_start, {
|
|
|
165402
166023
|
buildTelegramConfig: () => buildTelegramConfig,
|
|
165403
166024
|
buildGatewayConfig: () => buildGatewayConfig
|
|
165404
166025
|
});
|
|
165405
|
-
import { readFileSync as
|
|
166026
|
+
import { readFileSync as readFileSync62, existsSync as existsSync77 } from "fs";
|
|
165406
166027
|
import { resolve as resolve19 } from "path";
|
|
165407
166028
|
function loadGatewayEnv(path29 = ENV_PATH) {
|
|
165408
|
-
if (!
|
|
166029
|
+
if (!existsSync77(path29))
|
|
165409
166030
|
return {};
|
|
165410
|
-
const text =
|
|
166031
|
+
const text = readFileSync62(path29, "utf8");
|
|
165411
166032
|
const out = {};
|
|
165412
166033
|
for (const raw of text.split(/\r?\n/)) {
|
|
165413
166034
|
const line = raw.trim();
|
|
@@ -165527,6 +166148,537 @@ var init_gateway_start = __esm(() => {
|
|
|
165527
166148
|
ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
|
|
165528
166149
|
});
|
|
165529
166150
|
|
|
166151
|
+
// packages/omo-opencode/src/deployment/deployment-core.ts
|
|
166152
|
+
function registerTarget(target) {
|
|
166153
|
+
targets.set(target.name, target);
|
|
166154
|
+
}
|
|
166155
|
+
function getTarget(name2) {
|
|
166156
|
+
return targets.get(name2);
|
|
166157
|
+
}
|
|
166158
|
+
function listTargets() {
|
|
166159
|
+
return Array.from(targets.keys());
|
|
166160
|
+
}
|
|
166161
|
+
var targets;
|
|
166162
|
+
var init_deployment_core = __esm(() => {
|
|
166163
|
+
targets = new Map;
|
|
166164
|
+
});
|
|
166165
|
+
|
|
166166
|
+
// packages/omo-opencode/src/deployment/deploy-static.ts
|
|
166167
|
+
import { spawn as spawn6 } from "child_process";
|
|
166168
|
+
import { existsSync as existsSync78 } from "fs";
|
|
166169
|
+
import { resolve as resolve20 } from "path";
|
|
166170
|
+
function pushStage(stage, message, ok = true) {
|
|
166171
|
+
return { stage, message, ok };
|
|
166172
|
+
}
|
|
166173
|
+
function run2(cmd, args, cwd) {
|
|
166174
|
+
return new Promise((resolve21) => {
|
|
166175
|
+
let output = "";
|
|
166176
|
+
let error51 = "";
|
|
166177
|
+
const child = spawn6(cmd, args, { cwd, shell: false });
|
|
166178
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166179
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166180
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166181
|
+
});
|
|
166182
|
+
}
|
|
166183
|
+
var deployStatic;
|
|
166184
|
+
var init_deploy_static = __esm(() => {
|
|
166185
|
+
deployStatic = {
|
|
166186
|
+
name: "static",
|
|
166187
|
+
async deploy(ctx, params) {
|
|
166188
|
+
const stages = [];
|
|
166189
|
+
const buildDir = resolve20(ctx.projectRoot, params.buildDir ?? "dist");
|
|
166190
|
+
const destination = params.destination;
|
|
166191
|
+
const prebuild = params.prebuild ?? "bun run build";
|
|
166192
|
+
try {
|
|
166193
|
+
if (!destination) {
|
|
166194
|
+
return { target: "static", ok: false, stages: [pushStage("build", "missing destination parameter", false)], error: "missing destination" };
|
|
166195
|
+
}
|
|
166196
|
+
if (ctx.environment === "production" && ctx.requireValidation && !params.force) {
|
|
166197
|
+
return {
|
|
166198
|
+
target: "static",
|
|
166199
|
+
ok: false,
|
|
166200
|
+
stages: [pushStage("build", "production deploy requires explicit validation (force=true or use staging)", false)],
|
|
166201
|
+
error: "validation required"
|
|
166202
|
+
};
|
|
166203
|
+
}
|
|
166204
|
+
if (!ctx.execute) {
|
|
166205
|
+
return {
|
|
166206
|
+
target: "static",
|
|
166207
|
+
ok: true,
|
|
166208
|
+
url: destination,
|
|
166209
|
+
stages: [
|
|
166210
|
+
pushStage("build", `dry-run: would run '${prebuild}' in ${ctx.projectRoot}`),
|
|
166211
|
+
pushStage("push", `dry-run: would rsync ${buildDir} to ${destination}`),
|
|
166212
|
+
pushStage("verify", "dry-run: would verify 200 from deployed URL")
|
|
166213
|
+
]
|
|
166214
|
+
};
|
|
166215
|
+
}
|
|
166216
|
+
if (prebuild) {
|
|
166217
|
+
stages.push(pushStage("build", `running '${prebuild}'...`));
|
|
166218
|
+
const build = await run2(prebuild, [], ctx.projectRoot);
|
|
166219
|
+
if (!build.ok) {
|
|
166220
|
+
stages.push(pushStage("build", `build failed: ${build.error}`, false));
|
|
166221
|
+
return { target: "static", ok: false, stages, error: build.error };
|
|
166222
|
+
}
|
|
166223
|
+
stages.push(pushStage("build", "build succeeded"));
|
|
166224
|
+
}
|
|
166225
|
+
if (!existsSync78(buildDir)) {
|
|
166226
|
+
stages.push(pushStage("push", `build directory not found: ${buildDir}`, false));
|
|
166227
|
+
return { target: "static", ok: false, stages, error: "build directory missing" };
|
|
166228
|
+
}
|
|
166229
|
+
stages.push(pushStage("push", `syncing ${buildDir} to ${destination}...`));
|
|
166230
|
+
const rsync = await run2("rsync", ["-avz", "--delete", buildDir + "/", destination], ctx.projectRoot);
|
|
166231
|
+
if (!rsync.ok) {
|
|
166232
|
+
stages.push(pushStage("push", `rsync failed: ${rsync.error}`, false));
|
|
166233
|
+
return { target: "static", ok: false, stages, error: rsync.error };
|
|
166234
|
+
}
|
|
166235
|
+
stages.push(pushStage("push", "sync complete"));
|
|
166236
|
+
const url3 = params.verifyUrl;
|
|
166237
|
+
if (url3) {
|
|
166238
|
+
stages.push(pushStage("verify", `checking ${url3}...`));
|
|
166239
|
+
const check2 = await run2("curl", ["-sf", url3], ctx.projectRoot);
|
|
166240
|
+
if (!check2.ok) {
|
|
166241
|
+
stages.push(pushStage("verify", `verify failed: ${check2.error}`, false));
|
|
166242
|
+
return { target: "static", ok: false, stages, error: check2.error };
|
|
166243
|
+
}
|
|
166244
|
+
stages.push(pushStage("verify", "verify ok"));
|
|
166245
|
+
}
|
|
166246
|
+
return { target: "static", ok: true, url: url3, stages };
|
|
166247
|
+
} catch (err) {
|
|
166248
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166249
|
+
stages.push(pushStage("done", `unexpected error: ${error51}`, false));
|
|
166250
|
+
return { target: "static", ok: false, stages, error: error51 };
|
|
166251
|
+
}
|
|
166252
|
+
}
|
|
166253
|
+
};
|
|
166254
|
+
});
|
|
166255
|
+
|
|
166256
|
+
// packages/omo-opencode/src/deployment/deploy-vercel.ts
|
|
166257
|
+
import { spawn as spawn7 } from "child_process";
|
|
166258
|
+
function pushStage2(stage, message, ok = true) {
|
|
166259
|
+
return { stage, message, ok };
|
|
166260
|
+
}
|
|
166261
|
+
function run3(cmd, args, cwd, env5) {
|
|
166262
|
+
return new Promise((resolve21) => {
|
|
166263
|
+
let output = "";
|
|
166264
|
+
let error51 = "";
|
|
166265
|
+
const child = spawn7(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
|
|
166266
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166267
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166268
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166269
|
+
});
|
|
166270
|
+
}
|
|
166271
|
+
var deployVercel;
|
|
166272
|
+
var init_deploy_vercel = __esm(() => {
|
|
166273
|
+
deployVercel = {
|
|
166274
|
+
name: "vercel",
|
|
166275
|
+
async deploy(ctx, params) {
|
|
166276
|
+
const stages = [];
|
|
166277
|
+
const prod = ctx.environment === "production";
|
|
166278
|
+
const token = process.env.VERCEL_TOKEN || params.token;
|
|
166279
|
+
try {
|
|
166280
|
+
if (prod && ctx.requireValidation && !params.force) {
|
|
166281
|
+
return {
|
|
166282
|
+
target: "vercel",
|
|
166283
|
+
ok: false,
|
|
166284
|
+
stages: [pushStage2("build", "production deploy to Vercel requires explicit validation", false)],
|
|
166285
|
+
error: "validation required"
|
|
166286
|
+
};
|
|
166287
|
+
}
|
|
166288
|
+
if (!ctx.execute) {
|
|
166289
|
+
return {
|
|
166290
|
+
target: "vercel",
|
|
166291
|
+
ok: true,
|
|
166292
|
+
stages: [
|
|
166293
|
+
pushStage2("build", `dry-run: would run vercel deploy${prod ? " --prod" : ""}`),
|
|
166294
|
+
pushStage2("verify", "dry-run: would verify deployment URL")
|
|
166295
|
+
]
|
|
166296
|
+
};
|
|
166297
|
+
}
|
|
166298
|
+
if (!token && prod) {
|
|
166299
|
+
stages.push(pushStage2("build", "VERCEL_TOKEN missing", false));
|
|
166300
|
+
return { target: "vercel", ok: false, stages, error: "missing VERCEL_TOKEN" };
|
|
166301
|
+
}
|
|
166302
|
+
const args = ["deploy"];
|
|
166303
|
+
if (prod)
|
|
166304
|
+
args.push("--prod");
|
|
166305
|
+
if (token)
|
|
166306
|
+
args.push("--token", token);
|
|
166307
|
+
if (params.scope)
|
|
166308
|
+
args.push("--scope", params.scope);
|
|
166309
|
+
stages.push(pushStage2("push", `vercel ${args.join(" ")}...`));
|
|
166310
|
+
const result = await run3("vercel", args, ctx.projectRoot, token ? { VERCEL_TOKEN: token } : undefined);
|
|
166311
|
+
if (!result.ok) {
|
|
166312
|
+
stages.push(pushStage2("push", `vercel deploy failed: ${result.error}`, false));
|
|
166313
|
+
return { target: "vercel", ok: false, stages, error: result.error };
|
|
166314
|
+
}
|
|
166315
|
+
const urlMatch = result.output.match(/https:\/\/[^\s]+\.vercel\.app/);
|
|
166316
|
+
const url3 = urlMatch?.[0];
|
|
166317
|
+
stages.push(pushStage2("verify", url3 ? `deployed to ${url3}` : "deployed (URL not parsed)"));
|
|
166318
|
+
return { target: "vercel", ok: true, url: url3, stages };
|
|
166319
|
+
} catch (err) {
|
|
166320
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166321
|
+
stages.push(pushStage2("done", `unexpected error: ${error51}`, false));
|
|
166322
|
+
return { target: "vercel", ok: false, stages, error: error51 };
|
|
166323
|
+
}
|
|
166324
|
+
}
|
|
166325
|
+
};
|
|
166326
|
+
});
|
|
166327
|
+
|
|
166328
|
+
// packages/omo-opencode/src/deployment/deploy-vps.ts
|
|
166329
|
+
import { spawn as spawn8 } from "child_process";
|
|
166330
|
+
function pushStage3(stage, message, ok = true) {
|
|
166331
|
+
return { stage, message, ok };
|
|
166332
|
+
}
|
|
166333
|
+
function run4(cmd, args, cwd, env5) {
|
|
166334
|
+
return new Promise((resolve21) => {
|
|
166335
|
+
let output = "";
|
|
166336
|
+
let error51 = "";
|
|
166337
|
+
const child = spawn8(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
|
|
166338
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166339
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166340
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166341
|
+
});
|
|
166342
|
+
}
|
|
166343
|
+
var deployVps;
|
|
166344
|
+
var init_deploy_vps = __esm(() => {
|
|
166345
|
+
deployVps = {
|
|
166346
|
+
name: "vps",
|
|
166347
|
+
async deploy(ctx, params) {
|
|
166348
|
+
const stages = [];
|
|
166349
|
+
const host = params.host;
|
|
166350
|
+
const user = params.user ?? "deploy";
|
|
166351
|
+
const remoteDir = params.remoteDir;
|
|
166352
|
+
const buildDir = params.buildDir ?? "dist";
|
|
166353
|
+
const service = params.service;
|
|
166354
|
+
const healthUrl = params.healthUrl;
|
|
166355
|
+
try {
|
|
166356
|
+
if (!host || !remoteDir) {
|
|
166357
|
+
return { target: "vps", ok: false, stages: [pushStage3("build", "missing host or remoteDir", false)], error: "missing parameters" };
|
|
166358
|
+
}
|
|
166359
|
+
if (ctx.environment === "production" && ctx.requireValidation && !params.force) {
|
|
166360
|
+
return {
|
|
166361
|
+
target: "vps",
|
|
166362
|
+
ok: false,
|
|
166363
|
+
stages: [pushStage3("build", "production deploy to VPS requires explicit validation", false)],
|
|
166364
|
+
error: "validation required"
|
|
166365
|
+
};
|
|
166366
|
+
}
|
|
166367
|
+
if (!ctx.execute) {
|
|
166368
|
+
return {
|
|
166369
|
+
target: "vps",
|
|
166370
|
+
ok: true,
|
|
166371
|
+
stages: [
|
|
166372
|
+
pushStage3("build", `dry-run: would build in ${ctx.projectRoot}`),
|
|
166373
|
+
pushStage3("push", `dry-run: would rsync ${buildDir} to ${user}@${host}:${remoteDir}`),
|
|
166374
|
+
pushStage3("verify", `dry-run: would restart ${service ?? "service"} + health check ${healthUrl ?? ""}`)
|
|
166375
|
+
]
|
|
166376
|
+
};
|
|
166377
|
+
}
|
|
166378
|
+
stages.push(pushStage3("build", "building..."));
|
|
166379
|
+
const build = await run4("bun", ["run", "build"], ctx.projectRoot);
|
|
166380
|
+
if (!build.ok) {
|
|
166381
|
+
stages.push(pushStage3("build", `build failed: ${build.error}`, false));
|
|
166382
|
+
return { target: "vps", ok: false, stages, error: build.error };
|
|
166383
|
+
}
|
|
166384
|
+
stages.push(pushStage3("build", "build ok"));
|
|
166385
|
+
stages.push(pushStage3("push", `rsync to ${host}...`));
|
|
166386
|
+
const rsync = await run4("rsync", ["-avz", "--delete", `${buildDir}/`, `${user}@${host}:${remoteDir}/`], ctx.projectRoot);
|
|
166387
|
+
if (!rsync.ok) {
|
|
166388
|
+
stages.push(pushStage3("push", `rsync failed: ${rsync.error}`, false));
|
|
166389
|
+
return { target: "vps", ok: false, stages, error: rsync.error };
|
|
166390
|
+
}
|
|
166391
|
+
stages.push(pushStage3("push", "rsync ok"));
|
|
166392
|
+
if (service) {
|
|
166393
|
+
stages.push(pushStage3("verify", `restarting ${service}...`));
|
|
166394
|
+
const restart = await run4("ssh", [`${user}@${host}`, `sudo systemctl restart ${service}`], ctx.projectRoot);
|
|
166395
|
+
if (!restart.ok) {
|
|
166396
|
+
stages.push(pushStage3("verify", `restart failed: ${restart.error}`, false));
|
|
166397
|
+
return { target: "vps", ok: false, stages, error: restart.error };
|
|
166398
|
+
}
|
|
166399
|
+
stages.push(pushStage3("verify", "restart ok"));
|
|
166400
|
+
}
|
|
166401
|
+
if (healthUrl) {
|
|
166402
|
+
stages.push(pushStage3("verify", `health check ${healthUrl}...`));
|
|
166403
|
+
await new Promise((r2) => setTimeout(r2, 2000));
|
|
166404
|
+
const health = await run4("curl", ["-sf", healthUrl], ctx.projectRoot);
|
|
166405
|
+
if (!health.ok) {
|
|
166406
|
+
stages.push(pushStage3("verify", `health check failed: ${health.error}`, false));
|
|
166407
|
+
return { target: "vps", ok: false, stages, error: health.error };
|
|
166408
|
+
}
|
|
166409
|
+
stages.push(pushStage3("verify", "health ok"));
|
|
166410
|
+
}
|
|
166411
|
+
return { target: "vps", ok: true, url: healthUrl, stages };
|
|
166412
|
+
} catch (err) {
|
|
166413
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166414
|
+
stages.push(pushStage3("done", `unexpected error: ${error51}`, false));
|
|
166415
|
+
return { target: "vps", ok: false, stages, error: error51 };
|
|
166416
|
+
}
|
|
166417
|
+
}
|
|
166418
|
+
};
|
|
166419
|
+
});
|
|
166420
|
+
|
|
166421
|
+
// packages/omo-opencode/src/deployment/deploy-cli.ts
|
|
166422
|
+
import { resolve as resolve21 } from "path";
|
|
166423
|
+
async function runDeploy(options) {
|
|
166424
|
+
const target = getTarget(options.target);
|
|
166425
|
+
if (!target) {
|
|
166426
|
+
console.error(`Unknown deployment target: ${options.target}`);
|
|
166427
|
+
console.error(`Available: ${["static", "vercel", "vps", "docker", "wordpress"].join(", ")}`);
|
|
166428
|
+
return 1;
|
|
166429
|
+
}
|
|
166430
|
+
const project = options.projectRoot ? undefined : await getActiveProject();
|
|
166431
|
+
if (!options.projectRoot && !project) {
|
|
166432
|
+
console.error("No active project. Run `matrixos project switch <slug>` or pass --project-root.");
|
|
166433
|
+
return 1;
|
|
166434
|
+
}
|
|
166435
|
+
const projectRoot = resolve21(options.projectRoot ?? getProjectDir(project.slug));
|
|
166436
|
+
const ctx = {
|
|
166437
|
+
projectRoot,
|
|
166438
|
+
projectSlug: project?.slug,
|
|
166439
|
+
environment: options.environment ?? (options.dryRun ? "staging" : "production"),
|
|
166440
|
+
execute: !options.dryRun,
|
|
166441
|
+
requireValidation: true
|
|
166442
|
+
};
|
|
166443
|
+
const params = {};
|
|
166444
|
+
for (const p2 of options.params ?? []) {
|
|
166445
|
+
const [key, ...rest] = p2.split("=");
|
|
166446
|
+
if (key)
|
|
166447
|
+
params[key] = rest.join("=");
|
|
166448
|
+
}
|
|
166449
|
+
if (ctx.environment === "production" && ctx.requireValidation && !options.force) {
|
|
166450
|
+
console.warn("Production deployment. This action requires explicit validation.");
|
|
166451
|
+
console.warn("Re-run with --force to confirm, or use --env staging.");
|
|
166452
|
+
return 1;
|
|
166453
|
+
}
|
|
166454
|
+
const result = await target.deploy(ctx, params);
|
|
166455
|
+
if (result.ok) {
|
|
166456
|
+
console.log(`\u2713 Deployed to ${result.target}${result.url ? ` \u2192 ${result.url}` : ""}`);
|
|
166457
|
+
for (const s of result.stages) {
|
|
166458
|
+
console.log(` [${s.stage}] ${s.ok ? "\u2713" : "\u2717"} ${s.message}`);
|
|
166459
|
+
}
|
|
166460
|
+
return 0;
|
|
166461
|
+
}
|
|
166462
|
+
console.error(`\u2717 Deploy to ${result.target} failed: ${result.error ?? "unknown error"}`);
|
|
166463
|
+
for (const s of result.stages) {
|
|
166464
|
+
console.log(` [${s.stage}] ${s.ok ? "\u2713" : "\u2717"} ${s.message}`);
|
|
166465
|
+
}
|
|
166466
|
+
return 1;
|
|
166467
|
+
}
|
|
166468
|
+
var init_deploy_cli = __esm(() => {
|
|
166469
|
+
init_project_context();
|
|
166470
|
+
init_deployment_core();
|
|
166471
|
+
});
|
|
166472
|
+
|
|
166473
|
+
// packages/omo-opencode/src/deployment/index.ts
|
|
166474
|
+
var exports_deployment = {};
|
|
166475
|
+
__export(exports_deployment, {
|
|
166476
|
+
targets: () => targets,
|
|
166477
|
+
runDeploy: () => runDeploy,
|
|
166478
|
+
registerTarget: () => registerTarget,
|
|
166479
|
+
listTargets: () => listTargets,
|
|
166480
|
+
getTarget: () => getTarget,
|
|
166481
|
+
deployVps: () => deployVps,
|
|
166482
|
+
deployVercel: () => deployVercel,
|
|
166483
|
+
deployStatic: () => deployStatic
|
|
166484
|
+
});
|
|
166485
|
+
var init_deployment = __esm(() => {
|
|
166486
|
+
init_deployment_core();
|
|
166487
|
+
init_deploy_static();
|
|
166488
|
+
init_deploy_vercel();
|
|
166489
|
+
init_deploy_vps();
|
|
166490
|
+
init_deploy_static();
|
|
166491
|
+
init_deploy_vercel();
|
|
166492
|
+
init_deploy_vps();
|
|
166493
|
+
init_deploy_cli();
|
|
166494
|
+
init_deployment_core();
|
|
166495
|
+
registerTarget(deployStatic);
|
|
166496
|
+
registerTarget(deployVercel);
|
|
166497
|
+
registerTarget(deployVps);
|
|
166498
|
+
});
|
|
166499
|
+
|
|
166500
|
+
// packages/omo-opencode/src/audit/self-audit.ts
|
|
166501
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync29, readdirSync as readdirSync17, readFileSync as readFileSync63, writeFileSync as writeFileSync29 } from "fs";
|
|
166502
|
+
import { join as join83 } from "path";
|
|
166503
|
+
function getAuditDir(cwd = process.cwd()) {
|
|
166504
|
+
return join83(cwd, ".matrixos", "audits");
|
|
166505
|
+
}
|
|
166506
|
+
function getWeekString(date5 = new Date) {
|
|
166507
|
+
const d = new Date(Date.UTC(date5.getFullYear(), date5.getMonth(), date5.getDate()));
|
|
166508
|
+
const dayNum = d.getUTCDay() || 7;
|
|
166509
|
+
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
166510
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
166511
|
+
const weekNo = Math.ceil(((+d - +yearStart) / 86400000 + 1) / 7);
|
|
166512
|
+
return `${d.getUTCFullYear()}-W${String(weekNo).padStart(2, "0")}`;
|
|
166513
|
+
}
|
|
166514
|
+
function parseWeekDateRange(weekStr) {
|
|
166515
|
+
const [year, week] = weekStr.split("-W").map(Number);
|
|
166516
|
+
const jan4 = new Date(Date.UTC(year, 0, 4));
|
|
166517
|
+
const monday = new Date(Date.UTC(year, 0, 4 - ((jan4.getUTCDay() || 7) - 1) + (week - 1) * 7));
|
|
166518
|
+
const sunday = new Date(+monday + 6 * 86400000);
|
|
166519
|
+
return { from: monday.toISOString().slice(0, 10), to: sunday.toISOString().slice(0, 10) };
|
|
166520
|
+
}
|
|
166521
|
+
function generateAuditReport(tasks, signals, weekStr) {
|
|
166522
|
+
const week = weekStr ?? getWeekString();
|
|
166523
|
+
const period = parseWeekDateRange(week);
|
|
166524
|
+
const summary = {
|
|
166525
|
+
total: tasks.length,
|
|
166526
|
+
done: tasks.filter((t2) => t2.status === "done").length,
|
|
166527
|
+
failed: tasks.filter((t2) => t2.status === "failed").length,
|
|
166528
|
+
inProgress: tasks.filter((t2) => t2.status === "in-progress").length,
|
|
166529
|
+
blocked: tasks.filter((t2) => t2.status === "blocked").length
|
|
166530
|
+
};
|
|
166531
|
+
const byProject = {};
|
|
166532
|
+
for (const t2 of tasks) {
|
|
166533
|
+
const p2 = t2.project || "default";
|
|
166534
|
+
byProject[p2] = byProject[p2] || { done: 0, failed: 0, blocked: 0 };
|
|
166535
|
+
if (t2.status === "done")
|
|
166536
|
+
byProject[p2].done += 1;
|
|
166537
|
+
if (t2.status === "failed")
|
|
166538
|
+
byProject[p2].failed += 1;
|
|
166539
|
+
if (t2.status === "blocked")
|
|
166540
|
+
byProject[p2].blocked += 1;
|
|
166541
|
+
}
|
|
166542
|
+
const errorCounts = new Map;
|
|
166543
|
+
for (const s of signals) {
|
|
166544
|
+
if (s.type !== "error")
|
|
166545
|
+
continue;
|
|
166546
|
+
const key = `${s.project || "global"}: ${s.message}`;
|
|
166547
|
+
errorCounts.set(key, (errorCounts.get(key) || 0) + (s.count || 1));
|
|
166548
|
+
}
|
|
166549
|
+
const topErrors = [...errorCounts.entries()].sort((a2, b2) => b2[1] - a2[1]).slice(0, 5).map(([message, count]) => ({ type: "error", message, count }));
|
|
166550
|
+
const recommendations = [];
|
|
166551
|
+
if (summary.failed > 0) {
|
|
166552
|
+
recommendations.push(`Analyser ${summary.failed} t\xE2che(s) en \xE9chec et cr\xE9er une skill/r\xE8gle par pattern r\xE9current.`);
|
|
166553
|
+
}
|
|
166554
|
+
if (summary.blocked > 0) {
|
|
166555
|
+
recommendations.push(`D\xE9bloquer ${summary.blocked} t\xE2che(s) bloqu\xE9es avant le prochain sprint.`);
|
|
166556
|
+
}
|
|
166557
|
+
if (topErrors.length > 0) {
|
|
166558
|
+
recommendations.push(`Top erreur : "${topErrors[0].message}" \u2014 prioriser un guard/automated fix.`);
|
|
166559
|
+
}
|
|
166560
|
+
if (recommendations.length === 0) {
|
|
166561
|
+
recommendations.push("Semaine propre. Poursuivre la veille et la documentation des d\xE9cisions.");
|
|
166562
|
+
}
|
|
166563
|
+
return { week, period, summary, byProject, topErrors, recommendations };
|
|
166564
|
+
}
|
|
166565
|
+
function formatAuditReport(report) {
|
|
166566
|
+
const lines = [
|
|
166567
|
+
`# Auto-audit hebdomadaire \u2014 ${report.week}`,
|
|
166568
|
+
"",
|
|
166569
|
+
`**P\xE9riode** : ${report.period.from} \u2192 ${report.period.to}`,
|
|
166570
|
+
"",
|
|
166571
|
+
"## R\xE9sum\xE9",
|
|
166572
|
+
"",
|
|
166573
|
+
`| M\xE9trique | Valeur |`,
|
|
166574
|
+
`|----------|--------|`,
|
|
166575
|
+
`| Total | ${report.summary.total} |`,
|
|
166576
|
+
`| Termin\xE9es | ${report.summary.done} |`,
|
|
166577
|
+
`| \xC9chou\xE9es | ${report.summary.failed} |`,
|
|
166578
|
+
`| En cours | ${report.summary.inProgress} |`,
|
|
166579
|
+
`| Bloqu\xE9es | ${report.summary.blocked} |`,
|
|
166580
|
+
"",
|
|
166581
|
+
"## Par projet",
|
|
166582
|
+
"",
|
|
166583
|
+
`| Projet | Termin\xE9es | \xC9chou\xE9es | Bloqu\xE9es |`,
|
|
166584
|
+
`|--------|-----------|----------|----------|`
|
|
166585
|
+
];
|
|
166586
|
+
for (const [project, stats] of Object.entries(report.byProject).sort()) {
|
|
166587
|
+
lines.push(`| ${project} | ${stats.done} | ${stats.failed} | ${stats.blocked} |`);
|
|
166588
|
+
}
|
|
166589
|
+
lines.push("");
|
|
166590
|
+
lines.push("## Top erreurs");
|
|
166591
|
+
lines.push("");
|
|
166592
|
+
if (report.topErrors.length === 0) {
|
|
166593
|
+
lines.push("Aucune erreur significative cette semaine.");
|
|
166594
|
+
} else {
|
|
166595
|
+
for (const err of report.topErrors) {
|
|
166596
|
+
lines.push(`- **${err.count}\xD7** ${err.message}`);
|
|
166597
|
+
}
|
|
166598
|
+
}
|
|
166599
|
+
lines.push("");
|
|
166600
|
+
lines.push("## Recommandations");
|
|
166601
|
+
lines.push("");
|
|
166602
|
+
for (const rec of report.recommendations) {
|
|
166603
|
+
lines.push(`- ${rec}`);
|
|
166604
|
+
}
|
|
166605
|
+
lines.push("");
|
|
166606
|
+
return lines.join(`
|
|
166607
|
+
`);
|
|
166608
|
+
}
|
|
166609
|
+
function writeAuditReport(report, cwd) {
|
|
166610
|
+
const dir = getAuditDir(cwd);
|
|
166611
|
+
mkdirSync29(dir, { recursive: true });
|
|
166612
|
+
const path29 = join83(dir, `${report.week}.md`);
|
|
166613
|
+
writeFileSync29(path29, formatAuditReport(report), "utf-8");
|
|
166614
|
+
return path29;
|
|
166615
|
+
}
|
|
166616
|
+
var init_self_audit = () => {};
|
|
166617
|
+
|
|
166618
|
+
// packages/omo-opencode/src/cli/self-audit-command.ts
|
|
166619
|
+
var exports_self_audit_command = {};
|
|
166620
|
+
__export(exports_self_audit_command, {
|
|
166621
|
+
normalizeStatus: () => normalizeStatus,
|
|
166622
|
+
executeSelfAuditCommand: () => executeSelfAuditCommand
|
|
166623
|
+
});
|
|
166624
|
+
async function executeSelfAuditCommand(options = {}) {
|
|
166625
|
+
if (options.installCron) {
|
|
166626
|
+
const store4 = createCronStore();
|
|
166627
|
+
const job = store4.add({
|
|
166628
|
+
name: "Weekly self-audit",
|
|
166629
|
+
schedule: "0 22 * * 0",
|
|
166630
|
+
command: "matrixos self-audit",
|
|
166631
|
+
channel: undefined,
|
|
166632
|
+
recipient: undefined,
|
|
166633
|
+
enabled: true
|
|
166634
|
+
});
|
|
166635
|
+
return { ok: true, message: `Weekly self-audit cron job installed: ${job.id}` };
|
|
166636
|
+
}
|
|
166637
|
+
const dbPath = options.tasksDb ?? process.env.TASK_LEDGER_DB ?? "/root/.matrixos/tasks.db";
|
|
166638
|
+
let tasks = [];
|
|
166639
|
+
let signals = [];
|
|
166640
|
+
try {
|
|
166641
|
+
const rawLedger = createTaskLedger(createSqliteDatabase(dbPath));
|
|
166642
|
+
const since = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
166643
|
+
const allTasks = rawLedger.list?.() ?? [];
|
|
166644
|
+
tasks = allTasks.filter((t2) => !t2.created_at || String(t2.created_at) >= since);
|
|
166645
|
+
} catch (err) {
|
|
166646
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
166647
|
+
return {
|
|
166648
|
+
ok: false,
|
|
166649
|
+
message: `Could not read task ledger at ${dbPath}: ${detail}`
|
|
166650
|
+
};
|
|
166651
|
+
}
|
|
166652
|
+
const report = generateAuditReport(tasks.map((t2) => ({
|
|
166653
|
+
id: String(t2.id ?? t2.task_id ?? "unknown"),
|
|
166654
|
+
title: String(t2.title ?? t2.summary ?? "untitled"),
|
|
166655
|
+
status: normalizeStatus(t2.status),
|
|
166656
|
+
project: t2.project || t2.context?.project || undefined,
|
|
166657
|
+
errorCount: t2.error_count || t2.errorCount || 0
|
|
166658
|
+
})), signals, options.week);
|
|
166659
|
+
const path29 = writeAuditReport(report);
|
|
166660
|
+
return { ok: true, path: path29, message: `Self-audit written to ${path29}`, report };
|
|
166661
|
+
}
|
|
166662
|
+
function normalizeStatus(status2) {
|
|
166663
|
+
if (!status2)
|
|
166664
|
+
return "in-progress";
|
|
166665
|
+
const s = String(status2).toLowerCase();
|
|
166666
|
+
if (["done", "completed", "finished", "closed"].includes(s))
|
|
166667
|
+
return "done";
|
|
166668
|
+
if (["fail", "failed", "error"].includes(s))
|
|
166669
|
+
return "failed";
|
|
166670
|
+
if (["blocked", "stuck"].includes(s))
|
|
166671
|
+
return "blocked";
|
|
166672
|
+
if (["in-progress", "in_progress", "wip", "active"].includes(s))
|
|
166673
|
+
return "in-progress";
|
|
166674
|
+
return s;
|
|
166675
|
+
}
|
|
166676
|
+
var init_self_audit_command = __esm(() => {
|
|
166677
|
+
init_src6();
|
|
166678
|
+
init_store();
|
|
166679
|
+
init_self_audit();
|
|
166680
|
+
});
|
|
166681
|
+
|
|
165530
166682
|
// packages/omo-opencode/src/cli/rgpd-command.ts
|
|
165531
166683
|
var exports_rgpd_command = {};
|
|
165532
166684
|
__export(exports_rgpd_command, {
|
|
@@ -180251,64 +181403,8 @@ async function boulder(options) {
|
|
|
180251
181403
|
`);
|
|
180252
181404
|
return 0;
|
|
180253
181405
|
}
|
|
180254
|
-
// packages/omo-opencode/src/features/cron/store.ts
|
|
180255
|
-
init_zod();
|
|
180256
|
-
var CronJobSchema = object({
|
|
180257
|
-
id: string2().min(1),
|
|
180258
|
-
name: string2().min(1).max(100),
|
|
180259
|
-
schedule: string2().min(1).max(100),
|
|
180260
|
-
command: string2().min(1),
|
|
180261
|
-
channel: _enum2(["telegram", "discord", "whatsapp"]).optional(),
|
|
180262
|
-
recipient: string2().optional(),
|
|
180263
|
-
enabled: boolean2().default(true),
|
|
180264
|
-
createdAt: string2(),
|
|
180265
|
-
updatedAt: string2()
|
|
180266
|
-
}).strict();
|
|
180267
|
-
function createCronStore() {
|
|
180268
|
-
const jobs = new Map;
|
|
180269
|
-
let counter = 0;
|
|
180270
|
-
return {
|
|
180271
|
-
add(input) {
|
|
180272
|
-
counter += 1;
|
|
180273
|
-
const now = new Date().toISOString();
|
|
180274
|
-
const job = {
|
|
180275
|
-
id: `cron-${counter}`,
|
|
180276
|
-
name: input.name,
|
|
180277
|
-
schedule: input.schedule,
|
|
180278
|
-
command: input.command,
|
|
180279
|
-
channel: input.channel,
|
|
180280
|
-
recipient: input.recipient,
|
|
180281
|
-
enabled: input.enabled ?? true,
|
|
180282
|
-
createdAt: now,
|
|
180283
|
-
updatedAt: now
|
|
180284
|
-
};
|
|
180285
|
-
CronJobSchema.parse(job);
|
|
180286
|
-
jobs.set(job.id, job);
|
|
180287
|
-
return job;
|
|
180288
|
-
},
|
|
180289
|
-
get(id) {
|
|
180290
|
-
return jobs.get(id);
|
|
180291
|
-
},
|
|
180292
|
-
list(filter) {
|
|
180293
|
-
const all = Array.from(jobs.values());
|
|
180294
|
-
return all.filter((j) => {
|
|
180295
|
-
if (filter?.enabled !== undefined && j.enabled !== filter.enabled)
|
|
180296
|
-
return false;
|
|
180297
|
-
if (filter?.channel && j.channel !== filter.channel)
|
|
180298
|
-
return false;
|
|
180299
|
-
return true;
|
|
180300
|
-
});
|
|
180301
|
-
},
|
|
180302
|
-
remove(id) {
|
|
180303
|
-
return jobs.delete(id);
|
|
180304
|
-
},
|
|
180305
|
-
size() {
|
|
180306
|
-
return jobs.size;
|
|
180307
|
-
}
|
|
180308
|
-
};
|
|
180309
|
-
}
|
|
180310
|
-
|
|
180311
181406
|
// packages/omo-opencode/src/cli/cron.ts
|
|
181407
|
+
init_store();
|
|
180312
181408
|
var store2 = createCronStore();
|
|
180313
181409
|
function cronAdd(options) {
|
|
180314
181410
|
const job = store2.add({
|
|
@@ -180461,289 +181557,12 @@ function createDailyBrief(opts) {
|
|
|
180461
181557
|
};
|
|
180462
181558
|
}
|
|
180463
181559
|
|
|
180464
|
-
// packages/task-ledger-core/src/schema.ts
|
|
180465
|
-
init_zod();
|
|
180466
|
-
var TaskSourceSchema = _enum2(["webhook", "cron", "user", "kanban"]);
|
|
180467
|
-
var TaskStatusSchema = _enum2([
|
|
180468
|
-
"pending",
|
|
180469
|
-
"running",
|
|
180470
|
-
"done",
|
|
180471
|
-
"failed",
|
|
180472
|
-
"cancelled"
|
|
180473
|
-
]);
|
|
180474
|
-
var TaskPrioritySchema = _enum2(["high", "medium", "low"]);
|
|
180475
|
-
var TaskSchema = object({
|
|
180476
|
-
id: string2().min(1),
|
|
180477
|
-
source: TaskSourceSchema,
|
|
180478
|
-
context: string2().nullable(),
|
|
180479
|
-
status: TaskStatusSchema,
|
|
180480
|
-
priority: TaskPrioritySchema.nullable(),
|
|
180481
|
-
payload: string2(),
|
|
180482
|
-
agent_assigned: string2().nullable(),
|
|
180483
|
-
session_id: string2().nullable(),
|
|
180484
|
-
result: string2().nullable(),
|
|
180485
|
-
cost_tokens: number2().int().nonnegative().default(0),
|
|
180486
|
-
cost_usd: number2().nonnegative().default(0),
|
|
180487
|
-
created_at: number2().int(),
|
|
180488
|
-
started_at: number2().int().nullable(),
|
|
180489
|
-
completed_at: number2().int().nullable()
|
|
180490
|
-
}).strict();
|
|
180491
|
-
var TaskInsertSchema = object({
|
|
180492
|
-
id: string2().min(1).optional(),
|
|
180493
|
-
source: TaskSourceSchema,
|
|
180494
|
-
context: string2().nullable().optional(),
|
|
180495
|
-
status: TaskStatusSchema.optional(),
|
|
180496
|
-
priority: TaskPrioritySchema.nullable().optional(),
|
|
180497
|
-
payload: string2(),
|
|
180498
|
-
agent_assigned: string2().nullable().optional(),
|
|
180499
|
-
session_id: string2().nullable().optional(),
|
|
180500
|
-
cost_tokens: number2().int().nonnegative().optional(),
|
|
180501
|
-
cost_usd: number2().nonnegative().optional()
|
|
180502
|
-
}).strict();
|
|
180503
|
-
var TaskPatchSchema = object({
|
|
180504
|
-
status: TaskStatusSchema.optional(),
|
|
180505
|
-
priority: TaskPrioritySchema.nullable().optional(),
|
|
180506
|
-
agent_assigned: string2().nullable().optional(),
|
|
180507
|
-
session_id: string2().nullable().optional(),
|
|
180508
|
-
result: string2().nullable().optional(),
|
|
180509
|
-
cost_tokens: number2().int().nonnegative().optional(),
|
|
180510
|
-
cost_usd: number2().nonnegative().optional(),
|
|
180511
|
-
started_at: number2().int().nullable().optional(),
|
|
180512
|
-
completed_at: number2().int().nullable().optional()
|
|
180513
|
-
}).strict();
|
|
180514
|
-
var TaskFilterSchema = object({
|
|
180515
|
-
source: TaskSourceSchema.optional(),
|
|
180516
|
-
context: string2().optional(),
|
|
180517
|
-
status: TaskStatusSchema.optional(),
|
|
180518
|
-
agent_assigned: string2().optional(),
|
|
180519
|
-
session_id: string2().optional(),
|
|
180520
|
-
priority: TaskPrioritySchema.optional()
|
|
180521
|
-
}).strict();
|
|
180522
|
-
|
|
180523
|
-
// packages/task-ledger-core/src/ledger.ts
|
|
180524
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
180525
|
-
var CREATE_TABLE_SQL = `
|
|
180526
|
-
CREATE TABLE IF NOT EXISTS tasks (
|
|
180527
|
-
id TEXT PRIMARY KEY,
|
|
180528
|
-
source TEXT NOT NULL,
|
|
180529
|
-
context TEXT,
|
|
180530
|
-
status TEXT NOT NULL,
|
|
180531
|
-
priority TEXT,
|
|
180532
|
-
payload TEXT NOT NULL,
|
|
180533
|
-
agent_assigned TEXT,
|
|
180534
|
-
session_id TEXT,
|
|
180535
|
-
result TEXT,
|
|
180536
|
-
cost_tokens INTEGER DEFAULT 0,
|
|
180537
|
-
cost_usd REAL DEFAULT 0,
|
|
180538
|
-
created_at INTEGER NOT NULL,
|
|
180539
|
-
started_at INTEGER,
|
|
180540
|
-
completed_at INTEGER
|
|
180541
|
-
)
|
|
180542
|
-
`;
|
|
180543
|
-
var CREATE_INDEX_STATUS = `CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status)`;
|
|
180544
|
-
var CREATE_INDEX_CONTEXT = `CREATE INDEX IF NOT EXISTS idx_tasks_context ON tasks(context)`;
|
|
180545
|
-
var CREATE_INDEX_SOURCE = `CREATE INDEX IF NOT EXISTS idx_tasks_source ON tasks(source)`;
|
|
180546
|
-
var INSERT_SQL = `
|
|
180547
|
-
INSERT INTO tasks (id, source, context, status, priority, payload, agent_assigned, session_id, result, cost_tokens, cost_usd, created_at, started_at, completed_at)
|
|
180548
|
-
VALUES ($id, $source, $context, $status, $priority, $payload, $agent_assigned, $session_id, $result, $cost_tokens, $cost_usd, $created_at, $started_at, $completed_at)
|
|
180549
|
-
`;
|
|
180550
|
-
var SELECT_BY_ID_SQL = `SELECT * FROM tasks WHERE id = $id`;
|
|
180551
|
-
var DELETE_BY_ID_SQL = `DELETE FROM tasks WHERE id = $id`;
|
|
180552
|
-
var UPDATE_SQL = `
|
|
180553
|
-
UPDATE tasks SET
|
|
180554
|
-
status = COALESCE($status, status),
|
|
180555
|
-
priority = COALESCE($priority, priority),
|
|
180556
|
-
agent_assigned = COALESCE($agent_assigned, agent_assigned),
|
|
180557
|
-
session_id = COALESCE($session_id, session_id),
|
|
180558
|
-
result = COALESCE($result, result),
|
|
180559
|
-
cost_tokens = COALESCE($cost_tokens, cost_tokens),
|
|
180560
|
-
cost_usd = COALESCE($cost_usd, cost_usd),
|
|
180561
|
-
started_at = COALESCE($started_at, started_at),
|
|
180562
|
-
completed_at = COALESCE($completed_at, completed_at)
|
|
180563
|
-
WHERE id = $id
|
|
180564
|
-
`;
|
|
180565
|
-
function rowToTask(row) {
|
|
180566
|
-
return {
|
|
180567
|
-
id: row.id,
|
|
180568
|
-
source: row.source,
|
|
180569
|
-
context: row.context,
|
|
180570
|
-
status: row.status,
|
|
180571
|
-
priority: row.priority,
|
|
180572
|
-
payload: row.payload,
|
|
180573
|
-
agent_assigned: row.agent_assigned,
|
|
180574
|
-
session_id: row.session_id,
|
|
180575
|
-
result: row.result,
|
|
180576
|
-
cost_tokens: row.cost_tokens,
|
|
180577
|
-
cost_usd: row.cost_usd,
|
|
180578
|
-
created_at: row.created_at,
|
|
180579
|
-
started_at: row.started_at,
|
|
180580
|
-
completed_at: row.completed_at
|
|
180581
|
-
};
|
|
180582
|
-
}
|
|
180583
|
-
function createTaskLedger(db) {
|
|
180584
|
-
db.exec(CREATE_TABLE_SQL);
|
|
180585
|
-
db.exec(CREATE_INDEX_STATUS);
|
|
180586
|
-
db.exec(CREATE_INDEX_CONTEXT);
|
|
180587
|
-
db.exec(CREATE_INDEX_SOURCE);
|
|
180588
|
-
return {
|
|
180589
|
-
insert(input) {
|
|
180590
|
-
const now = Date.now();
|
|
180591
|
-
const task2 = TaskSchema.parse({
|
|
180592
|
-
id: input.id ?? randomUUID2(),
|
|
180593
|
-
source: input.source,
|
|
180594
|
-
context: input.context ?? null,
|
|
180595
|
-
status: input.status ?? "pending",
|
|
180596
|
-
priority: input.priority ?? null,
|
|
180597
|
-
payload: input.payload,
|
|
180598
|
-
agent_assigned: input.agent_assigned ?? null,
|
|
180599
|
-
session_id: input.session_id ?? null,
|
|
180600
|
-
result: null,
|
|
180601
|
-
cost_tokens: input.cost_tokens ?? 0,
|
|
180602
|
-
cost_usd: input.cost_usd ?? 0,
|
|
180603
|
-
created_at: now,
|
|
180604
|
-
started_at: null,
|
|
180605
|
-
completed_at: null
|
|
180606
|
-
});
|
|
180607
|
-
db.exec(INSERT_SQL, {
|
|
180608
|
-
$id: task2.id,
|
|
180609
|
-
$source: task2.source,
|
|
180610
|
-
$context: task2.context,
|
|
180611
|
-
$status: task2.status,
|
|
180612
|
-
$priority: task2.priority,
|
|
180613
|
-
$payload: task2.payload,
|
|
180614
|
-
$agent_assigned: task2.agent_assigned,
|
|
180615
|
-
$session_id: task2.session_id,
|
|
180616
|
-
$result: task2.result,
|
|
180617
|
-
$cost_tokens: task2.cost_tokens,
|
|
180618
|
-
$cost_usd: task2.cost_usd,
|
|
180619
|
-
$created_at: task2.created_at,
|
|
180620
|
-
$started_at: task2.started_at,
|
|
180621
|
-
$completed_at: task2.completed_at
|
|
180622
|
-
});
|
|
180623
|
-
return task2;
|
|
180624
|
-
},
|
|
180625
|
-
get(id) {
|
|
180626
|
-
const rows = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
180627
|
-
if (rows.length === 0)
|
|
180628
|
-
return null;
|
|
180629
|
-
return rowToTask(rows[0]);
|
|
180630
|
-
},
|
|
180631
|
-
list(filter) {
|
|
180632
|
-
const conditions = [];
|
|
180633
|
-
const params = {};
|
|
180634
|
-
if (filter?.source) {
|
|
180635
|
-
conditions.push("source = $source");
|
|
180636
|
-
params.$source = filter.source;
|
|
180637
|
-
}
|
|
180638
|
-
if (filter?.context) {
|
|
180639
|
-
conditions.push("context = $context");
|
|
180640
|
-
params.$context = filter.context;
|
|
180641
|
-
}
|
|
180642
|
-
if (filter?.status) {
|
|
180643
|
-
conditions.push("status = $status");
|
|
180644
|
-
params.$status = filter.status;
|
|
180645
|
-
}
|
|
180646
|
-
if (filter?.agent_assigned) {
|
|
180647
|
-
conditions.push("agent_assigned = $agent_assigned");
|
|
180648
|
-
params.$agent_assigned = filter.agent_assigned;
|
|
180649
|
-
}
|
|
180650
|
-
if (filter?.session_id) {
|
|
180651
|
-
conditions.push("session_id = $session_id");
|
|
180652
|
-
params.$session_id = filter.session_id;
|
|
180653
|
-
}
|
|
180654
|
-
if (filter?.priority) {
|
|
180655
|
-
conditions.push("priority = $priority");
|
|
180656
|
-
params.$priority = filter.priority;
|
|
180657
|
-
}
|
|
180658
|
-
const where = conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : "";
|
|
180659
|
-
const sql = `SELECT * FROM tasks${where} ORDER BY created_at DESC`;
|
|
180660
|
-
const rows = db.query(sql, params);
|
|
180661
|
-
return rows.map(rowToTask);
|
|
180662
|
-
},
|
|
180663
|
-
update(id, patch) {
|
|
180664
|
-
const existing = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
180665
|
-
if (existing.length === 0)
|
|
180666
|
-
return null;
|
|
180667
|
-
const params = { $id: id };
|
|
180668
|
-
if (patch.status !== undefined)
|
|
180669
|
-
params.$status = patch.status;
|
|
180670
|
-
if (patch.priority !== undefined)
|
|
180671
|
-
params.$priority = patch.priority;
|
|
180672
|
-
if (patch.agent_assigned !== undefined)
|
|
180673
|
-
params.$agent_assigned = patch.agent_assigned;
|
|
180674
|
-
if (patch.session_id !== undefined)
|
|
180675
|
-
params.$session_id = patch.session_id;
|
|
180676
|
-
if (patch.result !== undefined)
|
|
180677
|
-
params.$result = patch.result;
|
|
180678
|
-
if (patch.cost_tokens !== undefined)
|
|
180679
|
-
params.$cost_tokens = patch.cost_tokens;
|
|
180680
|
-
if (patch.cost_usd !== undefined)
|
|
180681
|
-
params.$cost_usd = patch.cost_usd;
|
|
180682
|
-
if (patch.started_at !== undefined)
|
|
180683
|
-
params.$started_at = patch.started_at;
|
|
180684
|
-
if (patch.completed_at !== undefined)
|
|
180685
|
-
params.$completed_at = patch.completed_at;
|
|
180686
|
-
db.exec(UPDATE_SQL, params);
|
|
180687
|
-
return this.get(id);
|
|
180688
|
-
},
|
|
180689
|
-
remove(id) {
|
|
180690
|
-
const before = db.query(SELECT_BY_ID_SQL, { $id: id });
|
|
180691
|
-
if (before.length === 0)
|
|
180692
|
-
return false;
|
|
180693
|
-
db.exec(DELETE_BY_ID_SQL, { $id: id });
|
|
180694
|
-
return true;
|
|
180695
|
-
},
|
|
180696
|
-
listPending() {
|
|
180697
|
-
const rows = db.query(`SELECT * FROM tasks WHERE status = 'pending' ORDER BY created_at ASC`);
|
|
180698
|
-
return rows.map(rowToTask);
|
|
180699
|
-
},
|
|
180700
|
-
listFailed() {
|
|
180701
|
-
const rows = db.query(`SELECT * FROM tasks WHERE status = 'failed' ORDER BY created_at ASC`);
|
|
180702
|
-
return rows.map(rowToTask);
|
|
180703
|
-
},
|
|
180704
|
-
listByContext(context) {
|
|
180705
|
-
const rows = db.query(`SELECT * FROM tasks WHERE context = $context ORDER BY created_at DESC`, { $context: context });
|
|
180706
|
-
return rows.map(rowToTask);
|
|
180707
|
-
},
|
|
180708
|
-
close() {
|
|
180709
|
-
db.close();
|
|
180710
|
-
}
|
|
180711
|
-
};
|
|
180712
|
-
}
|
|
180713
|
-
|
|
180714
|
-
// packages/task-ledger-core/src/sqlite.ts
|
|
180715
|
-
import { Database as Database2 } from "bun:sqlite";
|
|
180716
|
-
function createSqliteDatabase(dbPath) {
|
|
180717
|
-
const db = new Database2(dbPath);
|
|
180718
|
-
db.exec("PRAGMA journal_mode = WAL");
|
|
180719
|
-
db.exec("PRAGMA foreign_keys = ON");
|
|
180720
|
-
return {
|
|
180721
|
-
exec(sql, ...params) {
|
|
180722
|
-
if (params.length === 0) {
|
|
180723
|
-
db.run(sql);
|
|
180724
|
-
} else {
|
|
180725
|
-
const named = params[0];
|
|
180726
|
-
db.run(sql, named);
|
|
180727
|
-
}
|
|
180728
|
-
},
|
|
180729
|
-
query(sql, ...params) {
|
|
180730
|
-
if (params.length === 0) {
|
|
180731
|
-
return db.prepare(sql).all();
|
|
180732
|
-
}
|
|
180733
|
-
const named = params[0];
|
|
180734
|
-
return db.prepare(sql).all(named);
|
|
180735
|
-
},
|
|
180736
|
-
close() {
|
|
180737
|
-
db.close();
|
|
180738
|
-
}
|
|
180739
|
-
};
|
|
180740
|
-
}
|
|
180741
|
-
|
|
180742
181560
|
// packages/omo-opencode/src/cli/daily-brief.ts
|
|
181561
|
+
init_src6();
|
|
180743
181562
|
async function dailyBriefSend(options) {
|
|
180744
181563
|
try {
|
|
180745
181564
|
const rawLedger = createTaskLedger(createSqliteDatabase(process.env.TASK_LEDGER_DB ?? "/root/.matrixos/tasks.db"));
|
|
180746
|
-
const
|
|
181565
|
+
const ledger2 = {
|
|
180747
181566
|
listPending: () => rawLedger.listPending(),
|
|
180748
181567
|
listFailed: () => rawLedger.list({ status: "failed" })
|
|
180749
181568
|
};
|
|
@@ -180768,7 +181587,7 @@ async function dailyBriefSend(options) {
|
|
|
180768
181587
|
recipient_id: recipient,
|
|
180769
181588
|
channel
|
|
180770
181589
|
}),
|
|
180771
|
-
ledger,
|
|
181590
|
+
ledger: ledger2,
|
|
180772
181591
|
sender,
|
|
180773
181592
|
now: () => Date.now()
|
|
180774
181593
|
});
|
|
@@ -186062,7 +186881,7 @@ function createDataProvider(config5) {
|
|
|
186062
186881
|
} catch {}
|
|
186063
186882
|
if (entries.length > 0)
|
|
186064
186883
|
return entries;
|
|
186065
|
-
const
|
|
186884
|
+
const types16 = ["episodic", "semantic", "procedural", "reflection"];
|
|
186066
186885
|
const mockContent = [
|
|
186067
186886
|
"User prefers concise responses with bullet points",
|
|
186068
186887
|
"Project MaTrixOS uses Bun runtime and TypeScript strict mode",
|
|
@@ -186076,7 +186895,7 @@ function createDataProvider(config5) {
|
|
|
186076
186895
|
entries.push({
|
|
186077
186896
|
id: `mem_${randomBetween(1000, 9999)}`,
|
|
186078
186897
|
content: randomChoice(mockContent),
|
|
186079
|
-
type: randomChoice(
|
|
186898
|
+
type: randomChoice(types16),
|
|
186080
186899
|
confidence: Math.round(randomBetween(60, 99)),
|
|
186081
186900
|
created_at: new Date(Date.now() - randomBetween(0, 604800000)).toISOString()
|
|
186082
186901
|
});
|
|
@@ -186652,6 +187471,9 @@ function configureRuntimeCommands(program2) {
|
|
|
186652
187471
|
init_package();
|
|
186653
187472
|
var VERSION4 = package_default.version;
|
|
186654
187473
|
var program2 = new Command;
|
|
187474
|
+
function collectParams(value, previous) {
|
|
187475
|
+
return previous.concat([value]);
|
|
187476
|
+
}
|
|
186655
187477
|
function resolveInstallArgs(options, invocationName = process.env.OMO_INVOCATION_NAME) {
|
|
186656
187478
|
const defaultPlatform = invocationName === "lazycodex" || invocationName === "lazycodex-ai" ? "codex" : undefined;
|
|
186657
187479
|
const platform2 = options.platform ?? defaultPlatform;
|
|
@@ -186846,6 +187668,63 @@ program2.command("export [name]").description("Export a mini-OS profile as a sta
|
|
|
186846
187668
|
process.exit(result.exitCode);
|
|
186847
187669
|
});
|
|
186848
187670
|
program2.addCommand(createMcpOAuthCommand());
|
|
187671
|
+
var project = program2.command("project").description("Manage MaTrixOS projects (active context, kanban, knowledge base)");
|
|
187672
|
+
project.command("create <slug>").description("Create a new project").option("-n, --name <name>", "Display name").option("-d, --description <text>", "Short description").action(async (slug, options) => {
|
|
187673
|
+
const { createProject: createProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187674
|
+
const info = createProject2(slug, { name: options.name, description: options.description });
|
|
187675
|
+
process.stdout.write(JSON.stringify(info, null, 2) + `
|
|
187676
|
+
`);
|
|
187677
|
+
});
|
|
187678
|
+
project.command("list").alias("ls").description("List all projects").action(async () => {
|
|
187679
|
+
const { listProjects: listProjects2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187680
|
+
const list = listProjects2();
|
|
187681
|
+
process.stdout.write(JSON.stringify(list, null, 2) + `
|
|
187682
|
+
`);
|
|
187683
|
+
});
|
|
187684
|
+
project.command("switch <slug>").description("Switch the active project").action(async (slug) => {
|
|
187685
|
+
const { switchProject: switchProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187686
|
+
const info = switchProject2(slug);
|
|
187687
|
+
process.stdout.write(JSON.stringify(info, null, 2) + `
|
|
187688
|
+
`);
|
|
187689
|
+
});
|
|
187690
|
+
project.command("active").description("Show the active project").action(async () => {
|
|
187691
|
+
const { getActiveProject: getActiveProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187692
|
+
const info = getActiveProject2();
|
|
187693
|
+
process.stdout.write(JSON.stringify(info ?? null, null, 2) + `
|
|
187694
|
+
`);
|
|
187695
|
+
});
|
|
187696
|
+
project.command("archive <slug>").description("Archive a project (removes it from the active list)").action(async (slug) => {
|
|
187697
|
+
const { archiveProject: archiveProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187698
|
+
const info = archiveProject2(slug);
|
|
187699
|
+
process.stdout.write(JSON.stringify(info, null, 2) + `
|
|
187700
|
+
`);
|
|
187701
|
+
});
|
|
187702
|
+
project.command("unarchive <slug>").description("Unarchive a project").action(async (slug) => {
|
|
187703
|
+
const { unarchiveProject: unarchiveProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187704
|
+
const info = unarchiveProject2(slug);
|
|
187705
|
+
process.stdout.write(JSON.stringify(info, null, 2) + `
|
|
187706
|
+
`);
|
|
187707
|
+
});
|
|
187708
|
+
project.command("delete <slug>").description("Permanently delete a project").action(async (slug) => {
|
|
187709
|
+
const { deleteProject: deleteProject2 } = await Promise.resolve().then(() => (init_project_context(), exports_project_context));
|
|
187710
|
+
deleteProject2(slug);
|
|
187711
|
+
process.stdout.write(JSON.stringify({ ok: true, deleted: slug }, null, 2) + `
|
|
187712
|
+
`);
|
|
187713
|
+
});
|
|
187714
|
+
project.command("search <query>").description("Search the active project KB and memory").option("-p, --project <slug>", "Search a specific project instead of the active one").action(async (query, options) => {
|
|
187715
|
+
const { searchProject: searchProject2 } = await Promise.resolve().then(() => (init_project_memory(), exports_project_memory));
|
|
187716
|
+
const hits = await searchProject2(query, { projectSlug: options.project });
|
|
187717
|
+
process.stdout.write(JSON.stringify(hits, null, 2) + `
|
|
187718
|
+
`);
|
|
187719
|
+
});
|
|
187720
|
+
project.command("add-doc <slug> <file>").description("Copy a document into the project KB").action(async (slug, filePath) => {
|
|
187721
|
+
const { addKbDocument: addKbDocument2 } = await Promise.resolve().then(() => (init_project_memory(), exports_project_memory));
|
|
187722
|
+
const { readFileSync: readFileSync64 } = await import("fs");
|
|
187723
|
+
const content = readFileSync64(filePath, "utf-8");
|
|
187724
|
+
const dest = addKbDocument2(slug, filePath, content);
|
|
187725
|
+
process.stdout.write(JSON.stringify({ ok: true, dest }, null, 2) + `
|
|
187726
|
+
`);
|
|
187727
|
+
});
|
|
186849
187728
|
var gateway2 = program2.command("gateway").description("Gateway configuration \u2014 bot token management");
|
|
186850
187729
|
var gatewayAdopt = gateway2.command("adopt").description("Adopt a gateway channel (Telegram, Discord, WhatsApp)");
|
|
186851
187730
|
var gatewayAdoptTelegram = gatewayAdopt.command("telegram").description("Set up the Telegram gateway: prompt for bot token, validate, write .klc-gateway.env").option("-t, --token <value>", "Bot token (non-interactive)").option("-c, --chat <id>", "Restrict to a single chat id").addHelpText("after", `
|
|
@@ -186909,13 +187788,48 @@ gateway2.command("status").description("Check gateway status (best-effort, inspe
|
|
|
186909
187788
|
}, null, 2) + `
|
|
186910
187789
|
`);
|
|
186911
187790
|
});
|
|
186912
|
-
program2.command("
|
|
187791
|
+
program2.command("deploy <target>").description("Deploy the active project (static, vercel, vps)").option("-e, --env <env>", "Environment (staging, production, preview)", "production").option("-n, --dry-run", "Show what would happen without executing").option("-f, --force", "Skip production validation prompt").option("-r, --project-root <path>", "Override project root directory").option("-p, --param <param>", "Target-specific parameter (key=value)", collectParams, []).action(async (target, options) => {
|
|
187792
|
+
const { runDeploy: runDeploy2 } = await Promise.resolve().then(() => (init_deployment(), exports_deployment));
|
|
187793
|
+
const env5 = options.env;
|
|
187794
|
+
const code = await runDeploy2({
|
|
187795
|
+
target,
|
|
187796
|
+
environment: env5,
|
|
187797
|
+
dryRun: options.dryRun,
|
|
187798
|
+
force: options.force,
|
|
187799
|
+
projectRoot: options.projectRoot,
|
|
187800
|
+
params: options.param
|
|
187801
|
+
});
|
|
187802
|
+
process.exit(code);
|
|
187803
|
+
});
|
|
187804
|
+
program2.command("self-audit").description("Generate the weekly self-audit report from task ledger and scanner signals").option("-w, --week <week>", "ISO week string, e.g. 2026-W30").option("-j, --json", "Output JSON instead of markdown").option("--tasks-db <path>", "Path to the task ledger SQLite DB").option("--install-cron", "Install the weekly cron job (Sunday 22:00)").action(async (options) => {
|
|
187805
|
+
const { executeSelfAuditCommand: executeSelfAuditCommand2 } = await Promise.resolve().then(() => (init_self_audit_command(), exports_self_audit_command));
|
|
187806
|
+
const result = await executeSelfAuditCommand2(options);
|
|
187807
|
+
if (options.json) {
|
|
187808
|
+
process.stdout.write(JSON.stringify(result, null, 2) + `
|
|
187809
|
+
`);
|
|
187810
|
+
} else if (result.path) {
|
|
187811
|
+
console.log(`Self-audit written to ${result.path}`);
|
|
187812
|
+
} else {
|
|
187813
|
+
console.log(result.message);
|
|
187814
|
+
}
|
|
187815
|
+
process.exit(result.ok ? 0 : 1);
|
|
187816
|
+
});
|
|
187817
|
+
program2.command("adopt").description("Re-run the MaTrixOS adoption wizard (providers, channels, profile)").argument("[channel]", "optional channel to adopt (telegram). Redirects to: matrixos gateway adopt <channel>").addHelpText("after", `
|
|
186913
187818
|
Examples:
|
|
186914
187819
|
$ matrixos adopt # interactive re-adoption (TUI)
|
|
187820
|
+
$ matrixos adopt telegram # alias for: matrixos gateway adopt telegram
|
|
186915
187821
|
|
|
186916
187822
|
For channel-specific setup, use:
|
|
186917
187823
|
$ matrixos gateway adopt telegram
|
|
186918
|
-
`).action(async () => {
|
|
187824
|
+
`).action(async (channel) => {
|
|
187825
|
+
if (channel) {
|
|
187826
|
+
const { runAdopt: runAdopt3 } = await Promise.resolve().then(() => (init_adopt(), exports_adopt));
|
|
187827
|
+
const result2 = await runAdopt3({ channel, nonInteractive: true });
|
|
187828
|
+
console.log(result2.message);
|
|
187829
|
+
if (!result2.ok)
|
|
187830
|
+
process.exit(1);
|
|
187831
|
+
return;
|
|
187832
|
+
}
|
|
186919
187833
|
const { runAdopt: runAdopt2 } = await Promise.resolve().then(() => (init_adopt(), exports_adopt));
|
|
186920
187834
|
const result = await runAdopt2({});
|
|
186921
187835
|
if (!result.ok)
|