@moon791017/neo-skills 1.1.21 → 1.1.23

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.
@@ -0,0 +1,266 @@
1
+ # /// script
2
+ # dependencies = []
3
+ # ///
4
+
5
+ """
6
+ generate-agents-md.py - Automated non-interactive AGENTS.md generator for neo-harness.
7
+
8
+ Analyzes a target repository, detects build/test/lint toolchains, and generates
9
+ a strict AGENTS.md file that enforces AI agent harness laws and sensor gates.
10
+ Enforces a hard limit of 32 KiB (32,768 bytes) on the generated AGENTS.md.
11
+ """
12
+
13
+ import argparse
14
+ import json
15
+ import os
16
+ import sys
17
+ from pathlib import Path
18
+
19
+ MAX_BYTES = 32768 # 32 KiB limit
20
+
21
+
22
+ def log_diag(msg: str) -> None:
23
+ """Print diagnostic messages to stderr."""
24
+ print(f"[generate-agents-md] {msg}", file=sys.stderr)
25
+
26
+
27
+ def detect_project_facts(target_dir: Path) -> dict:
28
+ """Scan the target repository and extract toolchains and project facts."""
29
+ facts = {
30
+ "project_name": target_dir.name,
31
+ "tech_stack": "General",
32
+ "test_command": "echo 'No test command configured'",
33
+ "lint_command": "echo 'No lint command configured'",
34
+ "typecheck_command": "echo 'No typecheck command configured'",
35
+ "build_command": "echo 'No build command configured'",
36
+ }
37
+
38
+ # 1. Node.js / TypeScript
39
+ pkg_json_path = target_dir / "package.json"
40
+ if pkg_json_path.exists():
41
+ try:
42
+ with open(pkg_json_path, "r", encoding="utf-8") as f:
43
+ data = json.load(f)
44
+ facts["project_name"] = data.get("name", target_dir.name)
45
+ scripts = data.get("scripts", {})
46
+ facts["tech_stack"] = "Node.js / JavaScript"
47
+ if (target_dir / "tsconfig.json").exists():
48
+ facts["tech_stack"] = "Node.js / TypeScript"
49
+ facts["typecheck_command"] = "npx tsc --noEmit"
50
+
51
+ if "test" in scripts:
52
+ facts["test_command"] = "npm test"
53
+ if "lint" in scripts:
54
+ facts["lint_command"] = "npm run lint"
55
+ if "build" in scripts:
56
+ facts["build_command"] = "npm run build"
57
+ if "typecheck" in scripts:
58
+ facts["typecheck_command"] = "npm run typecheck"
59
+ except Exception as e:
60
+ log_diag(f"Warning: Failed to parse package.json: {e}")
61
+
62
+ # 2. Python
63
+ pyproject_path = target_dir / "pyproject.toml"
64
+ setup_py_path = target_dir / "setup.py"
65
+ if pyproject_path.exists() or setup_py_path.exists() or list(target_dir.glob("*.py")):
66
+ facts["tech_stack"] = "Python"
67
+ test_cmds = []
68
+ if (target_dir / "tests").exists() or (target_dir / "test").exists():
69
+ test_cmds.append("pytest")
70
+ facts["test_command"] = " && ".join(test_cmds) if test_cmds else "pytest"
71
+ facts["lint_command"] = "ruff check ."
72
+ facts["typecheck_command"] = "mypy ."
73
+ facts["build_command"] = "python3 -m build"
74
+
75
+ # 3. Rust
76
+ cargo_path = target_dir / "Cargo.toml"
77
+ if cargo_path.exists():
78
+ facts["tech_stack"] = "Rust"
79
+ facts["test_command"] = "cargo test"
80
+ facts["lint_command"] = "cargo clippy -- -D warnings"
81
+ facts["typecheck_command"] = "cargo check"
82
+ facts["build_command"] = "cargo build"
83
+
84
+ # 4. Go
85
+ go_mod_path = target_dir / "go.mod"
86
+ if go_mod_path.exists():
87
+ facts["tech_stack"] = "Go"
88
+ facts["test_command"] = "go test ./..."
89
+ facts["lint_command"] = "golangci-lint run"
90
+ facts["typecheck_command"] = "go vet ./..."
91
+ facts["build_command"] = "go build ./..."
92
+
93
+ # 5. .NET / C#
94
+ if list(target_dir.glob("*.csproj")) or list(target_dir.glob("*.sln")):
95
+ facts["tech_stack"] = ".NET / C#"
96
+ facts["test_command"] = "dotnet test"
97
+ facts["lint_command"] = "dotnet format --verify-no-changes"
98
+ facts["typecheck_command"] = "dotnet build --no-incremental"
99
+ facts["build_command"] = "dotnet build"
100
+
101
+ # 6. Neo Skills Syntax Check
102
+ syntax_script = target_dir / "scripts" / "check-skills-syntax.py"
103
+ if syntax_script.exists():
104
+ facts["syntax_command"] = "python3 scripts/check-skills-syntax.py"
105
+
106
+ return facts
107
+
108
+
109
+ def generate_agents_md_content(facts: dict) -> str:
110
+ """Generate the AGENTS.md Markdown content based on project facts."""
111
+ rows = []
112
+ if facts.get("test_command") and not facts["test_command"].startswith("echo 'No"):
113
+ rows.append(f"| **Unit / Integration Tests** | `{facts['test_command']}` | Verify behavioral correctness |")
114
+ if facts.get("syntax_command") and not facts["syntax_command"].startswith("echo 'No"):
115
+ rows.append(f"| **Skill Syntax Check** | `{facts['syntax_command']}` | Verify skill markdown and frontmatter syntax |")
116
+ if facts.get("typecheck_command") and not facts["typecheck_command"].startswith("echo 'No"):
117
+ rows.append(f"| **Type Check** | `{facts['typecheck_command']}` | Verify static type contracts |")
118
+ if facts.get("lint_command") and not facts["lint_command"].startswith("echo 'No"):
119
+ rows.append(f"| **Lint & Format** | `{facts['lint_command']}` | Enforce code style and syntax rules |")
120
+ if facts.get("build_command") and not facts["build_command"].startswith("echo 'No"):
121
+ rows.append(f"| **Build Check** | `{facts['build_command']}` | Confirm clean compilation |")
122
+
123
+ table_header = "| Command Type | Exact Command Line | Purpose / Scope |\n| :--- | :--- | :--- |"
124
+ table_body = "\n".join(rows) if rows else "| **None** | `echo 'No commands configured'` | N/A |"
125
+ commands_table = f"{table_header}\n{table_body}"
126
+
127
+ content = f"""# {facts['project_name']} AGENTS.md
128
+
129
+ ---
130
+
131
+ ## 1. Project Overview
132
+
133
+ - **Primary Technology Stack**: `{facts['tech_stack']}`
134
+ - **Coding & Architectural Conventions**:
135
+ - Follow modular architecture and existing code formatting.
136
+ - Inspect existing implementation files before creating new utilities.
137
+ - Do NOT introduce unrequested third-party dependencies.
138
+
139
+ ---
140
+
141
+ ## 2. Commands
142
+
143
+ List exact command lines used for project development, testing, linting, typechecking, and building:
144
+
145
+ {commands_table}
146
+
147
+ ---
148
+
149
+ ## 3. Workflow
150
+
151
+ The development workflow strictly follows this 9-stage closed loop:
152
+
153
+ ```mermaid
154
+ graph TD
155
+ Step1[1. Perceive Task] --> Step2[2. Establish Baseline]
156
+ Step2 --> Step3[3. Reproduce Problem]
157
+ Step3 --> Step4[4. Plan Edits]
158
+ Step4 --> Step5[5. Minimal Implementation]
159
+ Step5 --> Step6[6. Incremental Verification]
160
+ Step6 --> Step7[7. Self-Review]
161
+ Step7 -->|Fail| Step4
162
+ Step7 -->|Pass| Step9[9. Handoff upon Pass]
163
+ ```
164
+
165
+ 1. **Perceive Task**: Read project guidelines (`AGENTS.md`) and target source files to understand goals and constraints.
166
+ 2. **Establish Baseline**: Run existing test and build commands to confirm the project is in a stable, passing state.
167
+ 3. **Reproduce Problem**: Write or run test cases/verification steps that reliably reproduce the issue or requirement.
168
+ 4. **Plan Edits**: Decompose the task into small, atomic edit plans to avoid large single-turn changes.
169
+ 5. **Minimal Implementation**: Apply minimal code changes while preserving existing comments and public API contracts.
170
+ 6. **Incremental Verification**: Run local test, lint, and build commands immediately after each edit.
171
+ 7. **Self-Review**: Inspect diffs and execution logs; if checks fail, read full un-truncated error logs to find the root cause.
172
+ 8. **Remediate on Failure**: If verification or self-review fails, return to "Plan Edits / Minimal Implementation" to adjust.
173
+ 9. **Handoff upon Pass**: Once all verification sensors pass, present a concise report with empirical proof for handoff.
174
+
175
+ ---
176
+
177
+ ## 4. Forbidden Antipattern Redlines
178
+
179
+ | Forbidden Action | Why It Is Prohibited | Required Behavior |
180
+ | :--- | :--- | :--- |
181
+ | **Silent Exception Swallowing** | Hides runtime failures and causes silent data corruption. | Let exceptions surface or handle explicitly with logging. |
182
+ | **Test Deletion / Suppression** | Forces builds to pass without fixing underlying bugs. | Fix root cause in source or update contract with justification. |
183
+ | **Hallucinated Signatures** | Invokes non-existent methods causing runtime crashes. | View symbol definition using search tools first. |
184
+ | **Unverified Completion Claim** | Misleads user regarding feature or bug state. | Run test/build commands and present log proof. |
185
+ """
186
+ return content
187
+
188
+
189
+ def enforce_size_limit(content: str) -> str:
190
+ """Ensure the content size does not exceed 32 KiB (32,768 bytes)."""
191
+ encoded = content.encode("utf-8")
192
+ if len(encoded) <= MAX_BYTES:
193
+ return content
194
+
195
+ log_diag(f"Warning: Content size ({len(encoded)} bytes) exceeds 32 KiB limit. Pruning...")
196
+ # Truncate lines from bottom if necessary, preserving structure
197
+ lines = content.splitlines()
198
+ while lines and len("\n".join(lines).encode("utf-8")) > MAX_BYTES:
199
+ lines.pop()
200
+
201
+ pruned_content = "\n".join(lines) + "\n\n<!-- Truncated to fit within 32 KiB limit -->\n"
202
+ return pruned_content
203
+
204
+
205
+ def main():
206
+ parser = argparse.ArgumentParser(
207
+ description="Non-interactive AGENTS.md generator for neo-harness."
208
+ )
209
+ parser.add_argument(
210
+ "--target-dir",
211
+ type=str,
212
+ default=".",
213
+ help="Path to target project directory (default: current directory)",
214
+ )
215
+ parser.add_argument(
216
+ "--output",
217
+ type=str,
218
+ default="",
219
+ help="Output path for AGENTS.md (default: <target-dir>/AGENTS.md)",
220
+ )
221
+ parser.add_argument(
222
+ "--dry-run",
223
+ action="store_true",
224
+ help="Output content to stdout without writing file",
225
+ )
226
+ parser.add_argument(
227
+ "--force",
228
+ action="store_true",
229
+ help="Overwrite output file if it already exists",
230
+ )
231
+
232
+ args = parser.parse_args()
233
+
234
+ target_dir = Path(args.target_dir).resolve()
235
+ if not target_dir.exists() or not target_dir.is_dir():
236
+ log_diag(f"Error: Target directory '{target_dir}' does not exist or is not a directory.")
237
+ sys.exit(1)
238
+
239
+ output_path = Path(args.output) if args.output else target_dir / "AGENTS.md"
240
+
241
+ log_diag(f"Scanning target directory: {target_dir}")
242
+ facts = detect_project_facts(target_dir)
243
+ log_diag(f"Detected project name: {facts['project_name']}, tech stack: {facts['tech_stack']}")
244
+
245
+ content = generate_agents_md_content(facts)
246
+ content = enforce_size_limit(content)
247
+
248
+ byte_size = len(content.encode("utf-8"))
249
+ log_diag(f"Generated AGENTS.md size: {byte_size} bytes ({byte_size/1024:.2f} KiB)")
250
+
251
+ if args.dry_run:
252
+ sys.stdout.write(content)
253
+ return
254
+
255
+ if output_path.exists() and not args.force:
256
+ log_diag(f"Warning: Output file '{output_path}' exists. Use --force to overwrite.")
257
+ sys.exit(1)
258
+
259
+ with open(output_path, "w", encoding="utf-8") as f:
260
+ f.write(content)
261
+
262
+ log_diag(f"Successfully generated '{output_path}' ({byte_size} bytes).")
263
+
264
+
265
+ if __name__ == "__main__":
266
+ main()
@@ -1,127 +0,0 @@
1
- ---
2
- name: neo-agent-harness
3
- description: >
4
- Use this skill when the user asks to improve AI-assisted development reliability,
5
- AGENTS.md, skills, tests, CI, hooks, review loops, agent workflow governance,
6
- loop engineering, agent automations, worktree isolation, maker/checker separation,
7
- or external state design for long-running agents.
8
- It designs feedforward guides, feedback sensors, verification gates, human
9
- decision points, and loop architectures from repository evidence.
10
- ---
11
-
12
- # Agent Harness Architect Skill
13
-
14
- ## Trigger On
15
- - The user asks to design or improve an AI agent development workflow.
16
- - The user wants coding agents to be more reliable, safer, or easier to supervise.
17
- - The user asks for AGENTS.md, skills, tests, CI, hooks, review loops, or project rules to be planned together.
18
- - The task is about harness engineering, agent harnessability, feedback loops, or "humans on the loop".
19
- - The user wants to design scheduled automations, cron-driven agent loops, or recurring agent tasks.
20
- - The user wants multiple agents to work in parallel and needs an isolation strategy (worktree isolation).
21
- - The user wants to design maker/checker separation (generation and verification by different agents).
22
- - The user wants to design external memory or cross-conversation state persistence for agents.
23
- - The user asks how to evolve from a harness to loop-driven development.
24
-
25
- ## Core Principle
26
- Treat agent-assisted development as a controlled engineering system. Do not only improve prompts; design the guides, sensors, verification steps, and human decision points that let agents work with higher confidence.
27
-
28
- When the task involves automations, parallel agents, or continuous loops, extend the design to cover loop architecture: the scheduling, isolation, separation, integration, and state layers that let the harness run itself.
29
-
30
- Use this skill for planning first. Do not modify files unless the user explicitly asks for implementation after the harness plan is clear.
31
-
32
- ## Perceive
33
- 1. Inspect the repository before asking questions:
34
- - Project instructions: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`.
35
- - Skill or prompt assets: `skills/`, `.codex/skills/`, `.claude/skills/`, `.github/skills/`.
36
- - Validation commands: `package.json`, `pyproject.toml`, `Makefile`, CI workflow files, build scripts.
37
- - Safety and governance: hooks, linters, formatters, secret scanners, dependency scanners.
38
- - Existing documentation: README, architecture docs, ADRs, testing docs, contribution docs.
39
- - Agent definitions: `.codex/agents/`, `.claude/agents/`, subagent configs, agent team definitions.
40
- - Automation and scheduling: cron configs, GitHub Actions workflows, hooks, `/loop` or `/goal` usage.
41
- - State files: progress markdown, task boards, Linear integrations, cross-conversation state.
42
- 2. Identify the project type, primary languages, current test surface, CI status, and release/deploy path.
43
- 3. Separate discoverable repository facts from product or team preferences that require user confirmation.
44
-
45
- ## Reason
46
- Analyze the project through these dimensions:
47
-
48
- 1. **Feedforward guides**
49
- - What should the agent know before editing?
50
- - Examples: project rules, coding style, architecture boundaries, task decomposition, testing strategy, domain vocabulary, safe file ownership.
51
- 2. **Feedback sensors**
52
- - What can check the agent's work after each change?
53
- - Examples: typecheck, tests, lint, build, static analysis, security checks, architecture tests, review agents, smoke tests.
54
- 3. **Control type**
55
- - Prefer computational controls for fast deterministic checks.
56
- - Use inferential controls for semantic review, architecture judgment, test-quality review, and risk assessment.
57
- 4. **Regulation category**
58
- - Maintainability: readability, duplication, complexity, style, testability.
59
- - Architecture fitness: module boundaries, performance, observability, security, deployability.
60
- - Behaviour: requirements, acceptance criteria, user journeys, fixtures, manual test points.
61
- 5. **Human role**
62
- - Move human effort from repeated low-level correction to high-value decisions: scope, product fit, risk acceptance, architectural tradeoffs, and harness evolution.
63
- 6. **Loop design** (conditional: activate only when the task involves scheduled automations, parallel agents, or continuous loops)
64
- - **Automations**: which tasks suit scheduled triggers? Frequency, trigger conditions, result routing (triage inbox vs auto-process).
65
- - **Worktrees**: how to isolate parallel agents? Independent branches and working directories needed?
66
- - **Maker/checker separation**: which steps need generation and verification by different agents? (For sub-agent definition and implementation, use the neo-sub-agent skill.)
67
- - **Connectors**: which external tools does the loop need to reach? (issue tracker, CI, Slack, staging API, database)
68
- - **State**: how to persist cross-conversation progress? Format (markdown / board / Linear)? Who updates it?
69
- - **Loop risks**: assess comprehension debt, cognitive surrender, and unattended verification risk levels.
70
-
71
- For detailed patterns and examples, read [reference/harness-patterns.md](reference/harness-patterns.md) when the task needs a full harness design, maturity model, or improvement roadmap. For the complete source article synthesis behind this skill, read [reference/agent-harness-engineering.md](reference/agent-harness-engineering.md) only when deeper conceptual background is needed. For loop engineering patterns, the five loop primitives, risk model, and maturity guidance, read [reference/loop-engineering.md](reference/loop-engineering.md) when the task involves automations, parallel agents, maker/checker separation, or loop-driven development.
72
-
73
- ## Act
74
- Output in Traditional Chinese (Taiwan). Use this structure:
75
-
76
- ### 1. 現況盤點
77
- - Summarize the repository facts discovered.
78
- - Mention the current guides, sensors, and missing signals.
79
- - If loop-relevant infrastructure exists (automations, agent definitions, state files), include it here.
80
-
81
- ### 2. Harnessability 評估
82
- - Rate the current harnessability as `低`, `中`, or `高`.
83
- - Explain the rating with concrete evidence from the repository.
84
-
85
- ### 3. Feedforward Guides 設計
86
- - List the rules, docs, skills, templates, or examples agents should receive before work starts.
87
- - Mark each item as existing, needs update, or missing.
88
-
89
- ### 4. Feedback Sensors 設計
90
- - List fast local checks, CI checks, security checks, semantic reviews, and manual checks.
91
- - Distinguish computational from inferential checks.
92
-
93
- ### 5. 開發前改善清單
94
- - Prioritize improvements as P0, P1, and P2.
95
- - P0 must focus on changes that reduce repeated agent mistakes or prevent high-risk failures.
96
-
97
- ### 5.5 Loop 設計(條件式:僅當任務涉及 loop 時輸出)
98
- - List tasks suited for scheduled automation, with suggested frequency.
99
- - Describe the isolation strategy for parallel agents (worktree / branch / container).
100
- - Identify which steps need maker/checker separation and their verification criteria.
101
- - List required connectors and external integrations.
102
- - Design the state persistence scheme and update responsibilities.
103
- - Assess loop risks: comprehension debt, cognitive surrender, unattended verification, and propose safeguards.
104
-
105
- ### 6. 人類決策點
106
- - State where humans should stay on the loop.
107
- - Identify decisions that should not be delegated fully to agents.
108
- - When loop design is involved, assess these three specific risks:
109
- - **Verification responsibility**: error accumulation when the loop runs unattended.
110
- - **Comprehension debt**: the faster the loop produces code, the wider the understanding gap.
111
- - **Cognitive surrender**: tendency to stop having opinions when the loop runs itself.
112
- - Clearly mark which loop stages still require human intervention (scope decisions, risk acceptance, architectural tradeoffs).
113
-
114
- ### 7. 驗證方式
115
- - Provide exact commands or review steps when discoverable.
116
- - If a command is unknown, state the missing fact instead of inventing one.
117
-
118
- ## Constraints
119
- - Do not treat AI-generated tests as sufficient proof of behaviour correctness.
120
- - Do not replace deterministic tooling with LLM judgment when a fast tool can check the same thing.
121
- - Do not recommend broad automation before the project has reliable local validation commands.
122
- - Do not propose fully autonomous changes for security, compliance, production deploys, or product-scope decisions.
123
- - Keep the output actionable and tied to repository evidence.
124
- - Do not recommend loop-driven automations for projects that lack reliable local validation commands and stable CI.
125
- - When designing loops, explicitly assess comprehension debt, cognitive surrender, and unattended verification risks.
126
- - For sub-agent design and implementation details, defer to the neo-sub-agent skill to avoid responsibility overlap.
127
- - Mark loop engineering concepts as emerging practice, not established best practice.