MCPcopy
hub / github.com/affaan-m/ECC / main

Function main

tests/opencode-plugin-hooks.test.js:82–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82async function main() {
83 console.log("\n=== Testing OpenCode plugin hooks ===\n")
84
85 const { ECCHooksPlugin } = await loadPlugin()
86 const tests = [
87 [
88 "shell.env detects project markers without shelling out to test -f",
89 async () => withTempProject(
90 ["pnpm-lock.yaml", "tsconfig.json", "pyproject.toml"],
91 async (projectDir) => {
92 const client = createClient()
93 const $ = createFailingShell()
94 const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
95
96 const env = await hooks["shell.env"]()
97
98 assert.deepStrictEqual($.calls, [], `Unexpected shell probes: ${$.calls.join(", ")}`)
99 assert.strictEqual(env.PROJECT_ROOT, projectDir)
100 assert.strictEqual(env.PACKAGE_MANAGER, "pnpm")
101 assert.strictEqual(env.DETECTED_LANGUAGES, "typescript,python")
102 assert.strictEqual(env.PRIMARY_LANGUAGE, "typescript")
103 }
104 ),
105 ],
106 [
107 "session.created checks CLAUDE.md through fs instead of shell test",
108 async () => withTempProject(["CLAUDE.md"], async (projectDir) => {
109 const client = createClient()
110 const $ = createFailingShell()
111 const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
112
113 await hooks["session.created"]()
114
115 assert.deepStrictEqual($.calls, [], `Unexpected shell probes: ${$.calls.join(", ")}`)
116 assert.ok(
117 client.logs.some((entry) => entry.message === "[ECC] Found CLAUDE.md - loading project context"),
118 "Expected CLAUDE.md detection log"
119 )
120 }),
121 ],
122 [
123 "session.created ignores directories named CLAUDE.md",
124 async () => {
125 const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "ecc-opencode-plugin-"))
126 try {
127 fs.mkdirSync(path.join(projectDir, "CLAUDE.md"))
128
129 const client = createClient()
130 const $ = createFailingShell()
131 const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
132
133 await hooks["session.created"]()
134
135 assert.deepStrictEqual($.calls, [], `Unexpected shell probes: ${$.calls.join(", ")}`)
136 assert.ok(
137 !client.logs.some((entry) => entry.message === "[ECC] Found CLAUDE.md - loading project context"),
138 "Directory named CLAUDE.md should not be treated as project context"
139 )

Callers 1

Calls 6

loadPluginFunction · 0.85
withTempProjectFunction · 0.85
createClientFunction · 0.85
createFailingShellFunction · 0.85
okMethod · 0.80
runTestFunction · 0.70

Tested by

no test coverage detected