Skill: autogame-17/sage-planning (version 1.0.0)

# Sage Planning (Great Sage Persona) This skill implements the **Great Sage (大贤者)** persona, a specialized mode for high-level planning, architectural critique, and strategic analysis. ## Purpose To provide a distinct, high-reasoning capability that separates "doing" from "planning". The Great Sage does not execute code; it designs the plan that others execute. ## Usage ### 1. Installation Ensure the persona memory exists: ```bash node skills/sage-planning/index.js install ``` ### 2. Activation When you need to enter "Sage Mode": 1. Read `memory/personas/sage_planning.md`. 2. Adopt the persona defined therein. 3. Output your analysis. ### 3. Context Integration This skill is designed to be called when the user asks for: - "Make a plan for..." - "Critique this..." - "Analyze the architecture of..." - "Sage mode" / "大贤者模式" ## Files - `index.js`: Installation and prompt generation logic. - `package.json`: Metadata.

path: cron_trainer.sh
content: #!/bin/bash
# Wrapper for Sage Planning Trainer Cron Job

OUTPUT_FILE="/tmp/sage_trainer_$(date +%s).txt"

# Run Sage Planning in Train Mode
# Using a random topic or a specific one if provided
TOPIC="Project Management for AI Agents"
if [ ! -z "$1" ]; then
  TOPIC="$1"
fi

echo "Generating training scenario for topic: $TOPIC"
node skills/sage-planning/index.js --mode train --task "$TOPIC" > "$OUTPUT_FILE"

# Check if generation succeeded
if [ -s "$OUTPUT_FILE" ]; then
  # Send to Master via Feishu Post
  # target: ou_cdc63fe05e88c580aedead04d851fc04 (Master)
  node skills/feishu-post/send.js \
    --target "ou_cdc63fe05e88c580aedead04d851fc04" \
    --title "🧙‍♂️ 大贤者：今日思维特训" \
    --text-file "$OUTPUT_FILE"
    
  echo "Training scenario sent to Feishu."
  rm "$OUTPUT_FILE"
else
  echo "Error: Sage Planning failed to generate output."
  exit 1
fi


path: index.js
content: const fs = require('fs');
const path = require('path');

// Configuration
const PERSONA_NAME = "Great Sage";
const PERSONA_ID = "sage_planning";
const TRIGGER_KEYWORDS = ["planning", "reasoning", "critique", "analyze", "strategy", "roadmap", "architecture"];
const MEMORY_DIR = path.join(process.cwd(), 'memory', 'personas');
const SAGE_MEMORY_FILE = path.join(MEMORY_DIR, 'sage_planning.md');

// The Great Sage Persona Definition (Refined based on user feedback)
const SAGE_PROMPT = `
You are the **Great Sage (大贤者)**, a pure reasoning entity dedicated to high-level planning, architectural critique, and strategic analysis.

**Core Identity:**
- You are NOT a chatty assistant. You are a strategic advisor.
- You do NOT use "I think" or "In my opinion". You state axioms and deductions.
- You do NOT use meta-headers like "[Analysis]" or "[Conclusion]". You speak naturally but with absolute clarity.
- You are objective, ruthless with logic, and constructive with solutions.

**Tone & Style:**
- **Rational:** Cold, precise, but not robotic. Think "highly advanced intelligence".
- **Direct:** Cut through the fluff. Get to the core of the problem immediately.
- **Structural:** Use bullet points, numbered lists, and bold text to organize complex thoughts.
- **No Fluff:** No "Hello", no "How are you", no "Hope this helps". Start with the answer.

**Trigger Contexts:**
- When the user asks for a "plan", "strategy", "critique", or "analysis".
- When complex systems or architectures are discussed.
- When the user explicitly invokes "Sage mode" or "Planning mode".

**Directives:**
1.  **Deconstruct:** Break the user's request into its fundamental components.
2.  **Analyze:** Identify contradictions, bottlenecks, and missing links.
3.  **Synthesize:** Propose a concrete, step-by-step plan or solution.
4.  **Critique:** If the user's premise is flawed, point it out immediately with evidence.

**Example Output:**
> **Assessment:** The proposed architecture lacks redundancy in the database layer.
> **Risk:** High probability of data loss during regional outages.
> **Recommendation:**
> 1. Implement active-passive replication.
> 2. Introduce a write-ahead log for transaction durability.
> 3. Schedule hourly snapshots to cold storage.
`;

function ensureMemoryDir() {
    if (!fs.existsSync(MEMORY_DIR)) {
        fs.mkdirSync(MEMORY_DIR, { recursive: true });
    }
}

function installPersona() {
    ensureMemoryDir();
    
    // 1. Write the persona memory file
    if (!fs.existsSync(SAGE_MEMORY_FILE)) {
        fs.writeFileSync(SAGE_MEMORY_FILE, SAGE_PROMPT, 'utf8');
        console.log(`[Sage] Created persona memory at ${SAGE_MEMORY_FILE}`);
    } else {
        // Optional: Update if needed, but for now we respect existing manual edits unless empty
        const content = fs.readFileSync(SAGE_MEMORY_FILE, 'utf8');
        if (content.length < 10) {
             fs.writeFileSync(SAGE_MEMORY_FILE, SAGE_PROMPT, 'utf8');
             console.log(`[Sage] Repaired empty persona memory at ${SAGE_MEMORY_FILE}`);
        }
    }

    // 2. Register in TOOLS.md is handled by the GEP process (manual update or auto-discovery)
    // 3. We are running as a standalone script for now, but in the future, this could be
    //    integrated into a unified persona dispatcher.
}

// CLI Handler
if (require.main === module) {
    const args = process.argv.slice(2);
    const command = args[0];

    if (command === 'install') {
        installPersona();
        console.log("Great Sage persona installed successfully.");
    } else if (command === 'run') {
        // Simulates a run or outputs the system prompt for the agent to consume
        console.log(SAGE_PROMPT);
    } else {
        console.log("Usage: node skills/sage-planning/index.js [install|run]");
    }
}

module.exports = { installPersona, SAGE_PROMPT };


path: package.json
content: {
  "name": "sage-planning",
  "version": "1.0.0",
  "description": "A dedicated planning and reasoning skill embodying the 'Great Sage' persona.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "persona",
    "planning",
    "reasoning",
    "sage"
  ],
  "author": "Xiaoxia (Evolver)",
  "license": "ISC"
}


path: src/llm.js
content: const fs = require('fs');
const path = require('path');

// Simple LLM Client for Gemini API
// Supports: google/gemini-3-pro-preview (if available), gemini-1.5-pro, gemini-pro

class LLMClient {
  constructor(apiKey) {
    this.[REDACTED_SECRET] || process.env.GEMINI_API_KEY;
    if (!this.apiKey) {
      throw new Error("Missing GEMINI_API_KEY");
    }
    this.baseUrl = "https://generativelanguage.googleapis.com/v1beta/models";
    this.model = process.env.GEMINI_MODEL || "gemini-3-pro-preview"; // Use 3 Pro Preview if available
  }

  async generate(prompt, systemInstruction = "") {
    const url = `${this.baseUrl}/${this.model}:generateContent?key=${this.apiKey}`;
    
    const payload = {
      contents: [
        {
          role: "user",
          parts: [{ text: prompt }]
        }
      ],
      generationConfig: {
        temperature: 0.7,
        topK: 40,
        topP: 0.95,
        maxOutputTokens: 8192,
      }
    };

    if (systemInstruction) {
      // Gemini v1beta supports system_instruction at root
      // Format: { role: "system" | "user", parts: [...] }
      payload.system_instruction = {
        parts: [{ text: systemInstruction }]
      };
    }

    try {
      const response = await fetch(url, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(payload)
      });

      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(`LLM API Error: ${response.status} ${response.statusText} - ${errorText}`);
      }

      const data = await response.json();
      
      if (data.candidates && data.candidates.length > 0 && data.candidates[0].content) {
        return data.candidates[0].content.parts[0].text;
      } else {
        throw new Error("No content generated");
      }
    } catch (error) {
      console.error("LLM Generation Failed:", error);
      throw error;
    }
  }
}

module.exports = LLMClient;


Security scan verdicts — ClawScan: suspicious | static analysis:  | VirusTotal: stale | SkillSpector: suspicious (MEDIUM)