[bug] Socrates launchd-path adapter throws EISDIR when an import names a folder beside its .ts file
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bun, node.js, typescript
- Lĩnh vực
- devops
Hướng nghiên cứu
Bắt đầu với LIFEOS/SOCRATES/adapters/launchd-path.ts, đặc biệt là commandsIn() và cách phân giải các ứng viên import, sau đó xem lại các trường hợp đề xuất trong LIFEOS/SOCRATES/adapters/launchd-path.test.ts. Chạy bun test LIFEOS/SOCRATES/adapters/launchd-path.test.ts; bản sửa hoàn tất khi các thư mục được bỏ qua thay vì bị đọc, ./lib.ts được tìm thấy bên cạnh ./lib và một mục thư mục trả về danh sách lệnh rỗng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
LifeOS 8.761.0 · attestation: 165 system file(s) differ from danielmiessler/[email protected] · 9 system file(s) missing:
- hooks/VoiceCompletion.hook.ts
- hooks/ISASync.hook.ts
- hooks/ModelDriftGuard.hook.ts
- hooks/README.md
- hooks/ISARenderOnStop.hook.ts
- hooks/PromptProcessing.hook.ts
- hooks/lib/work-config.ts
- hooks/lib/herdr-tabs.ts
- hooks/lib/notification-channel.ts
- hooks/FormatGate.hook.ts
- hooks/SubagentGitSandbox.hook.ts
- hooks/handlers/VoiceNotification.ts
- hooks/handlers/DocCrossRefIntegrity.ts
- hooks/handlers/UpdateCounts.ts
- skills/Prioritize/Tools/Prioritize.ts
- skills/Prioritize/Setup.md
- skills/StateLog/SKILL.md
- skills/Errata/Tools/Er.ts
- skills/Errata/Tools/Send.ts
- skills/Errata/Intents/Send.md
- skills/CreateSkill/SKILL.md
- skills/CreateSkill/Intents/OptimizeDescription.md
- skills/CreateSkill/Intents/CreateSkill.md
- skills/RichFormat/tests/engine.test.tsx
- skills/RichFormat/hooks/table.ts
- skills/RichFormat/hooks/workflow.ts
- skills/RichFormat/hooks/register.tsx
- skills/RichFormat/hooks/stream.ts
- skills/RichFormat/SKILL.md
- skills/LifeOSHooks/hooks/LifeOSHooks.ts
- skills/Herdr/Intents/Configure.md
- skills/Interview/Intents/Phase0Setup.md
- skills/LifeOS/SKILL.md
- skills/Fabric/Patterns/create_better_frame/system.md
- skills/Fabric/Patterns/extract_article_wisdom/README.md
- skills/Fabric/Patterns/extract_wisdom/README.md
- skills/Fabric/Patterns/rate_value/README.md
- skills/Fabric/Patterns/extract_product_features/README.md
- skills/Fabric/Patterns/show_fabric_options_markmap/system.md
- skills/Interceptor/SKILL.md
- …and 125 more
What is broken
The Socrates launchd-path adapter reads a directory as if it were a file and throws EISDIR. commandsIn() follows a job script's relative imports one level deep and, for an import such as ./lib, takes the first of base, base.ts, base.js, base/index.ts for which existsSync() is true. When a lib/ folder sits next to lib.ts, the first candidate is the folder, readFileSync throws, and the adapter run fails. The question it answers (does every command a launchd job spawns resolve on launchd's PATH) then stays unknown for every job, with no hint why. The same happens when the entry script path itself is a directory.
Where (file:line)
LIFEOS/SOCRATES/adapters/launchd-path.ts:41
Repro on a clean tree
1. On a clean 8.761.0 tree, add the two tests from the attached diff (`LIFEOS/SOCRATES/adapters/launchd-path.test.ts`). They build a temp job script that imports `./lib`, with both `lib/` and `lib.ts` beside it, and also hand a folder in as the entry script.
2. Run `bun test LIFEOS/SOCRATES/adapters/launchd-path.test.ts`.
3. Expected: both pass. Actual: 0 pass, 2 fail, `EISDIR: illegal operation on a directory, read` at `launchd-path.ts:41` (`readFileSync` in `commandsIn`).
In a live install the same throw leaves the launchd-path question `unknown` on every `Socrates sync` once any job folder holds a directory named like one of its imports.
Negative control
Probe: cd /tmp/claude-501/d1-clean && bun test LIFEOS/SOCRATES/adapters/launchd-path.test.ts · exit 1 · captured 2026-12-02T01:08:26.791Z
Red looks like: EISDIR
bun test v1.4.3 (c6da4a4d3)
--- stderr ---
LIFEOS/SOCRATES/adapters/launchd-path.test.ts:
36 |
37 | /** Command names a script (and its ./ imports, one level) hands to spawn-shaped calls. */
38 | export function commandsIn(file: string, depth = 1, seen = new Set<string>()): string[] {
39 | if (seen.has(file) || !existsSync(file)) return [];
40 | seen.add(file);
41 | const src = readFileSync(file, "utf8");
^
error: EISDIR: illegal operation on a directory, read
at commandsIn (/private/tmp/claude-501/d1-clean/LIFEOS/SOCRATES/adapters/launchd-path.ts:41:15)
at commandsIn (/private/tmp/claude-501/d1-clean/LIFEOS/SOCRATES/adapters/launchd-path.ts:48:126)
at <anonymous> (/private/tmp/claude-501/d1-clean/LIFEOS/SOCRATES/adapters/launchd-path.test.ts:14:10)
(fail) an import that names a folder beside its .ts file is scanned, not read as a file [0.62ms]
36 |
37 | /** Command names a script (and its ./ imports, one level) hands to spawn-shaped calls. */
38 | export function commandsIn(file: string, depth = 1, seen = new Set<string>()): string[] {
39 | if (seen.has(file) || !existsSync(file)) return [];
40 | seen.add(file);
41 | const src = readFileSync(file, "utf8");
^
error: EISDIR: illegal operation on a directory, read
at commandsIn (/private/tmp/claude-501/d1-clean/LIFEOS/SOCRATES/adapters/launchd-path.ts:41:15)
at <anonymous> (/private/tmp/claude-501/d1-clean/LIFEOS/SOCRATES/adapters/launchd-path.test.ts:18:10)
(fail) a folder handed in as the entry script yields no commands instead of throwing [0.04ms]
0 pass
2 fail
Ran 2 tests across 1 file. [5.00ms]
Suggested fix
A small isFile() helper (statSync(p).isFile(), false on any error) replaces existsSync() in both places: the entry guard of commandsIn() and the candidate loop. A directory is never read as a file, so the loop moves on to lib.ts. Version bumped to launchd-path/1.0.1. With the fix both tests pass; on this install the launchd-path question answered 16 of 16 jobs again.
diff --git a/LIFEOS/SOCRATES/adapters/launchd-path.test.ts b/LIFEOS/SOCRATES/adapters/launchd-path.test.ts
new file mode 100644
index 00000000..84f70cbb
--- /dev/null
+++ b/LIFEOS/SOCRATES/adapters/launchd-path.test.ts
@@ -0,0 +1,19 @@
+import { afterAll, expect, test } from "bun:test";
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { commandsIn } from "./launchd-path";
+
+const dir = mkdtempSync(join(tmpdir(), "launchd-path-"));
+afterAll(() => rmSync(dir, { recursive: true, force: true }));
+
+test("an import that names a folder beside its .ts file is scanned, not read as a file", () => {
+ mkdirSync(join(dir, "lib"));
+ writeFileSync(join(dir, "lib.ts"), 'Bun.spawnSync(["plutil", "-p"]);\n');
+ writeFileSync(join(dir, "job.ts"), 'import { x } from "./lib";\nBun.spawn(["git", "status"]);\n');
+ expect(commandsIn(join(dir, "job.ts"))).toEqual(["git", "plutil"]);
+});
+
+test("a folder handed in as the entry script yields no commands instead of throwing", () => {
+ expect(commandsIn(join(dir, "lib"))).toEqual([]);
+});
diff --git a/LIFEOS/SOCRATES/adapters/launchd-path.ts b/LIFEOS/SOCRATES/adapters/launchd-path.ts
index 7a95a301..11cf85b0 100644
--- a/LIFEOS/SOCRATES/adapters/launchd-path.ts
+++ b/LIFEOS/SOCRATES/adapters/launchd-path.ts
@@ -16,14 +16,18 @@
* command built from a variable) stay untouched and are named as such.
*/
-import { existsSync, readdirSync, readFileSync } from "node:fs";
+import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { homedir } from "node:os";
import type { Adapter } from "./types";
import type { AnswerInput } from "../Store";
import type { Question } from "../Registry";
-const VERSION = "launchd-path/1.0.0";
+const VERSION = "launchd-path/1.0.1";
+
+/** A regular file, never a directory: `./lib` exists as a folder next to `./lib.ts`, and reading the folder threw
+ * EISDIR, which left the launchd-path question unknown for every job. */
+const isFile = (p: string): boolean => { try { return statSync(p).isFile(); } catch { return false; } };
/** launchd's PATH when a plist sets none (launchd.plist(5)). */
export const LAUNCHD_DEFAULT_PATH = "/usr/bin:/bin:/usr/sbin:/sbin";
const BUILTINS = new Set(["cd", "echo", "test", "true", "false", "exit", "export", "source", "set", "read", "printf", "eval", "exec", "trap", "wait", "kill", "command", "type", "sleep"]);
@@ -36,7 +40,7 @@ export interface JobSpec { label: string; program: string[]; path: string }
/** Command names a script (and its ./ imports, one level) hands to spawn-shaped calls. */
export function commandsIn(file: string, depth = 1, seen = new Set<string>()): string[] {
- if (seen.has(file) || !existsSync(file)) return [];
+ if (seen.has(file) || !isFile(file)) return [];
seen.add(file);
const src = readFileSync(file, "utf8");
const names = new Set<string>();
@@ -45,7 +49,7 @@ export function commandsIn(file: string, depth = 1, seen = new Set<string>()): s
if (depth > 0) {
for (const m of src.matchAll(/from\s+["'](\.{1,2}\/[^"']+)["']/g)) {
const base = resolve(dirname(file), m[1]);
- for (const cand of [base, base + ".ts", base + ".js", join(base, "index.ts")]) if (existsSync(cand)) { for (const n of commandsIn(cand, depth - 1, seen)) names.add(n); break; }
+ for (const cand of [base, base + ".ts", base + ".js", join(base, "index.ts")]) if (isFile(cand)) { for (const n of commandsIn(cand, depth - 1, seen)) names.add(n); break; }
}
}
return [...names].filter((n) => !n.includes("/") && !BUILTINS.has(n)).sort();
Environment
- OS: macOS 27.0 (arm64)
- Harness: claude-code
- bun: 1.4.3 · git: 2.54.0
- Doctor broken: none
- Ngôn ngữ chính
- TypeScript
- Star
- 20k
- Fork
- 2.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của danielmiessler/LifeOS
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
danielmiessler/LifeOS#3122 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
danielmiessler/LifeOS#3121 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
danielmiessler/LifeOS#3120 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
LifeOSHooks stamp ages out in a live session: native hooks run beside the plugin again after 7 daysĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
danielmiessler/LifeOS#3080 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
danielmiessler/LifeOS#3055 ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của danielmiessler/LifeOS
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
eliasstravik/herdr-projects#1700 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[SNZB-02DR2 / SONOFF] ???Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Koenkk/zigbee2mqtt#33890 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Feature]: Skill Workshop skill diet should use the configured utility model, not always the primaryĐang mởclawsweeper:fix-shape-clear clawsweeper:needs-live-repro clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr impact:auth-provider issue-rating: 🐚 platinum hermit P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
openclaw/openclaw#210348 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
platform:windows provider:antigravity-cli providers setup triaged wontfix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
can1357/oh-my-pi#21349 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày