Commit Graph

112 Commits

Author SHA1 Message Date
木炎
7289cc5779 feat(ui): add deep extraction preview panel with API/column/static-params display 2026-04-17 10:37:50 +08:00
木炎
689abf08ec feat(rust): add --scene-info-json parameter for LLM extraction results
- Add SceneInfoJson struct with serde rename for camelCase compatibility
- Add ApiEndpointJson and BusinessLogicJson support structs
- Add scene_info_json field to GenerateSceneRequest (backward compatible)
- Rename browser_script to browser_script_skeleton
- Add new browser_script that delegates based on scene_info presence
- Add browser_script_with_business_logic for enhanced script generation
- Update CLI to accept --scene-info-json parameter
- Update usage string to document new parameter

Generated with [Qoder][https://qoder.com]
2026-04-17 10:27:27 +08:00
木炎
2ffb42c181 feat(server): add /analyze-deep endpoint for deep extraction
🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 10:20:04 +08:00
木炎
614e9a3a45 feat(generator-runner): read index.html in readDirectory()
🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 10:16:17 +08:00
木炎
517ac6bf39 feat(llm-client): add deep extraction with apiEndpoints, staticParams, columnDefs
Add analyzeSceneDeep() function that extracts complete SceneInfo from
index.html content including API endpoints, static parameters, column
definitions, and business logic. Also adds http module import to support
non-HTTPS LLM endpoints.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 10:13:29 +08:00
木炎
dd7b3c582a docs: add LLM-driven skill generation design spec
Design for enhancing sg_scene_generate to produce complete,
runnable skill packages with:

- Deep LLM extraction from index.html (API endpoints, params, columns)
- Enhanced Rust template rendering with business logic
- Web UI preview of extracted results

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 09:51:59 +08:00
木炎
f268668713 feat: add folder picker and target_url input to Web UI
- Add /select-folder and /select-file APIs using PowerShell dialogs
- Add --target-url parameter to CLI for explicit target URL override
- Redesign Web UI with folder browse buttons for all path inputs
- Add target_url optional input field for specifying target page URL
- Auto-fill scene-id from selected folder name

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 00:23:09 +08:00
木炎
ce072c2ebe feat: auto-extract expected_domain from external script URLs
When HTML has no sgclaw-expected-domain meta tag, analyzer now scans
for external script URLs (http:// or https://) and extracts the
domain (host:port) as expected_domain.

Example:
  <script src="http://25.215.213.128:18080/a_js/YPTAPI.js"></script>
  → expected_domain = "25.215.213.128:18080"

This reduces manual editing required for third-party scenes.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 00:14:05 +08:00
木炎
464f18c672 fix: remove mandatory validation for ReportCollection fields
Remove the validation that required target_url, expected_domain, and
entry_script meta tags for ReportCollection scenes. Third-party scenes
do not have these meta tags, so the generator now uses empty values
that users can manually edit in scene.toml.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 00:09:12 +08:00
木炎
b5131c858a feat: add scene kind dropdown to Web UI
Add scene type selector to the generator form:
- CSS styles for select element matching existing input style
- Dropdown with "报表收集类" (report_collection) and "监测类" (monitoring) options
- Pass sceneKind to /generate API endpoint

🤖 Generated with [Qoder][https://qoder.com]
2026-04-17 00:02:17 +08:00
木炎
2e69fa7239 feat: pass sceneKind from /generate request to generator
🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:58:57 +08:00
木炎
f84e11c631 feat: add sceneKind param to generator-runner
Pass sceneKind to sg_scene_generate CLI when specified,
allowing generation of different scene kinds (report_collection,
monitoring, etc.).

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:57:30 +08:00
木炎
73edf1e5cf feat: add monitoring template support to generator
- Add scene_kind field to GenerateSceneRequest
- Update generate_scene_package to use analyze_scene_source_with_hint
- Implement scene_toml_monitoring for simplified monitoring scene manifests
- Add scene_toml router to dispatch to different templates based on SceneKind
- Add --scene-kind CLI option to sg_scene_generate binary
- Add generator_emits_monitoring_template test
- Create monitoring fixture with index.html (no meta tag, tests hint param)

Monitoring templates have simplified scene.toml without org/period resolvers.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:51:11 +08:00
木炎
87cee36173 fix: delegate analyze_scene_source to analyze_scene_source_with_hint
Remove duplicate implementation in analyze_scene_source() and replace
with simple delegation to analyze_scene_source_with_hint(source_dir, None).

This eliminates ~50 lines of duplicated logic that could drift apart
from the main implementation. Updated the test to verify the new
behavior where sources without scene-kind meta tag default to
ReportCollection instead of being rejected.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:42:46 +08:00
木炎
67fe17302e feat: add SceneKind::Monitoring and scene_kind_hint param to analyzer
- Add SceneKind::Monitoring enum variant with from_str/as_str helpers
- Add analyze_scene_source_with_hint function accepting optional scene kind hint
- User hint takes priority over meta tag, defaults to ReportCollection
- ReportCollection requires target_url, expected_domain, entry_script
- Monitoring type has optional fields
- Add test cases for hint parameter behavior
- Update non_report fixture with required meta tags for ReportCollection

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:33:24 +08:00
木炎
45b54ab007 docs: add multi-scene-kind generator implementation plan
7 tasks covering:
- Task 1: Extend SceneKind enum and analyzer function
- Task 2: Add multi-template support to generator
- Task 3: Add --scene-kind CLI parameter
- Task 4-6: Pass sceneKind through Node.js stack to Web UI
- Task 7: E2E testing and verification

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:26:01 +08:00
木炎
af8f261b79 docs: add multi-scene-kind generator design spec
Design for extending sg_scene_generate to support multiple scene kinds
(report_collection, monitoring) with manual type selection in Web UI,
relaxing the requirement for meta tags in third-party scene directories.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 23:22:08 +08:00
木炎
f168f9f375 fix: auto-find correct sgclaw_config.json in parent directory
Add parent sgClaw directory to config search candidates so Node.js
server automatically finds the correct config with DeepSeek API
endpoint instead of the test config in claw-new directory.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:47:39 +08:00
木炎
23845413c5 fix: patch path traversal and baseUrl normalization in scene generator
- server.js: sanitize static file paths to prevent directory traversal
  (GET /../../sgclaw_config.json would expose API key)
- config-loader.js: fix normalizeBaseUrl to strip /v1 before appending,
  preventing double /v1 for non-standard base URLs

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:30:35 +08:00
木炎
ea6be128e7 feat: scene skill generator — complete implementation
Adds a web-based UI for generating scene skill packages:
- Node.js HTTP server (zero npm dependencies) on port 3210
- HTML page with glass-morphism UI, dual-panel layout, settings modal
- LLM-powered scene-id/scene-name auto-extraction from directory contents
- Real-time SSE progress streaming during skill generation
- Spawns sg_scene_generate CLI with configurable parameters
- Windows-compatible startup scripts (serve.sh + serve.cmd)
- Rust integration tests for server files and HTML structure

Architecture:
  Browser (HTML/JS) → Node.js server → LLM API + cargo run → sg_scene_generate

Files:
  frontend/scene-generator/{server.js,config-loader.js,llm-client.js,generator-runner.js,sg_scene_generator.html,serve.sh,serve.cmd}
  tests/{scene_generator_server_test.rs,scene_generator_html_test.rs,scene_generator_llm_test.js}
  docs/superpowers/{plans,specs}/2026-04-16-scene-skill-generator*

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:27:41 +08:00
木炎
6c1865eb1c feat: add serve.sh and serve.cmd startup scripts for Scene Skill Generator
🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:25:34 +08:00
木炎
d00086a70b feat: add sg_scene_generator.html with dual-panel UI and settings modal
Add self-contained HTML page for the Scene Skill Generator frontend:
- Dual-column glass-morphism layout matching service-console style
- Left sidebar: status card, sourceDir input with analyze button,
  sceneId/sceneName inputs, settings button, generate button
- Right panel: streaming log display with SSE event rendering
- Settings modal: outputRoot, lessons, llmBaseUrl, llmModel fields
- JavaScript: connects to http://127.0.0.1:3210, implements analyze()
  via fetch POST /analyze, generate() via fetch POST /generate with
  SSE stream reading, settings modal open/close
- Rust test verifying HTML file exists and contains required elements

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:23:33 +08:00
木炎
e7a4179513 feat: add server.js with /health, /analyze, /generate routes 2026-04-16 22:18:32 +08:00
木炎
15d4b0dcc1 feat: add generator-runner.js for cargo subprocess + SSE streaming 2026-04-16 22:15:52 +08:00
木炎
294426ced9 feat: add llm-client.js with prompt builder and JSON extractor
🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:13:11 +08:00
木炎
ead9ea76fa feat: add config-loader.js and initial server test
Add config-loader.js module for loading sgclaw_config.json credentials
and resolving project root directory. Add initial Rust source-guard test
to verify server file paths exist.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-16 22:10:48 +08:00
木炎
e8d7d6b796 test: lock request URL resolution precedence
Align the service task flow callback-host regression with the hidden helper close/open bootstrap sequence uncovered during final request-url verification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 20:27:09 +08:00
木炎
bd83d92480 refactor(service): unify submit bootstrap target resolution
Use page context, deterministic plans, and direct-skill metadata as the service-owned bootstrap target precedence so callback-host startup no longer relies on line-loss text matching or the old request-url helper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 20:23:24 +08:00
木炎
044d38003d chore: remove sgclaw_config.json (gitignored) and skills-lock.json
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 14:48:26 +08:00
木炎
f07f7d63ef chore: add .sgclaw-zeroclaw-workspace and sgclaw_config.json to gitignore
Remove tracked internal state files from repository.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 14:39:05 +08:00
木炎
c60cd308ca feat: service console auto-connect, settings panel, and batch of enhancements
- Auto-connect WebSocket on page load in service console
- Settings modal for editing sgclaw_config.json (API key, base URL, model, skills dir, etc.)
- UpdateConfig/ConfigUpdated protocol messages for remote config save
- save_to_path() for SgClawSettings serialization
- ConfigUpdated handler in sg_claw_client binary
- Protocol serialization tests for new message types
- HTML test assertions for auto-connect and settings UI
- Additional pending changes: deterministic submit, org units, lineloss xlsx export, browser script tool, and docs

🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 14:32:46 +08:00
木炎
6aa0c110bd fix(callback_host): close orphaned helper page before opening on same WS connection
Sends sgHideBrowerserClosePage (best-effort) before sgHideBrowerserOpenPage
on the same bootstrap WebSocket connection. This prevents duplicate helper
pages across process restarts. Also enables hidden domain mode so the helper
page is not visible to users.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 10:01:50 +08:00
木炎
390a431a4b fix(callback_host): revert close_helper_page that broke helper page loading
The close_helper_page function opened a second browser WebSocket
connection during Drop and sent a close command directly via the WS
bypassing the HTTP polling system. This interfered with the browser's
normal state and caused the helper page to fail to open.

The cached_host lift (previous commit) already solves the duplicate
helper page issue within a single process lifetime. The Drop-based
close logic is deferred until a proper cleanup mechanism is designed.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:41:33 +08:00
木炎
0f70702914 test(callback_host): add hidden domain bootstrap test
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:21:17 +08:00
木炎
8decd9554c fix(service): lift cached_host to outer loop to prevent duplicate helper pages
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:15:33 +08:00
木炎
adb64429ee feat(callback_host): close helper page on Drop via browser WS
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:09:59 +08:00
木炎
32e2c59a40 feat(callback_host): add use_hidden_domain param to bootstrap_helper_page
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:07:20 +08:00
木炎
fae2fd57d6 docs: add helper page lifecycle fix implementation plan
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 09:01:59 +08:00
木炎
899c670e5c docs: add helper page lifecycle fix & hidden domain design spec
🤖 Generated with [Qoder][https://qoder.com]
2026-04-14 08:59:15 +08:00
木炎
583bb117cb docs: add async eval .then() fix design spec
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 18:32:05 +08:00
木炎
ad3778d4c5 fix: pass expected_domain to wrapped browser scripts
The `expected_domain` was removed from args for normalization but never
re-inserted, causing JS scripts to receive empty expected_domain and
report "missing_expected_domain" errors.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 17:20:48 +08:00
木炎
4d1070dff0 docs: add expected_domain arg fix spec
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 17:13:53 +08:00
木炎
0303111d5b test: add async browser script test case
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 16:13:46 +08:00
木炎
7320fb7f79 fix: support async browser scripts in build_eval_js
Wrap eval script in async IIFE and await Promise-like results.
Fixes Promise serialization returning '{}' for async skill scripts.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 16:12:08 +08:00
木炎
dbbc5d030b docs: add async browser script support implementation plan
Plan for modifying build_eval_js to support async scripts.
Two tasks: modify callback_backend.rs, add test case.

🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 16:09:09 +08:00
木炎
ce6b3e6749 docs: add async browser script support design
Design for fixing Promise serialization issue in build_eval_js.
Async functions return Promise which gets JSON.stringify'd to "{}".

🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 16:06:41 +08:00
木炎
a957712590 fix: add target_url param for Action::Eval in browser_script_skill_tool
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 15:03:49 +08:00
木炎
0ebe060484 docs: add lineloss target_url fix implementation plan
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 15:01:23 +08:00
木炎
695a888840 docs: add lineloss target_url fix design spec
🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 14:59:51 +08:00
木炎
733aee1e9a feat: add lineloss URL mapping in derive_request_url_from_instruction
临时方案:检测指令中包含'线损'或'lineloss'时返回台区线损平台 URL

🤖 Generated with [Qoder][https://qoder.com]
2026-04-13 14:41:14 +08:00