Merge pull request #100 from pikasTech/fix/issue1037-ignore-non-shebang-tools
fix: ignore non-shebang gitbundle tool files
This commit is contained in:
@@ -166,7 +166,7 @@ HWLAB Workbench 的 project/workspace 不属于 RuntimeAssembly 四要素,也
|
|||||||
|
|
||||||
#### tools 目录
|
#### tools 目录
|
||||||
|
|
||||||
runner 对 workspace `tools/` 做统一装配:顶层带 shebang 的脚本会被 `chmod +x`,`tools/` 目录会追加到 `PATH`。`.ts` 工具脚本必须以 `#!/usr/bin/env bun` 或等价 shebang 开头;缺 shebang 必须 blocked 为 schema-invalid。短命令名称来自 repo 内真实文件,例如 `tools/hwpod`,不再由 runner 生成 wrapper。
|
runner 对 workspace `tools/` 做统一装配:顶层带 shebang 的脚本会被 `chmod +x`,`tools/` 目录会追加到 `PATH`。非 shebang 文件是随 bundle 复制的源码、测试或辅助文件,不作为可执行工具发现,也不触发 schema-invalid。短命令名称来自 repo 内真实文件,例如 `tools/hwpod`,不再由 runner 生成 wrapper。
|
||||||
|
|
||||||
#### promptRefs
|
#### promptRefs
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ async function prepareGitBundleTools(workspacePath: string): Promise<{ binPath?:
|
|||||||
const filePath = path.join(binPath, entry.name);
|
const filePath = path.join(binPath, entry.name);
|
||||||
const text = await readFile(filePath, "utf8");
|
const text = await readFile(filePath, "utf8");
|
||||||
const firstLine = text.split(/\r?\n/u, 1)[0] ?? "";
|
const firstLine = text.split(/\r?\n/u, 1)[0] ?? "";
|
||||||
if (entry.name.endsWith(".ts") && !firstLine.startsWith("#!")) throw new AgentRunError("schema-invalid", `gitbundle tool ${entry.name} must start with a shebang`, { httpStatus: 400 });
|
|
||||||
if (!firstLine.startsWith("#!")) continue;
|
if (!firstLine.startsWith("#!")) continue;
|
||||||
await chmod(filePath, 0o755);
|
await chmod(filePath, 0o755);
|
||||||
names.push(entry.name);
|
names.push(entry.name);
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ async function createLocalGitBundle(context: SelfTestContext): Promise<LocalBund
|
|||||||
await mkdir(path.join(repo, "tools"), { recursive: true });
|
await mkdir(path.join(repo, "tools"), { recursive: true });
|
||||||
await writeFile(path.join(repo, "tools", "hwpod"), "#!/usr/bin/env bun\nconsole.log(JSON.stringify({ ok: true, cli: 'hwpod-selftest', argv: process.argv.slice(2) }));\n", "utf8");
|
await writeFile(path.join(repo, "tools", "hwpod"), "#!/usr/bin/env bun\nconsole.log(JSON.stringify({ ok: true, cli: 'hwpod-selftest', argv: process.argv.slice(2) }));\n", "utf8");
|
||||||
await writeFile(path.join(repo, "tools", "hwpod-cli.mjs"), "console.log(JSON.stringify({ ok: true, cli: 'hwpod-cli-selftest', argv: process.argv.slice(2) }));\n", "utf8");
|
await writeFile(path.join(repo, "tools", "hwpod-cli.mjs"), "console.log(JSON.stringify({ ok: true, cli: 'hwpod-cli-selftest', argv: process.argv.slice(2) }));\n", "utf8");
|
||||||
|
await writeFile(path.join(repo, "tools", "hwpod-node.test.ts"), "console.log('test-only source file without shebang');\n", "utf8");
|
||||||
await mkdir(path.join(repo, "internal", "agent", "prompts"), { recursive: true });
|
await mkdir(path.join(repo, "internal", "agent", "prompts"), { recursive: true });
|
||||||
await writeFile(path.join(repo, "internal", "agent", "prompts", "hwlab-v02-runtime.md"), [
|
await writeFile(path.join(repo, "internal", "agent", "prompts", "hwlab-v02-runtime.md"), [
|
||||||
"HWLAB v0.2 runtime prompt self-test",
|
"HWLAB v0.2 runtime prompt self-test",
|
||||||
@@ -237,7 +238,7 @@ async function createLocalGitBundle(context: SelfTestContext): Promise<LocalBund
|
|||||||
"Use hwpod-ctl for HWPOD runtime inspection and control-plane state.",
|
"Use hwpod-ctl for HWPOD runtime inspection and control-plane state.",
|
||||||
].join("\n"), "utf8");
|
].join("\n"), "utf8");
|
||||||
await writeFile(path.join(repo, "skills", "hwpod-ctl", "scripts", "hwpod-ctl.mjs"), "console.log(JSON.stringify({ ok: true, cli: 'hwpod-ctl-skill-selftest' }));\n", "utf8");
|
await writeFile(path.join(repo, "skills", "hwpod-ctl", "scripts", "hwpod-ctl.mjs"), "console.log(JSON.stringify({ ok: true, cli: 'hwpod-ctl-skill-selftest' }));\n", "utf8");
|
||||||
await execFile("git", ["add", "README.md", "tools/hwpod", "tools/hwpod-cli.mjs", "internal/agent/prompts/hwlab-v02-runtime.md", "skills/hwpod-cli/SKILL.md", "skills/hwpod-cli/scripts/hwpod-cli.mjs", "skills/hwpod-ctl/SKILL.md", "skills/hwpod-ctl/scripts/hwpod-ctl.mjs"], { cwd: repo });
|
await execFile("git", ["add", "README.md", "tools/hwpod", "tools/hwpod-cli.mjs", "tools/hwpod-node.test.ts", "internal/agent/prompts/hwlab-v02-runtime.md", "skills/hwpod-cli/SKILL.md", "skills/hwpod-cli/scripts/hwpod-cli.mjs", "skills/hwpod-ctl/SKILL.md", "skills/hwpod-ctl/scripts/hwpod-ctl.mjs"], { cwd: repo });
|
||||||
await execFile("git", ["-c", "user.email=selftest@example.invalid", "-c", "user.name=AgentRun SelfTest", "commit", "-m", "bundle selftest"], { cwd: repo });
|
await execFile("git", ["-c", "user.email=selftest@example.invalid", "-c", "user.name=AgentRun SelfTest", "commit", "-m", "bundle selftest"], { cwd: repo });
|
||||||
const { stdout } = await execFile("git", ["rev-parse", "HEAD"], { cwd: repo });
|
const { stdout } = await execFile("git", ["rev-parse", "HEAD"], { cwd: repo });
|
||||||
return { repoUrl: repo, commitId: stdout.trim() };
|
return { repoUrl: repo, commitId: stdout.trim() };
|
||||||
|
|||||||
Reference in New Issue
Block a user