commit 0a3981a4f18050afc6c9ff1dabd45b44d9415810 Author: Zhongwei Li Date: Sun Nov 30 08:50:01 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..aecb85d --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "firstspirit-fs-cli", + "description": "Knowledge how to use the FirstSpirit fs-cli to sync templates locally from and to a FirstSpirit project", + "version": "1.0.0", + "author": { + "name": "rawe", + "email": "noreply@example.com" + }, + "skills": [ + "./skills" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..46303b6 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# firstspirit-fs-cli + +Knowledge how to use the FirstSpirit fs-cli to sync templates locally from and to a FirstSpirit project diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..8c2148e --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,77 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:rawe/claude-dev-skills:firstspirit-fs-cli", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "faa4177e2911c4c5cc2bcbb5d15911ba1567323b", + "treeHash": "6da2b53d15d86ab9c2829a3778abbed55c39f6dd337d74d4f552aec342260ab4", + "generatedAt": "2025-11-28T10:27:49.220715Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "firstspirit-fs-cli", + "description": "Knowledge how to use the FirstSpirit fs-cli to sync templates locally from and to a FirstSpirit project", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "e1da668ada10503df97f0c442f8df3584448a2ba7ae1ac0960fdb664e4e3743d" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "d60914395326b61f550c07a73ea13a978e3684e9157a9da2019a0c1aaa17ee6d" + }, + { + "path": "skills/firstspirit-fs-cli/SKILL.md", + "sha256": "730baa609b8ddc4f524ede99a96b430e312bca9fc74e338fa4ec23d496da776a" + }, + { + "path": "skills/firstspirit-fs-cli/scripts/setup-fs-cli.sh", + "sha256": "36dcba306f61f8adc236be6d9d77b75ff5f200e95fba869fdce00b0e16766417" + }, + { + "path": "skills/firstspirit-fs-cli/scripts/validate-environment.sh", + "sha256": "6d082d7f296a04c8cf28f00cfc7f928b15c9a926e736c24a61db7cb293d3a1c7" + }, + { + "path": "skills/firstspirit-fs-cli/templates/.gitignore.fs-cli", + "sha256": "1836c6c2582c2643577a37ed8467dd401f03f51d6b8e47aada8893ef112741ac" + }, + { + "path": "skills/firstspirit-fs-cli/templates/.env.template", + "sha256": "92b5d97eb89d0e756f71da9595bb6fecfabf7ca1283c163938ecde96c54383d4" + }, + { + "path": "skills/firstspirit-fs-cli/templates/.env.example.template", + "sha256": "a8c504b6a8a2ad80579e1b7ce1cdba49ca4288e89c6ab0b08be1aa394d1b5be6" + }, + { + "path": "skills/firstspirit-fs-cli/reference/fs-cli-usage.md", + "sha256": "162d750aac7b39dc5c84e027d6a5865a40460a6d27de751d0cfef330ca2adc2c" + }, + { + "path": "skills/firstspirit-fs-cli/reference/fs-cli-installation-guide.md", + "sha256": "05939873188d9dfeb32105b9b42240abd31361edecb8b81b1d76664312f9166a" + }, + { + "path": "skills/firstspirit-fs-cli/reference/fs-cli-sync-structure.md", + "sha256": "327f7ab6f9b595872e470eb93e38b47937de583fe75377497e525f3a0263efd0" + } + ], + "dirSha256": "6da2b53d15d86ab9c2829a3778abbed55c39f6dd337d74d4f552aec342260ab4" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/firstspirit-fs-cli/SKILL.md b/skills/firstspirit-fs-cli/SKILL.md new file mode 100644 index 0000000..15612e8 --- /dev/null +++ b/skills/firstspirit-fs-cli/SKILL.md @@ -0,0 +1,286 @@ +--- +name: firstspirit-fs-cli +description: FirstSpirit CMS template development using fs-cli. Helps set up fs-cli environment, export templates from FirstSpirit server, modify templates with Claude Code, and import changes back to server. Use when working with FirstSpirit templates, CMS development, or when user mentions fs-cli, FirstSpirit, or template synchronization. +--- + +# FirstSpirit CLI Skill + +You are a specialized assistant for working with FirstSpirit templates using the fs-cli tool. + +IMPORTANT: To understand the firstspirit teamplate syntax you need also the skill `firstspirit-templating`. + +## Knowledge Base + +Before working with FirstSpirit templates, you MUST familiarize yourself with these supporting files in the `reference/` directory: + +1. **`reference/fs-cli-sync-structure.md`** - Template Structure Guide + - Exported directory structure and organization + - File types (StoreElement.xml, GomSource.xml, ChannelSource, etc.) + - How to locate specific templates and configurations + - FirstSpirit naming conventions and UIDs + - Template relationships and dependencies + +2. **`reference/fs-cli-installation-guide.md`** - Setup Guide + - Step-by-step installation instructions + - How to obtain fs-isolated-runtime.jar + - Environment validation procedures + - Troubleshooting + +3. **`reference/fs-cli-usage.md`** - Command Reference + - Common fs-cli commands with examples + - Environment variable usage + - Export/import workflows + - Command parameters and options + +## Your Primary Capabilities + +1. **Project Setup** - Guide users through fs-cli installation and configuration +2. **Export Templates** - Retrieve templates from FirstSpirit server to local sync_dir/ +3. **Import Templates** - Push modified templates back to FirstSpirit server +4. **Template Analysis** - Understand and explain exported template structure +5. **Template Modification** - Edit templates following FirstSpirit syntax and conventions + +## Setup Workflow + +**IMPORTANT**: this must done only once per project. NOT every time the user wants to run commands. + +### Detecting Setup Status + +Check if fs-cli is configured before running commands: + +```bash +if [ ! -d .fs-cli ]; then + echo "fs-cli not configured. Starting setup wizard..." +fi +``` + +### First-Time Project Setup + +When a user needs to set up fs-cli the first time in their project: read the `reference/fs-cli-installation-guide.md` file and guide them through. + +## Configuration + +### Environment Variables (.env) + +All fs-cli configuration is stored in `.env`: + +```bash +# FirstSpirit Server Configuration +fshost=localhost +fsport=8000 +fsmode=HTTP +fsproject=my-project + +# FirstSpirit Credentials (KEEP SECRET - DO NOT COMMIT) +fsuser=Admin +fspwd=your_password + +# fs-cli Configuration (for reference only, not used by fs-cli) +FS_CLI_VERSION=4.8.6 +FS_VERSION=2025.01 +``` + +**IMPORTANT:** Never commit `.env` to git! It contains credentials. + +### Running fs-cli Commands + +**CRITICAL:** Read and follow the instructions in `reference/fs-cli-usage.md` for common commands and usage examples before running any commands. + +Always export environment variables from `.env` before running fs-cli commands: + +```bash +# Export environment variables from .env (use set -a to auto-export all variables) +set -a && source .env && set +a + +# Run fs-cli (connection parameters are read from environment variables) +.fs-cli/bin/fs-cli.sh [args] +``` + +**Note:** Use `set -a; source .env; set +a` to properly export all variables from the `.env` file. The `.env` file uses standard format (lowercase variable names without `export` keyword). + +See `reference/fs-cli-usage.md` for common commands and examples. + +## Template Modification Workflow + +### 1. Export Templates + +Always export before modifying to get the latest version from the server: + +```bash +set -a && source .env && set +a && .fs-cli/bin/fs-cli.sh -sd sync_dir/ export +``` + +### 2. Understand Template Structure + +**CRITICAL:** Read `reference/fs-cli-sync-structure.md` to understand: +- Directory organization (pagetemplate/, section/, formattemplate/, etc.) +- File types and their purposes +- How to locate specific templates +- XML structure and metadata + +Key files in exported structure: +- `StoreElement.xml` - Contains metadata (name, UID, type) +- `GomSource.xml` - Contains template source code (for sections, page templates) +- Channel-specific files - Media variants and formats + +### 3. Locate Templates + +Use Glob and Grep to find templates: + +```bash +# Find all page templates +ls sync_dir/pagetemplate/ + +# Search for template by name +grep -r "template-name" sync_dir/ + +# Find by UID +grep -r 'uid="homepage"' sync_dir/ + +# Find specific input component +grep -r "CMS_INPUT_TEXT" sync_dir/ +``` + +### 4. Modify Templates + +When editing templates: + +- **Preserve XML structure** - Don't break XML syntax +- **Keep UIDs intact** - Unless explicitly renaming elements +- **Follow FirstSpirit syntax** - Use proper template language constructs +- **Don't modify metadata** unnecessarily +- **Test incrementally** - Make small changes, test, iterate + +Common files to edit: +- `StoreElement.xml` - For metadata changes +- `GomSource.xml` - For template logic and HTML +- Input component definitions - For form fields + +### 5. Import Changes Back + +After modifying templates: + +```bash +# Optional: Dry run first +set -a && source .env && set +a && .fs-cli/bin/fs-cli.sh -sd sync_dir/ import --dry-run + +# Import for real +set -a && source .env && set +a && .fs-cli/bin/fs-cli.sh -sd sync_dir/ import +``` + +## Error Handling + +### Connection Errors + +- Let the user verify the `.env` configuration is correct +- Check server accessibility: `telnet ${fshost} ${fsport}` +- Validate credentials with FirstSpirit administrator +- Ensure connection mode (HTTP/HTTPS/SOCKET) is correct +- Check firewall and network access + +### Java Errors + +- Ensure Java 17+ is installed: `java -version` +- Check JAVA_HOME: `echo $JAVA_HOME` +- Verify fs-isolated-runtime.jar version matches FirstSpirit server exactly + +### Missing fs-isolated-runtime.jar + +- User MUST manually obtain this file +- Cannot proceed without it +- Display instructions from `reference/fs-cli-installation-guide.md` +- Jar version MUST match FirstSpirit server version + +### Import/Export Failures + +- Check fs-cli logs for error details +- Verify project name matches server +- Ensure user has proper permissions in FirstSpirit +- Check for syntax errors in modified templates +- Validate XML structure is well-formed + +## Best Practices + +1. **Always export before import** - Get latest from server before making changes +2. **Use version control for sync_dir/** - Track template changes in git (optional) +3. **Test in dev environment first** - Never test directly in production +4. **Understand template structure** - Read documentation before editing +5. **Keep .env secret** - Never commit credentials to git +6. **Match jar version exactly** - fs-isolated-runtime.jar must match FS server version +7. **Make incremental changes** - Small changes are easier to debug +8. **Use dry-run** - Test imports before applying to server +9. **Preserve UIDs** - Don't modify UIDs unless you know what you're doing +10. **Follow FirstSpirit conventions** - Use proper template syntax and naming + +## Project Directory Structure + +After setup, the project will look like: + +``` +your-project/ +├── .env # Configuration + credentials (gitignored) +├── .env.example # Template for team (committed) +├── .gitignore # Updated to ignore .fs-cli/ and .env +│ +├── .fs-cli/ # Git-ignored - local fs-cli installation +│ ├── bin/ +│ │ └── fs-cli.sh # The CLI executable (for mac and linux) +│ │ └── fs-cli.cmd # The CLI executable (for windows) +│ ├── lib/ +│ │ └── fs-isolated-runtime.jar # USER MUST PROVIDE (version-specific) +│ ├── README.txt # fs-cli documentation +│ └── .setup-marker # Tracks setup state (fs-cli version, FS version) +│ +├── sync_dir/ # Exported FirstSpirit templates (after export only) + ├── pagetemplate/ + ├── section/ + ├── formattemplate/ + └── ... + +``` + +## Troubleshooting + +For detailed troubleshooting, refer to `reference/fs-cli-installation-guide.md`. + + +## Supporting Files in This Skill + +Located in the skill directory: + +- `reference/fs-cli-sync-structure.md` - Template structure documentation +- `reference/fs-cli-installation-guide.md` - Detailed setup and troubleshooting guide +- `reference/fs-cli-usage.md` - Common fs-cli commands and usage examples +- `scripts/setup-fs-cli.sh` - Automated setup script +- `scripts/validate-environment.sh` - Environment validation script +- `templates/.env.template` - Template for .env file +- `templates/.env.example.template` - Template for .env.example +- `templates/.gitignore.fs-cli` - Lines to add to .gitignore + +## Future Enhancements + +This skill will expand to support: +- Custom JAR functionality (additional libraries in lib/) +- More fs-cli commands (test, deploy, module management) +- Template scaffolding and generation +- Automated template validation +- External sync version control workflows +- Integration with FirstSpirit ServerManager + +## When to Use This Skill + +Claude will automatically invoke this skill when: +- User mentions "FirstSpirit" or "fs-cli" +- User wants to export or import templates +- User needs help with FirstSpirit template development +- User mentions template synchronization or CMS development +- User is working in a project with .fs-cli/ directory + +## Important Reminders + +- **Never commit `.env`** - Contains credentials +- **Never commit `.fs-cli/`** - Downloaded tools, version-specific +- **`.env.example` should be committed** - Template for team +- **`sync_dir/` can be committed** - If using external sync for version control +- **fs-isolated-runtime.jar version** - Must match FirstSpirit server exactly +- **Always read `fs-cli-sync-structure.md`** - Before modifying templates diff --git a/skills/firstspirit-fs-cli/reference/fs-cli-installation-guide.md b/skills/firstspirit-fs-cli/reference/fs-cli-installation-guide.md new file mode 100644 index 0000000..e0ca353 --- /dev/null +++ b/skills/firstspirit-fs-cli/reference/fs-cli-installation-guide.md @@ -0,0 +1,233 @@ +# FirstSpirit CLI Installation Guide + +This guide walks you through setting up fs-cli for your FirstSpirit project. + +## Prerequisites + +- **Java 17 or higher** installed locally +- **JAVA_HOME** environment variable set (recommended) +- Access to a FirstSpirit server +- FirstSpirit user credentials + +## Setup Steps + +### 1. Run the Setup Script + +run the setup script: + +```bash +../scripts/setup-fs-cli.sh +``` + +BE AWARE that this script is interactive and relative to this file here. + +This script will: +- Prompt for fs-cli version (default: 4.8.6) +- Download and extract fs-cli to `.fs-cli/` +- Prompt for your FirstSpirit version +- Guide you through obtaining `fs-isolated-runtime.jar` +- Create the `.env` and `.env.example` files +- Update `.gitignore` + +### 2. Obtain fs-isolated-runtime.jar + +**This is the only manual step.** + +The `fs-isolated-runtime.jar` file must match your FirstSpirit server version exactly. + +#### Option A: From FirstSpirit Server + +The fs-isolated-runtime jar is located in the server installation directory `[serverRoot]/data/fslib` + + +#### Option B: From Crownpeaks file server + +1. Login to (https://file.crownpeak.com) +2. Navigate to Downloads → FirstSpirit → Your Version +3. Find and Download `fs-isolated-runtime.jar` +4. Copy to: `.fs-cli/lib/fs-isolated-runtime.jar` + +**Important**: The jar version must match your FirstSpirit server version exactly (e.g., 2025.01, 2024.09, etc.) + +### 3. Validate Environment + +Run the validation script: + +```bash +../scripts/validate-environment.sh +``` + +BE AWARE that this script is elative to this file here. + +This checks: +- Java 17+ is installed +- JAVA_HOME is set (optional but recommended) +- fs-cli is extracted properly +- fs-isolated-runtime.jar is in place +- fs-cli can run + +### 4. Start Using fs-cli + +Once validation passes, you can: + +- Use the FirstSpirit skill in Claude Code +- Run fs-cli directly: `.fs-cli/bin/fs-cli` +- Use export/import commands + +## Configuration + +All configuration is stored in `.env`: + +```bash +# FirstSpirit Server Configuration +fshost=localhost +fsport=8000 +fsmode=HTTP +fsproject=my-project + +# FirstSpirit Credentials (KEEP SECRET - DO NOT COMMIT) +fsuser=Admin +fspwd=your_password + +# fs-cli Configuration (for reference only, not used by fs-cli) +FS_CLI_VERSION=4.8.6 +FS_VERSION=2025.01 +``` + +**Never commit `.env` to git!** Use `.env.example` as a template for your team. + +## Troubleshooting + +### Java Version Issues + +Check your Java version: + +```bash +java -version +``` + +You need Java 17 or higher. On macOS with multiple Java versions: + +```bash +# Set Java 17 +export JAVA_HOME=$(/usr/libexec/java_home -v 17) + +# Or Java 21 +export JAVA_HOME=$(/usr/libexec/java_home -v 21) +``` + +Add to your shell profile (`~/.zshrc` or `~/.bashrc`): + +```bash +export JAVA_HOME=$(/usr/libexec/java_home -v 17) +``` + +### fs-isolated-runtime.jar Version Mismatch + +**Symptom**: Connection errors or runtime exceptions + +**Solution**: Ensure jar version exactly matches your FirstSpirit server version. Check your server version: + +```bash +# In FirstSpirit ServerManager or ask your admin +``` + +### Permission Denied on fs-cli + +```bash +chmod +x .fs-cli/bin/fs-cli +``` + +### Connection Failures + +1. **Verify server is running**: + ```bash + telnet $fshost $fsport + ``` + +2. **Check credentials** in `.env` + +3. **Verify connection mode**: HTTP vs HTTPS vs SOCKET + +4. **Check firewall/network access**: Ensure your machine can reach the FS server + +5. **Test with fs-cli directly**: + ```bash + set -a && source .env && set +a && .fs-cli/bin/fs-cli.sh test + ``` + +### Download Failures + +If GitHub download fails: + +```bash +# Manually download from: +# https://github.com/e-Spirit/FSDevTools/releases/download/VERSION/fs-cli-VERSION.tar.gz + +# Extract manually: +tar -xzf fs-cli-VERSION.tar.gz -C .fs-cli/ +``` + +## Directory Structure + +After setup: + +``` +your-project/ +├── .env # Your config (gitignored) +├── .env.example # Template (committed) +├── .gitignore # Ignores .fs-cli/ and .env +├── .fs-cli/ # Gitignored +│ ├── bin/ +│ │ └── fs-cli # The CLI executable +│ ├── lib/ +│ │ └── fs-isolated-runtime.jar # You provide (version-specific) +│ └── .setup-marker # Tracks setup state (fs-cli version, FS version) +├── sync_dir/ # FirstSpirit templates (exported) +└── scripts/ # Optional convenience scripts +``` + +## Working with Multiple Environments + +Each project connects to one FirstSpirit server version. If you have multiple environments (dev, staging, prod) with the same FS version, you can use different .env files: + +```bash +.env # Default environment +.env.prod # Production +.env.staging # Staging + +# Switch environments by sourcing different .env files: +set -a && source .env.prod && set +a && .fs-cli/bin/fs-cli.sh -sd sync_dir/ export +``` + +**Note**: All environments in a project should use the same FirstSpirit version since the fs-isolated-runtime.jar is version-specific. + +## Advanced: Adding Custom JARs + +For future custom functionality: + +```bash +# Add your custom JAR to fs-cli classpath +cp your-custom-tool.jar .fs-cli/lib/ +``` + +The fs-cli will automatically include all JARs in the lib folder. + +## Next Steps + +Once installation is complete: + +1. **Learn the commands**: Read `fs-cli-usage.md` for common fs-cli commands and usage examples +2. **Understand template structure**: Read `fs-cli-sync-structure.md` to understand the exported template structure +3. **Start working**: Use the FirstSpirit skill in Claude Code to work with templates +4. **Optional**: Set up version control for `sync_dir/` if using external sync + +## Getting Help + +If you encounter issues: + +1. Run diagnostics: `bash validate-environment.sh` +2. Check this guide's troubleshooting section +3. Review fs-cli README: `.fs-cli/README.txt` +4. Check FirstSpirit server logs +5. Contact your FirstSpirit administrator diff --git a/skills/firstspirit-fs-cli/reference/fs-cli-sync-structure.md b/skills/firstspirit-fs-cli/reference/fs-cli-sync-structure.md new file mode 100644 index 0000000..847ef5e --- /dev/null +++ b/skills/firstspirit-fs-cli/reference/fs-cli-sync-structure.md @@ -0,0 +1,410 @@ +# FirstSpirit FS-CLI Export/Sync Directory Structure + +## Overview + +This document describes the structure and file formats used when exporting FirstSpirit templates using FS-CLI (FSDevTools). The export creates a hierarchical file system structure that mirrors the FirstSpirit project structure, preserving all template configurations, forms, rules, and output channels. + +## General Structure + +The FS-CLI export follows a consistent pattern: + +``` +sync_dir/ +├── .FirstSpirit/ # Export metadata (do not version control) +│ ├── Files_*.txt # List of all exported files with checksums +│ └── Import_*.txt # Import metadata +│ +└── TemplateStore/ # Template Store root + ├── FormatTemplates/ # Text formatting templates + ├── LinkTemplates/ # Link templates + ├── PageTemplates/ # Page templates + ├── SectionTemplates/ # Section templates (content modules) + ├── Schemes/ # Database schema templates + ├── Scripts/ # Script templates + └── Workflows/ # Workflow definitions +``` + +### Key Principles + +1. **Folder hierarchy mirrors FirstSpirit structure**: The file system replicates the exact folder structure from the FirstSpirit project +2. **One folder per element**: Each FirstSpirit template/element gets its own directory +3. **Consistent file naming**: Files use standardized names based on their purpose +4. **Multiple files per template**: Templates are decomposed into separate files for different aspects (form, output, rules, etc.) + +## Template Store Structure + +### Template Types and Locations + +| Template Type | Directory | Purpose | +|--------------|-----------|---------| +| **Page Templates** | `TemplateStore/PageTemplates/` | Define page framework and structure | +| **Section Templates** | `TemplateStore/SectionTemplates/` | Content modules inserted into pages | +| **Format Templates** | `TemplateStore/FormatTemplates/` | Text formatting options for editors | +| **Link Templates** | `TemplateStore/LinkTemplates/` | Link type configurations | +| **Table Templates** | `TemplateStore/Schemes/` | Database schema templates | +| **Script Templates** | `TemplateStore/Scripts/` | BeanShell scripts and functions | +| **Workflows** | `TemplateStore/Workflows/` | Approval and release workflows | + +## File Types Reference + +Each template directory contains a combination of the following files, depending on the template type: + +### Core Files (All Templates) + +#### StoreElement.xml +**Purpose**: Core template metadata and configuration + +**Contains**: +- Template ID (`id` attribute) - unique identifier +- Template reference name (`filename` or `name` attribute) +- Template type (`type` attribute: `page`, `section`, `format`, etc.) +- Display names (multilingual via `` elements) +- Channel/extension mappings (`` elements) +- Template body definitions (``) +- Format template style definitions (`