Commit Graph

195 Commits

Author SHA1 Message Date
Affaan Mustafa
02120fbf5f chore: add dist, __pycache__, and tasks to .gitignore
Prevents accidental commits of build output, Python bytecode
cache, and Claude Code team task files.
2026-02-13 01:11:37 -08:00
Affaan Mustafa
a4848da38b test: add tsconfig depth limit and cleanupAliases exception tests
- post-edit-typecheck: verify 25-level-deep directory completes without
  hanging (tests the max depth=20 walk-up guard)
- cleanupAliases: document behavior when sessionExists callback throws
  (propagates to caller, which is acceptable)
2026-02-13 01:10:30 -08:00
Affaan Mustafa
307ee05b2d fix: instinct-cli glob and evolve --generate (fixes #216, #217)
- Load both .yaml and .yml files in load_all_instincts() (#216)
  The *.yaml-only glob missed .yml files, causing 'No instincts found'
- Implement evolve --generate to create skill/command/agent files (#217)
  Previously printed a stub message. Now generates SKILL.md, command .md,
  and agent .md files from the clustering analysis into ~/.claude/homunculus/evolved/
2026-02-13 01:09:16 -08:00
Affaan Mustafa
c1b6e0bf11 test: add coverage for Claude Code JSONL format and assistant tool blocks
Tests the new transcript parsing from PR #215:
- entry.message.content format (string and array content)
- tool_use blocks nested in assistant message content arrays
- Verifies file paths and tool names extracted from both formats
2026-02-13 01:07:23 -08:00
Affaan Mustafa
654731f232 fix: add missing validation in renameAlias, add 6 tests
renameAlias was missing length (>128), reserved name, and empty string
validation that setAlias enforced. This inconsistency allowed renaming
aliases to reserved names like 'list' or 'delete'.

Also adds tests for:
- renameAlias empty string, reserved name, and length limit
- validate-skills whitespace-only SKILL.md rejection
- validate-rules whitespace-only file and recursive subdirectory scan
2026-02-13 01:05:59 -08:00
zdoc.app
95f63c3cb0 docs(zh-CN): sync Chinese docs with latest upstream changes (#202)
* docs(zh-CN): sync Chinese docs with latest upstream changes

* docs: improve Chinese translation consistency in go-test.md

* docs(zh-CN): update image paths to use shared assets directory

- Update image references from ./assets/ to ../../assets/
- Remove zh-CN/assets directory to use shared assets

---------

Co-authored-by: neo <neo.dowithless@gmail.com>
2026-02-13 01:04:58 -08:00
Siddhi Khandelwal
49aee612fb docs(opencode): clarify OpenCode-specific usage (#214)
* docs(opencode): clarify OpenCode-specific usage

Signed-off-by: Siddhi Khandelwal <siddhi.200727@gmail.com>

* docs(opencode): close bash code fence in CLI example

Signed-off-by: Siddhi Khandelwal <siddhi.200727@gmail.com>

---------

Signed-off-by: Siddhi Khandelwal <siddhi.200727@gmail.com>
2026-02-13 01:04:36 -08:00
dungan
4843a06b3a fix: Windows compatibility for hook scripts (execFileSync + tmux) (#215)
* fix: Windows compatibility for hook scripts

- post-edit-format.js: add `shell: process.platform === 'win32'` to
  execFileSync options so npx.cmd is resolved via cmd.exe on Windows
- post-edit-typecheck.js: same fix for tsc invocation via npx
- hooks.json: skip tmux-dependent hooks on Windows where tmux is
  unavailable (dev-server blocker and long-running command reminder)

On Windows, execFileSync('npx', ...) without shell:true fails with
ENOENT because Node.js cannot directly execute .cmd files. These
hooks silently fail on all Windows installations.

The tmux hooks unconditionally block dev server commands (exit 2) or
warn about tmux on Windows where tmux is not available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: parse Claude Code JSONL transcript format correctly

The session-end hook expected user messages at entry.content, but
Claude Code's actual JSONL format nests them at entry.message.content.
This caused all session files to be blank templates (0 user messages
despite 136+ actual entries).

- Check entry.message?.content in addition to entry.content
- Extract tool_use blocks from assistant message.content arrays

Verified with Claude Code v2.1.41 JSONL transcripts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: ddungan <sckim@mococo.co.kr>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 01:04:27 -08:00
Affaan Mustafa
1823b441a9 chore: sync agentshield stats to 102 rules, 912 tests 2026-02-12 17:34:23 -08:00
Affaan Mustafa
39280e251b fix: use valid model name in colon-in-values frontmatter test
The test was using 'claude-sonnet-4-5-20250929' which isn't in VALID_MODELS
(haiku/sonnet/opus). Use 'sonnet' with a description field containing
colons to properly test colon handling in frontmatter values.
2026-02-12 17:33:17 -08:00
Affaan Mustafa
926eba97c5 fix: add input validation, date range checks, and security hardening
- validate-agents.js: reject invalid model names in agent frontmatter
- package-manager.js: validate script/binary names against shell injection
- session-manager.js: reject impossible month/day values in filenames
- utils.js: support options.all for replaceInFile string patterns
- strategic-compact/SKILL.md: fix hook matcher syntax and script reference
- install.sh: warn when overwriting existing rule customizations
- Add 24 new tests covering all validation and edge cases
2026-02-12 17:32:04 -08:00
Affaan Mustafa
35aed05903 test: add 6 tests for command validation and session content verification
- validate-commands: creates: line skipping, valid cross-refs, unclosed
  code blocks, valid workflow diagrams
- session-end: backtick escaping in session files, tools/files in output
2026-02-12 17:15:21 -08:00
Affaan Mustafa
c0c54d0dae fix: use execFileSync with input option for Windows-compatible stdin tests
Windows cmd.exe treats single quotes literally, so `echo '...' | node -e '...'`
fails. Switched to execFileSync with the `input` option to pipe stdin data
directly without shell quoting issues.
2026-02-12 17:14:03 -08:00
Affaan Mustafa
8248310181 fix: add missing clickhouse-io skill to directory listing 2026-02-12 17:13:59 -08:00
Affaan Mustafa
40a68b323a fix: add 7 missing commands to README, remove phantom /security entry
Added: /python-review, /multi-plan, /multi-execute, /multi-backend,
/multi-frontend, /multi-workflow, /pm2, /sessions
Removed: /security (no matching command file; use security-review skill)
Updated count: 24 → 31 commands
2026-02-12 17:13:05 -08:00
Affaan Mustafa
e5f1c58c11 test: add regression tests for empty frontmatter field rejection
Add 2 tests verifying validate-agents correctly rejects agents with
empty model and empty tools values in YAML frontmatter.
2026-02-12 16:58:27 -08:00
Affaan Mustafa
f64a61bc94 chore: update AgentShield stats to 96 rules, 876 tests 2026-02-12 16:58:02 -08:00
Affaan Mustafa
cb4378a0f6 fix: correct stale counts and broken paths across docs
- .cursor/README.md: skills 30→37, commands ~28→31
- .opencode/MIGRATION.md: fix rules paths (rules/ → rules/common/)
- README.zh-CN.md: fix agent/skill/command counts
- docs/ja-JP/README.md: fix agent/skill/command counts
2026-02-12 16:55:49 -08:00
Affaan Mustafa
5107b3669f fix: box() off-by-one alignment, add 5 tests for readStdinJson and box alignment
- skill-create-output.js: fix top border being 1 char narrower than
  middle/bottom lines (width - title - 5 → width - title - 4)
- Add box alignment regression test verifying all lines have equal width
- Add 4 readStdinJson tests via subprocess (valid JSON, invalid JSON,
  empty stdin, nested objects) — last untested exported utility function
- All 338 tests passing
2026-02-12 16:53:06 -08:00
Affaan Mustafa
21c0f281b4 chore: update AgentShield stats to 91 rules, 851 tests 2026-02-12 16:52:12 -08:00
Affaan Mustafa
64796f99be fix: remove unused imports in test files (ESLint)
- validators.test.js: remove unused execSync (only execFileSync used)
- skill-create-output.test.js: remove unused path module
2026-02-12 16:51:40 -08:00
Affaan Mustafa
a74d708f7f Merge pull request #208 from eltociear/add-ja-doc
docs: add Japanese documents
2026-02-12 16:48:08 -08:00
Affaan Mustafa
db52081438 Merge pull request #210 from Warshoow/docs/token-optimization-guide
docs: add token optimization guide
2026-02-12 16:48:01 -08:00
Affaan Mustafa
e8f1250573 chore: update AgentShield stats to 86 rules, 825 tests 2026-02-12 16:47:03 -08:00
Affaan Mustafa
924bac4ddf fix: add word boundary to dev server hook regex, fix box() crash, add 27 tests
- hooks.json: add \b word boundary anchors to dev server blocking regex
  to prevent false positives matching "npm run develop", "npm run devtools" etc.
- skill-create-output.js: guard box() horizontal repeat with Math.max(0, ...)
  to prevent RangeError when title exceeds container width
- Add 13 tests for setup-package-manager.js CLI argument parsing
- Add 14 tests for skill-create-output.js SkillCreateOutput class
- All 333 tests passing
2026-02-12 16:46:06 -08:00
Affaan Mustafa
dc9aefbee1 fix: set USERPROFILE in tests for Windows os.homedir() compatibility
On Windows, os.homedir() uses USERPROFILE env var instead of HOME.
Tests that override HOME to a temp dir must also set USERPROFILE for
the session-manager, session-aliases, and session-start hook tests
to find files in the correct directory.
2026-02-12 16:41:58 -08:00
Affaan Mustafa
40b354a202 chore: update AgentShield stats to 792 tests, 84 rules 2026-02-12 16:41:39 -08:00
Affaan Mustafa
b1b28f2f92 fix: capture stderr in typecheck hook, add 13 tests for session-end and utils
- post-edit-typecheck.js: capture both stdout and stderr from tsc
- hooks.test.js: 7 extractSessionSummary tests (JSONL parsing, array content,
  malformed lines, empty transcript, long message truncation, env var fallback)
- utils.test.js: 6 tests (replaceInFile g-flag behavior, string replace,
  capture groups, writeFile overwrite, unicode content)

Total test count: 294 → 307
2026-02-12 16:31:07 -08:00
Affaan Mustafa
e9f0f1334f test: add 33 edge case tests for session-manager, session-aliases, and hooks
- session-manager: CRLF handling, empty sections, multi-heading title, context
  extraction, notes/context detection, MB file size, uppercase ID rejection
- session-aliases: missing timestamps sort, title search, createdAt preservation,
  whitespace-only path rejection, empty string title behavior
- hooks: session-start isolated HOME, template vs real session injection,
  learned skills count, check-console-log passthrough

Total test count: 261 → 294
2026-02-12 16:26:57 -08:00
Affaan Mustafa
6fa3bfe71d test: add cross-reference validation tests for validate-commands
- Add runValidatorWithDirs() helper for multi-constant overrides
- Test broken command references (e.g., /nonexistent-cmd)
- Test broken agent path references (e.g., agents/fake-agent.md)
- Test fenced code block exclusion (refs inside ``` are skipped)
- Test broken workflow agent references (e.g., planner -> ghost-agent)
- Total tests: 261 → 287 (+26)
2026-02-12 16:26:24 -08:00
Affaan Mustafa
8cf472a5f4 chore: update AgentShield stats to 767 tests, 76 rules 2026-02-12 16:26:22 -08:00
Affaan Mustafa
7ec5fc3a52 fix: add event type enum to hooks schema and avoid shared RegExp state
- hooks.schema.json: add enum constraint for hook event types
  (PreToolUse, PostToolUse, PreCompact, SessionStart, SessionEnd,
  Stop, Notification, SubagentStop) — enables IDE autocompletion
  and compile-time validation
- utils.js countInFile: always create fresh RegExp to avoid shared
  lastIndex state when reusing global regex instances
- README: update AgentShield stats (751 tests, 73 rules)
2026-02-12 16:24:48 -08:00
Affaan Mustafa
bc0520c6c1 fix: broken cross-references, version sync, and enhanced command validator
- Fix /build-and-fix → /build-fix in tdd.md, plan.md (+ cursor, zh-CN)
- Fix non-existent explorer agent → planner in orchestrate.md (+ cursor, zh-CN, zh-TW)
- Fix /python-test → /tdd in python-review.md (+ cursor, zh-CN)
- Sync package.json version from 1.0.0 to 1.4.1 to match plugin.json
- Enhance validate-commands.js with cross-reference checking:
  command refs, agent path refs, skill dir refs, workflow diagrams
- Strip fenced code blocks before scanning to avoid false positives
- Skip hypothetical "Creates:" lines in evolve.md examples
- Add 46 new tests (suggest-compact, session-manager, utils, hooks)
2026-02-12 16:19:04 -08:00
Affaan Mustafa
8ff54d8b06 fix: skip code blocks in command cross-reference validation
The validator was matching example/template content inside fenced code
blocks as real cross-references, causing false positives for evolve.md
(example /new-table command and debugger agent).

- Strip ``` blocks before running cross-reference checks
- Change evolve.md examples to use bold instead of backtick formatting
  for hypothetical outputs

All 261 tests pass.
2026-02-12 16:18:50 -08:00
Affaan Mustafa
29a6585cb9 feat: add docker-patterns skill for containerized development
Docker Compose for local dev, networking, volume strategies, container
security hardening, debugging commands, and anti-patterns.

Complements the existing deployment-patterns skill which covers CI/CD
and production Dockerfiles.

Closes #121
2026-02-12 16:14:20 -08:00
Affaan Mustafa
d9d0d3c444 fix: resolve symlinks in install.sh for npm/bun bin usage
When installed via `npm install ecc-universal`, the `ecc-install` bin
entry creates a symlink from the package manager's bin directory to
install.sh. The old `$(dirname "$0")` resolved to the bin directory
instead of the actual package directory, causing `cp` to fail with
"cannot stat '.../rules/common/.'".

Now follows the symlink chain with readlink before resolving SCRIPT_DIR.

Fixes #199
2026-02-12 16:12:21 -08:00
Affaan Mustafa
492c99ac24 fix: 3 bugs fixed, stdin encoding hardened, 37 CI validator tests added
Bug fixes:
- utils.js: glob-to-regex conversion now escapes all regex special chars
  (+, ^, $, |, (), {}, [], \) before converting * and ? wildcards
- validate-hooks.js: escape sequence processing order corrected —
  \\\\ now processed before \\n and \\t to prevent double-processing
- 6 hooks: added process.stdin.setEncoding('utf8') to prevent
  multi-byte UTF-8 character corruption at chunk boundaries
  (check-console-log, post-edit-format, post-edit-typecheck,
  post-edit-console-warn, session-end, evaluate-session)

New tests (37):
- CI validator test suite (tests/ci/validators.test.js):
  - validate-agents: 9 tests (real project, frontmatter parsing,
    BOM/CRLF, colons in values, missing fields, non-md skip)
  - validate-hooks: 13 tests (real project, invalid JSON, invalid
    event types, missing fields, async/timeout validation, inline JS
    syntax, array commands, legacy format)
  - validate-skills: 6 tests (real project, missing SKILL.md, empty
    files, non-directory entries)
  - validate-commands: 5 tests (real project, empty files, non-md skip)
  - validate-rules: 4 tests (real project, empty files)

Total test count: 228 (up from 191)
2026-02-12 16:08:49 -08:00
Affaan Mustafa
d22f172c52 chore: update AgentShield stats to 697 tests, 63 rules 2026-02-12 16:07:39 -08:00
Affaan Mustafa
fa26d00265 refactor: slim down 4 remaining oversized agents (73% reduction)
- go-build-resolver: 368 -> 94 lines (-74%), references golang-patterns skill
- refactor-cleaner: 306 -> 85 lines (-72%), removed project-specific rules & templates
- tdd-guide: 280 -> 80 lines (-71%), references tdd-workflow skill
- go-reviewer: 267 -> 76 lines (-72%), references golang-patterns skill

Combined with prior round: 10 agents optimized, 3,710 lines saved total.
All agents now under 225 lines. Largest: code-reviewer (224).
2026-02-12 16:05:09 -08:00
Affaan Mustafa
90ea2f327c fix: 2 bugs fixed, 17 tests added for hook scripts
Bug fixes:
- evaluate-session.js: whitespace-tolerant regex for counting user
  messages in JSONL transcripts (/"type":"user"/ → /"type"\s*:\s*"user"/)
- session-end.js: guard against null elements in content arrays
  (c.text → (c && c.text) to prevent TypeError)

New tests (17):
- evaluate-session: whitespace JSON regression test
- session-end: null content array elements regression test
- post-edit-console-warn: 5 tests (warn, skip non-JS, clean files,
  missing file, stdout passthrough)
- post-edit-format: 3 tests (empty stdin, non-JS skip, invalid JSON)
- post-edit-typecheck: 4 tests (empty stdin, non-TS skip, missing file,
  no tsconfig)

Total test count: 191 (up from 164)
2026-02-12 16:02:31 -08:00
Affaan Mustafa
380fd09b77 fix: use tests/run-all.js in npm test to avoid test file drift
The package.json test script listed individual test files, which fell
out of sync when session-manager.test.js and session-aliases.test.js
were added to tests/run-all.js but not to package.json. Now npm test
delegates to run-all.js so new test files are automatically included.
2026-02-12 16:01:01 -08:00
Affaan Mustafa
7d57de1299 test: add 13 tests for package-manager.js untested functions
- setProjectPackageManager: creates config, rejects unknown PM
- setPreferredPackageManager: rejects unknown PM
- detectFromPackageJson: invalid JSON, unknown PM name
- getExecCommand: without args
- getRunCommand: build, dev, and custom scripts
- DETECTION_PRIORITY: order verification
- getCommandPattern: install and custom action patterns

Total tests: 164 → 177
2026-02-12 15:59:56 -08:00
Affaan Mustafa
40a4fafa7f fix: add async/timeout to hooks schema and validate in CI
- hooks.schema.json: add async (boolean) and timeout (number) properties
  to hookItem definition, matching fields used in hooks.json
- validate-hooks.js: validate async and timeout types when present
- hooks.test.js: add SessionEnd to required event types check
2026-02-12 15:58:59 -08:00
Affaan Mustafa
639c9aaca3 fix: Windows path support, error handling, and dedup in validators
- session-manager.js: fix getSessionStats path detection to handle
  Windows paths (C:\...) in addition to Unix paths (/)
- package-manager.js: add try-catch to setPreferredPackageManager for
  consistent error handling with setProjectPackageManager
- validate-hooks.js: extract duplicated hook entry validation into
  reusable validateHookEntry() helper
- Update .d.ts JSDoc for both fixes
2026-02-12 15:57:20 -08:00
Affaan Mustafa
76b271ab6b fix: 6 bugs fixed, 67 tests added for session-manager and session-aliases
Bug fixes:
- utils.js: prevent duplicate 'g' flag in countInFile regex construction
- validate-agents.js: handle CRLF line endings in frontmatter parsing
- validate-hooks.js: handle \t and \\ escape sequences in inline JS validation
- session-aliases.js: prevent NaN in date sort when timestamps are missing
- session-aliases.js: persist rollback on rename failure instead of silent loss
- session-manager.js: require absolute paths in getSessionStats to prevent
  content strings ending with .tmp from being treated as file paths

New tests (164 total, up from 97):
- session-manager.test.js: 27 tests covering parseSessionFilename,
  parseSessionMetadata, getSessionStats, CRUD operations, getSessionSize,
  getSessionTitle, edge cases (null input, non-existent files, directories)
- session-aliases.test.js: 40 tests covering loadAliases (corrupted JSON,
  invalid structure), setAlias (validation, reserved names), resolveAlias,
  listAliases (sort, search, limit), deleteAlias, renameAlias, updateAliasTitle,
  resolveSessionAlias, getAliasesForSession, cleanupAliases, atomic write

Also includes hook-generated improvements:
- utils.d.ts: document that readStdinJson never rejects
- session-aliases.d.ts: fix updateAliasTitle type to accept null
- package-manager.js: add try-catch to setProjectPackageManager writeFile
2026-02-12 15:50:04 -08:00
Affaan Mustafa
ff9a91319f chore: update AgentShield stats to 611 tests, 36 rules 2026-02-12 15:49:34 -08:00
Affaan Mustafa
34d8bf8064 refactor: move embedded patterns from agents to skills (#174)
Reduces the 6 largest agent prompts by 79-87%, saving ~2,800 lines
that loaded into subagent context on every invocation.

Changes:
- e2e-runner.md: 797 → 107 lines (-87%)
- database-reviewer.md: 654 → 91 lines (-86%)
- security-reviewer.md: 545 → 108 lines (-80%)
- build-error-resolver.md: 532 → 114 lines (-79%)
- doc-updater.md: 452 → 107 lines (-76%)
- python-reviewer.md: 469 → 98 lines (-79%)

Patterns moved to on-demand skills (loaded only when referenced):
- New: skills/e2e-testing/SKILL.md (Playwright patterns, POM, CI/CD)
- Existing: postgres-patterns, security-review, python-patterns
2026-02-12 15:44:15 -08:00
Affaan Mustafa
328cbbdbb9 fix: handle Windows EOF error in large-input hook test
Windows pipes raise EOF instead of EPIPE when the child process
exits before stdin finishes flushing. Added EOF to the ignored
error codes in runHookWithInput.
2026-02-12 15:43:47 -08:00
Affaan Mustafa
733295b44e docs: enhance 5 thin commands and add Rust API example
Commands enhanced with multi-language support, error recovery strategies,
and structured step-by-step workflows:
- build-fix: build system detection table, fix loop, recovery strategies
- test-coverage: framework detection, test generation rules, before/after report
- refactor-clean: safety tiers (SAFE/CAUTION/DANGER), multi-language tools
- update-codemaps: codemap format spec, diff detection, metadata headers
- update-docs: source-of-truth mapping, staleness checks, generated markers

New example:
- rust-api-CLAUDE.md: Axum + SQLx + PostgreSQL with layered architecture,
  thiserror patterns, compile-time SQL verification, integration test examples
2026-02-12 15:38:27 -08:00
Affaan Mustafa
4209421349 docs: add token optimization guide with recommended settings (#175)
Adds a comprehensive Token Optimization section to the README with:
- Recommended settings (model, MAX_THINKING_TOKENS, AUTOCOMPACT_PCT)
- Daily workflow commands table (/model, /clear, /compact, /cost)
- Strategic compaction guidance (when to compact vs not)
- Context window management (MCP tool description costs)
- Agent Teams cost warning
2026-02-12 15:37:48 -08:00