CommandCodeAI / CommandCodeAI/command-code

feat: Mod - Adding test harness to Mod Api to make it easier to write tests and have agent verify mod works

未關閉
#612 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
沒有語言資料
星號
4k
分支
350
PR 合併指標
30 天內沒有已合併 PR

描述

Summary

When writing and iterating on a mod, I find the the model will write a temp script which imports some of the mod functions to test the output and if it works properly, for example:

xecute Shell Command
Command Code needs to execute node --experimental-strip-types --no-warnings -e "
Promise.all([
  import('./.commandcode/mods/erd.ts'),
  import('./.commandcode/mods/erd/markdown.ts'),
  import('./.commandcode/mods/erd/renderer.ts'),
  import('./.commandcode/mods/erd/commands.ts'),
  import('./.commandcode/mods/erd/tools.ts'),
]).then(() => { console.log('ALL MODULES LOAD OK'); }).catch(e => { console.error('FAIL', e); process.exit(1); });
" 2>&1 | head -20.

Press [ctrl+e] to explain this command

❯ 1. Yes

Some are more involved and check output not just if load.


Execute Shell Command
Command Code needs to execute node --experimental-strip-types --no-warnings -e "
const fs = require('fs');
Promise.all([
  import('./.commandcode/mods/erd/parser.ts'),
  import('./.commandcode/mods/erd/queries.ts'),
  import('./.commandcode/mods/erd/markdown.ts'),
]).then(([p, q, md]) => {
  const sql = fs.readFileSync('schema/schema.sql', 'utf8');
  const schema = p.parseSchema(sql, 'sqlite');
  console.log('listTables →', md.renderMarkdown(q.listTables(schema)).length, 'lines');
  console.log('listIndexes →', md.renderMarkdown(q.listIndexes(schema)).length, 'lines');
  console.log('listForeignKeys →', md.renderMarkdown(q.listForeignKeys(schema)).length, 'lines');
  console.log('findColumn →', md.renderMarkdown(q.findColumn(schema, 'id')).length, 'lines');
  console.log('schemaSummary →', md.renderMarkdown(q.schemaSummary(schema, 'sqlite')).length, 'lines');
  console.log('describeTable →', md.renderMarkdown(q.describeTable(schema, 'users', 'sqlite')).length, 'lines');
  console.log('ALL QUERY FUNCTIONS RENDER CLEANLY');
}).catch(e => { console.error('FAIL', e); process.exit(1); });
" 2>&1 | head -20.

Press [ctrl+e] to explain this command

❯ 1. Yes
  2. Yes, don't ask again for this exact command in this project
  3. No, tell Command Code what to do differently
Expected Behavior

Would be useful as mods get more complex an refactor to have a proper test harness or suite like vitest that can be run easily manually or within agent as part of th mod-builder skill.

Actual Behavior

Mode has to cobble together one off scripts and runs that have to be permitted each Tim since the command is unique often per run so hard to write permissions to allow.

Can see from example above the shell command on-line a script and not sure I'd want to permit blanket node --experimental-strip-types --no-warnings -e allow permissions here.

Steps to reproduce the issue
  1. build mod
  2. try to test it
Command Code Version

1.7.0

Operating System

macOS

Terminal/IDE

ghostty

Shell

zsh

Additional context

No response

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先檢視 Mod API 和 th-mod-builder skill,然後將 issue 中的 Node 指令範例與目前的 mod 工作流程進行比較。定義 harness 應涵蓋的內容、應如何手動執行或透過 agent 執行,以及成功載入模組和輸出檢查應是什麼樣子;未識別出特定的實作檔案或測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
node.js, typescript
領域
cli, developer-experience, testing
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
冷清
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。