jsgui3-server 0.0.151 → 0.0.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/admin-ui/v1/controls/admin_shell.js +33 -0
- package/admin-ui/v1/server.js +14 -1
- package/docs/agi/skills/README.md +23 -0
- package/docs/agi/skills/agent-output-control/SKILL.md +56 -0
- package/docs/agi/skills/ai-deep-research/SKILL.md +52 -0
- package/docs/agi/skills/autonomous-ui-inspection/SKILL.md +102 -0
- package/docs/agi/skills/deep-research/SKILL.md +156 -0
- package/docs/agi/skills/endurance/SKILL.md +53 -0
- package/docs/agi/skills/exploring-other-codebases/SKILL.md +56 -0
- package/docs/agi/skills/instruction-adherence/SKILL.md +73 -0
- package/docs/agi/skills/jsgui3-activation-debug/SKILL.md +94 -0
- package/docs/agi/skills/jsgui3-context-menu-patterns/SKILL.md +94 -0
- package/docs/agi/skills/puppeteer-efficient-ui-verification/SKILL.md +65 -0
- package/docs/agi/skills/runaway-process-guard/SKILL.md +49 -0
- package/docs/agi/skills/session-discipline/SKILL.md +40 -0
- package/docs/agi/skills/skill-writing/SKILL.md +211 -0
- package/docs/agi/skills/static-analysis/SKILL.md +58 -0
- package/docs/agi/skills/targeted-testing/SKILL.md +63 -0
- package/docs/agi/skills/understanding-jsgui3/SKILL.md +85 -0
- package/docs/api-reference.md +120 -2
- package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +1 -0
- package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +33 -0
- package/docs/books/website-design/01-introduction.md +73 -0
- package/docs/books/website-design/02-current-state.md +195 -0
- package/docs/books/website-design/03-base-class.md +181 -0
- package/docs/books/website-design/04-webpage.md +307 -0
- package/docs/books/website-design/05-website.md +456 -0
- package/docs/books/website-design/06-pages-storage.md +170 -0
- package/docs/books/website-design/07-api-layer.md +285 -0
- package/docs/books/website-design/08-server-integration.md +271 -0
- package/docs/books/website-design/09-cross-agent-review.md +190 -0
- package/docs/books/website-design/10-open-questions.md +196 -0
- package/docs/books/website-design/11-converged-recommendation.md +205 -0
- package/docs/books/website-design/12-content-model.md +395 -0
- package/docs/books/website-design/13-webpage-module-spec.md +404 -0
- package/docs/books/website-design/14-website-module-spec.md +541 -0
- package/docs/books/website-design/15-multi-repo-plan.md +275 -0
- package/docs/books/website-design/16-minimal-first.md +203 -0
- package/docs/books/website-design/17-implementation-report-codex.md +81 -0
- package/docs/books/website-design/README.md +43 -0
- package/docs/bundling-system-deep-dive.md +112 -3
- package/docs/configuration-reference.md +84 -0
- package/docs/proposals/jsgui3-website-and-webpage-design-jsgui3-server-support.md +257 -0
- package/docs/proposals/jsgui3-website-and-webpage-design-review.md +73 -0
- package/docs/proposals/jsgui3-website-and-webpage-design.md +732 -0
- package/docs/swagger.md +316 -0
- package/examples/controls/1) window/server.js +6 -1
- package/examples/controls/21) mvvm and declarative api/check.js +94 -0
- package/examples/controls/21) mvvm and declarative api/check_output.txt +25 -0
- package/examples/controls/21) mvvm and declarative api/check_output_2.txt +27 -0
- package/examples/controls/21) mvvm and declarative api/client.js +241 -0
- declarative api/e2e-screenshot-1-name-change.png +0 -0
- declarative api/e2e-screenshot-2-toggled.png +0 -0
- declarative api/e2e-screenshot-3-final.png +0 -0
- declarative api/e2e-screenshot-final.png +0 -0
- package/examples/controls/21) mvvm and declarative api/e2e-test.js +175 -0
- package/examples/controls/21) mvvm and declarative api/out.html +1 -0
- package/examples/controls/21) mvvm and declarative api/page_out.html +1 -0
- package/examples/controls/21) mvvm and declarative api/server.js +18 -0
- package/examples/data-views/01) query-endpoint/server.js +61 -0
- package/labs/website-design/001-base-class-overhead/check.js +162 -0
- package/labs/website-design/002-pages-storage/check.js +244 -0
- package/labs/website-design/002-pages-storage/results.txt +0 -0
- package/labs/website-design/003-type-detection/check.js +193 -0
- package/labs/website-design/003-type-detection/results.txt +0 -0
- package/labs/website-design/004-two-stage-validation/check.js +314 -0
- package/labs/website-design/004-two-stage-validation/results.txt +0 -0
- package/labs/website-design/005-normalize-input/check.js +303 -0
- package/labs/website-design/006-serve-website-spike/check.js +290 -0
- package/labs/website-design/README.md +34 -0
- package/labs/website-design/manifest.json +68 -0
- package/labs/website-design/run-all.js +60 -0
- package/middleware/json-body.js +126 -0
- package/openapi.js +474 -0
- package/package.json +13 -7
- package/publishers/Publishers.js +6 -5
- package/publishers/http-function-publisher.js +135 -126
- package/publishers/http-webpage-publisher.js +89 -11
- package/publishers/query-publisher.js +116 -0
- package/publishers/swagger-publisher.js +203 -0
- package/publishers/swagger-ui.js +578 -0
- package/resources/adapters/array-adapter.js +143 -0
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +90 -22
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +50 -14
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +48 -14
- package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +396 -44
- package/resources/query-resource.js +131 -0
- package/serve-factory.js +677 -18
- package/server.js +585 -167
- package/tests/README.md +86 -2
- package/tests/admin-ui-jsgui-controls.test.js +16 -1
- package/tests/bundling-default-control-elimination.puppeteer.test.js +32 -1
- package/tests/control-elimination-root-feature-pruning.test.js +440 -0
- package/tests/control-elimination-static-bracket-access.test.js +245 -0
- package/tests/control-scan-manifest-regression.test.js +2 -0
- package/tests/end-to-end.test.js +22 -21
- package/tests/fixtures/control_scan_manifest_expectations.json +4 -2
- package/tests/helpers/playwright-e2e-harness.js +326 -0
- package/tests/helpers/puppeteer-e2e-harness.js +62 -1
- package/tests/openapi.test.js +319 -0
- package/tests/playwright-smoke.test.js +134 -0
- package/tests/project-local-controls-bundling.puppeteer.test.js +462 -0
- package/tests/publish-enhancements.test.js +673 -0
- package/tests/query-publisher.test.js +430 -0
- package/tests/quick-json-body-test.js +169 -0
- package/tests/serve.test.js +425 -122
- package/tests/swagger-publisher.test.js +1076 -0
- package/tests/test-runner.js +4 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: instruction-adherence
|
|
3
|
+
description: "Use when instruction drift is likely: multi-step tasks, mid-task detours (tooling upgrades), or when agents must consult Skills and re-anchor repeatedly. Triggers: 'stay on track', 'follow instructions', 'resume main task', 'detour', 'intermediate task done'."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Instruction Adherence (Stay On Track)
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
This Skill is about reliably following instructions across:
|
|
11
|
+
- Multiple instruction sources (system/developer/mode files, repo docs, user request)
|
|
12
|
+
- Memory sources (Skills registry, sessions, lessons/patterns)
|
|
13
|
+
- Multi-step execution where detours happen (e.g., "improve CLI tooling" mid-stream)
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
- The current user request (objective + success criteria)
|
|
18
|
+
- The active mode/persona (if any)
|
|
19
|
+
- Repo guardrails (AGENTS.md, testing commands)
|
|
20
|
+
|
|
21
|
+
## Procedure
|
|
22
|
+
|
|
23
|
+
### 1) Capture an "Instruction Snapshot" (mandatory)
|
|
24
|
+
|
|
25
|
+
In your working notes, write a short snapshot:
|
|
26
|
+
- **Objective**: 1 sentence
|
|
27
|
+
- **Must do**: 3–7 bullets
|
|
28
|
+
- **Must not**: 3–7 bullets
|
|
29
|
+
- **Evidence**: what output/tests/checks will prove done
|
|
30
|
+
|
|
31
|
+
This becomes the "north star" when you get interrupted.
|
|
32
|
+
|
|
33
|
+
### 2) Run the memory retrieval ritual (Skills → Docs)
|
|
34
|
+
|
|
35
|
+
- Skills: scan `docs/agi/skills/` and follow any matching SOP.
|
|
36
|
+
- Docs: check `AGENTS.md` and relevant documentation.
|
|
37
|
+
|
|
38
|
+
### 3) Build a "Task Ledger" with explicit parent/child tasks
|
|
39
|
+
|
|
40
|
+
Use a structured task list that prevents detours from becoming the main task:
|
|
41
|
+
- Parent task: user's objective
|
|
42
|
+
- Child tasks: discovery → implement → validate → document
|
|
43
|
+
- If a detour is required (e.g., CLI tooling improvement), make it a **child task** with:
|
|
44
|
+
- **Entry criteria** (why it's needed)
|
|
45
|
+
- **Exit criteria** (what "done" means)
|
|
46
|
+
- **Return step** (the exact next step to resume)
|
|
47
|
+
|
|
48
|
+
### 4) The Re-anchor loop (run after every subtask)
|
|
49
|
+
|
|
50
|
+
After any meaningful milestone (or after 3–5 tool calls):
|
|
51
|
+
- Re-read the Instruction Snapshot
|
|
52
|
+
- Mark completed tasks
|
|
53
|
+
- Confirm the next step is still on the parent objective
|
|
54
|
+
- If you drifted, explicitly choose to:
|
|
55
|
+
- Resume parent objective, or
|
|
56
|
+
- Create a follow-up and stop the detour
|
|
57
|
+
|
|
58
|
+
### 5) "Detour complete → resume" protocol
|
|
59
|
+
|
|
60
|
+
When an intermediate task (like CLI tooling improvement) is completed:
|
|
61
|
+
1. Record a one-paragraph summary + evidence in the session notes.
|
|
62
|
+
2. Add/update a Skill or Lesson if it will recur.
|
|
63
|
+
3. Immediately take the "Return step" you wrote in the task ledger.
|
|
64
|
+
|
|
65
|
+
## Validation (evidence checklist)
|
|
66
|
+
|
|
67
|
+
- Working notes contain an Instruction Snapshot.
|
|
68
|
+
- Task ledger clearly separates parent objective vs detours.
|
|
69
|
+
- At least one re-anchor checkpoint is recorded.
|
|
70
|
+
- Session summary includes an **Instruction Reflection**:
|
|
71
|
+
- What instructions helped?
|
|
72
|
+
- What was missing/wrong?
|
|
73
|
+
- What durable doc/agent update was made?
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: jsgui3-activation-debug
|
|
3
|
+
description: Debug jsgui3 client-side activation issues. Use when SSR renders but clicks don't work, this.dom.el is null, or you see Missing context.map_Controls / activation failures.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# jsgui3 Activation Debug
|
|
7
|
+
|
|
8
|
+
## Triggers
|
|
9
|
+
|
|
10
|
+
- "jsgui3", "clicks don't work", "activation", "Missing context.map_Controls"
|
|
11
|
+
|
|
12
|
+
## Scope
|
|
13
|
+
|
|
14
|
+
- Diagnose "renders but no interactivity" failures
|
|
15
|
+
- Ensure client bundle is current when tests run in a browser
|
|
16
|
+
- Add a minimal check script when behavior is unclear
|
|
17
|
+
|
|
18
|
+
## Inputs
|
|
19
|
+
|
|
20
|
+
- Which server/route/control is affected
|
|
21
|
+
- Whether the issue reproduces in E2E (Puppeteer/Playwright)
|
|
22
|
+
- Whether client bundling is involved
|
|
23
|
+
|
|
24
|
+
## Procedure
|
|
25
|
+
|
|
26
|
+
1. Confirm this is an activation issue, not just CSS/DOM.
|
|
27
|
+
- View the page source — if the HTML looks correct, it's likely activation.
|
|
28
|
+
- If the HTML is wrong, it's an SSR bug (different skill).
|
|
29
|
+
|
|
30
|
+
2. Follow the documented activation flow and look for the canonical signatures:
|
|
31
|
+
- `data-jsgui-id` attributes on SSR elements
|
|
32
|
+
- `data-jsgui-type` for constructor mapping
|
|
33
|
+
- Client bundle loading correctly in browser Network tab
|
|
34
|
+
|
|
35
|
+
3. Check the client bundle is up to date:
|
|
36
|
+
- If using bundled client JS, ensure it was rebuilt after any control changes.
|
|
37
|
+
- The server's bundler in `serve-factory.js` handles this automatically in most cases.
|
|
38
|
+
|
|
39
|
+
4. Check `activate()` implementation:
|
|
40
|
+
- Is `super.activate()` being called?
|
|
41
|
+
- Is `this.dom.el` available at the time of activation?
|
|
42
|
+
- Are event listeners being attached in `activate()`, not in the constructor?
|
|
43
|
+
|
|
44
|
+
5. If unclear, create a minimal reproduction check:
|
|
45
|
+
```javascript
|
|
46
|
+
// Quick check: does the control load and render?
|
|
47
|
+
const Server = require('./server');
|
|
48
|
+
const s = new Server({port: 0});
|
|
49
|
+
// ... mount the control, start, check response
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Common Error Messages
|
|
53
|
+
|
|
54
|
+
- **`Missing context.map_Controls for type <X>`**: SSR said the element is type X, but the client doesn't have a constructor registered. Client falls back to generic `Control`.
|
|
55
|
+
- **`Missing context.map_Controls for type undefined`**: Often corresponds to tags where `data-jsgui-type` is intentionally not emitted (html/head/body). Usually log noise.
|
|
56
|
+
- **`&&& no corresponding control`**: Emitted during pre-activation when DOM contains text nodes that don't correspond to a control entry. Often benign whitespace.
|
|
57
|
+
|
|
58
|
+
## Validated Patterns
|
|
59
|
+
|
|
60
|
+
### Pattern: Manual DOM Query in `activate()`
|
|
61
|
+
When standard control field linking is insufficient, explicitly querying the DOM in `activate()` is a robust fallback:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
activate() {
|
|
65
|
+
if (this.__active) return;
|
|
66
|
+
this.__active = true;
|
|
67
|
+
|
|
68
|
+
const el = this.dom?.el;
|
|
69
|
+
if (!el) return;
|
|
70
|
+
|
|
71
|
+
// 1. Read config from data attributes
|
|
72
|
+
this.initial_width = parseInt(el.dataset.initialWidth, 10);
|
|
73
|
+
|
|
74
|
+
// 2. Query explicitly for child elements
|
|
75
|
+
this._expand_handle_el = el.querySelector("[data-expand-handle]");
|
|
76
|
+
|
|
77
|
+
// 3. Bind events
|
|
78
|
+
if (this._expand_handle_el) {
|
|
79
|
+
this._expand_handle_el.addEventListener("click", this._handle_expand.bind(this));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Anti-Patterns to Avoid
|
|
85
|
+
|
|
86
|
+
- **Blindly Editing CSS**: Assuming a control isn't working because of z-index or pointer-events, when the real issue is that the JS `activate()` method never fired on the client.
|
|
87
|
+
- **Skipping Build**: Making changes to control logic and running E2E tests without rebuilding the client bundle first, leading to false negatives.
|
|
88
|
+
|
|
89
|
+
## References
|
|
90
|
+
|
|
91
|
+
- jsgui3 understanding: `docs/agi/skills/understanding-jsgui3/SKILL.md`
|
|
92
|
+
- Comprehensive documentation: `docs/comprehensive-documentation.md`
|
|
93
|
+
- Controls development guide: `docs/controls-development.md`
|
|
94
|
+
- Server source: `server.js`, `serve-factory.js`
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: jsgui3-context-menu-patterns
|
|
3
|
+
description: Standard pattern for implementing context menus in jsgui3 applications (Web & Electron), ensuring consistent behavior for activation, positioning, and dismissal. Triggers — context menu, right-click menu, popup menu, overlay positioning, click-outside dismissal.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: jsgui3 Context Menu Patterns
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
Standard pattern for implementing context menus in jsgui3 applications, ensuring consistent behavior for activation, positioning, and dismissal.
|
|
10
|
+
|
|
11
|
+
## The Pattern
|
|
12
|
+
|
|
13
|
+
1. **Activation**: Listen for `contextmenu` event on the target element (or delegated container).
|
|
14
|
+
2. **Prevention**: Call `e.preventDefault()` to stop the native browser context menu.
|
|
15
|
+
3. **Creation**: Create or show the menu DOM element.
|
|
16
|
+
* Append to `document.body` (or a dedicated overlay layer) to avoid z-index/clipping issues.
|
|
17
|
+
* Position using `fixed` or `absolute` coordinates based on `e.clientX` / `e.clientY`.
|
|
18
|
+
* **Clamp** coordinates to viewport bounds to prevent overflow.
|
|
19
|
+
4. **Dismissal**:
|
|
20
|
+
* Add **global** `click` listener to `document` (use `capture: true` or check `e.target` to allow clicks inside the menu).
|
|
21
|
+
* Add **global** `keydown` listener for `Escape` key.
|
|
22
|
+
* Remove these listeners immediately upon menu closure to prevent leaks.
|
|
23
|
+
5. **Cleanup**: Always remove the menu element and listeners when closed.
|
|
24
|
+
|
|
25
|
+
## Implementation Example (jsgui3)
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
// In your control's activate() method:
|
|
29
|
+
this.dom.el.addEventListener('contextmenu', (e) => {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
this.show_context_menu(e.clientX, e.clientY);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
show_context_menu(x, y) {
|
|
35
|
+
// 1. Close existing
|
|
36
|
+
if (this._active_menu) this._active_menu.remove();
|
|
37
|
+
|
|
38
|
+
// 2. Create Menu (using jsgui or raw DOM)
|
|
39
|
+
const menu = document.createElement('div');
|
|
40
|
+
menu.className = 'context-menu';
|
|
41
|
+
|
|
42
|
+
// 3. Position & Clamp
|
|
43
|
+
const width = 150; // Estimated or measured
|
|
44
|
+
const height = 100;
|
|
45
|
+
|
|
46
|
+
// Clamp X
|
|
47
|
+
if (x + width > window.innerWidth) x -= width;
|
|
48
|
+
// Clamp Y
|
|
49
|
+
if (y + height > window.innerHeight) y -= height;
|
|
50
|
+
|
|
51
|
+
menu.style.left = `${x}px`;
|
|
52
|
+
menu.style.top = `${y}px`;
|
|
53
|
+
|
|
54
|
+
// 4. Add Items
|
|
55
|
+
// ... append items ...
|
|
56
|
+
|
|
57
|
+
document.body.appendChild(menu);
|
|
58
|
+
this._active_menu = menu;
|
|
59
|
+
|
|
60
|
+
// 5. Setup Dismissal
|
|
61
|
+
const close_handler = (ev) => {
|
|
62
|
+
// Don't close if clicking inside menu
|
|
63
|
+
if (ev.type === 'click' && menu.contains(ev.target)) return;
|
|
64
|
+
|
|
65
|
+
// Close on click outside or Escape
|
|
66
|
+
if (ev.type === 'click' || (ev.type === 'keydown' && ev.key === 'Escape')) {
|
|
67
|
+
menu.remove();
|
|
68
|
+
this._active_menu = null;
|
|
69
|
+
document.removeEventListener('click', close_handler);
|
|
70
|
+
document.removeEventListener('keydown', close_handler);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Defer listener to avoid immediate trigger
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
document.addEventListener('click', close_handler);
|
|
77
|
+
document.addEventListener('keydown', close_handler);
|
|
78
|
+
}, 0);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Validation
|
|
83
|
+
|
|
84
|
+
Verify context menu behavior:
|
|
85
|
+
- Right-click shows menu at cursor position
|
|
86
|
+
- Menu is clamped within viewport
|
|
87
|
+
- Click outside dismisses menu
|
|
88
|
+
- Escape key dismisses menu
|
|
89
|
+
- No event listener leaks after menu closure
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- Understanding jsgui3: `docs/agi/skills/understanding-jsgui3/SKILL.md`
|
|
94
|
+
- Controls development: `docs/controls-development.md`
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: puppeteer-efficient-ui-verification
|
|
3
|
+
description: Fast, repeatable UI verification using Puppeteer without paying browser startup per test. Use scenario suites + deterministic fixtures before jumping to full E2E tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Puppeteer Efficient UI Verification
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
- Choose the fastest *correct* browser-level verification method
|
|
11
|
+
- Run multiple UI scenarios per browser session (scenario suites)
|
|
12
|
+
- Capture evidence (artifacts + console/network logs) so failures are actionable
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
- What changed (files / feature)
|
|
17
|
+
- Do you need browser semantics (events, CSS/layout, client bundle activation)?
|
|
18
|
+
- Do you need a deterministic fixture (DB seed, synthetic page)?
|
|
19
|
+
|
|
20
|
+
## Procedure (verification ladder)
|
|
21
|
+
|
|
22
|
+
1. Prefer server-side/SSR checks when possible
|
|
23
|
+
- If the change is server-only or SSR-only, create/run a check script that loads the module and verifies output.
|
|
24
|
+
- If the change touches server startup, start the server and verify it responds:
|
|
25
|
+
```bash
|
|
26
|
+
node -e "const s = require('./server'); console.log('Server module loaded OK')"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. If you need "one URL in a browser", use a simple Puppeteer script
|
|
30
|
+
- Navigate to the page, wait for a key selector, capture screenshot + console logs.
|
|
31
|
+
- Best for quick debugging of console errors and 404s.
|
|
32
|
+
|
|
33
|
+
3. If you need multiple interactions, use a scenario suite (single browser)
|
|
34
|
+
- Use a runner script that starts one browser and runs multiple scenarios sequentially.
|
|
35
|
+
- Each scenario navigates, waits for readiness, and asserts conditions.
|
|
36
|
+
- Artifacts are written to `tmp/ui-scenarios/` by default.
|
|
37
|
+
|
|
38
|
+
4. Promote to full E2E test when it's a regression
|
|
39
|
+
- Add a proper test file in `tests/`.
|
|
40
|
+
|
|
41
|
+
## Suite authoring SOP (deterministic fixtures)
|
|
42
|
+
|
|
43
|
+
When creating a new scenario suite:
|
|
44
|
+
|
|
45
|
+
1. Create a runner script under `tests/scenarios/` or `scripts/scenarios/`.
|
|
46
|
+
2. Export `start_server()` that:
|
|
47
|
+
- starts the server on port `0` (random port)
|
|
48
|
+
- returns `{ base_url, shutdown() }`
|
|
49
|
+
3. Add scenarios with stable ids (`"001"`, `"002"`, …).
|
|
50
|
+
4. Add **readiness gates** for client activation (jsgui3):
|
|
51
|
+
- prefer `page.waitForFunction()` on deterministic signals
|
|
52
|
+
5. On failures, ensure you have evidence:
|
|
53
|
+
- screenshot + HTML snapshot + captured logs
|
|
54
|
+
|
|
55
|
+
## Validation
|
|
56
|
+
|
|
57
|
+
- Scenario suite run exits cleanly (no hanging server/browser)
|
|
58
|
+
- At least one scenario validates the user-visible invariant
|
|
59
|
+
- Failures produce artifacts that explain the bug (not just "timeout")
|
|
60
|
+
|
|
61
|
+
## References
|
|
62
|
+
|
|
63
|
+
- Test directory: `tests/`
|
|
64
|
+
- jsgui3 activation flow: `docs/comprehensive-documentation.md`
|
|
65
|
+
- Control lifecycle: see `understanding-jsgui3` skill
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: runaway-process-guard
|
|
3
|
+
description: Prevents infinite loops and runaway execution by enforcing strict timeouts, circuit breakers, and semantic repetition detection.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Runaway Process Guard
|
|
7
|
+
|
|
8
|
+
This skill codifies explicit rules for preventing an AI agent from getting stuck in infinite loops, runaway scripts, or deadlocked background processes. Because agents inherently optimize for continuation and lack an intuitive "sense of time," these external operational rules must be strictly adhered to whenever interacting with the terminal or writing polling loops.
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
- Applies to all custom scripts written by the agent that involve loops (`while`, `for`, `setInterval`).
|
|
12
|
+
- Applies to all agent interactions with background commands (using `run_command` and `command_status`).
|
|
13
|
+
- Does **not** supersede domain-specific graceful degradation if a tool provides a native way to timeout gracefully, but acts as the hard ceiling above it.
|
|
14
|
+
|
|
15
|
+
## The 3 Pillars of Runaway Prevention
|
|
16
|
+
|
|
17
|
+
### 1. Hard Timeboxing (Programmatic Circuit Breakers)
|
|
18
|
+
Never write a custom polling script or infinite loop without a programmatic wall-clock timeout.
|
|
19
|
+
* **Rule:** Every `while(running)` or indefinite status check loop MUST track `Date.now()`.
|
|
20
|
+
* **Implementation:**
|
|
21
|
+
```javascript
|
|
22
|
+
const MAX_WAIT_MS = 60000; // 1 minute
|
|
23
|
+
const start = Date.now();
|
|
24
|
+
while (running && (Date.now() - start < MAX_WAIT_MS)) {
|
|
25
|
+
// ... poll ...
|
|
26
|
+
}
|
|
27
|
+
if (running) {
|
|
28
|
+
console.error("TIMEOUT_CIRCUIT_BREAKER_TRIPPED");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
* **Rule:** When using `execSync` from Node, ALWAYS pass the `{ timeout: X }` flag.
|
|
33
|
+
|
|
34
|
+
### 2. Semantic Repetition Detection (Agent Circuit Breaker)
|
|
35
|
+
When polling a background process using the `command_status` tool, you must act as the circuit breaker.
|
|
36
|
+
* **Rule:** If you check the status of a command 3 times and the text output reveals identical states (e.g., repeatedly showing the same output over 60 seconds), you MUST assume the process is deadlocked or state tracking has failed.
|
|
37
|
+
* **Action:** Immediately cease waiting. Do not passive-poll in hopes that it will magically resolve.
|
|
38
|
+
|
|
39
|
+
### 3. Immediate Termination Protocols
|
|
40
|
+
If a process is determined to be stuck (either by tripping the semantic repetition detector or visually hanging during a user interaction):
|
|
41
|
+
* **Action:** Use the `send_command_input` tool with `Terminate: true` to kill the background job.
|
|
42
|
+
* **Action:** If a script spawned detached daemon processes, terminating the parent CLI command will not kill the workers. You MUST issue explicit kill/stop commands to eradicate the orphaned runaways.
|
|
43
|
+
|
|
44
|
+
## Escalation / Pivot
|
|
45
|
+
When a circuit breaker is tripped:
|
|
46
|
+
1. Do not immediately rewrite the script and try the exact same approach again.
|
|
47
|
+
2. Record the timeout failure in an artifact or thought process.
|
|
48
|
+
3. Investigate if the underlying system provides an alternate, safer primitive.
|
|
49
|
+
4. Prompt the user for guidance if the underlying mechanism seems fundamentally broken.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: session-discipline
|
|
3
|
+
description: Enforce session-first workflow (plan → implement → verify → document). Use whenever starting non-trivial work, debugging >15 minutes, or doing cross-cutting changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Session Discipline
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
- Ensure every non-trivial task has proper planning and tracking
|
|
11
|
+
- Keep evidence (commands/tests) and outcomes discoverable
|
|
12
|
+
- Reduce "handover friction" by making every action resumable from docs
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
- Task description and objective one-liner
|
|
17
|
+
- Type/category of work
|
|
18
|
+
|
|
19
|
+
## Procedure
|
|
20
|
+
|
|
21
|
+
1. Create working notes with a clear objective, done-when criteria, change set, risks, and tests.
|
|
22
|
+
2. Log commands + findings in working notes as you go.
|
|
23
|
+
3. Summarize outcomes + follow-ups with named owners when done.
|
|
24
|
+
|
|
25
|
+
## Validation
|
|
26
|
+
|
|
27
|
+
- Ensure follow-ups have owners if anything is deferred.
|
|
28
|
+
- Working notes capture actual commands run and their outcomes.
|
|
29
|
+
|
|
30
|
+
## Escalation / Research request
|
|
31
|
+
|
|
32
|
+
If you need deeper background and existing docs aren't sufficient:
|
|
33
|
+
|
|
34
|
+
- Add a follow-up: "Request research agent to expand Skill <name>"
|
|
35
|
+
- Include: expected triggers, target files, and what validation should exist
|
|
36
|
+
|
|
37
|
+
## References
|
|
38
|
+
|
|
39
|
+
- Repo guidelines: `AGENTS.md`
|
|
40
|
+
- Skills directory: `docs/agi/skills/`
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-writing
|
|
3
|
+
description: "Write excellent Antigravity Skills — reusable capability packs with trigger phrases, SOPs, and validation. Use when creating a new Skill, improving an existing one, or auditing skill quality. Triggers: write a skill, new skill, create skill, skill review, improve skill, skill quality."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Writing Excellent Antigravity Skills
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Use this Skill when you need to:
|
|
11
|
+
|
|
12
|
+
- **Create a new Skill** from scratch (or from session learnings)
|
|
13
|
+
- **Upgrade an existing Skill** that's thin, outdated, or missing key sections
|
|
14
|
+
- **Audit skill quality** across the registry
|
|
15
|
+
- **Extract a Skill** from a successful session or workflow
|
|
16
|
+
|
|
17
|
+
This is a meta-skill: it teaches how to write Skills that teach agents to do things well.
|
|
18
|
+
|
|
19
|
+
Out of scope:
|
|
20
|
+
- Writing *workflows* (`.agent/workflows/`) — those are sequential checklists, not capability packs
|
|
21
|
+
- Writing *lessons* or *patterns* — those are distilled one-liners, not SOPs
|
|
22
|
+
|
|
23
|
+
## Core Principle: A Skill Is a Decision-Making Machine
|
|
24
|
+
|
|
25
|
+
> **A good Skill doesn't just tell the agent *what to do* — it tells the agent *what to think about* while doing it.**
|
|
26
|
+
|
|
27
|
+
The difference between a weak Skill and a strong one:
|
|
28
|
+
|
|
29
|
+
| Weak Skill | Strong Skill |
|
|
30
|
+
|-----------|-------------|
|
|
31
|
+
| "Run these 5 commands" | "Here's the mental model. Here are the commands. Here's how to tell if they worked. Here's what to do when they don't." |
|
|
32
|
+
| Agent follows steps blindly | Agent *reasons* about the domain and adapts |
|
|
33
|
+
| Breaks when reality deviates | Handles edge cases because the agent understands *why* |
|
|
34
|
+
|
|
35
|
+
## Mental Model: The Skill Quality Pyramid
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
┌─────────────┐
|
|
39
|
+
│ MENTAL │ ← The agent can reason about WHY
|
|
40
|
+
│ MODELS │ (principles, heuristics, trade-offs)
|
|
41
|
+
├─────────────┤
|
|
42
|
+
│ DECISION │ ← The agent knows WHEN to do what
|
|
43
|
+
│ POINTS │ (if X → do A, if Y → do B)
|
|
44
|
+
├─────────────┤
|
|
45
|
+
│ CONCRETE │ ← The agent knows HOW
|
|
46
|
+
│ ACTIONS │ (commands, code patterns, API calls)
|
|
47
|
+
├─────────────┤
|
|
48
|
+
│ GUARD │ ← The agent knows when to STOP
|
|
49
|
+
│ RAILS │ (anti-patterns, stopping rules, escalation)
|
|
50
|
+
└─────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Level 1 (Actions only)** — the agent can follow the steps. Fragile.
|
|
54
|
+
**Level 2 (Actions + Decisions)** — the agent can handle branching. Better.
|
|
55
|
+
**Level 3 (Actions + Decisions + Mental Models)** — the agent can adapt. Strong.
|
|
56
|
+
**Level 4 (All four layers)** — the agent can self-correct. Excellent.
|
|
57
|
+
|
|
58
|
+
Your goal: write Level 3–4 Skills.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Procedure
|
|
63
|
+
|
|
64
|
+
### Phase 0 — Decide If This Should Be a Skill
|
|
65
|
+
|
|
66
|
+
Not everything deserves a Skill. Use this decision tree:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
Is this a repeatable capability (not a one-off task)?
|
|
70
|
+
├── No → Write a session note or follow-up instead
|
|
71
|
+
└── Yes
|
|
72
|
+
├── Is it a simple checklist with no branching logic?
|
|
73
|
+
│ ├── Yes → Write a workflow (`.agent/workflows/`)
|
|
74
|
+
│ └── No
|
|
75
|
+
│ └── Does it require domain reasoning or decision-making?
|
|
76
|
+
│ ├── Yes → WRITE A SKILL ✓
|
|
77
|
+
│ └── No → Consider a pattern
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Phase 1 — Deep Research Before Writing
|
|
81
|
+
|
|
82
|
+
**Never write a Skill from scratch.** Always research first:
|
|
83
|
+
|
|
84
|
+
1. **Check for existing Skills** that overlap
|
|
85
|
+
2. **Mine session history** for the source material
|
|
86
|
+
3. **Identify the core mental model**
|
|
87
|
+
4. **Identify anti-patterns**
|
|
88
|
+
|
|
89
|
+
### Phase 2 — Design the Skill Structure
|
|
90
|
+
|
|
91
|
+
Every Skill MUST have these sections (the **Mandatory Six**):
|
|
92
|
+
|
|
93
|
+
| Section | Purpose | Quality Test |
|
|
94
|
+
|---------|---------|-------------|
|
|
95
|
+
| **Frontmatter** | Discovery — when should this Skill activate? | Would a search for any related keyword find this Skill? |
|
|
96
|
+
| **Scope** | Boundaries — what does/doesn't this Skill cover? | Could an agent confidently decide "this Skill applies" or "this Skill doesn't apply"? |
|
|
97
|
+
| **Inputs** | Prerequisites — what info does the agent need? | If the agent doesn't have these inputs, would it know to ask? |
|
|
98
|
+
| **Procedure** | The SOP — step-by-step with decision points | Could an agent follow this without asking for help on the happy path? |
|
|
99
|
+
| **Validation** | Proof — how does the agent verify the work? | Are there specific commands with expected outputs? |
|
|
100
|
+
| **References** | Pointers — related docs, tools, skills | Would an agent know where to go for deeper context? |
|
|
101
|
+
|
|
102
|
+
### Phase 3 — Write the Frontmatter (Most Important Part)
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
---
|
|
106
|
+
name: my-skill-name
|
|
107
|
+
description: "Verb-first description of what the skill does and WHEN to use it. Include trigger phrases."
|
|
108
|
+
---
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Rules for great frontmatter:**
|
|
112
|
+
|
|
113
|
+
1. **Name**: lowercase, hyphenated, 2-4 words. Self-explanatory without reading the description.
|
|
114
|
+
2. **Description**: Must answer TWO questions in a single sentence:
|
|
115
|
+
- What does this Skill **do**? (verb-first: "Diagnose...", "Write...", "Debug...")
|
|
116
|
+
- When should an agent **use** it? (situation triggers)
|
|
117
|
+
3. **Trigger phrases**: Include exact words a user or agent would use.
|
|
118
|
+
|
|
119
|
+
### Phase 4 — Write the Procedure
|
|
120
|
+
|
|
121
|
+
Follow these writing principles:
|
|
122
|
+
|
|
123
|
+
1. **Use imperative voice** ("Run this command", not "The agent should run")
|
|
124
|
+
2. **Number the steps**
|
|
125
|
+
3. **Include decision points inline**
|
|
126
|
+
4. **Show exact commands**
|
|
127
|
+
5. **Explain WHY alongside WHAT**
|
|
128
|
+
6. **Include concrete thresholds** when applicable
|
|
129
|
+
7. **Keep the Skill under 500 lines.**
|
|
130
|
+
|
|
131
|
+
### Phase 5 — Write Anti-Patterns
|
|
132
|
+
|
|
133
|
+
Good anti-patterns are:
|
|
134
|
+
- **Named** (so they can be referenced in conversation)
|
|
135
|
+
- **Grounded** in real experience
|
|
136
|
+
- **Specific** about cost
|
|
137
|
+
|
|
138
|
+
### Phase 6 — Write Validation and Escalation
|
|
139
|
+
|
|
140
|
+
**Validation** answers: "How does the agent know the Skill worked?"
|
|
141
|
+
**Escalation** answers: "When should the agent stop and ask for help?"
|
|
142
|
+
|
|
143
|
+
Both must be concrete. Avoid "if something goes wrong" — specify *what*.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Quality Audit Checklist
|
|
148
|
+
|
|
149
|
+
| # | Check | Pass? |
|
|
150
|
+
|---|-------|-------|
|
|
151
|
+
| 1 | Frontmatter has verb-first description with trigger phrases | |
|
|
152
|
+
| 2 | Scope clearly separates in-scope from out-of-scope | |
|
|
153
|
+
| 3 | Inputs lists what the agent needs before starting | |
|
|
154
|
+
| 4 | Procedure uses numbered steps with inline decision points | |
|
|
155
|
+
| 5 | Procedure shows exact commands (not abstract descriptions) | |
|
|
156
|
+
| 6 | Procedure explains WHY alongside WHAT | |
|
|
157
|
+
| 7 | Validation has concrete commands with expected outputs | |
|
|
158
|
+
| 8 | References points to related docs, tools, and Skills | |
|
|
159
|
+
| 9 | Mental model names the core thinking pattern (if applicable) | |
|
|
160
|
+
| 10 | Anti-patterns listed with names, costs, and alternatives | |
|
|
161
|
+
| 11 | Escalation criteria are specific (not "if something goes wrong") | |
|
|
162
|
+
| 12 | Under 500 lines (deeper content in references/) | |
|
|
163
|
+
|
|
164
|
+
**Scoring:** 10-12 Excellent · 7-9 Good · 4-6 Needs work · 1-3 Stub
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Anti-Patterns to Avoid
|
|
169
|
+
|
|
170
|
+
### ❌ The Checklist Masquerading as a Skill
|
|
171
|
+
**Symptom:** Skill is just a numbered list of commands with no decision logic.
|
|
172
|
+
**Fix:** Add decision points, WHY explanations, and a mental model section.
|
|
173
|
+
|
|
174
|
+
### ❌ The Encyclopaedia
|
|
175
|
+
**Symptom:** Skill is 800+ lines and tries to cover every scenario.
|
|
176
|
+
**Fix:** Keep SKILL.md under 500 lines. Put deep reference in `references/` files.
|
|
177
|
+
|
|
178
|
+
### ❌ The Vague Oracle
|
|
179
|
+
**Symptom:** Skill uses "use your judgment", "handle appropriately", "investigate as needed".
|
|
180
|
+
**Fix:** Replace every vague phrase with a concrete criterion, threshold, or decision point.
|
|
181
|
+
|
|
182
|
+
### ❌ The Island Skill
|
|
183
|
+
**Symptom:** Skill doesn't reference any other Skills.
|
|
184
|
+
**Fix:** Add an Integration section naming related Skills and when to chain them.
|
|
185
|
+
|
|
186
|
+
### ❌ Trigger Poverty
|
|
187
|
+
**Symptom:** Frontmatter has a generic description and 1-2 trigger phrases.
|
|
188
|
+
**Fix:** Add 5-10 trigger phrases covering problem-phrasing, task-phrasing, domain terms, and error messages.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Validation
|
|
193
|
+
|
|
194
|
+
After writing a Skill:
|
|
195
|
+
|
|
196
|
+
1. **Frontmatter search test:** Search for 3 different trigger phrases. Does the Skill appear?
|
|
197
|
+
2. **Cold-start test:** Could an agent encountering this domain for the first time follow the Skill without asking for help?
|
|
198
|
+
3. **Edge-case test:** Does the Skill handle the most common failure mode?
|
|
199
|
+
4. **Audit checklist:** Score using the Quality Audit Checklist. Target 10+.
|
|
200
|
+
|
|
201
|
+
## Escalation
|
|
202
|
+
|
|
203
|
+
- If unsure whether to write a Skill vs. workflow vs. pattern: default to Skill if it requires judgment calls, workflow if it's a pure checklist
|
|
204
|
+
- If the Skill's domain is unfamiliar: use `deep-research` first to build understanding
|
|
205
|
+
|
|
206
|
+
## References
|
|
207
|
+
|
|
208
|
+
- Skills directory: `docs/agi/skills/`
|
|
209
|
+
- Exemplar Skills (study these):
|
|
210
|
+
- `docs/agi/skills/deep-research/SKILL.md` — authoritative, reasoning toolkit
|
|
211
|
+
- `docs/agi/skills/runaway-process-guard/SKILL.md` — tactical, guard-rail focused
|