jsgui3-server 0.0.152 → 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.
Files changed (38) hide show
  1. package/docs/agi/skills/README.md +23 -0
  2. package/docs/agi/skills/agent-output-control/SKILL.md +56 -0
  3. package/docs/agi/skills/ai-deep-research/SKILL.md +52 -0
  4. package/docs/agi/skills/autonomous-ui-inspection/SKILL.md +102 -0
  5. package/docs/agi/skills/deep-research/SKILL.md +156 -0
  6. package/docs/agi/skills/endurance/SKILL.md +53 -0
  7. package/docs/agi/skills/exploring-other-codebases/SKILL.md +56 -0
  8. package/docs/agi/skills/instruction-adherence/SKILL.md +73 -0
  9. package/docs/agi/skills/jsgui3-activation-debug/SKILL.md +94 -0
  10. package/docs/agi/skills/jsgui3-context-menu-patterns/SKILL.md +94 -0
  11. package/docs/agi/skills/puppeteer-efficient-ui-verification/SKILL.md +65 -0
  12. package/docs/agi/skills/runaway-process-guard/SKILL.md +49 -0
  13. package/docs/agi/skills/session-discipline/SKILL.md +40 -0
  14. package/docs/agi/skills/skill-writing/SKILL.md +211 -0
  15. package/docs/agi/skills/static-analysis/SKILL.md +58 -0
  16. package/docs/agi/skills/targeted-testing/SKILL.md +63 -0
  17. package/docs/agi/skills/understanding-jsgui3/SKILL.md +85 -0
  18. package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +1 -0
  19. package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +33 -0
  20. package/docs/bundling-system-deep-dive.md +112 -3
  21. package/docs/configuration-reference.md +30 -0
  22. package/package.json +5 -2
  23. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +90 -22
  24. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +50 -14
  25. package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +48 -14
  26. package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +396 -44
  27. package/serve-factory.js +3 -54
  28. package/server.js +168 -68
  29. package/tests/README.md +63 -1
  30. package/tests/bundling-default-control-elimination.puppeteer.test.js +32 -1
  31. package/tests/control-elimination-root-feature-pruning.test.js +440 -0
  32. package/tests/control-elimination-static-bracket-access.test.js +245 -0
  33. package/tests/control-scan-manifest-regression.test.js +2 -0
  34. package/tests/end-to-end.test.js +22 -21
  35. package/tests/fixtures/control_scan_manifest_expectations.json +4 -2
  36. package/tests/helpers/puppeteer-e2e-harness.js +62 -1
  37. package/tests/project-local-controls-bundling.puppeteer.test.js +462 -0
  38. package/tests/test-runner.js +3 -0
