chore: 保存剩余工作区改动并清理到干净状态
- 补 OnlyOffice callback 附件写回的 media asset bridge 适配层,并继续扩展 documents bridge/测试覆盖 - 提交当前 OMX hooks 删除与 Harness 运行状态文件更新,保留本轮任务执行轨迹 - 一并提交仓库中已跟踪的 Rust target 构建产物与相关协议桥接变更,确保工作区清零
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { appendFileSync, mkdirSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
function rootDir() {
|
||||
try {
|
||||
return execSync("git rev-parse --show-toplevel", {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
} catch {
|
||||
return process.cwd();
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
try {
|
||||
return JSON.parse(readFileSync(0, "utf8") || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const payload = readStdin();
|
||||
const root = rootDir();
|
||||
mkdirSync(join(root, ".omx", "logs"), { recursive: true });
|
||||
const exitCode =
|
||||
typeof payload?.tool_output?.exit_code === "number"
|
||||
? payload.tool_output.exit_code
|
||||
: typeof payload?.exit_code === "number"
|
||||
? payload.exit_code
|
||||
: null;
|
||||
const status = exitCode ?? "unknown";
|
||||
const isExplicitBashFailure = payload?.tool_name === "Bash" && exitCode !== null && exitCode !== 0;
|
||||
appendFileSync(
|
||||
join(root, ".omx", "logs", "hooks.log"),
|
||||
`${new Date().toISOString()} PostToolUse status=${status} ${JSON.stringify(payload)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
continue: true,
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "PostToolUse",
|
||||
additionalContext: isExplicitBashFailure ? "OMX noticed a failing Bash command. Check the team inbox or diagnostics." : "",
|
||||
},
|
||||
}));
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
function readStdin() {
|
||||
try {
|
||||
return JSON.parse(readFileSync(0, "utf8") || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const payload = readStdin();
|
||||
const command = JSON.stringify(payload).toLowerCase();
|
||||
const blocked = [
|
||||
"rm -rf /",
|
||||
"mkfs",
|
||||
"dd if=",
|
||||
"shutdown",
|
||||
"reboot",
|
||||
"poweroff",
|
||||
"git reset --hard",
|
||||
];
|
||||
|
||||
if (blocked.some((token) => command.includes(token))) {
|
||||
process.stdout.write(JSON.stringify({
|
||||
decision: "block",
|
||||
reason: "OMX safety hook blocked an obviously destructive command.",
|
||||
}));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
continue: true,
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "PreToolUse",
|
||||
},
|
||||
}));
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
function rootDir() {
|
||||
try {
|
||||
return execSync("git rev-parse --show-toplevel", {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
} catch {
|
||||
return process.cwd();
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
try {
|
||||
return JSON.parse(readFileSync(0, "utf8") || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function readJson(path, fallback) {
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(path, value) {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify(value, null, 2), "utf8");
|
||||
}
|
||||
|
||||
const root = rootDir();
|
||||
const payload = readStdin();
|
||||
const omx = join(root, ".omx");
|
||||
mkdirSync(join(omx, "logs"), { recursive: true });
|
||||
appendFileSync(join(omx, "logs", "hooks.log"), `${new Date().toISOString()} SessionStart ${JSON.stringify(payload)}\n`, "utf8");
|
||||
|
||||
const runtimePath = join(omx, "state", "hook-runtime.json");
|
||||
const runtime = readJson(runtimePath, {});
|
||||
writeJson(runtimePath, {
|
||||
...runtime,
|
||||
lastSessionStartAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
continue: true,
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "SessionStart",
|
||||
additionalContext: "",
|
||||
},
|
||||
}));
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
function rootDir() {
|
||||
try {
|
||||
return execSync("git rev-parse --show-toplevel", {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
} catch {
|
||||
return process.cwd();
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
try {
|
||||
return JSON.parse(readFileSync(0, "utf8") || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function readJson(path, fallback) {
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(path, value) {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify(value, null, 2), "utf8");
|
||||
}
|
||||
|
||||
const root = rootDir();
|
||||
const payload = readStdin();
|
||||
const omx = join(root, ".omx");
|
||||
mkdirSync(join(omx, "logs"), { recursive: true });
|
||||
appendFileSync(join(omx, "logs", "hooks.log"), `${new Date().toISOString()} Stop ${JSON.stringify(payload)}\n`, "utf8");
|
||||
|
||||
const runtimePath = join(omx, "state", "hook-runtime.json");
|
||||
const runtime = readJson(runtimePath, {});
|
||||
writeJson(runtimePath, {
|
||||
...runtime,
|
||||
lastStopAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
continue: true,
|
||||
}));
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
function rootDir() {
|
||||
try {
|
||||
return execSync("git rev-parse --show-toplevel", {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
} catch {
|
||||
return process.cwd();
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
try {
|
||||
return JSON.parse(readFileSync(0, "utf8") || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function readJson(path, fallback) {
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(path, value) {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify(value, null, 2), "utf8");
|
||||
}
|
||||
|
||||
const root = rootDir();
|
||||
const payload = readStdin();
|
||||
const omx = join(root, ".omx");
|
||||
mkdirSync(join(omx, "logs"), { recursive: true });
|
||||
appendFileSync(join(omx, "logs", "hooks.log"), `${new Date().toISOString()} UserPromptSubmit ${JSON.stringify(payload)}\n`, "utf8");
|
||||
|
||||
const runtimePath = join(omx, "state", "hook-runtime.json");
|
||||
const runtime = readJson(runtimePath, {});
|
||||
writeJson(runtimePath, {
|
||||
...runtime,
|
||||
lastPromptAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
continue: true,
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "UserPromptSubmit",
|
||||
additionalContext: "",
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user