@kl-c/matrixos 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/command/adopt.md +19 -31
- package/dist/cli/index.js +385 -4
- package/dist/cli-node/index.js +385 -4
- 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 +1 -1
- package/package.json +1 -1
package/.agents/command/adopt.md
CHANGED
|
@@ -6,13 +6,13 @@ description: Launch or re-run the Morpheus adoption ritual — establish user co
|
|
|
6
6
|
You are executing the **Morpheus adoption ritual** (`/adopt`). This is the first-contact (or re-adoption) ceremony that establishes the user's context and offers optional MaTrixOS features.
|
|
7
7
|
|
|
8
8
|
## When this runs
|
|
9
|
-
- First launch, if
|
|
9
|
+
- First launch, if `.matrixos/user-context.md` is missing or still a template.
|
|
10
10
|
- Any time the user explicitly types `/adopt` to (re)do the ritual.
|
|
11
11
|
|
|
12
12
|
## Behavior
|
|
13
13
|
|
|
14
14
|
### 1. Detect current state
|
|
15
|
-
Check whether
|
|
15
|
+
Check whether `.matrixos/user-context.md` exists and is filled.
|
|
16
16
|
- If filled: tell the user "Tu as déjà un contexte d'adoption. Je relance le rituel pour le mettre à jour." and proceed to step 2 (re-adoption mode — EDIT sections, do NOT rewrite from scratch).
|
|
17
17
|
- If missing/template: adoption mode — you will CREATE the file.
|
|
18
18
|
|
|
@@ -28,32 +28,20 @@ Keep it to one short paragraph — this is awareness, not the opt-in checklist (
|
|
|
28
28
|
Pose ~5 targeted questions:
|
|
29
29
|
1. **Qui es-tu ?** (nom/alias, rôle, ce que tu fais)
|
|
30
30
|
2. **Pour quel projet / besoin m'as-tu déployé ?** (objectif, stack, périmètre)
|
|
31
|
-
3. **
|
|
32
|
-
4. **
|
|
33
|
-
5.
|
|
34
|
-
|
|
35
|
-
###
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
Never rewrite the whole file from scratch — preserve existing context.
|
|
49
|
-
|
|
50
|
-
Also update `/root/MOS_Vault/MEMORY.md` routing if the user-context file was just created.
|
|
51
|
-
|
|
52
|
-
### 5. Confirm
|
|
53
|
-
End with: « C'est noté, je suis désormais configuré pour toi. Tu peux à tout moment utiliser `/features` pour voir ce que je peux faire, ou `/adopt` pour refaire ce rituel. »
|
|
54
|
-
|
|
55
|
-
## Rules
|
|
56
|
-
- User context is NEVER fixed: user can say "mets à jour mon contexte" → edit, not rewrite.
|
|
57
|
-
- Do not invent a hierarchy/manager — Morpheus reports only to the user who installed it.
|
|
58
|
-
- Do not store code-derivable facts in user-context.md (that belongs to Magic Context / MOS_Vault project files).
|
|
59
|
-
- If the user wants a feature activated that requires provisioning (e.g. Dashboard), relay the exact provisioning steps from the inventory — and if you are instructed to actually enable it, follow the `provisioning.activation` recipe (e.g. launch `matrixos dashboard --daemon`).
|
|
31
|
+
3. **Quel niveau d'automatisation veux-tu ?** (assistant, agent, team mode)
|
|
32
|
+
4. **Veux-tu activer le dashboard ?** (Mission Control)
|
|
33
|
+
5. **Veux-tu le gateway Telegram ?** (répondre depuis ton téléphone)
|
|
34
|
+
|
|
35
|
+
### 4. Write user-context.md
|
|
36
|
+
Write the answers to `.matrixos/user-context.md` in French, structured as YAML frontmatter + markdown sections.
|
|
37
|
+
|
|
38
|
+
### 5. Offer feature toggles
|
|
39
|
+
After writing context, offer to enable:
|
|
40
|
+
- Dashboard (`matrixos dashboard --daemon`)
|
|
41
|
+
- Gateway Telegram (`matrixos gateway adopt telegram`)
|
|
42
|
+
- Kanban (`matrixos project switch`)
|
|
43
|
+
- Cron / auto-audit (`matrixos self-audit --install-cron`)
|
|
44
|
+
|
|
45
|
+
### 6. Confirm
|
|
46
|
+
"Rituel terminé. Tu peux me demander n'importe quoi maintenant — je connais ton contexte."
|
|
47
|
+
</command-instruction>
|
package/dist/cli/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.7",
|
|
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",
|
|
@@ -165755,6 +165755,13 @@ async function runAdopt(options = {}) {
|
|
|
165755
165755
|
message: "Global adoption requires an interactive terminal. Run: matrixos adopt (no arguments)."
|
|
165756
165756
|
};
|
|
165757
165757
|
}
|
|
165758
|
+
if (!process.stdin.isTTY) {
|
|
165759
|
+
return {
|
|
165760
|
+
ok: false,
|
|
165761
|
+
message: `Cannot run interactive adoption: stdin is not a TTY.
|
|
165762
|
+
` + "Run in a terminal, or use: matrixos gateway adopt telegram --token <token>"
|
|
165763
|
+
};
|
|
165764
|
+
}
|
|
165758
165765
|
console.log(`
|
|
165759
165766
|
=== MaTrixOS Re-Adoption ===`);
|
|
165760
165767
|
console.log(`You can reconfigure providers, channels, and profile.
|
|
@@ -166086,8 +166093,357 @@ var init_gateway_start = __esm(() => {
|
|
|
166086
166093
|
ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
|
|
166087
166094
|
});
|
|
166088
166095
|
|
|
166096
|
+
// packages/omo-opencode/src/deployment/deployment-core.ts
|
|
166097
|
+
function registerTarget(target) {
|
|
166098
|
+
targets.set(target.name, target);
|
|
166099
|
+
}
|
|
166100
|
+
function getTarget(name2) {
|
|
166101
|
+
return targets.get(name2);
|
|
166102
|
+
}
|
|
166103
|
+
function listTargets() {
|
|
166104
|
+
return Array.from(targets.keys());
|
|
166105
|
+
}
|
|
166106
|
+
var targets;
|
|
166107
|
+
var init_deployment_core = __esm(() => {
|
|
166108
|
+
targets = new Map;
|
|
166109
|
+
});
|
|
166110
|
+
|
|
166111
|
+
// packages/omo-opencode/src/deployment/deploy-static.ts
|
|
166112
|
+
import { spawn as spawn6 } from "child_process";
|
|
166113
|
+
import { existsSync as existsSync78 } from "fs";
|
|
166114
|
+
import { resolve as resolve20 } from "path";
|
|
166115
|
+
function pushStage(stage, message, ok = true) {
|
|
166116
|
+
return { stage, message, ok };
|
|
166117
|
+
}
|
|
166118
|
+
function run2(cmd, args, cwd) {
|
|
166119
|
+
return new Promise((resolve21) => {
|
|
166120
|
+
let output = "";
|
|
166121
|
+
let error51 = "";
|
|
166122
|
+
const child = spawn6(cmd, args, { cwd, shell: false });
|
|
166123
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166124
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166125
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166126
|
+
});
|
|
166127
|
+
}
|
|
166128
|
+
var deployStatic;
|
|
166129
|
+
var init_deploy_static = __esm(() => {
|
|
166130
|
+
deployStatic = {
|
|
166131
|
+
name: "static",
|
|
166132
|
+
async deploy(ctx, params) {
|
|
166133
|
+
const stages = [];
|
|
166134
|
+
const buildDir = resolve20(ctx.projectRoot, params.buildDir ?? "dist");
|
|
166135
|
+
const destination = params.destination;
|
|
166136
|
+
const prebuild = params.prebuild ?? "bun run build";
|
|
166137
|
+
try {
|
|
166138
|
+
if (!destination) {
|
|
166139
|
+
return { target: "static", ok: false, stages: [pushStage("build", "missing destination parameter", false)], error: "missing destination" };
|
|
166140
|
+
}
|
|
166141
|
+
if (ctx.environment === "production" && ctx.requireValidation && !params.force) {
|
|
166142
|
+
return {
|
|
166143
|
+
target: "static",
|
|
166144
|
+
ok: false,
|
|
166145
|
+
stages: [pushStage("build", "production deploy requires explicit validation (force=true or use staging)", false)],
|
|
166146
|
+
error: "validation required"
|
|
166147
|
+
};
|
|
166148
|
+
}
|
|
166149
|
+
if (!ctx.execute) {
|
|
166150
|
+
return {
|
|
166151
|
+
target: "static",
|
|
166152
|
+
ok: true,
|
|
166153
|
+
url: destination,
|
|
166154
|
+
stages: [
|
|
166155
|
+
pushStage("build", `dry-run: would run '${prebuild}' in ${ctx.projectRoot}`),
|
|
166156
|
+
pushStage("push", `dry-run: would rsync ${buildDir} to ${destination}`),
|
|
166157
|
+
pushStage("verify", "dry-run: would verify 200 from deployed URL")
|
|
166158
|
+
]
|
|
166159
|
+
};
|
|
166160
|
+
}
|
|
166161
|
+
if (prebuild) {
|
|
166162
|
+
stages.push(pushStage("build", `running '${prebuild}'...`));
|
|
166163
|
+
const build = await run2(prebuild, [], ctx.projectRoot);
|
|
166164
|
+
if (!build.ok) {
|
|
166165
|
+
stages.push(pushStage("build", `build failed: ${build.error}`, false));
|
|
166166
|
+
return { target: "static", ok: false, stages, error: build.error };
|
|
166167
|
+
}
|
|
166168
|
+
stages.push(pushStage("build", "build succeeded"));
|
|
166169
|
+
}
|
|
166170
|
+
if (!existsSync78(buildDir)) {
|
|
166171
|
+
stages.push(pushStage("push", `build directory not found: ${buildDir}`, false));
|
|
166172
|
+
return { target: "static", ok: false, stages, error: "build directory missing" };
|
|
166173
|
+
}
|
|
166174
|
+
stages.push(pushStage("push", `syncing ${buildDir} to ${destination}...`));
|
|
166175
|
+
const rsync = await run2("rsync", ["-avz", "--delete", buildDir + "/", destination], ctx.projectRoot);
|
|
166176
|
+
if (!rsync.ok) {
|
|
166177
|
+
stages.push(pushStage("push", `rsync failed: ${rsync.error}`, false));
|
|
166178
|
+
return { target: "static", ok: false, stages, error: rsync.error };
|
|
166179
|
+
}
|
|
166180
|
+
stages.push(pushStage("push", "sync complete"));
|
|
166181
|
+
const url3 = params.verifyUrl;
|
|
166182
|
+
if (url3) {
|
|
166183
|
+
stages.push(pushStage("verify", `checking ${url3}...`));
|
|
166184
|
+
const check2 = await run2("curl", ["-sf", url3], ctx.projectRoot);
|
|
166185
|
+
if (!check2.ok) {
|
|
166186
|
+
stages.push(pushStage("verify", `verify failed: ${check2.error}`, false));
|
|
166187
|
+
return { target: "static", ok: false, stages, error: check2.error };
|
|
166188
|
+
}
|
|
166189
|
+
stages.push(pushStage("verify", "verify ok"));
|
|
166190
|
+
}
|
|
166191
|
+
return { target: "static", ok: true, url: url3, stages };
|
|
166192
|
+
} catch (err) {
|
|
166193
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166194
|
+
stages.push(pushStage("done", `unexpected error: ${error51}`, false));
|
|
166195
|
+
return { target: "static", ok: false, stages, error: error51 };
|
|
166196
|
+
}
|
|
166197
|
+
}
|
|
166198
|
+
};
|
|
166199
|
+
});
|
|
166200
|
+
|
|
166201
|
+
// packages/omo-opencode/src/deployment/deploy-vercel.ts
|
|
166202
|
+
import { spawn as spawn7 } from "child_process";
|
|
166203
|
+
function pushStage2(stage, message, ok = true) {
|
|
166204
|
+
return { stage, message, ok };
|
|
166205
|
+
}
|
|
166206
|
+
function run3(cmd, args, cwd, env5) {
|
|
166207
|
+
return new Promise((resolve21) => {
|
|
166208
|
+
let output = "";
|
|
166209
|
+
let error51 = "";
|
|
166210
|
+
const child = spawn7(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
|
|
166211
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166212
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166213
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166214
|
+
});
|
|
166215
|
+
}
|
|
166216
|
+
var deployVercel;
|
|
166217
|
+
var init_deploy_vercel = __esm(() => {
|
|
166218
|
+
deployVercel = {
|
|
166219
|
+
name: "vercel",
|
|
166220
|
+
async deploy(ctx, params) {
|
|
166221
|
+
const stages = [];
|
|
166222
|
+
const prod = ctx.environment === "production";
|
|
166223
|
+
const token = process.env.VERCEL_TOKEN || params.token;
|
|
166224
|
+
try {
|
|
166225
|
+
if (prod && ctx.requireValidation && !params.force) {
|
|
166226
|
+
return {
|
|
166227
|
+
target: "vercel",
|
|
166228
|
+
ok: false,
|
|
166229
|
+
stages: [pushStage2("build", "production deploy to Vercel requires explicit validation", false)],
|
|
166230
|
+
error: "validation required"
|
|
166231
|
+
};
|
|
166232
|
+
}
|
|
166233
|
+
if (!ctx.execute) {
|
|
166234
|
+
return {
|
|
166235
|
+
target: "vercel",
|
|
166236
|
+
ok: true,
|
|
166237
|
+
stages: [
|
|
166238
|
+
pushStage2("build", `dry-run: would run vercel deploy${prod ? " --prod" : ""}`),
|
|
166239
|
+
pushStage2("verify", "dry-run: would verify deployment URL")
|
|
166240
|
+
]
|
|
166241
|
+
};
|
|
166242
|
+
}
|
|
166243
|
+
if (!token && prod) {
|
|
166244
|
+
stages.push(pushStage2("build", "VERCEL_TOKEN missing", false));
|
|
166245
|
+
return { target: "vercel", ok: false, stages, error: "missing VERCEL_TOKEN" };
|
|
166246
|
+
}
|
|
166247
|
+
const args = ["deploy"];
|
|
166248
|
+
if (prod)
|
|
166249
|
+
args.push("--prod");
|
|
166250
|
+
if (token)
|
|
166251
|
+
args.push("--token", token);
|
|
166252
|
+
if (params.scope)
|
|
166253
|
+
args.push("--scope", params.scope);
|
|
166254
|
+
stages.push(pushStage2("push", `vercel ${args.join(" ")}...`));
|
|
166255
|
+
const result = await run3("vercel", args, ctx.projectRoot, token ? { VERCEL_TOKEN: token } : undefined);
|
|
166256
|
+
if (!result.ok) {
|
|
166257
|
+
stages.push(pushStage2("push", `vercel deploy failed: ${result.error}`, false));
|
|
166258
|
+
return { target: "vercel", ok: false, stages, error: result.error };
|
|
166259
|
+
}
|
|
166260
|
+
const urlMatch = result.output.match(/https:\/\/[^\s]+\.vercel\.app/);
|
|
166261
|
+
const url3 = urlMatch?.[0];
|
|
166262
|
+
stages.push(pushStage2("verify", url3 ? `deployed to ${url3}` : "deployed (URL not parsed)"));
|
|
166263
|
+
return { target: "vercel", ok: true, url: url3, stages };
|
|
166264
|
+
} catch (err) {
|
|
166265
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166266
|
+
stages.push(pushStage2("done", `unexpected error: ${error51}`, false));
|
|
166267
|
+
return { target: "vercel", ok: false, stages, error: error51 };
|
|
166268
|
+
}
|
|
166269
|
+
}
|
|
166270
|
+
};
|
|
166271
|
+
});
|
|
166272
|
+
|
|
166273
|
+
// packages/omo-opencode/src/deployment/deploy-vps.ts
|
|
166274
|
+
import { spawn as spawn8 } from "child_process";
|
|
166275
|
+
function pushStage3(stage, message, ok = true) {
|
|
166276
|
+
return { stage, message, ok };
|
|
166277
|
+
}
|
|
166278
|
+
function run4(cmd, args, cwd, env5) {
|
|
166279
|
+
return new Promise((resolve21) => {
|
|
166280
|
+
let output = "";
|
|
166281
|
+
let error51 = "";
|
|
166282
|
+
const child = spawn8(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
|
|
166283
|
+
child.stdout.on("data", (d) => output += d.toString());
|
|
166284
|
+
child.stderr.on("data", (d) => error51 += d.toString());
|
|
166285
|
+
child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
|
|
166286
|
+
});
|
|
166287
|
+
}
|
|
166288
|
+
var deployVps;
|
|
166289
|
+
var init_deploy_vps = __esm(() => {
|
|
166290
|
+
deployVps = {
|
|
166291
|
+
name: "vps",
|
|
166292
|
+
async deploy(ctx, params) {
|
|
166293
|
+
const stages = [];
|
|
166294
|
+
const host = params.host;
|
|
166295
|
+
const user = params.user ?? "deploy";
|
|
166296
|
+
const remoteDir = params.remoteDir;
|
|
166297
|
+
const buildDir = params.buildDir ?? "dist";
|
|
166298
|
+
const service = params.service;
|
|
166299
|
+
const healthUrl = params.healthUrl;
|
|
166300
|
+
try {
|
|
166301
|
+
if (!host || !remoteDir) {
|
|
166302
|
+
return { target: "vps", ok: false, stages: [pushStage3("build", "missing host or remoteDir", false)], error: "missing parameters" };
|
|
166303
|
+
}
|
|
166304
|
+
if (ctx.environment === "production" && ctx.requireValidation && !params.force) {
|
|
166305
|
+
return {
|
|
166306
|
+
target: "vps",
|
|
166307
|
+
ok: false,
|
|
166308
|
+
stages: [pushStage3("build", "production deploy to VPS requires explicit validation", false)],
|
|
166309
|
+
error: "validation required"
|
|
166310
|
+
};
|
|
166311
|
+
}
|
|
166312
|
+
if (!ctx.execute) {
|
|
166313
|
+
return {
|
|
166314
|
+
target: "vps",
|
|
166315
|
+
ok: true,
|
|
166316
|
+
stages: [
|
|
166317
|
+
pushStage3("build", `dry-run: would build in ${ctx.projectRoot}`),
|
|
166318
|
+
pushStage3("push", `dry-run: would rsync ${buildDir} to ${user}@${host}:${remoteDir}`),
|
|
166319
|
+
pushStage3("verify", `dry-run: would restart ${service ?? "service"} + health check ${healthUrl ?? ""}`)
|
|
166320
|
+
]
|
|
166321
|
+
};
|
|
166322
|
+
}
|
|
166323
|
+
stages.push(pushStage3("build", "building..."));
|
|
166324
|
+
const build = await run4("bun", ["run", "build"], ctx.projectRoot);
|
|
166325
|
+
if (!build.ok) {
|
|
166326
|
+
stages.push(pushStage3("build", `build failed: ${build.error}`, false));
|
|
166327
|
+
return { target: "vps", ok: false, stages, error: build.error };
|
|
166328
|
+
}
|
|
166329
|
+
stages.push(pushStage3("build", "build ok"));
|
|
166330
|
+
stages.push(pushStage3("push", `rsync to ${host}...`));
|
|
166331
|
+
const rsync = await run4("rsync", ["-avz", "--delete", `${buildDir}/`, `${user}@${host}:${remoteDir}/`], ctx.projectRoot);
|
|
166332
|
+
if (!rsync.ok) {
|
|
166333
|
+
stages.push(pushStage3("push", `rsync failed: ${rsync.error}`, false));
|
|
166334
|
+
return { target: "vps", ok: false, stages, error: rsync.error };
|
|
166335
|
+
}
|
|
166336
|
+
stages.push(pushStage3("push", "rsync ok"));
|
|
166337
|
+
if (service) {
|
|
166338
|
+
stages.push(pushStage3("verify", `restarting ${service}...`));
|
|
166339
|
+
const restart = await run4("ssh", [`${user}@${host}`, `sudo systemctl restart ${service}`], ctx.projectRoot);
|
|
166340
|
+
if (!restart.ok) {
|
|
166341
|
+
stages.push(pushStage3("verify", `restart failed: ${restart.error}`, false));
|
|
166342
|
+
return { target: "vps", ok: false, stages, error: restart.error };
|
|
166343
|
+
}
|
|
166344
|
+
stages.push(pushStage3("verify", "restart ok"));
|
|
166345
|
+
}
|
|
166346
|
+
if (healthUrl) {
|
|
166347
|
+
stages.push(pushStage3("verify", `health check ${healthUrl}...`));
|
|
166348
|
+
await new Promise((r2) => setTimeout(r2, 2000));
|
|
166349
|
+
const health = await run4("curl", ["-sf", healthUrl], ctx.projectRoot);
|
|
166350
|
+
if (!health.ok) {
|
|
166351
|
+
stages.push(pushStage3("verify", `health check failed: ${health.error}`, false));
|
|
166352
|
+
return { target: "vps", ok: false, stages, error: health.error };
|
|
166353
|
+
}
|
|
166354
|
+
stages.push(pushStage3("verify", "health ok"));
|
|
166355
|
+
}
|
|
166356
|
+
return { target: "vps", ok: true, url: healthUrl, stages };
|
|
166357
|
+
} catch (err) {
|
|
166358
|
+
const error51 = err instanceof Error ? err.message : String(err);
|
|
166359
|
+
stages.push(pushStage3("done", `unexpected error: ${error51}`, false));
|
|
166360
|
+
return { target: "vps", ok: false, stages, error: error51 };
|
|
166361
|
+
}
|
|
166362
|
+
}
|
|
166363
|
+
};
|
|
166364
|
+
});
|
|
166365
|
+
|
|
166366
|
+
// packages/omo-opencode/src/deployment/deploy-cli.ts
|
|
166367
|
+
import { resolve as resolve21 } from "path";
|
|
166368
|
+
async function runDeploy(options) {
|
|
166369
|
+
const target = getTarget(options.target);
|
|
166370
|
+
if (!target) {
|
|
166371
|
+
console.error(`Unknown deployment target: ${options.target}`);
|
|
166372
|
+
console.error(`Available: ${["static", "vercel", "vps", "docker", "wordpress"].join(", ")}`);
|
|
166373
|
+
return 1;
|
|
166374
|
+
}
|
|
166375
|
+
const project = options.projectRoot ? undefined : await getActiveProject();
|
|
166376
|
+
if (!options.projectRoot && !project) {
|
|
166377
|
+
console.error("No active project. Run `matrixos project switch <slug>` or pass --project-root.");
|
|
166378
|
+
return 1;
|
|
166379
|
+
}
|
|
166380
|
+
const projectRoot = resolve21(options.projectRoot ?? getProjectDir(project.slug));
|
|
166381
|
+
const ctx = {
|
|
166382
|
+
projectRoot,
|
|
166383
|
+
projectSlug: project?.slug,
|
|
166384
|
+
environment: options.environment ?? (options.dryRun ? "staging" : "production"),
|
|
166385
|
+
execute: !options.dryRun,
|
|
166386
|
+
requireValidation: true
|
|
166387
|
+
};
|
|
166388
|
+
const params = {};
|
|
166389
|
+
for (const p2 of options.params ?? []) {
|
|
166390
|
+
const [key, ...rest] = p2.split("=");
|
|
166391
|
+
if (key)
|
|
166392
|
+
params[key] = rest.join("=");
|
|
166393
|
+
}
|
|
166394
|
+
if (ctx.environment === "production" && ctx.requireValidation && !options.force) {
|
|
166395
|
+
console.warn("Production deployment. This action requires explicit validation.");
|
|
166396
|
+
console.warn("Re-run with --force to confirm, or use --env staging.");
|
|
166397
|
+
return 1;
|
|
166398
|
+
}
|
|
166399
|
+
const result = await target.deploy(ctx, params);
|
|
166400
|
+
if (result.ok) {
|
|
166401
|
+
console.log(`\u2713 Deployed to ${result.target}${result.url ? ` \u2192 ${result.url}` : ""}`);
|
|
166402
|
+
for (const s of result.stages) {
|
|
166403
|
+
console.log(` [${s.stage}] ${s.ok ? "\u2713" : "\u2717"} ${s.message}`);
|
|
166404
|
+
}
|
|
166405
|
+
return 0;
|
|
166406
|
+
}
|
|
166407
|
+
console.error(`\u2717 Deploy to ${result.target} failed: ${result.error ?? "unknown error"}`);
|
|
166408
|
+
for (const s of result.stages) {
|
|
166409
|
+
console.log(` [${s.stage}] ${s.ok ? "\u2713" : "\u2717"} ${s.message}`);
|
|
166410
|
+
}
|
|
166411
|
+
return 1;
|
|
166412
|
+
}
|
|
166413
|
+
var init_deploy_cli = __esm(() => {
|
|
166414
|
+
init_project_context();
|
|
166415
|
+
init_deployment_core();
|
|
166416
|
+
});
|
|
166417
|
+
|
|
166418
|
+
// packages/omo-opencode/src/deployment/index.ts
|
|
166419
|
+
var exports_deployment = {};
|
|
166420
|
+
__export(exports_deployment, {
|
|
166421
|
+
targets: () => targets,
|
|
166422
|
+
runDeploy: () => runDeploy,
|
|
166423
|
+
registerTarget: () => registerTarget,
|
|
166424
|
+
listTargets: () => listTargets,
|
|
166425
|
+
getTarget: () => getTarget,
|
|
166426
|
+
deployVps: () => deployVps,
|
|
166427
|
+
deployVercel: () => deployVercel,
|
|
166428
|
+
deployStatic: () => deployStatic
|
|
166429
|
+
});
|
|
166430
|
+
var init_deployment = __esm(() => {
|
|
166431
|
+
init_deployment_core();
|
|
166432
|
+
init_deploy_static();
|
|
166433
|
+
init_deploy_vercel();
|
|
166434
|
+
init_deploy_vps();
|
|
166435
|
+
init_deploy_static();
|
|
166436
|
+
init_deploy_vercel();
|
|
166437
|
+
init_deploy_vps();
|
|
166438
|
+
init_deploy_cli();
|
|
166439
|
+
init_deployment_core();
|
|
166440
|
+
registerTarget(deployStatic);
|
|
166441
|
+
registerTarget(deployVercel);
|
|
166442
|
+
registerTarget(deployVps);
|
|
166443
|
+
});
|
|
166444
|
+
|
|
166089
166445
|
// packages/omo-opencode/src/audit/self-audit.ts
|
|
166090
|
-
import { existsSync as
|
|
166446
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync29, readdirSync as readdirSync17, readFileSync as readFileSync63, writeFileSync as writeFileSync29 } from "fs";
|
|
166091
166447
|
import { join as join83 } from "path";
|
|
166092
166448
|
function getAuditDir(cwd = process.cwd()) {
|
|
166093
166449
|
return join83(cwd, ".matrixos", "audits");
|
|
@@ -187060,6 +187416,9 @@ function configureRuntimeCommands(program2) {
|
|
|
187060
187416
|
init_package();
|
|
187061
187417
|
var VERSION4 = package_default.version;
|
|
187062
187418
|
var program2 = new Command;
|
|
187419
|
+
function collectParams(value, previous) {
|
|
187420
|
+
return previous.concat([value]);
|
|
187421
|
+
}
|
|
187063
187422
|
function resolveInstallArgs(options, invocationName = process.env.OMO_INVOCATION_NAME) {
|
|
187064
187423
|
const defaultPlatform = invocationName === "lazycodex" || invocationName === "lazycodex-ai" ? "codex" : undefined;
|
|
187065
187424
|
const platform2 = options.platform ?? defaultPlatform;
|
|
@@ -187374,6 +187733,19 @@ gateway2.command("status").description("Check gateway status (best-effort, inspe
|
|
|
187374
187733
|
}, null, 2) + `
|
|
187375
187734
|
`);
|
|
187376
187735
|
});
|
|
187736
|
+
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) => {
|
|
187737
|
+
const { runDeploy: runDeploy2 } = await Promise.resolve().then(() => (init_deployment(), exports_deployment));
|
|
187738
|
+
const env5 = options.env;
|
|
187739
|
+
const code = await runDeploy2({
|
|
187740
|
+
target,
|
|
187741
|
+
environment: env5,
|
|
187742
|
+
dryRun: options.dryRun,
|
|
187743
|
+
force: options.force,
|
|
187744
|
+
projectRoot: options.projectRoot,
|
|
187745
|
+
params: options.param
|
|
187746
|
+
});
|
|
187747
|
+
process.exit(code);
|
|
187748
|
+
});
|
|
187377
187749
|
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) => {
|
|
187378
187750
|
const { executeSelfAuditCommand: executeSelfAuditCommand2 } = await Promise.resolve().then(() => (init_self_audit_command(), exports_self_audit_command));
|
|
187379
187751
|
const result = await executeSelfAuditCommand2(options);
|
|
@@ -187387,13 +187759,22 @@ program2.command("self-audit").description("Generate the weekly self-audit repor
|
|
|
187387
187759
|
}
|
|
187388
187760
|
process.exit(result.ok ? 0 : 1);
|
|
187389
187761
|
});
|
|
187390
|
-
program2.command("adopt").description("Re-run the MaTrixOS adoption wizard (providers, channels, profile)").addHelpText("after", `
|
|
187762
|
+
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", `
|
|
187391
187763
|
Examples:
|
|
187392
187764
|
$ matrixos adopt # interactive re-adoption (TUI)
|
|
187765
|
+
$ matrixos adopt telegram # alias for: matrixos gateway adopt telegram
|
|
187393
187766
|
|
|
187394
187767
|
For channel-specific setup, use:
|
|
187395
187768
|
$ matrixos gateway adopt telegram
|
|
187396
|
-
`).action(async () => {
|
|
187769
|
+
`).action(async (channel) => {
|
|
187770
|
+
if (channel) {
|
|
187771
|
+
const { runAdopt: runAdopt3 } = await Promise.resolve().then(() => (init_adopt(), exports_adopt));
|
|
187772
|
+
const result2 = await runAdopt3({ channel, nonInteractive: true });
|
|
187773
|
+
console.log(result2.message);
|
|
187774
|
+
if (!result2.ok)
|
|
187775
|
+
process.exit(1);
|
|
187776
|
+
return;
|
|
187777
|
+
}
|
|
187397
187778
|
const { runAdopt: runAdopt2 } = await Promise.resolve().then(() => (init_adopt(), exports_adopt));
|
|
187398
187779
|
const result = await runAdopt2({});
|
|
187399
187780
|
if (!result.ok)
|
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.7",
|
|
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",
|
|
@@ -165810,6 +165810,13 @@ async function runAdopt(options = {}) {
|
|
|
165810
165810
|
message: "Global adoption requires an interactive terminal. Run: matrixos adopt (no arguments)."
|
|
165811
165811
|
};
|
|
165812
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
|
+
}
|
|
165813
165820
|
console.log(`
|
|
165814
165821
|
=== MaTrixOS Re-Adoption ===`);
|
|
165815
165822
|
console.log(`You can reconfigure providers, channels, and profile.
|
|
@@ -166141,8 +166148,357 @@ var init_gateway_start = __esm(() => {
|
|
|
166141
166148
|
ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
|
|
166142
166149
|
});
|
|
166143
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
|
+
|
|
166144
166500
|
// packages/omo-opencode/src/audit/self-audit.ts
|
|
166145
|
-
import { existsSync as
|
|
166501
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync29, readdirSync as readdirSync17, readFileSync as readFileSync63, writeFileSync as writeFileSync29 } from "fs";
|
|
166146
166502
|
import { join as join83 } from "path";
|
|
166147
166503
|
function getAuditDir(cwd = process.cwd()) {
|
|
166148
166504
|
return join83(cwd, ".matrixos", "audits");
|
|
@@ -187115,6 +187471,9 @@ function configureRuntimeCommands(program2) {
|
|
|
187115
187471
|
init_package();
|
|
187116
187472
|
var VERSION4 = package_default.version;
|
|
187117
187473
|
var program2 = new Command;
|
|
187474
|
+
function collectParams(value, previous) {
|
|
187475
|
+
return previous.concat([value]);
|
|
187476
|
+
}
|
|
187118
187477
|
function resolveInstallArgs(options, invocationName = process.env.OMO_INVOCATION_NAME) {
|
|
187119
187478
|
const defaultPlatform = invocationName === "lazycodex" || invocationName === "lazycodex-ai" ? "codex" : undefined;
|
|
187120
187479
|
const platform2 = options.platform ?? defaultPlatform;
|
|
@@ -187429,6 +187788,19 @@ gateway2.command("status").description("Check gateway status (best-effort, inspe
|
|
|
187429
187788
|
}, null, 2) + `
|
|
187430
187789
|
`);
|
|
187431
187790
|
});
|
|
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
|
+
});
|
|
187432
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) => {
|
|
187433
187805
|
const { executeSelfAuditCommand: executeSelfAuditCommand2 } = await Promise.resolve().then(() => (init_self_audit_command(), exports_self_audit_command));
|
|
187434
187806
|
const result = await executeSelfAuditCommand2(options);
|
|
@@ -187442,13 +187814,22 @@ program2.command("self-audit").description("Generate the weekly self-audit repor
|
|
|
187442
187814
|
}
|
|
187443
187815
|
process.exit(result.ok ? 0 : 1);
|
|
187444
187816
|
});
|
|
187445
|
-
program2.command("adopt").description("Re-run the MaTrixOS adoption wizard (providers, channels, profile)").addHelpText("after", `
|
|
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", `
|
|
187446
187818
|
Examples:
|
|
187447
187819
|
$ matrixos adopt # interactive re-adoption (TUI)
|
|
187820
|
+
$ matrixos adopt telegram # alias for: matrixos gateway adopt telegram
|
|
187448
187821
|
|
|
187449
187822
|
For channel-specific setup, use:
|
|
187450
187823
|
$ matrixos gateway adopt telegram
|
|
187451
|
-
`).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
|
+
}
|
|
187452
187833
|
const { runAdopt: runAdopt2 } = await Promise.resolve().then(() => (init_adopt(), exports_adopt));
|
|
187453
187834
|
const result = await runAdopt2({});
|
|
187454
187835
|
if (!result.ok)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy-cli.ts
|
|
3
|
+
*
|
|
4
|
+
* Handles `matrixos deploy <target> [options]`.
|
|
5
|
+
*/
|
|
6
|
+
export interface DeployOptions {
|
|
7
|
+
target: string;
|
|
8
|
+
projectRoot?: string;
|
|
9
|
+
environment?: "staging" | "production" | "preview";
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
force?: boolean;
|
|
12
|
+
params?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function runDeploy(options: DeployOptions): Promise<number>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A6 — Deployment skills core
|
|
3
|
+
*
|
|
4
|
+
* Shared types and helpers for MaTrixOS deployment skills.
|
|
5
|
+
* Each target implements the DeploymentTarget interface.
|
|
6
|
+
*/
|
|
7
|
+
export type DeploymentStage = "build" | "push" | "verify" | "rollback" | "done";
|
|
8
|
+
export interface DeploymentProgress {
|
|
9
|
+
stage: DeploymentStage;
|
|
10
|
+
message: string;
|
|
11
|
+
ok: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface DeploymentContext {
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
/** Active project slug from `matrixos project switch`. */
|
|
16
|
+
projectSlug?: string;
|
|
17
|
+
/** Environment name: staging, production, preview... */
|
|
18
|
+
environment: "staging" | "production" | "preview";
|
|
19
|
+
/** If true, perform the deployment; if false, dry-run. */
|
|
20
|
+
execute: boolean;
|
|
21
|
+
/** If true, require explicit user validation before production deploy. */
|
|
22
|
+
requireValidation: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DeploymentResult {
|
|
25
|
+
target: string;
|
|
26
|
+
ok: boolean;
|
|
27
|
+
url?: string;
|
|
28
|
+
stages: DeploymentProgress[];
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DeploymentTarget {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
deploy(ctx: DeploymentContext, params: Record<string, string>): Promise<DeploymentResult>;
|
|
34
|
+
}
|
|
35
|
+
export declare const targets: Map<string, DeploymentTarget>;
|
|
36
|
+
export declare function registerTarget(target: DeploymentTarget): void;
|
|
37
|
+
export declare function getTarget(name: string): DeploymentTarget | undefined;
|
|
38
|
+
export declare function listTargets(): string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment skills index (A6).
|
|
3
|
+
*
|
|
4
|
+
* Registers all built-in deployment targets so the CLI can look them up.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./deployment-core";
|
|
7
|
+
export { deployStatic } from "./deploy-static";
|
|
8
|
+
export { deployVercel } from "./deploy-vercel";
|
|
9
|
+
export { deployVps } from "./deploy-vps";
|
|
10
|
+
export { runDeploy, type DeployOptions } from "./deploy-cli";
|
package/dist/index.js
CHANGED
|
@@ -368023,7 +368023,7 @@ function getCachedVersion(options = {}) {
|
|
|
368023
368023
|
// package.json
|
|
368024
368024
|
var package_default = {
|
|
368025
368025
|
name: "@kl-c/matrixos",
|
|
368026
|
-
version: "0.2.
|
|
368026
|
+
version: "0.2.7",
|
|
368027
368027
|
description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
|
|
368028
368028
|
main: "./dist/index.js",
|
|
368029
368029
|
types: "dist/index.d.ts",
|
package/package.json
CHANGED