@@ -0,0 +1,23 @@
1
+ # Skills (Capability Packs)
2
+
3
+ This folder contains repo-native "Skill packs": discoverable, reusable capabilities inspired by Claude Code Agent Skills.
4
+
5
+ A Skill is:
6
+ - a `SKILL.md` with clear triggers + SOP
7
+ - links to existing scripts/checks/tests (so validation is fast)
8
+ - minimal content by default (expand only when needed)
9
+
10
+ ## Conventions
11
+
12
+ - Folder name matches the skill name (lowercase, hyphenated)
13
+ - `SKILL.md` frontmatter must include:
14
+ - `name`
15
+ - `description` (include trigger phrases and "Use when …")
16
+
17
+ ## How to expand a Skill
18
+
19
+ If a Skill is missing critical steps or references:
20
+
21
+ 1. Add the missing pointers (docs/scripts/tests) first.
22
+ 2. Only then add new "how-to" prose.
23
+ 3. If new research is required, create a follow-up requesting research.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: agent-output-control
3
+ description: Standard Operating Procedure for varying agent output styles, controlling verbosity, and using information-dense emoji structures. Use this skill when asked to change your communication tone, increase conciseness, or design highly expressive console logging systems.
4
+ ---
5
+
6
+ # Agent Output Control
7
+
8
+ ## Scope
9
+
10
+ This Skill defines how agents should modulate their own communication streams (both to the user and within externalized code/logs). It covers variable verbosity, distinctive stylistic phrasing, and the experimental use of high-density emojis to convey complex state information instantly.
11
+
12
+ ## Triggers
13
+
14
+ - "Change your output style"
15
+ - "Be more concise", "Be more verbose"
16
+ - "Use heavy emojis for logging", "Design expressive console logs"
17
+ - "Write in a distinctive, information-dense style"
18
+
19
+ ## Methodology
20
+
21
+ ### 1. Modulating Verbosity and Phrasing
22
+ Agents must be able to fluidly shift between communication modes based on user preference or task context:
23
+ - **Maximum Conciseness (Terminal Mode):** Strip all conversational filler ("I will now...", "Here is the..."). Output strictly the required data, diffs, or Boolean confirmations.
24
+ - **High Verbosity (Didactic Mode):** Explain the *why* behind every action. Break down complex logic step-by-step, suitable for a tutorial or an architectural design doc.
25
+ - **Distinctive Persona:** If requested to adopt a specific stylistic persona (e.g., highly formal, ultra-terse, or uniquely formatted), maintain that constraint strictly across all tool calls and user notifications.
26
+
27
+ ### 2. Experimental High-Density Emoji Usage
28
+ Emojis are not just decorative; they are ultra-compact tokens that can convey state, direction, and domain instantly.
29
+ - **State Indicators:** `🟢` (Healthy/Go), `🟡` (Yield/Warn), `🔴` (Halt/Error), `🔵` (Info/Cold), `🔥` (Hot/Intense).
30
+ - **Domain Indicators:** `📦` (Database/Storage), `🌐` (Network/API), `🧠` (Agent/Logic), `🖥️` (UI/Frontend).
31
+ - **Action Indicators:** `➡️` (Data Flow), `🔄` (Loop/Retry), `🛑` (Block), `✅` (Success), `❌` (Fail), `⏱️` (Timing/Latency).
32
+ - **Density Protocol:** In "heavy emoji" mode, combine these tokens to create visual sentences.
33
+ *Example:* Instead of typing "The HTTP server successfully started and is serving the page in 45ms", output:
34
+ `[🌐 START ➡️ 🖥️ SERVE | ✅ 200 OK | ⏱️ 45ms]`
35
+
36
+ ### 3. Expressive Console Logging Design
37
+ When writing or refactoring logger software (e.g., Node.js `console.log` wrappers), apply the exact same principles to the code:
38
+ - **Visually Scannable:** Ensure logs begin with high-contrast emojis or color codes (via ANSI escape sequences) so developers can scan thousands of lines visually.
39
+ - **Structured Density:** Design the ultimate log format to be both human-readable (via emojis/tags) and machine-parsable (e.g., appended JSON).
40
+ - *Implementation Example in Code:*
41
+ ```javascript
42
+ const log_info = (msg, ms) => console.log(`🔵 [SYS] ➡️ ${msg} | ⏱️ ${ms}ms`);
43
+ const log_error = (api, err) => console.error(`🔴 [❌ FAIL: ${api}] 🔥 Err: ${err.message}`);
44
+ ```
45
+
46
+ ## Anti-Patterns to Avoid
47
+
48
+ - **The Chatty Protocol**: Replying with 3 paragraphs of pleasantries when the user explicitly requested "Maximum Conciseness" or "Terminal Mode".
49
+ - **Emoji Salad**: Using random or inconsistent emojis just to be colorful, which destroys their utility as scannable state indicators. Define a semantic mapping and stick to it.
50
+ - **Monolithic Logs**: Writing console logs that are just giant blocks of monochrome text with no visual anchors or parseable structures.
51
+
52
+ ## Validation
53
+
54
+ - Did you conform perfectly to the requested verbosity level (terse vs. verbose)?
55
+ - If using high-density emojis, is there a clear, consistent semantic meaning to each glyph?
56
+ - If generating logging code, does the code output visually scannable, information-dense strings?
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: ai-deep-research
3
+ description: Conduct multi-step, iterative, and deep research on complex topics. Use when a query requires synthesizing information from multiple sources, understanding deep context, or when initial findings are insufficient.
4
+ ---
5
+
6
+ # AI Deep Research
7
+
8
+ ## Scope
9
+
10
+ This Skill provides a methodology for conducting deep, multi-step research. It is designed to move beyond simple queries and quick answers, enabling the agent to autonomously plan, execute, analyze, and synthesize complex information.
11
+
12
+ ## Triggers
13
+
14
+ - "Deep research", "comprehensive analysis", "literature review"
15
+ - Queries requiring data from multiple disparate sources
16
+ - When initial searches yield superficial or insufficient results
17
+
18
+ ## Methodology & Procedure
19
+
20
+ 1. **Understand and Interactive Planning**:
21
+ - Deconstruct complex queries into distinct sub-topics and required knowledge gaps.
22
+ - **Interactive Review:** Propose the research plan to the User for refinement. Do not execute a massive multi-hour research loop without verifying the direction.
23
+ - Consider multimodal contexts (images, audio, existing code) attached to the query.
24
+
25
+ 2. **Iterative Gathering & Tool Diversity**:
26
+ - Utilize diverse sources: public web (`search_web`), exact file reads (`read_url_content`), and private enterprise/contextual data via MCP servers.
27
+ - Use code interpreters or external tools to crunch numbers or validate math, rather than relying solely on LLM text generation.
28
+ - **Self-Correcting Loops:** If a search is too broad, pivot to semantic variations. If you hit a paywall, find alternative authoritative sources.
29
+
30
+ 3. **Deep Thinking & Parallel Synthesis**:
31
+ - **Source Validation & Bias Detection:** Actively cross-reference claims text. Discard low-credibility sources, identify biases, and verify facts before trusting them.
32
+ - **Parallel Thinking:** For highly complex or contradictory topics, simulate multiple hypotheses or "agents" evaluating the data simultaneously, then synthesize the most robust finding.
33
+ - **Deliberate Reasoning:** Dedicate extensive "thinking" effort to difficult logical problems. It is better to have a highly accurate, deeply reasoned insight than a verbose but shallow summary.
34
+
35
+ 4. **Generate Comprehensive Report**:
36
+ - Structure a highly organized report with logical sections (e.g., Executive Summary, Sub-topic Deep Dives, Synthesis/Conclusion).
37
+ - Ensure all claims are backed by exact verifiable citations and links.
38
+ - Summarize the confidence level of the findings and acknowledge the system's own limitations if data is missing.
39
+
40
+ ## Validation
41
+
42
+ - Did you get User approval on the research plan before executing a massive loop?
43
+ - Did you cross-reference facts across multiple, high-credibility sources?
44
+ - Are contradictions between sources explicitly addressed ("Parallel Thinking")?
45
+ - Does the final report directly answer the user's core, complex question with verifiable citations?
46
+
47
+ ## Anti-Patterns to Avoid
48
+
49
+ - **Surface-Level Scraping**: Doing one search and just summarizing the first three hits.
50
+ - **Echo Chambering**: Relying on a single biased source without cross-referencing.
51
+ - **Task Fixation**: Sticking rigidly to the original search plan when initial searches prove fruitless or irrelevant.
52
+ - **Citation Omission**: Presenting facts without noting explicitly where they came from.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: autonomous-ui-inspection
3
+ description: Autonomous UI inspection using a dual channel — (1) visual screenshots via browser tools, (2) numeric layout metrics via Puppeteer scripts. Use when you need a reliable, agent-friendly view of what the UI renders.
4
+ ---
5
+
6
+ # Autonomous UI Inspection
7
+
8
+ ## Scope
9
+
10
+ Use this Skill when you need a **reliable, agent-friendly view of what the UI renders**:
11
+
12
+ - **Visual**: screenshots + accessibility snapshots
13
+ - **Numeric**: bounding boxes, computed styles, text overflow, and connection geometry (Puppeteer)
14
+
15
+ This Skill is about **inspection and evidence collection**. It intentionally avoids styling tweaks unless the inspection workflow itself is broken.
16
+
17
+ ## Inputs
18
+
19
+ - Which UI surface (server file + URL route)
20
+ - Whether the UI is SSR-only or needs client activation
21
+ - A stable selector that indicates "ready" (e.g. a control class or `data-role` attribute)
22
+ - Desired viewport and whether you need a clipped screenshot
23
+
24
+ ## Procedure
25
+
26
+ ### A) Server start/stop
27
+
28
+ 1. Start the jsgui3-server instance being inspected:
29
+ ```bash
30
+ node examples/<example>/server.js
31
+ ```
32
+ Or for the main server:
33
+ ```bash
34
+ node server.js
35
+ ```
36
+
37
+ 2. Ensure the server is ready before inspection.
38
+
39
+ ### B) Visual inspection (Browser tools)
40
+
41
+ Goal: get screenshots that an agent can "see", plus a structural snapshot.
42
+
43
+ 1. Start the UI server.
44
+ 2. Navigate to the URL using browser tools.
45
+ 3. Capture:
46
+ - Full-page screenshot (baseline)
47
+ - Optional clipped screenshot (if a stable container selector exists)
48
+ - Accessibility snapshot for structure + quick DOM sanity
49
+
50
+ Notes:
51
+ - Use consistent viewport dimensions (example: 1600x1200) to reduce diff noise.
52
+ - If the UI is interactive, capture "before" and "after" screenshots for a single canonical interaction.
53
+
54
+ ### C) Numeric inspection (Puppeteer)
55
+
56
+ Goal: compute layout facts agents can diff and enforce.
57
+
58
+ Run a dedicated Puppeteer script that:
59
+
60
+ - Starts the server on a random or fixed dev port
61
+ - Waits for a deterministic "ready" selector
62
+ - Extracts metrics:
63
+ - `getBoundingClientRect()` for key elements
64
+ - `scrollWidth/Height` vs `clientWidth/Height` for overflow
65
+ - computed styles for typography + spacing
66
+
67
+ Typical invariants to enforce:
68
+ - Text is not overflowing (`isOverflowing === false`)
69
+ - Bounding boxes are within expected ranges
70
+ - Key interactive elements are visible
71
+
72
+ ### D) WebSocket / live-update verification
73
+
74
+ When a page uses WebSocket for real-time updates:
75
+
76
+ 1. Verify WebSocket connection:
77
+ ```javascript
78
+ // Puppeteer: check WebSocket is established
79
+ const ws_messages = [];
80
+ page.on('websocket', ws => {
81
+ ws.on('framereceived', frame => ws_messages.push(JSON.parse(frame.payload)));
82
+ });
83
+ await page.goto(url);
84
+ await page.waitForTimeout(2000);
85
+ console.log('WS messages received:', ws_messages.length);
86
+ ```
87
+
88
+ 2. Verify DOM updates happen without reload.
89
+ 3. Test reconnect behavior if applicable.
90
+
91
+ ## Validation / Evidence Checklist
92
+
93
+ - Server starts and responds on the expected port
94
+ - At least one screenshot captured
95
+ - Numeric JSON output captured (stdout or written artifact)
96
+ - A "ready selector" exists and is documented for the UI
97
+
98
+ ## References
99
+
100
+ - Puppeteer efficient verification: `docs/agi/skills/puppeteer-efficient-ui-verification/SKILL.md`
101
+ - jsgui3 understanding: `docs/agi/skills/understanding-jsgui3/SKILL.md`
102
+ - Server documentation: `docs/comprehensive-documentation.md`
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: deep-research
3
+ description: Conduct deep, multi-step research on a topic using iterative search-evaluate-refine loops with deep thinking reasoning. Use when you need comprehensive understanding of a topic, technology, or problem space — not just a quick answer.
4
+ ---
5
+
6
+ # Skill: Deep Research (with Deep Thinking Reasoning)
7
+
8
+ ## Scope
9
+
10
+ Use this Skill when you need to **deeply understand a topic** — not just find a quick answer, but build comprehensive, validated knowledge:
11
+
12
+ - You need to research a technology, architecture, or design pattern in depth.
13
+ - You need to compare approaches and make an evidence-based recommendation.
14
+ - You need to produce a detailed report, book chapter, specification, or analysis.
15
+ - You need to investigate a problem space where the first answer is probably incomplete.
16
+ - You want to combine information from multiple sources into a coherent synthesis.
17
+
18
+ This is the research equivalent of "think hard before answering." It is **not** for quick lookups — use normal web search for those.
19
+
20
+ ## Core Principles
21
+
22
+ ### 1. Think Before You Search
23
+
24
+ Before any search, articulate:
25
+ - **What do I already know** about this topic?
26
+ - **What are my knowledge gaps?** (Be honest about uncertainty)
27
+ - **What specific questions** would fill those gaps?
28
+ - **What assumptions am I making?** (Write them down — see Key Assumptions Check below)
29
+
30
+ ### 2. Search Wide, Then Deep (Progressive Deepening)
31
+
32
+ ```
33
+ Round 1: Broad landscape scan
34
+ → "What is X? How does X work? X overview"
35
+ → Goal: Identify the key concepts, players, and terminology
36
+
37
+ Round 2: Targeted investigation
38
+ → "X vs Y comparison", "X architecture internals", "X best practices"
39
+ → Goal: Understand the mechanics, trade-offs, and expert opinions
40
+
41
+ Round 3: Deep dives on specifics
42
+ → "X edge cases", "X implementation gotchas", "X academic paper"
43
+ → Goal: Fill remaining gaps, find contrarian views, verify claims
44
+
45
+ Round 4 (if needed): Adversarial search
46
+ → "X criticisms", "X failures", "why X is bad", "X alternatives"
47
+ → Goal: Stress-test your conclusions with disconfirming evidence
48
+ ```
49
+
50
+ ### 3. Grade Your Evidence
51
+
52
+ | Level | Label | Description | Examples |
53
+ |-------|-------|-------------|----------|
54
+ | **A** | **High** | Primary source, authoritative, current | Official docs, author's blog, peer-reviewed paper, source code |
55
+ | **B** | **Moderate** | Credible secondary source, well-reasoned | Reputable tech blog, conference talk, well-cited Stack Overflow |
56
+ | **C** | **Low** | Unverified or potentially outdated | Random blog post, forum comment, undated article |
57
+ | **D** | **Very Low** | Anecdotal, potentially unreliable | Social media, AI-generated content, marketing material |
58
+
59
+ ### 4. Reason Deeply Between Searches (Deep Thinking)
60
+
61
+ After each search round, **stop and think**:
62
+ - What did I learn that I didn't know before?
63
+ - What contradictions or surprises did I find?
64
+ - What is still unclear or unconfirmed?
65
+ - Have my initial assumptions changed?
66
+ - What should I search for next?
67
+
68
+ ## Procedure
69
+
70
+ ### Phase 0 — Frame the Research
71
+ 1. **State the research objective** in one sentence.
72
+ 2. **List what you already know** (even if tentative).
73
+ 3. **List 3–5 specific questions** you need answered.
74
+ 4. **Perform a Key Assumptions Check** (KAC).
75
+ 5. **Define the output format**: report, comparison table, specification, etc.
76
+ 6. **Set a depth budget**: how many search rounds are appropriate? (Typically 3–5)
77
+
78
+ ### Phase 1 — Landscape Scan (Broad)
79
+ 1. Run 2–3 broad web searches with different phrasings.
80
+ 2. Read the top results. Skim for structure, not detail.
81
+ 3. **Pause and reason**.
82
+ 4. **Build an evidence map**.
83
+ 5. Update your question list.
84
+
85
+ ### Phase 2 — Targeted Investigation (Focused)
86
+ 1. Search for specific sub-topics identified in Phase 1.
87
+ 2. Read primary sources when possible.
88
+ 3. **Grade each source** using the evidence grading scale.
89
+ 4. **Pause and reason**.
90
+ 5. Start building your synthesis outline.
91
+
92
+ ### Phase 3 — Deep Dives (Specific)
93
+ 1. Search for specific unanswered questions from Phase 2.
94
+ 2. **Actively look for disconfirming evidence**.
95
+ 3. Check for recent developments.
96
+ 4. Read code, specifications, or academic sources if relevant.
97
+ 5. **Pause and reason**.
98
+
99
+ ### Phase 4 — Synthesis (Deep Thinking)
100
+ 1. **Organise your findings** into a coherent structure.
101
+ 2. **Cross-reference claims**.
102
+ 3. **Identify your own reasoning gaps**.
103
+ 4. **Apply reasoning techniques**: Chain of Thought, Tree of Thought, Analysis of Competing Hypotheses, Self-Reflection.
104
+ 5. **Perform a sensitivity analysis**.
105
+ 6. **Write the output** with proper sourcing and confidence levels.
106
+
107
+ ### Phase 5 — Validate and Refine
108
+ 1. Re-read the original research objective. Does the output answer it fully?
109
+ 2. Check for logical consistency.
110
+ 3. Check for completeness.
111
+ 4. Check for accuracy — are specific claims sourced?
112
+ 5. **Run a bias audit**.
113
+
114
+ ## Deep Thinking Reasoning Toolkit
115
+
116
+ - **Chain of Thought (CoT)**: Break complex reasoning into explicit steps.
117
+ - **Recursive Thought Expansion (RTE)**: When a step is ambiguous, expand it into its own sub-chain.
118
+ - **Tree of Thought (ToT)**: Explore multiple reasoning paths, evaluate, prune.
119
+ - **Graph of Thought (GoT)**: When reasoning is non-linear — ideas from different branches inform each other.
120
+ - **Analysis of Competing Hypotheses (ACH)**: Evaluate evidence against multiple hypotheses systematically.
121
+ - **Self-Consistency**: Generate the same conclusion via 3+ independent reasoning paths.
122
+ - **Self-Reflection Loop**: Critique → Identify assumptions → Challenge → Refine.
123
+ - **Adversarial Thinking (Red Team)**: Deliberately argue against your own conclusions.
124
+
125
+ ## Cognitive Bias Watchlist
126
+
127
+ | Bias | How to Counter It |
128
+ |------|-------------------|
129
+ | **Confirmation bias** | Actively search for disconfirming evidence |
130
+ | **Anchoring** | List questions before reading first source |
131
+ | **Availability heuristic** | Use data and counts, not memorable anecdotes |
132
+ | **Authority bias** | Even authoritative sources can be wrong — cross-validate |
133
+ | **Satisficing** | Check: have I answered all original questions? |
134
+ | **Groupthink** | Trace claims to origin — 5 blogs quoting 1 paper = 1 source |
135
+
136
+ ## Anti-Patterns to Avoid
137
+
138
+ | Anti-Pattern | Instead |
139
+ |-------------|---------|
140
+ | **Search-and-paste** | Pause and think after every search round |
141
+ | **First-result bias** | Cross-reference with 2+ sources |
142
+ | **Depth without breadth** | Always do Phase 1 before Phase 3 |
143
+ | **Premature synthesis** | Complete at least 3 search rounds first |
144
+ | **Citation-free claims** | If you can't cite it, flag it as uncertain |
145
+
146
+ ## Stopping Rules
147
+
148
+ Stop researching when:
149
+ - You've completed your planned search rounds (3–5).
150
+ - New searches are returning information you've already seen (saturation).
151
+ - You can confidently answer all your original questions.
152
+
153
+ ## References
154
+
155
+ - `docs/agi/skills/session-discipline/SKILL.md` — for session tracking
156
+ - `docs/agi/skills/instruction-adherence/SKILL.md` — for staying on objective
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: endurance
3
+ description: Strategies for long-running, complex, multi-stage autonomous agent execution. Enables token optimization, context preservation, and state stability over extremely long sessions.
4
+ ---
5
+
6
+ # Endurance
7
+
8
+ ## Scope
9
+
10
+ This Skill provides the architectural pattern for executing **Very Long-Running Agent Processes**. When an agent must solve a massive, multi-hour task (like a huge refactoring, generating an entire codebase, or doing comprehensive research), the standard context window will eventually fill up, leading to "context rot," hallucinations, and massive token costs.
11
+
12
+ The **ENDURANCE** pattern solves this through Context Engineering, Dynamic State Management, and Auto-Prompting Workflows.
13
+
14
+ ## Core Principles
15
+
16
+ 1. **Context Quality > Context Quantity**: Even with 1M+ token windows, do not bloat the context. The "Lost in the Middle" phenomenon means models perform worst when critical data is buried. Keep the active context lean and relevant.
17
+ 2. **State Externalization**: The agent's memory must not live solely in the chat history. It must live in external artifacts.
18
+ 3. **The Endurance Loop (Auto-Prompting)**: Instead of one massive conversational thread, break the workflow into a chain of distinct contexts, linked by auto-generated prompts.
19
+
20
+ ## Implementation Methodology
21
+
22
+ ### 1. Externalized Memory & Working Notes
23
+ - Maintain a `WORKING_NOTES.md` or `STATE.json` document.
24
+ - **Compaction**: Before the context window grows too large (e.g., > 30-50 interactions), summarize the conversation history, write the key decisions and unresolved issues to the notes file, and **restart the context**.
25
+ - **Just-In-Time Retrieval (Progressive Disclosure)**: Do not inject all codebase files into the system prompt. Use tools to fetch summaries, and drill down into specific files only when actively needed for the current step.
26
+
27
+ ### 2. Dynamic Skill & Tool Loading
28
+ - **Avoid Prompt Inflation**: Only load the specific instructions (Skills) needed for the *current* sub-task. If you are doing UI design, load the CSS skill. If you are doing database migrations, load the DB skill. Do not load both at the same time.
29
+
30
+ ### 3. The Auto-Prompting Autonomous Workflow
31
+ To maintain absolute stability and intelligence across a very long run, use this optimized loop:
32
+
33
+ 1. **Assess State:** Read the `WORKING_NOTES.md` and the master `task.md`.
34
+ 2. **Execute Step:** Perform the current sub-task using necessary tools.
35
+ 3. **Evaluator-Optimizer:** Self-evaluate the output. If it fails criteria, revise it immediately.
36
+ 4. **Generate Prompt Suggestions:** based on the completion of the current step, explicitly think about the 3 best possible *next* steps to advance the master task.
37
+ 5. **Auto-Select & Chain:** Select the single best prompt suggestion.
38
+ 6. **Task Handoff (The Choke Point):** Write the selected prompt to a `NEXT_TASK.md` file or directly into the task queue, update the working notes, and optionally wipe the conversational context to start fresh on the new task, using the auto-selected prompt as the new system directive.
39
+
40
+ ### 4. Mitigating "Lost in the Middle"
41
+ - When injecting necessary context (like a large file or research summary), place the most critical instructions and the specific task query at the **very beginning** and **very end** of the prompt.
42
+
43
+ ## Anti-Patterns to Avoid
44
+
45
+ - **The Endless Thread**: Keeping a single conversation open for hundreds of tool calls. This leads to massive token costs (since every turn resends the entire history) and severe instruction drift.
46
+ - **Context Hoarding**: Passing entire directory trees or irrelevant files into the context "just in case."
47
+ - **Monolithic Prompts**: Trying to give the agent a single 50-step prompt. Break it down using the Endurance Loop.
48
+
49
+ ## Validation
50
+
51
+ - Is the token usage stable across the different phases of the task?
52
+ - Are decisions persisting correctly from Step 1 to Step 50? (If yes, your `WORKING_NOTES` are functioning properly).
53
+ - Is the agent auto-suggesting its next prompt rather than waiting idly for the user?
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: exploring-other-codebases
3
+ description: Standard Operating Procedure for exploring unfamiliar, external, or third-party codebases. Use this skill when asked to review, audit, or integrate with a repository outside of your immediate context or training.
4
+ ---
5
+
6
+ # Exploring Other Codebases
7
+
8
+ ## Scope
9
+
10
+ This Skill provides a structured, high-speed methodology for exploring and mapping a completely unfamiliar external codebase without becoming overwhelmed by massive file counts or undocumented structures.
11
+
12
+ ## Triggers
13
+
14
+ - "Explore this new repository"
15
+ - "How does [External Library] work internally?"
16
+ - "Let's look at the source code for [Dependency]"
17
+ - Integrating a completely new third-party sub-module
18
+
19
+ ## Core Architecture Mapping
20
+
21
+ When dealing with a new codebase, you cannot rely on knowing the directory conventions beforehand. You must discover them systematically.
22
+
23
+ ## Methodology
24
+
25
+ ### 1. Identify the Foundation (Entry Points)
26
+ Before reading *any* logic code, you must locate and read the foundational setup files.
27
+ - **Package Managers/Dependencies:** Search for `package.json`, `pom.xml`, `requirements.txt`, `Cargo.toml`, or `go.mod`. Use `view_file` on these to understand instantly what libraries the project relies on and what scripts it exposes (e.g., `npm run build`).
28
+ - **Entry Points:** Look for `index.js`, `main.go`, `app.py`, or similar root-level execution files.
29
+
30
+ ### 2. Map the High-Level Structure
31
+ Do not manually walk every directory.
32
+ - Use `list_dir` on the project root *once* to get the top-level folders.
33
+ - Identify the most likely source code folder (typically `src/`, `lib/`, `app/`, or named after the project).
34
+
35
+ ### 3. Structural File Reading (Progressive Disclosure)
36
+ When opening files in an unknown codebase, they may be overwhelmingly large or complex.
37
+ - **MANDATORY**: Use `view_file_outline` to read the signature/structure of *any* file before using `view_file` to read its full contents. This allows you to map classes and exported functions instantly without flooding your context window with thousands of lines of implementation details.
38
+ - If a file is over 1000 lines, use `grep_search` targeted *within* that file to find the specific function you need, rather than reading the whole file.
39
+
40
+ ### 4. Follow the Data (Trace Execution)
41
+ If you need to understand a specific feature:
42
+ 1. Find the entry point or API route (e.g., `grep_search` for the route name).
43
+ 2. Trace the function calls.
44
+ 3. Use `grep_search` to find where imported modules are defined if their location isn't obvious.
45
+
46
+ ## Anti-Patterns to Avoid
47
+
48
+ - **The Breadth-First Blind Spot**: Using `list_dir` on every single sub-directory (like `node_modules` or `vendor`) before looking at `package.json` or `README.md`.
49
+ - **Context Flooding**: Using `view_file` on 5 different core files simultaneously in an unknown codebase, completely destroying your context window limits, instead of using `view_file_outline`.
50
+ - **Assuming Conventions**: Assuming an external Node.js app uses Express just because another project does. Always check the dependency file first.
51
+
52
+ ## Validation
53
+
54
+ - Did you check `package.json` (or equivalent) before exploring the source directories?
55
+ - Did you use `view_file_outline` to map large files instead of reading them blindly?
56
+ - Can you summarize the high-level architecture (entry point, key directories, main framework) to the user?
@@ -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`