This commit is contained in:
eddiesoehnel committed 2026-07-23 14:13:45 -06:00
1 parent 92ef20cee0
commit 7af769f85e
46 files changed
+4417 -2

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
# Skills
| Skill | Purpose |
| --- | --- |
| `structure-ai-ready-repository/` | Assess, plan, create, correct, and validate an AI-ready repository structure. |
Read `skills.md` for trigger conditions, inputs, outputs, approval requirements, and related scripts.
@@ -0,0 +1,119 @@
---
name: structure-ai-ready-repository
description: Assess, plan, create, or correct a new or existing repository so humans and AI agents can discover, understand, validate, and reuse it. Use when a user asks to start a repository with an AI-ready structure, audit or reorganize an existing repository, add machine-readable repository metadata, improve agent entry points, standardize repository documentation, or apply the general AI-ready repository template. By default, create a repository-local task plan for review and require explicit approval before implementing structural changes; bypass the plan only when the user explicitly authorizes immediate implementation.
---
# Structure an AI-Ready Repository
Create the smallest repository structure that makes the project clear to humans and AI agents. Preserve useful existing conventions and content.
## Load the standard
Read [references/repository-structure-standard.md](references/repository-structure-standard.md) before proposing a structure. Treat it as a menu and decision standard, not a command to create every listed file.
Use [assets/repository-structure-plan-template.md](assets/repository-structure-plan-template.md) for the required review artifact.
Use `scripts/audit_repository.py` for a read-only baseline and final structural check. Do not treat the script as a substitute for inspecting repository purpose, existing instructions, or project-native tests.
## Phase 1: Inspect
1. Resolve the target repository and determine whether it is new or existing.
2. Begin with a short identity and publication round. Ask only for values the user has not already supplied:
- author or authors;
- publisher and maintainer;
- canonical repository URL;
- intended license.
3. If `AUTHOR.md` exists, read it first, present its values for confirmation, and ask only about missing or conflicting facts. Do not silently inherit identity from a template or source repository.
4. For an existing repository, inspect its files, Git status, documentation, manifests, tests, host configuration, and any `AGENTS.md` or equivalent instructions. Preserve unrelated user changes.
5. Infer the most suitable profile: documentation/guide, skill/workflow, software/automation, dataset, or a justified custom minimum.
6. Separate facts found in the repository from assumptions and recommendations.
7. Run the read-only audit when Python is available. Record failures as planning inputs, not as permission to change files.
## Phase 2: Write the review plan
Create exactly one active plan at:
```text
tasks/<task-id>/repository-structure-plan.md
```
Use lowercase kebab-case for `<task-id>`, normally `structure-ai-ready-repository`.
For a new repository, creating the target directory and this task-plan path is the only pre-approval repository write allowed. For an existing repository, do not modify anything outside the task folder before approval.
The plan must include:
- target and current state;
- selected repository profile and rationale;
- proposed tree;
- a file action table using `create`, `preserve`, `modify`, `move`, `deprecate`, or `leave absent`;
- purpose and planned content for every created or modified file;
- existing-content preservation and migration notes;
- host-specific choices;
- validation commands and definition of done;
- risks, assumptions, open questions, and out-of-scope work;
- approval status and plan revision.
Use `move` or `deprecate` only when necessary. Never propose deletion as an implied cleanup step.
Present the plan to the user and stop. Ask the user to approve it or request amendments. Do not implement in the same turn that first creates the plan.
## Phase 3: Amend or approve
When the user requests changes:
1. Update the same plan.
2. Increment the plan revision.
3. Set status to `awaiting approval`.
4. Summarize the amendments and stop for review again.
Proceed only after the user explicitly approves the current revision. Approval must clearly refer to the plan or proposed structure. Questions, partial agreement, silence, or approval of an older revision do not authorize implementation.
If implementation requires a material departure from the approved plan, update the plan, explain the change, and return to `awaiting approval`.
## Phase 4: Implement the approved plan
1. Reinspect Git status and relevant files to detect changes since planning.
2. Mark the current revision `approved` with the approval evidence.
3. Apply only approved actions.
4. Merge with useful existing content. Do not overwrite complete documentation, manifests, licenses, CI, host configuration, or agent instructions merely to match a template.
5. Create only relevant folders and files. Avoid empty ceremonial structure.
6. Keep human and AI entry points explicit:
- explain purpose, audience, inputs, outputs, setup, usage, validation, version, and license in `README.md`;
- identify authoritative files and retrieval order in `repository.json`;
- provide scoped agent instructions in the repository's established agent-instruction file;
- index skills, scripts, templates, schemas, data, and examples when they exist.
- create or update `UPDATES.md` for future notes and proposals, while keeping completed versioned changes in `CHANGELOG.md`.
- create `AUTHOR.md` as the canonical human-readable attribution file and keep it aligned with `repository.json`, `CITATION.cff`, and `LICENSE`.
7. Use placeholders only when the user has not supplied a value and the placeholder is visibly marked. Never invent URLs, maintainers, licenses, security contacts, provenance, or credentials.
8. Do not create commits, branches, remotes, releases, or hosting-platform settings unless the user separately requested them.
## Phase 5: Validate and record
1. Run `scripts/audit_repository.py` with the approved profile.
2. Parse machine-readable files and check version alignment, internal paths, and declared entry points.
3. Run relevant repository-native tests, linters, schema checks, and link checks that can safely run.
4. Search created examples and receipts for secrets, personal data, and organization-specific residue.
5. Confirm that `UPDATES.md` contains future planning notes only and is not presented as approval or completed work.
6. Create:
```text
tasks/<task-id>/implementation-receipt.md
tasks/<task-id>/validation-results.md
```
Record the approved revision, actual actions, deviations, commands, results, unresolved issues, and rollback guidance. Set the plan status to `implemented` only when approved work is complete.
## Final report
Report:
- the verified author, publisher, maintainer, canonical URL, and license;
- the selected profile and resulting entry points;
- created, modified, preserved, moved, and intentionally omitted files;
- validation results and anything not tested;
- deviations from the approved plan;
- remaining human decisions;
- task-plan and receipt locations.
Do not describe the repository as compliant merely because expected filenames exist. Content, links, metadata, and instructions must agree with the actual project.
@@ -0,0 +1,4 @@
interface:
display_name: "Structure AI-Ready Repository"
short_description: "Plan and build AI-findable repositories"
default_prompt: "Use $structure-ai-ready-repository to confirm repository identity and publication details, then assess and propose an AI-ready structure for review."
@@ -0,0 +1,104 @@
# Repository Structure Plan
## Plan Control
- Task ID: `[lowercase-kebab-case]`
- Target repository: `[absolute path]`
- Repository mode: `[new | existing]`
- Profile: `[documentation-guide | skill-workflow | software-automation | dataset | custom]`
- Revision: `1`
- Status: `awaiting approval`
- Created: `[YYYY-MM-DD]`
- Updated: `[YYYY-MM-DD]`
- Approval evidence: `Not approved`
## Outcome
[What the completed repository structure should make easier for humans and AI agents.]
## Identity And Publication
- Author(s): `[verified names]`
- Publisher: `[verified name]`
- Maintainer: `[verified name]`
- Canonical repository URL: `[verified URL or explicitly unset]`
- License: `[verified license or decision required]`
- Identity source: `[user response | AUTHOR.md | other verified source]`
## Current State
### Facts
- [Observed fact]
### Assumptions
- [Assumption requiring confirmation]
### Baseline Audit
- Command: `[command or not run]`
- Result: `[summary]`
## Profile Decision
[Selected profile, rationale, and why a larger or smaller profile is not appropriate.]
## Proposed Structure
```text
repository-name/
└── ...
```
## File Actions
| Path | Action | Purpose and planned content | Existing-content treatment |
|---|---|---|---|
| `README.md` | `create/modify/preserve` | [Purpose] | [Merge/preserve notes] |
Allowed actions: `create`, `preserve`, `modify`, `move`, `deprecate`, `leave absent`.
## Human and AI Entry Points
- Human starts at: `[path]`
- AI agent starts at: `[path]`
- Authoritative manifest: `[path]`
- Retrieve next: `[ordered paths]`
## Hosting Platform Choices
[Detected host conventions and any proposed issue, pull-request, CI, or metadata files.]
## Validation and Definition of Done
- [ ] Required files contain project-specific, accurate content.
- [ ] Machine-readable files parse and agree with authoritative values.
- [ ] Declared paths and internal links resolve.
- [ ] Version references align.
- [ ] Relevant project-native tests pass.
- [ ] Examples are synthetic or anonymized.
- [ ] No secrets or private data are introduced.
- [ ] Agent instructions are scoped and non-conflicting.
Commands:
```text
[planned validation commands]
```
## Risks and Preservation Notes
- [Risk, user-owned change, compatibility constraint, or migration concern]
## Out of Scope
- [Work deliberately excluded]
## Open Questions
- [Question that materially affects the plan]
## Approval
Approve this exact revision before implementation. Amendments create a new revision and return the plan to `awaiting approval`.
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,190 @@
#!/usr/bin/env python3
"""Read-only structural audit for an AI-ready repository."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import re
import sys
PROFILES = {
"documentation-guide": {
"README.md",
"AUTHOR.md",
"repository.json",
"LICENSE",
"CHANGELOG.md",
"UPDATES.md",
"VERSION",
"CITATION.cff",
"docs",
},
"skill-workflow": {
"README.md",
"AUTHOR.md",
"repository.json",
"LICENSE",
"CHANGELOG.md",
"UPDATES.md",
"VERSION",
"AGENTS.md",
"skills.md",
"skills",
"templates",
"examples",
},
"software-automation": {
"README.md",
"AUTHOR.md",
"repository.json",
"LICENSE",
"CHANGELOG.md",
"UPDATES.md",
"VERSION",
"CONTRIBUTING.md",
"SECURITY.md",
"AGENTS.md",
"docs",
"scripts",
"tests",
},
"dataset": {
"README.md",
"AUTHOR.md",
"repository.json",
"LICENSE",
"CHANGELOG.md",
"UPDATES.md",
"VERSION",
"CITATION.cff",
"data",
"schemas",
"docs",
},
}
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("repository", type=Path, help="Repository root to inspect")
parser.add_argument(
"--profile",
choices=sorted(PROFILES),
required=True,
help="Approved repository profile",
)
parser.add_argument("--json", action="store_true", help="Emit JSON")
return parser.parse_args()
def read_version_from_citation(path: Path) -> str | None:
if not path.is_file():
return None
match = re.search(
r"(?m)^version:\s*[\"']?([^\"'\s#]+)",
path.read_text(encoding="utf-8-sig"),
)
return match.group(1) if match else None
def audit(root: Path, profile: str) -> dict:
findings: list[dict[str, str]] = []
if not root.is_dir():
return {
"repository": str(root),
"profile": profile,
"passed": False,
"findings": [{"level": "error", "message": "Repository path is not a directory"}],
}
for relative in sorted(PROFILES[profile]):
if not (root / relative).exists():
findings.append({"level": "error", "message": f"Missing required path: {relative}"})
manifest_path = root / "repository.json"
manifest = None
if manifest_path.is_file():
try:
manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
findings.append({"level": "error", "message": f"repository.json is invalid: {exc}"})
else:
for key in ("schema_version", "repository_id", "title", "description", "version", "entrypoints"):
if key not in manifest:
findings.append({"level": "error", "message": f"repository.json lacks key: {key}"})
entrypoints = manifest.get("entrypoints", {})
if isinstance(entrypoints, dict):
for audience in ("human", "ai"):
declared = entrypoints.get(audience)
if not declared:
findings.append(
{"level": "error", "message": f"Missing {audience} entrypoint declaration"}
)
elif not (root / declared).exists():
findings.append(
{
"level": "error",
"message": f"Declared {audience} entrypoint does not exist: {declared}",
}
)
else:
findings.append({"level": "error", "message": "entrypoints must be an object"})
version_path = root / "VERSION"
version = version_path.read_text(encoding="utf-8-sig").strip() if version_path.is_file() else None
if version and manifest and manifest.get("version") != version:
findings.append(
{
"level": "error",
"message": f"VERSION ({version}) differs from repository.json ({manifest.get('version')})",
}
)
citation_version = read_version_from_citation(root / "CITATION.cff")
if version and citation_version and citation_version != version:
findings.append(
{
"level": "error",
"message": f"VERSION ({version}) differs from CITATION.cff ({citation_version})",
}
)
readme = root / "README.md"
if readme.is_file() and not readme.read_text(encoding="utf-8-sig").strip():
findings.append({"level": "error", "message": "README.md is empty"})
return {
"repository": str(root.resolve()),
"profile": profile,
"passed": not any(item["level"] == "error" for item in findings),
"findings": findings,
}
def emit_markdown(result: dict) -> None:
print(f"# Repository Audit\n\n- Repository: `{result['repository']}`")
print(f"- Profile: `{result['profile']}`")
print(f"- Result: `{'PASS' if result['passed'] else 'FAIL'}`")
print("\n## Findings")
if not result["findings"]:
print("\n- No structural errors found.")
else:
for finding in result["findings"]:
print(f"\n- {finding['level'].upper()}: {finding['message']}")
def main() -> int:
args = parse_args()
result = audit(args.repository, args.profile)
if args.json:
print(json.dumps(result, indent=2))
else:
emit_markdown(result)
return 0 if result["passed"] else 1
if __name__ == "__main__":
sys.exit(main())