From 8f6369711317b8b73303d51e713e7d7cc89a23a5 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Wed, 1 Apr 2026 16:09:54 -0700 Subject: [PATCH] fix: port safe ci cleanup from backlog --- WORKING-CONTEXT.md | 2 ++ eslint.config.js | 6 ++++++ scripts/hooks/pre-bash-commit-quality.js | 2 +- scripts/lib/skill-improvement/observations.js | 4 ++-- skills/ck/commands/list.mjs | 3 +-- skills/ck/commands/migrate.mjs | 8 ++++++-- skills/ck/commands/save.mjs | 4 ++-- skills/ck/commands/shared.mjs | 8 ++++---- tests/lib/changed-files-store.test.js | 2 +- tests/scripts/post-bash-command-log.test.js | 1 + tests/scripts/trae-install.test.js | 4 ++-- 11 files changed, 28 insertions(+), 16 deletions(-) diff --git a/WORKING-CONTEXT.md b/WORKING-CONTEXT.md index 5eba4887..d6e0689e 100644 --- a/WORKING-CONTEXT.md +++ b/WORKING-CONTEXT.md @@ -62,6 +62,7 @@ Public ECC plugin repo for agents, skills, commands, hooks, rules, install surfa - `#1110` install-time Claude hook root resolution - `#1106` portable Codex Context7 key extraction - `#1107` Codex baseline merge and sample agent-role sync + - `#1119` stale CI/lint cleanup that still contained safe low-risk fixes - Port or rebuild inside ECC after full audit: - `#894` Jira integration - `#814` + `#808` rebuild as a single consolidated notifications lane for Opencode and cross-harness surfaces @@ -104,3 +105,4 @@ Keep this file detailed for only the current sprint, blockers, and next actions. - 2026-04-01: Replaced the GNU-only `grep -P` parser in `scripts/sync-ecc-to-codex.sh` with a portable Node parser for Context7 key extraction. Added source-level regression coverage so BSD/macOS syncs do not drift back to non-portable parsing. - 2026-04-01: Targeted regression suite after the direct ports is green: `tests/scripts/install-apply.test.js`, `tests/scripts/sync-ecc-to-codex.test.js`, and `tests/scripts/codex-hooks.test.js`. - 2026-04-01: Ported the useful core of `#1107` directly into `main` as an add-only Codex baseline merge. `scripts/sync-ecc-to-codex.sh` now fills missing non-MCP defaults from `.codex/config.toml`, syncs sample agent role files into `~/.codex/agents`, and preserves user config instead of replacing it. Added regression coverage for sparse configs and implicit parent tables. +- 2026-04-01: Ported the safe low-risk cleanup from `#1119` directly into `main` instead of keeping an obsolete CI PR open. This included `.mjs` eslint handling, stricter null checks, Windows home-dir coverage in bash-log tests, and longer Trae shell-test timeouts. diff --git a/eslint.config.js b/eslint.config.js index e4906869..acb4b672 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -24,5 +24,11 @@ module.exports = [ 'no-undef': 'error', 'eqeqeq': 'warn' } + }, + { + files: ['**/*.mjs'], + languageOptions: { + sourceType: 'module' + } } ]; diff --git a/scripts/hooks/pre-bash-commit-quality.js b/scripts/hooks/pre-bash-commit-quality.js index a601317d..b554bff1 100644 --- a/scripts/hooks/pre-bash-commit-quality.js +++ b/scripts/hooks/pre-bash-commit-quality.js @@ -67,7 +67,7 @@ function findFileIssues(filePath) { try { const content = getStagedFileContent(filePath); - if (content == null) { + if (content === null || content === undefined) { return issues; } const lines = content.split('\n'); diff --git a/scripts/lib/skill-improvement/observations.js b/scripts/lib/skill-improvement/observations.js index 6c37e5ae..1544c4b9 100644 --- a/scripts/lib/skill-improvement/observations.js +++ b/scripts/lib/skill-improvement/observations.js @@ -37,8 +37,8 @@ function createSkillObservation(input) { ? input.skill.path.trim() : null; const success = Boolean(input.success); - const error = input.error == null ? null : String(input.error); - const feedback = input.feedback == null ? null : String(input.feedback); + const error = input.error === null || input.error === undefined ? null : String(input.error); + const feedback = input.feedback === null || input.feedback === undefined ? null : String(input.feedback); const variant = typeof input.variant === 'string' && input.variant.trim().length > 0 ? input.variant.trim() : 'baseline'; diff --git a/skills/ck/commands/list.mjs b/skills/ck/commands/list.mjs index c4cd04e2..2acba26a 100644 --- a/skills/ck/commands/list.mjs +++ b/skills/ck/commands/list.mjs @@ -8,8 +8,7 @@ * exit 0: success exit 1: no projects */ -import { readProjects, loadContext, today, CONTEXTS_DIR } from './shared.mjs'; -import { renderListTable } from './shared.mjs'; +import { readProjects, loadContext, today, renderListTable } from './shared.mjs'; const cwd = process.env.PWD || process.cwd(); const projects = readProjects(); diff --git a/skills/ck/commands/migrate.mjs b/skills/ck/commands/migrate.mjs index d4966fa8..eaa3fbd9 100644 --- a/skills/ck/commands/migrate.mjs +++ b/skills/ck/commands/migrate.mjs @@ -11,7 +11,7 @@ * exit 0: success exit 1: error */ -import { readFileSync, writeFileSync, existsSync, renameSync } from 'fs'; +import { readFileSync, existsSync, renameSync } from 'fs'; import { resolve } from 'path'; import { readProjects, writeProjects, saveContext, today, shortId, CONTEXTS_DIR } from './shared.mjs'; @@ -112,7 +112,11 @@ for (const [projectPath, info] of Object.entries(projects)) { const contextMd = existsSync(contextMdPath) ? readFileSync(contextMdPath, 'utf8') : ''; let meta = {}; if (existsSync(metaPath)) { - try { meta = JSON.parse(readFileSync(metaPath, 'utf8')); } catch {} + try { + meta = JSON.parse(readFileSync(metaPath, 'utf8')); + } catch (e) { + console.warn(` ! ${contextDir}: invalid meta.json, continuing with defaults (${e.message})`); + } } // Extract fields from CONTEXT.md diff --git a/skills/ck/commands/save.mjs b/skills/ck/commands/save.mjs index 0d25029c..f4cb692f 100644 --- a/skills/ck/commands/save.mjs +++ b/skills/ck/commands/save.mjs @@ -20,8 +20,8 @@ import { readFileSync, mkdirSync, writeFileSync } from 'fs'; import { resolve } from 'path'; import { readProjects, writeProjects, loadContext, saveContext, - today, shortId, gitSummary, nativeMemoryDir, encodeProjectPath, - CONTEXTS_DIR, CURRENT_SESSION, + today, shortId, gitSummary, nativeMemoryDir, + CURRENT_SESSION, } from './shared.mjs'; const isInit = process.argv.includes('--init'); diff --git a/skills/ck/commands/shared.mjs b/skills/ck/commands/shared.mjs index 49a36363..f826f4c1 100644 --- a/skills/ck/commands/shared.mjs +++ b/skills/ck/commands/shared.mjs @@ -5,8 +5,8 @@ * No external dependencies. Node.js stdlib only. */ -import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync } from 'fs'; -import { resolve, basename } from 'path'; +import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs'; +import { resolve } from 'path'; import { homedir } from 'os'; import { spawnSync } from 'child_process'; import { randomBytes } from 'crypto'; @@ -270,7 +270,7 @@ export function renderContextMd(ctx) { } /** Render the bordered briefing box used by /ck:resume */ -export function renderBriefingBox(ctx, meta = {}) { +export function renderBriefingBox(ctx, _meta = {}) { const latest = ctx.sessions?.[ctx.sessions.length - 1] || {}; const W = 57; const pad = (str, w) => { @@ -344,7 +344,7 @@ export function renderInfoBlock(ctx) { } /** Render ASCII list table used by /ck:list */ -export function renderListTable(entries, cwd, todayStr) { +export function renderListTable(entries, cwd, _todayStr) { // entries: [{name, contextDir, path, context, lastUpdated}] // Sorted alphabetically by contextDir before calling const rows = entries.map((e, i) => { diff --git a/tests/lib/changed-files-store.test.js b/tests/lib/changed-files-store.test.js index 85dd6251..8e1ed497 100644 --- a/tests/lib/changed-files-store.test.js +++ b/tests/lib/changed-files-store.test.js @@ -24,7 +24,7 @@ async function runTests() { let store try { store = await import(pathToFileURL(storePath).href) - } catch (err) { + } catch (_err) { console.log('\n[warn] Skipping: build .opencode first (cd .opencode && npm run build)\n') process.exit(0) } diff --git a/tests/scripts/post-bash-command-log.test.js b/tests/scripts/post-bash-command-log.test.js index 6ba72583..aa7802d8 100644 --- a/tests/scripts/post-bash-command-log.test.js +++ b/tests/scripts/post-bash-command-log.test.js @@ -26,6 +26,7 @@ function runHook(mode, payload, homeDir) { env: { ...process.env, HOME: homeDir, + USERPROFILE: homeDir, }, }); } diff --git a/tests/scripts/trae-install.test.js b/tests/scripts/trae-install.test.js index 8328e81b..d7c2c6b5 100644 --- a/tests/scripts/trae-install.test.js +++ b/tests/scripts/trae-install.test.js @@ -29,7 +29,7 @@ function runInstall(options = {}) { }, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], - timeout: 20000, + timeout: 60000, }); } @@ -43,7 +43,7 @@ function runUninstall(options = {}) { encoding: 'utf8', input: options.input || 'y\n', stdio: ['pipe', 'pipe', 'pipe'], - timeout: 20000, + timeout: 60000, }); }