Skip to content

feat: add Factory AI, OpenCode, Gemini targets + skill resource files with security#70

Open
mrwogu wants to merge 8 commits intomainfrom
feature/factory-ai
Open

feat: add Factory AI, OpenCode, Gemini targets + skill resource files with security#70
mrwogu wants to merge 8 commits intomainfrom
feature/factory-ai

Conversation

@mrwogu
Copy link
Owner

@mrwogu mrwogu commented Mar 4, 2026

Summary

Adds three new compilation targets (Factory AI, OpenCode, Gemini CLI) and implements secure skill resource file discovery and output.

New Compilation Targets

  • Factory AI — YAML-based AGENTS.md + .factory/ skills and commands
  • OpenCode — YAML-based agents.yaml with project rules
  • Gemini CLIGEMINI.md with embedded skill instructions

All three formatters support the full feature matrix: identity, standards, restrictions, skills, shortcuts, agents, and resource files.

Skill Resource Files

Skills can now include additional files (scripts, templates, configs) alongside SKILL.md. These are discovered automatically and output to the correct locations for each target.

Security Hardening

  • Symlink detectionlstat() rejects symlink files, realpath() catches symlinked directories
  • Path traversal preventionisSafeRelativePath() with absolute path and .. segment checks
  • Binary file rejection — null byte detection
  • Aggregate limits — max 100 files, 1MB per file, 10MB total per skill
  • Junk file filtering — skips .env, .DS_Store, node_modules/, .git/, etc.
  • Defense-in-depth — path validation at both resolver (discovery) and formatter (output) layers
  • Skill name sanitization — rejects names with .., /, \ in all formatters

Configuration

New skills.universalDir config option enables reading from .agents/skills/ directory:

skills:
  universalDir: true

Commits

Commit Scope
feat(core) Target types, skill resource types, config schema
feat(formatters) Factory AI, OpenCode, Gemini formatters
feat(formatters) Resource file output with path validation
feat(resolver) Skill resource discovery with security hardening
feat(cli) New targets support, skills config threading
test Formatter tests, security scenario tests
feat(playground) New target support in playground
docs Local skills guide, updated references
chore Compiled output for new targets

Test Results

  • 486 tests passing (1 pre-existing flaky timeout in update-check-smoke)
  • New security tests: symlinks, binary rejection, path traversal, aggregate limits, junk skipping

@codecov
Copy link

codecov bot commented Mar 4, 2026

Bundle Report

Changes will increase total bundle size by 70.95kB (8.64%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
promptscript-cli 891.83kB 70.95kB (8.64%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: promptscript-cli

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 68.73kB 809.07kB 9.28% ⚠️
src/templates/migrate-skill.d.ts 1.97kB 15.64kB 14.39% ⚠️
README.md 46 bytes 6.42kB 0.72%
src/types.d.ts 62 bytes 2.62kB 2.43%
src/types.d.ts.map 43 bytes 1.76kB 2.5%
src/utils/ai-tools-detector.d.ts 36 bytes 1.51kB 2.43%
src/utils/ai-tools-detector.d.ts.map 30 bytes 937 bytes 3.31%
src/templates/migrate-skill.d.ts.map 36 bytes 346 bytes 11.61% ⚠️

@codecov
Copy link

codecov bot commented Mar 4, 2026

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@mrwogu mrwogu force-pushed the feature/factory-ai branch from e684341 to f1fa60c Compare March 4, 2026 18:17
@mrwogu mrwogu changed the title feat: add Factory AI as compilation target feat: add Factory AI, OpenCode, and Gemini CLI as compilation targets Mar 5, 2026
@mrwogu mrwogu force-pushed the feature/factory-ai branch from c396fb1 to 5d46e6a Compare March 5, 2026 14:02
mrwogu added 5 commits March 5, 2026 21:54
…esource config

- Add 'factory', 'opencode', 'gemini' to CompilationTarget union
- Add SkillResource type to AST (relativePath + content)
- Add additionalFiles to SkillManifest
- Add skills.universalDir config option
- Update JSON schema with new targets and skills section
- Factory AI: YAML-based AGENTS.md + .factory/ skills and commands
- OpenCode: YAML-based agents.yaml with project rules
- Gemini CLI: GEMINI.md with embedded skill instructions
- Register new formatters in feature matrix and parity matrix
- Export new formatters from package index
- Add sanitizeResourceFiles() and isSafeSkillName() to BaseFormatter
- Output additionalFiles alongside skill files in all formatters
- Validate paths against traversal and reject unsafe skill names
- Defense-in-depth: path validation at both resolver and formatter layers
…ning

- Discover resource files in skill directories (everything except SKILL.md)
- Symlink detection with lstat() and realpath() verification
- Path traversal validation with isSafeRelativePath()
- Binary file rejection via null byte detection
- Aggregate limits: 100 files max, 1MB per file, 10MB total
- Skip known junk files (.env, .DS_Store) and dirs (node_modules, .git)
- Support .agents/skills/ universal directory via skills.universalDir config
- Verbose logging for all skipped resources
- Add factory, opencode, gemini to CLI compile command
- Thread skills.universalDir config from promptscript.yaml to compiler
- Add Factory AI detection in ai-tools-detector
- Add skill migration template for Factory AI format
- Support recursive additionalFiles in compiler output
@mrwogu mrwogu force-pushed the feature/factory-ai branch from 5d46e6a to a7da107 Compare March 5, 2026 20:58
@mrwogu mrwogu changed the title feat: add Factory AI, OpenCode, and Gemini CLI as compilation targets feat: add Factory AI, OpenCode, Gemini targets + skill resource files with security Mar 5, 2026
mrwogu added 2 commits March 5, 2026 22:57
- Add comprehensive Factory AI, OpenCode, Gemini formatter tests
- Add skill resource discovery tests with security scenarios
- Test symlink detection, binary rejection, path traversal prevention
- Test aggregate limits (count, size), junk file skipping
- Update parity matrix and feature coverage tests for new targets
- Add normalize and CLI tests for new targets
@mrwogu mrwogu force-pushed the feature/factory-ai branch from a7da107 to 357c471 Compare March 5, 2026 22:00
@mrwogu mrwogu force-pushed the feature/factory-ai branch from 357c471 to dad6a1e Compare March 5, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant