Skip to content

Openclaw local plugin integration#1488

Merged
Hun-ger merged 6 commits intoopenclaw-local-plugin-20260408from
openclaw-local-plugin-integration
Apr 17, 2026
Merged

Openclaw local plugin integration#1488
Hun-ger merged 6 commits intoopenclaw-local-plugin-20260408from
openclaw-local-plugin-integration

Conversation

@Hun-ger
Copy link
Copy Markdown
Collaborator

@Hun-ger Hun-ger commented Apr 17, 2026

Description

This PR integrates recent fixes to improve skill generation and handle viewer authentication gracefully.

  • Skill Generator: Aligned the skill generation prompt template with skill-creator best practices. Added explicit instructions to assume the agent is smart, improved trigger descriptions, enforced stricter metadata/naming rules, and prevented the generation of extraneous boilerplate files.
  • Viewer: Added a check in the loadConfig function to show a "session expired" toast notification when receiving a 401 Unauthorized response, preventing silent authentication failures.

Related Issue (Required): Fixes #1434, Fixes #1424

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit Test
  • Test Script Or Test Steps (please provide)
    • Generated a new skill to verify that the output correctly follows the updated prompt constraints (e.g., kebab-case naming, no extra files, proper trigger keywords).
    • Manually simulated a 401 response during config load in the viewer to ensure the session expiration toast appears properly.
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Reviewer Checklist

Danielwangyy and others added 6 commits April 5, 2026 15:14
loadConfig() silently returned on non-200 responses, leaving the
settings form with empty/default values. Users saw blank model fields
and "Provider and Model are required" errors on test, with no hint
that the real issue was an expired session.

Other settings functions (doSaveConfig, saveModelsConfig, testModel)
already handle 401 correctly via `toast(t('settings.session.expired'))`.
This commit applies the same pattern to loadConfig for consistency.

Made-with: Cursor
- Constrain skill name to 2-4 word kebab-case
- Limit frontmatter to name + description only
- Add rule against creating extra documentation files
- Add 'assume agent is smart' principle
- Strengthen trigger condition requirements in description
- Clarify metadata as optional OpenClaw extension

Fixes #1423
## Problem

When a user's Viewer session expires and they navigate to the
**Settings** tab, `loadConfig()` fetches `/api/config` which returns
HTTP 401. The function silently returns on `!r.ok`, leaving all form
fields at their empty/default values.

**User-visible symptoms:**
- Embedding model field appears blank (even though `openclaw.json` has a
valid config)
- Clicking "Test Connection" shows: *"❌ 连接失败 — Provider and Model are
required"*
- No indication that the actual issue is an expired session
- Users may think their configuration was lost after a plugin upgrade

## Root Cause

```js
// html.ts — loadConfig()
const r = await fetch('/api/config');
if (!r.ok) return;          // ← silently swallows 401
```

Other settings functions already handle this correctly:

| Function | 401 handling |
|---|---|
| `doSaveConfig()` | ✅ `toast(t('settings.session.expired'), 'error')` |
| `saveModelsConfig()` | ✅ `toast(t('settings.session.expired'),
'error')` |
| `testModel()` | ✅ Shows expired message in result element |
| **`loadConfig()`** | ❌ Silent return — **this PR** |

## Fix

One-line addition: check for 401 before the generic `!r.ok` guard, show
the same session-expired toast that other functions use.

```diff
 async function loadConfig(){
   try{
     const r=await fetch('/api/config');
+    if(r.status===401){toast(t('settings.session.expired'),'error');return;}
     if(!r.ok) return;
```

No new i18n keys — reuses existing `settings.session.expired`.

## Testing

1. Open Viewer → Settings tab (should load normally)
2. Wait for session to expire (or manually delete the session cookie)
3. Navigate away from Settings and back
4. **Before fix:** Blank form, no error
5. **After fix:** Toast "登录已过期,请刷新页面重新登录"

Made with [Cursor](https://cursor.com)
…es (#1434)

## What

Aligns the skill generation prompt template (`STEP1_SKILL_MD_PROMPT`)
with [skill-creator best
practices](https://github.com/anthropics/skills/blob/main/skills/skill-creator/SKILL.md),
addressing all 6 issues raised in #1423.

## Changes

1. **Name constraint**: 2-4 word kebab-case (was unconstrained)
2. **Frontmatter**: Limited to `name` + `description` only
3. **No extra files**: Explicitly prohibits README/CHANGELOG/etc
generation
4. **Assume smart agent**: Only include info the agent doesn't already
know
5. **Stronger trigger rules**: Description must include trigger
scenarios + keywords
6. **Progressive disclosure**: Multi-variant skills should use
references/ subdirectory

## Question for maintainers

The current template includes `metadata: { openclaw: { emoji } }` in
frontmatter. Per best practices, frontmatter should only have `name` and
`description`. I've moved the metadata guidance to an HTML comment at
the end of the file body, noting it as an optional OpenClaw extension.
Please let me know if you'd prefer a different approach.

## Testing

- Manual review of prompt template alignment with spec
- Only string literal changes, no logic affected

Fixes #1423
@Hun-ger Hun-ger merged commit 72a29f5 into openclaw-local-plugin-20260408 Apr 17, 2026
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.

3 participants