From bd8f9a641fbde91c99870fcb312790cd88cbd2f5 Mon Sep 17 00:00:00 2001 From: eddiesoehnel Date: Fri, 24 Jul 2026 16:17:28 -0600 Subject: [PATCH] added --- AGENTS.md | 6 +- CHANGELOG.md | 18 +++ CITATION.cff | 2 +- README.md | 33 +++-- VERSION | 2 +- content-index.json | 108 ++++++++++++++ docs/architecture.md | 17 ++- docs/glossary.md | 12 ++ docs/implementation.md | 33 ++++- examples/README.md | 1 + examples/example-content-index.json | 27 ++++ repository.json | 14 +- schemas/README.md | 1 + schemas/content-index.schema.json | 133 ++++++++++++++++++ scripts/README.md | 5 +- scripts/validate_repository.py | 96 +++++++++++++ skills.md | 12 +- skills/structure-ai-ready-repository/SKILL.md | 18 ++- .../repository-structure-standard.md | 63 +++++++++ .../scripts/audit_repository.py | 78 ++++++++++ .../implementation-receipt.md | 34 +++++ .../repository-structure-plan.md | 40 ++++++ tasks/add-content-index/validation-results.md | 29 ++++ templates/README.md | 5 + templates/content-index.json.template | 24 ++++ tests/README.md | 3 +- tests/test_repository.py | 36 +++++ 27 files changed, 817 insertions(+), 33 deletions(-) create mode 100644 content-index.json create mode 100644 examples/example-content-index.json create mode 100644 schemas/content-index.schema.json create mode 100644 tasks/add-content-index/implementation-receipt.md create mode 100644 tasks/add-content-index/repository-structure-plan.md create mode 100644 tasks/add-content-index/validation-results.md create mode 100644 templates/content-index.json.template diff --git a/AGENTS.md b/AGENTS.md index e11d069..a5ac5a9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,8 +8,9 @@ Read, in order: 2. `AUTHOR.md` 3. `repository-variables.json` 4. `repository.json` -5. `skills.md` -6. The relevant skill or documentation for the task +5. `content-index.json` when retrieving an individual document +6. `skills.md` +7. The relevant skill or documentation for the task ## Repository Purpose @@ -51,6 +52,7 @@ Also validate any modified skill with the available Codex skill validator. ## File-Specific Guidance - Update `schemas/repository.schema.json` when the manifest contract changes. +- Update `schemas/content-index.schema.json` when the document-index contract changes. - Update `schemas/repository-variables.schema.json` when the reusable variables contract changes. - Update both the skill reference and root documentation when the repository standard changes. diff --git a/CHANGELOG.md b/CHANGELOG.md index c807adb..b3c2ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,24 @@ All notable released changes to this repository are documented here. ### Security +## [0.3.0] - 2026-07-24 + +### Added + +- Optional `content-index.json` file-level discovery layer for repositories + containing recurring or numerous individual documents. +- Draft 2020-12 content-index schema, reusable template, synthetic example, and + working reference index. +- Dependency-free validation for required fields, unique content IDs and paths, + indexed-file existence, safe relative paths, and related-content references. +- Content-index coverage in the reusable repository audit and unit tests. + +### Changed + +- Repository standard, skill, architecture, implementation guide, glossary, + retrieval order, and examples now distinguish repository-level metadata from + individual-document indexing. + ## [0.2.0] - 2026-07-24 ### Added diff --git a/CITATION.cff b/CITATION.cff index c32c639..f84dd33 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: "If you use this repository template, please cite it using this metadata." title: "AI-Ready Repository Template" type: software -version: 0.2.0 +version: 0.3.0 date-released: 2026-07-24 authors: - family-names: "Soehnel" diff --git a/README.md b/README.md index 5dddbaf..0be2c02 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ This repository is a working reference implementation of its own standard. It co 2. **Interactive AI skill** — assesses a new or existing repository, proposes the right structure, waits for approval by default, then creates and validates the approved assets. 3. **Deterministic validation** — checks required paths, metadata, attribution, versions, entry points, declared contents, licenses, and relative links. +For content-heavy repositories, the standard also defines +`content-index.json`: a compact file-level catalog that keeps recurring +updates, articles, research, policies, and other document collections out of +the repository-level manifest. + It can be used as: - a template for a new repository; @@ -108,6 +113,7 @@ Profiles are minimum useful structures, not commands to create every possible fo | [`AUTHOR.md`](AUTHOR.md) | Canonical author, publisher, maintainer, and attribution record. | | [`repository-variables.json`](repository-variables.json) | Verified stable identity, publication, rights, profile, and skill defaults. | | [`repository.json`](repository.json) | Authoritative machine-readable repository manifest. | +| [`content-index.json`](content-index.json) | Machine-readable catalog of the principal individual documents in this content-heavy reference repository. | | [`AGENTS.md`](AGENTS.md) | Repository-scoped operating instructions for AI agents. | | [`skills.md`](skills.md) | Skill index, triggers, inputs, outputs, and approval requirements. | @@ -127,7 +133,7 @@ Profiles are minimum useful structures, not commands to create every possible fo | [`docs/`](docs/README.md) | Architecture, implementation guidance, and glossary. | | [`templates/`](templates/README.md) | Reusable variables, manifest, author, and future-update templates. | | [`examples/`](examples/README.md) | Synthetic completed examples. | -| [`schemas/`](schemas/README.md) | JSON Schema for the repository manifest. | +| [`schemas/`](schemas/README.md) | JSON Schemas for the repository manifest, content index, and stable repository variables. | | [`scripts/`](scripts/README.md) | Dependency-free validation for this repository. | | [`tests/`](tests/README.md) | Automated repository validation tests. | | [`data/`](data/README.md) | Rules for public data when a repository needs it. | @@ -170,6 +176,7 @@ Depending on the selected profile, the skill produces: - a verified, reusable `repository-variables.json`; - verified author and publication metadata; - a machine-readable `repository.json`; +- an optional `content-index.json` for repositories with recurring or numerous individual documents; - profile-appropriate documentation, indexes, templates, examples, scripts, schemas, and tests; - host-specific contribution files when relevant; - validation results and, in the normal workflow, task plans and receipts. @@ -182,10 +189,11 @@ An AI agent should read: 2. [`AUTHOR.md`](AUTHOR.md) 3. [`repository-variables.json`](repository-variables.json) 4. [`repository.json`](repository.json) -5. [`AGENTS.md`](AGENTS.md) -6. [`skills.md`](skills.md) -7. The relevant skill -8. Only the references and supporting files required for the current task +5. [`content-index.json`](content-index.json) when locating an individual document +6. [`AGENTS.md`](AGENTS.md) +7. [`skills.md`](skills.md) +8. The relevant skill +9. Only the references and supporting files required for the current task Treat `UPDATES.md` as planning context, not authorization. Treat `CHANGELOG.md` as the record of completed versioned work. @@ -205,6 +213,7 @@ It checks: - author, publisher, maintainer, citation, and license alignment; - human, AI, skill, script, and template entry points; - declared content and retrieval paths; +- `content-index.json` required fields, unique IDs and paths, indexed-file existence, and related-content references; - version and license consistency; - relative Markdown links. @@ -223,11 +232,13 @@ When using this template for another repository: 1. replace the verified values in `repository-variables.json`; 2. replace the identity values in `AUTHOR.md`; 3. align `repository.json`, `CITATION.cff`, and `LICENSE`; -4. replace the canonical URL and hosting metadata; -5. choose the correct profile; -6. remove irrelevant example structure; -7. update tests and validation requirements; -8. run the complete validation workflow. +4. decide whether the repository is content-heavy enough to require + `content-index.json`; +5. replace the canonical URL and hosting metadata; +6. choose the correct profile; +7. remove irrelevant example structure; +8. update tests and validation requirements; +9. run the complete validation workflow. Do not leave Eddie Soehnel's identity on a derived repository unless that attribution remains accurate. @@ -239,7 +250,7 @@ See [SECURITY.md](SECURITY.md). ## Version, Author, And License -- **Version:** `0.2.0` +- **Version:** `0.3.0` - **Author, publisher, and maintainer:** Eddie Soehnel - **License:** MIT - **Canonical repository:** `https://projects.eddiesoehnel.com/adminprojects/repo-template` diff --git a/VERSION b/VERSION index 0ea3a94..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/content-index.json b/content-index.json new file mode 100644 index 0000000..0c05ad3 --- /dev/null +++ b/content-index.json @@ -0,0 +1,108 @@ +{ + "$schema": "./schemas/content-index.schema.json", + "schema_version": "1.0", + "collection_id": "repo-template-documentation", + "title": "AI-Ready Repository Template Documentation", + "description": "Machine-readable index of the principal standards and implementation documents in this repository.", + "updated_at": "2026-07-24", + "items": [ + { + "content_id": "repo-template-readme", + "title": "AI-Ready Repository Template", + "description": "Primary overview, usage guidance, repository map, and validation instructions.", + "content_type": "repository-overview", + "path": "README.md", + "canonical_url": null, + "published_at": "2026-07-23", + "updated_at": "2026-07-24", + "status": "published", + "author": "Eddie Soehnel", + "topics": [ + "ai-findability", + "repository-structure" + ], + "related_content_ids": [ + "repository-structure-standard", + "repository-implementation-guide" + ] + }, + { + "content_id": "repository-structure-standard", + "title": "AI-Ready Repository Structure Standard", + "description": "Detailed decision standard for repository files, profiles, metadata, safety, validation, and AI retrieval.", + "content_type": "standard", + "path": "skills/structure-ai-ready-repository/references/repository-structure-standard.md", + "canonical_url": null, + "published_at": "2026-07-23", + "updated_at": "2026-07-24", + "status": "published", + "author": "Eddie Soehnel", + "topics": [ + "ai-findability", + "repository-structure", + "repository-metadata" + ], + "related_content_ids": [ + "repo-template-readme", + "repository-implementation-guide" + ] + }, + { + "content_id": "repository-implementation-guide", + "title": "Implementation Guide", + "description": "Practical workflow for applying the repository standard to new and existing repositories.", + "content_type": "implementation-guide", + "path": "docs/implementation.md", + "canonical_url": null, + "published_at": "2026-07-23", + "updated_at": "2026-07-24", + "status": "published", + "author": "Eddie Soehnel", + "topics": [ + "repository-implementation", + "repository-profiles" + ], + "related_content_ids": [ + "repository-structure-standard", + "repository-architecture" + ] + }, + { + "content_id": "repository-architecture", + "title": "Architecture", + "description": "Explains the separation between guidance, machine-readable contracts, reusable AI behavior, and deterministic validation.", + "content_type": "architecture", + "path": "docs/architecture.md", + "canonical_url": null, + "published_at": "2026-07-23", + "updated_at": "2026-07-24", + "status": "published", + "author": "Eddie Soehnel", + "topics": [ + "repository-architecture", + "machine-readable-metadata" + ], + "related_content_ids": [ + "repository-implementation-guide" + ] + }, + { + "content_id": "repository-glossary", + "title": "Glossary", + "description": "Defines the principal terms used by the repository standard and skill.", + "content_type": "glossary", + "path": "docs/glossary.md", + "canonical_url": null, + "published_at": "2026-07-23", + "updated_at": "2026-07-24", + "status": "published", + "author": "Eddie Soehnel", + "topics": [ + "repository-terminology" + ], + "related_content_ids": [ + "repository-structure-standard" + ] + } + ] +} diff --git a/docs/architecture.md b/docs/architecture.md index 82e0aa6..0c730fb 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -12,6 +12,10 @@ repository-variables.json ---> schemas/repository-variables.schema.json | v repository.json -------------> schemas/repository.schema.json + | + +----> content-index.json ---> schemas/content-index.schema.json + | | + | +----> individual authoritative documents | v skills/structure-ai-ready-repository/ @@ -35,7 +39,9 @@ scripts/validate_repository.py + tests/ record. `repository-variables.json` stores verified stable inputs for future repository-structure work. `AGENTS.md` is the AI operating entry point. `repository.json` provides authoritative structured metadata and retrieval -order. +order. For content-heavy repositories, `content-index.json` provides the +file-level discovery layer between the repository manifest and the complete +authoritative documents. ### Standard @@ -49,6 +55,13 @@ The skill inspects a target repository, selects a profile, creates a reviewable Templates provide reusable starting artifacts with explicit placeholders. Examples are synthetic completed artifacts that demonstrate expected shape without carrying private or organization-specific data. +### Content indexing + +`repository.json` stays small by describing major collections. +`content-index.json` contains one compact record per individual document. The +Markdown files remain authoritative and do not require chunk IDs, knowledge +IDs, or semantic QA artifacts merely because they are indexed. + ### Validation The root validator checks this implemented template. The skill audit checks required structure for a selected profile in any target repository. Unit tests protect validator behavior and repository consistency. @@ -69,3 +82,5 @@ The root validator checks this implemented template. The skill audit checks requ - Allow a user to explicitly authorize immediate implementation. - Prefer verified nulls or visible placeholders over invented metadata. - Use deterministic scripts for structural validation. +- Use a separate content index only when individual-document volume would make + the repository manifest cumbersome. diff --git a/docs/glossary.md b/docs/glossary.md index 96bc528..2e5a89d 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -20,6 +20,18 @@ The file designated as the primary source for a value or contract, such as `VERS The canonical human-readable record of repository authorship, publishing, maintenance, preferred attribution, and downstream replacement guidance. +## Content index + +The optional machine-readable `content-index.json` file that catalogs +individual documents in a content-heavy repository without duplicating their +full text. + +## Content-heavy repository + +A repository with recurring or numerous individually useful documents, such as +updates, articles, research entries, policies, or guides, where listing every +file in `repository.json` would be cumbersome. + ## Entry point A declared starting file for a human or AI agent. diff --git a/docs/implementation.md b/docs/implementation.md index 5918f1d..b8ae1c8 100644 --- a/docs/implementation.md +++ b/docs/implementation.md @@ -18,10 +18,13 @@ Add profile-specific files only when they support real content or validation. 3. Create `repository-variables.json` using `templates/repository-variables.json.template`. 4. Create `repository.json` using `templates/repository.json.template`. -5. Select and create profile-required documentation and folders. -6. Add a verified license, version, and change record. -7. Add host-specific contribution templates. -8. Validate the repository. +5. If the repository contains recurring or numerous individual documents, + create `content-index.json` using + `templates/content-index.json.template`; otherwise leave it absent. +6. Select and create profile-required documentation and folders. +7. Add a verified license, version, and change record. +8. Add host-specific contribution templates. +9. Validate the repository. ## Existing Repository Workflow @@ -44,6 +47,28 @@ Every implementation should answer: Declare these answers in `repository.json`. +## Content Index Decision + +Use `content-index.json` when the repository contains recurring updates, +articles, research entries, policies, guides, or enough individual documents +that listing them directly in `repository.json` would be cumbersome. + +Keep `repository.json` focused on repository identity, capabilities, entry +points, and major collections. Put one compact record per document in +`content-index.json`, and keep each Markdown file as the authoritative complete +text. + +For only three or four major documents, list them directly in +`repository.json` and omit the content index. + +Validate: + +- unique `content_id` values; +- unique repository-relative paths; +- existence of every indexed file; +- resolution of `related_content_ids`; +- declaration of `content-index.json` in `repository.json`. + ## Identity And Publication At the beginning of a repository build, read `repository-variables.json` when diff --git a/examples/README.md b/examples/README.md index 702d959..860b338 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,5 +6,6 @@ All examples in this directory are synthetic and do not represent an actual orga | --- | --- | | `example-repository-variables.json` | Completed stable repository-skill variables for a fictional repository. | | `example-repository.json` | Completed documentation-profile manifest for a fictional repository. | +| `example-content-index.json` | Completed file-level document catalog for a fictional content-heavy repository. | Use examples to understand expected shape. Do not copy fictional URLs, maintainers, or identifiers into a real repository. diff --git a/examples/example-content-index.json b/examples/example-content-index.json new file mode 100644 index 0000000..17330c4 --- /dev/null +++ b/examples/example-content-index.json @@ -0,0 +1,27 @@ +{ + "$schema": "../schemas/content-index.schema.json", + "schema_version": "1.0", + "collection_id": "example-field-guides", + "title": "Synthetic Field Guides", + "description": "Synthetic example index for a repository containing recurring field-guide documents.", + "updated_at": "2026-01-15", + "items": [ + { + "content_id": "field-guide-winter-site-visit", + "title": "Winter Site Visit Field Guide", + "description": "Explains a synthetic preparation and documentation process for a winter site visit.", + "content_type": "field-guide", + "path": "docs/field-guides/winter-site-visit.md", + "canonical_url": "https://code.example.org/example-organization/field-guide/src/branch/main/docs/field-guides/winter-site-visit.md", + "published_at": "2026-01-15", + "updated_at": "2026-01-15", + "status": "published", + "author": "Alex Example", + "topics": [ + "field-practice", + "winter" + ], + "related_content_ids": [] + } + ] +} diff --git a/repository.json b/repository.json index 009938d..b37f851 100644 --- a/repository.json +++ b/repository.json @@ -23,7 +23,7 @@ "repository_status": "active", "visibility": "public", "maturity": "experimental", - "version": "0.2.0", + "version": "0.3.0", "created_at": "2026-07-23", "updated_at": "2026-07-24", "resource_types": [ @@ -72,12 +72,14 @@ "Assess a new or existing repository.", "Propose a profile-appropriate repository structure.", "Create machine-readable repository metadata.", + "Catalog individual documents in content-heavy repositories without expanding the repository manifest.", "Persist verified stable repository-skill variables.", "Validate required paths, entrypoints, versions, and links." ], "use_cases": [ "Start a new AI workflow repository.", "Correct an existing repository for AI findability.", + "Add a compact discovery index to a repository containing recurring updates, articles, research, policies, or guides.", "Standardize reusable repository documentation and metadata." ], "required_inputs": [ @@ -118,6 +120,13 @@ "description": "Verified stable identity, publication, rights, profile, and repository-skill defaults.", "required_for_use": true }, + { + "path": "content-index.json", + "type": "content-index", + "title": "Repository Content Index", + "description": "Machine-readable index of the principal standards and implementation documents in this repository.", + "required_for_use": true + }, { "path": "README.md", "type": "documentation", @@ -180,7 +189,7 @@ "maintenance": { "maintainer": "Eddie Soehnel", "review_frequency": "as-needed", - "last_reviewed_at": "2026-07-23", + "last_reviewed_at": "2026-07-24", "deprecated": false, "archived": false }, @@ -190,6 +199,7 @@ "AUTHOR.md", "repository-variables.json", "repository.json", + "content-index.json", "AGENTS.md", "skills.md" ], diff --git a/schemas/README.md b/schemas/README.md index a37713f..34ba386 100644 --- a/schemas/README.md +++ b/schemas/README.md @@ -4,5 +4,6 @@ | --- | --- | | `repository.schema.json` | JSON Schema contract for the repository manifest. | | `repository-variables.schema.json` | JSON Schema contract for stable repository-skill inputs. | +| `content-index.schema.json` | JSON Schema contract for optional file-level catalogs in content-heavy repositories. | The root validator performs dependency-free contract checks. Use a Draft 2020-12 compatible JSON Schema validator for complete schema validation. diff --git a/schemas/content-index.schema.json b/schemas/content-index.schema.json new file mode 100644 index 0000000..0dd149e --- /dev/null +++ b/schemas/content-index.schema.json @@ -0,0 +1,133 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://projects.eddiesoehnel.com/adminprojects/repo-template/schemas/content-index.schema.json", + "title": "Repository Content Index", + "description": "Compact machine-readable catalog of individual documents in a content-heavy repository.", + "type": "object", + "required": [ + "schema_version", + "collection_id", + "title", + "description", + "updated_at", + "items" + ], + "properties": { + "$schema": { + "type": "string" + }, + "schema_version": { + "type": "string", + "pattern": "^\\d+\\.\\d+$" + }, + "collection_id": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + }, + "title": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "minLength": 1 + }, + "updated_at": { + "type": "string", + "format": "date" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/contentItem" + } + } + }, + "additionalProperties": false, + "$defs": { + "stringArray": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "uniqueItems": true + }, + "contentItem": { + "type": "object", + "required": [ + "content_id", + "title", + "description", + "content_type", + "path", + "status" + ], + "properties": { + "content_id": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + }, + "title": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "minLength": 1 + }, + "content_type": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + }, + "path": { + "type": "string", + "minLength": 1 + }, + "canonical_url": { + "type": [ + "string", + "null" + ] + }, + "published_at": { + "type": [ + "string", + "null" + ], + "format": "date" + }, + "updated_at": { + "type": [ + "string", + "null" + ], + "format": "date" + }, + "status": { + "type": "string", + "enum": [ + "draft", + "published", + "deprecated", + "archived", + "superseded" + ] + }, + "author": { + "type": [ + "string", + "null" + ] + }, + "topics": { + "$ref": "#/$defs/stringArray" + }, + "related_content_ids": { + "$ref": "#/$defs/stringArray" + } + }, + "additionalProperties": false + } + } +} diff --git a/scripts/README.md b/scripts/README.md index 887d916..481fc3d 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -20,5 +20,6 @@ python scripts/validate_repository.py . --json The validator checks required paths, JSON parsing, repository-variable and manifest alignment, author/publisher alignment, entrypoint paths, manifest -contents paths, version alignment, license alignment, and relative Markdown -links. It does not prove content accuracy or check external URLs. +contents paths, optional content-index fields and references, version alignment, +license alignment, and relative Markdown links. It does not prove content +accuracy or check external URLs. diff --git a/scripts/validate_repository.py b/scripts/validate_repository.py index c492a7e..e4301a5 100644 --- a/scripts/validate_repository.py +++ b/scripts/validate_repository.py @@ -21,6 +21,7 @@ REQUIRED_PATHS = ( "CHANGELOG.md", "CITATION.cff", "CONTRIBUTING.md", + "content-index.json", "LICENSE", "README.md", "SECURITY.md", @@ -30,10 +31,12 @@ REQUIRED_PATHS = ( "data/README.md", "docs/README.md", "examples/README.md", + "examples/example-content-index.json", "receipts/README.md", "repository.json", "repository-variables.json", "schemas/README.md", + "schemas/content-index.schema.json", "schemas/repository.schema.json", "schemas/repository-variables.schema.json", "scripts/README.md", @@ -41,6 +44,7 @@ REQUIRED_PATHS = ( "skills/README.md", "skills/structure-ai-ready-repository/SKILL.md", "tasks/README.md", + "templates/content-index.json.template", "templates/README.md", "templates/repository-variables.json.template", "tests/README.md", @@ -65,6 +69,24 @@ MANIFEST_REQUIRED_KEYS = ( "ai_retrieval", ) +CONTENT_INDEX_REQUIRED_KEYS = ( + "schema_version", + "collection_id", + "title", + "description", + "updated_at", + "items", +) + +CONTENT_ITEM_REQUIRED_KEYS = ( + "content_id", + "title", + "description", + "content_type", + "path", + "status", +) + MARKDOWN_LINK = re.compile(r"(? dict | None declared = item.get("path") if isinstance(item, dict) else None if not declared or not (root / declared).exists(): add(findings, "error", f"Declared contents path does not exist: {declared}") + declared_paths = { + item.get("path") for item in contents if isinstance(item, dict) + } + if (root / "content-index.json").is_file() and "content-index.json" not in declared_paths: + add(findings, "error", "repository.json contents must declare content-index.json") retrieval = manifest.get("ai_retrieval", {}) if isinstance(retrieval, dict): @@ -163,6 +190,73 @@ def validate_manifest(root: Path, findings: list[dict[str, str]]) -> dict | None return manifest +def validate_content_index(root: Path, findings: list[dict[str, str]]) -> dict | None: + path = root / "content-index.json" + try: + index = json.loads(read_text(path)) + except (OSError, UnicodeError, json.JSONDecodeError) as exc: + add(findings, "error", f"content-index.json is invalid: {exc}") + return None + + for key in CONTENT_INDEX_REQUIRED_KEYS: + if key not in index: + add(findings, "error", f"content-index.json lacks required key: {key}") + + items = index.get("items") + if not isinstance(items, list): + add(findings, "error", "content-index.json items must be an array") + return index + + content_ids: set[str] = set() + paths: set[str] = set() + related_references: list[tuple[str, str]] = [] + for position, item in enumerate(items): + label = f"content-index.json item {position + 1}" + if not isinstance(item, dict): + add(findings, "error", f"{label} must be an object") + continue + for key in CONTENT_ITEM_REQUIRED_KEYS: + if key not in item: + add(findings, "error", f"{label} lacks required key: {key}") + + content_id = item.get("content_id") + if not isinstance(content_id, str) or not content_id: + add(findings, "error", f"{label} has an invalid content_id") + elif content_id in content_ids: + add(findings, "error", f"Duplicate content_id in content-index.json: {content_id}") + else: + content_ids.add(content_id) + + declared = item.get("path") + if not isinstance(declared, str) or not declared: + add(findings, "error", f"{label} has an invalid path") + else: + declared_path = Path(declared) + if declared_path.is_absolute() or ".." in declared_path.parts: + add(findings, "error", f"Unsafe content-index.json path: {declared}") + elif declared in paths: + add(findings, "error", f"Duplicate path in content-index.json: {declared}") + else: + paths.add(declared) + if not (root / declared_path).is_file(): + add(findings, "error", f"Indexed content path does not exist: {declared}") + + related = item.get("related_content_ids", []) + if not isinstance(related, list): + add(findings, "error", f"{label} related_content_ids must be an array") + elif isinstance(content_id, str): + related_references.extend((content_id, value) for value in related) + + for source_id, related_id in related_references: + if related_id not in content_ids: + add( + findings, + "error", + f"Unknown related_content_id in content-index.json: {source_id} -> {related_id}", + ) + return index + + def validate_variables( root: Path, manifest: dict | None, findings: list[dict[str, str]] ) -> dict | None: @@ -300,6 +394,8 @@ def validate(root: Path) -> dict: missing_core = False manifest = None if not (root / "repository.json").is_file() else validate_manifest(root, findings) + if (root / "content-index.json").is_file(): + validate_content_index(root, findings) if (root / "repository-variables.json").is_file(): validate_variables(root, manifest, findings) if not missing_core: diff --git a/skills.md b/skills.md index d5454b0..9a7cbca 100644 --- a/skills.md +++ b/skills.md @@ -2,22 +2,24 @@ ## How To Use This Index -Read this file after `README.md`, `repository.json`, and `AGENTS.md` to determine which skill applies. +Read this file after `README.md`, `repository.json`, optional +`content-index.json`, and `AGENTS.md` to determine which skill applies. ## Skills ### Structure AI-Ready Repository - **Path:** `skills/structure-ai-ready-repository/SKILL.md` -- **Purpose:** Assess, plan, create, correct, and validate a human- and AI-findable repository structure. -- **Use when:** Starting a repository, correcting inconsistent structure, adding repository metadata, or improving AI entry points. +- **Purpose:** Assess, plan, create, correct, and validate a human- and AI-findable repository structure, including optional file-level indexing for content-heavy repositories. +- **Use when:** Starting a repository, correcting inconsistent structure, adding repository metadata or a content index, or improving AI entry points. - **Inputs:** Target repository, project purpose, existing contents, `repository-variables.json` when present, verified author/publisher/maintainer identity, canonical URL, license, and any constraints. - **Outputs:** A profile-appropriate repository structure, - `repository-variables.json`, metadata, documentation, validation, and - normal-workflow task records. + `repository-variables.json`, repository metadata, optional + `content-index.json`, documentation, validation, and normal-workflow task + records. - **Human approval required:** Yes by default. The user may explicitly authorize immediate implementation. - **Related scripts:** `skills/structure-ai-ready-repository/scripts/audit_repository.py` and `scripts/validate_repository.py`. - **Reference standard:** `skills/structure-ai-ready-repository/references/repository-structure-standard.md`. diff --git a/skills/structure-ai-ready-repository/SKILL.md b/skills/structure-ai-ready-repository/SKILL.md index dfd97b8..80a46a2 100644 --- a/skills/structure-ai-ready-repository/SKILL.md +++ b/skills/structure-ai-ready-repository/SKILL.md @@ -35,8 +35,13 @@ Use `scripts/audit_repository.py` for a read-only baseline and final structural instructions. Preserve unrelated user changes. 6. Infer the most suitable profile: documentation/guide, skill/workflow, software/automation, dataset, or a justified custom minimum. -7. Separate facts found in the repository from assumptions and recommendations. -8. Run the read-only audit when Python is available. Record failures as +7. Determine whether the repository is content-heavy. Recommend + `content-index.json` when it contains recurring updates, articles, research + entries, policies, guides, or enough individual documents that listing each + one in `repository.json` would make the repository manifest cumbersome. + Keep small repositories on `repository.json` alone. +8. Separate facts found in the repository from assumptions and recommendations. +9. 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 @@ -101,6 +106,12 @@ If implementation requires a material departure from the approved plan, update t repository, rights, profile, and workflow defaults; add it to agent read order before `repository.json`. Omit optional unknown values or use `null` where the schema permits; never invent an organization. + - for an approved content-heavy repository, create `content-index.json` as + the compact catalog of individual authoritative documents. Declare it in + `repository.json`, keep document paths repository-relative, use stable + `content_id` values, and do not copy full document bodies into the index. + Do not add chunk IDs, knowledge IDs, `chunks.json`, or `qa.json` merely + because a document is cataloged. 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. @@ -109,7 +120,8 @@ If implementation requires a material departure from the approved plan, update t 1. Run `scripts/audit_repository.py` with the approved profile. 2. Parse machine-readable files and check `repository-variables.json` alignment, version alignment, internal paths, and - declared entry points. + declared entry points. When `content-index.json` exists, check unique content + IDs, unique paths, indexed-file existence, and related-content references. 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. diff --git a/skills/structure-ai-ready-repository/references/repository-structure-standard.md b/skills/structure-ai-ready-repository/references/repository-structure-standard.md index 14aab1f..7b0ebd8 100644 --- a/skills/structure-ai-ready-repository/references/repository-structure-standard.md +++ b/skills/structure-ai-ready-repository/references/repository-structure-standard.md @@ -45,6 +45,7 @@ repository-name/ ├── AUTHOR.md ├── repository-variables.json ├── repository.json +├── content-index.json # optional for content-heavy repositories ├── LICENSE ├── CHANGELOG.md ├── UPDATES.md @@ -578,6 +579,62 @@ Do not change IDs casually after publication because other catalogs, relationshi --- +## `content-index.json` + +### Purpose + +Provides a compact machine-readable catalog of the individual documents inside +a content-heavy repository. + +Use the separation: + +```text +repository.json + Repository identity, purpose, capabilities, entry points, and major collections. + +content-index.json + One compact discovery record per individual document. + +Individual Markdown file + Complete authoritative human- and AI-readable content. +``` + +Use `content-index.json` for recurring platform updates, articles, research +entries, policies, guides, or dozens of documents. A repository with only a few +major files may list those files directly in `repository.json` and omit the +content index. + +The index should include stable content IDs, titles, concise descriptions, +content types, repository-relative paths, status, dates, and topics. It may +include canonical URLs and relationships to other indexed items. + +Do not: + +* Copy full document bodies into the index. +* Treat the index as the authoritative source instead of the Markdown file. +* Add chunk IDs or knowledge IDs merely because a document is indexed. +* Generate `chunks.json` or `qa.json` unless a separate publishing or semantic + materialization workflow requires them. +* Allow duplicate IDs, duplicate paths, missing paths, absolute paths, or path + traversal. + +Declare the index in the `contents` array of `repository.json`: + +```json +{ + "path": "content-index.json", + "type": "content-index", + "title": "Repository Content Index", + "description": "Machine-readable index of the repository's published documents.", + "required_for_use": true +} +``` + +Use `templates/content-index.json.template` and validate against +`schemas/content-index.schema.json`. + +--- + ## `LICENSE` ### Purpose @@ -1701,6 +1758,7 @@ Optional: ```text CONTRIBUTING.md skills.md +content-index.json templates/ examples/ assets/ @@ -1737,6 +1795,7 @@ tests/ receipts/ CONTRIBUTING.md SECURITY.md +content-index.json when the repository contains a document collection ``` --- @@ -1771,6 +1830,7 @@ assets/ .env.example .gitignore dependency manifest +content-index.json when documentation or release notes form a large collection ``` --- @@ -1801,6 +1861,7 @@ scripts/ tests/ examples/ SECURITY.md +content-index.json when the repository catalogs many individually addressable records or documents ``` The README and `data/README.md` should document provenance, collection methodology, limitations, update frequency, field definitions, and rights. @@ -1966,6 +2027,8 @@ Before publishing a new repository: profile, workflow defaults, and verification metadata. [ ] AUTHOR.md contains verified author, publisher, maintainer, canonical URL, and adaptation guidance. [ ] repository.json is complete and valid JSON. +[ ] Content-heavy repositories include a valid `content-index.json`; small repositories intentionally omit it. +[ ] Every indexed content ID and path is unique and every indexed path exists. [ ] repository_id is stable and unique. [ ] Canonical URL is correct. [ ] LICENSE matches repository.json. diff --git a/skills/structure-ai-ready-repository/scripts/audit_repository.py b/skills/structure-ai-ready-repository/scripts/audit_repository.py index 75f08ff..9aa0830 100644 --- a/skills/structure-ai-ready-repository/scripts/audit_repository.py +++ b/skills/structure-ai-ready-repository/scripts/audit_repository.py @@ -94,6 +94,82 @@ def read_version_from_citation(path: Path) -> str | None: return match.group(1) if match else None +def audit_content_index(root: Path, findings: list[dict[str, str]]) -> None: + path = root / "content-index.json" + if not path.is_file(): + return + try: + index = json.loads(path.read_text(encoding="utf-8-sig")) + except (OSError, UnicodeError, json.JSONDecodeError) as exc: + findings.append({"level": "error", "message": f"content-index.json is invalid: {exc}"}) + return + + items = index.get("items") + if not isinstance(items, list): + findings.append( + {"level": "error", "message": "content-index.json items must be an array"} + ) + return + + content_ids: set[str] = set() + paths: set[str] = set() + for position, item in enumerate(items): + if not isinstance(item, dict): + findings.append( + { + "level": "error", + "message": f"content-index.json item {position + 1} must be an object", + } + ) + continue + content_id = item.get("content_id") + declared = item.get("path") + if not content_id: + findings.append( + { + "level": "error", + "message": f"content-index.json item {position + 1} lacks content_id", + } + ) + elif content_id in content_ids: + findings.append( + { + "level": "error", + "message": f"Duplicate content_id in content-index.json: {content_id}", + } + ) + else: + content_ids.add(content_id) + if not declared: + findings.append( + { + "level": "error", + "message": f"content-index.json item {position + 1} lacks path", + } + ) + elif declared in paths: + findings.append( + { + "level": "error", + "message": f"Duplicate path in content-index.json: {declared}", + } + ) + else: + paths.add(declared) + declared_path = Path(declared) + if ( + declared_path.is_absolute() + or ".." in declared_path.parts + or not (root / declared_path).is_file() + ): + findings.append( + { + "level": "error", + "message": f"Indexed content path does not exist or is unsafe: {declared}", + } + ) + + def audit(root: Path, profile: str) -> dict: findings: list[dict[str, str]] = [] if not root.is_dir(): @@ -235,6 +311,8 @@ def audit(root: Path, profile: str) -> dict: } ) + audit_content_index(root, findings) + 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: diff --git a/tasks/add-content-index/implementation-receipt.md b/tasks/add-content-index/implementation-receipt.md new file mode 100644 index 0000000..6737940 --- /dev/null +++ b/tasks/add-content-index/implementation-receipt.md @@ -0,0 +1,34 @@ +# Content Index Implementation Receipt + +## Result + +Implemented `content-index.json` as an optional file-level discovery layer for +content-heavy repositories. + +## Added + +- `content-index.json` +- `schemas/content-index.schema.json` +- `templates/content-index.json.template` +- `examples/example-content-index.json` + +## Updated + +- Repository manifest, retrieval order, standard, reusable skill, architecture, + implementation guide, glossary, schema/template/example indexes, validator, + reusable audit, tests, changelog, citation, and version. + +## Contract + +Each content item uses a stable `content_id`, concise metadata, a +repository-relative path, status, and optional dates, canonical URL, author, +topics, and related content IDs. + +The index does not contain full document bodies and does not require semantic +chunk or QA materialization. + +## Release + +The template version was advanced from `0.2.0` to `0.3.0`. + +No commit, push, publication, or deployment was performed. diff --git a/tasks/add-content-index/repository-structure-plan.md b/tasks/add-content-index/repository-structure-plan.md new file mode 100644 index 0000000..5f0ca1f --- /dev/null +++ b/tasks/add-content-index/repository-structure-plan.md @@ -0,0 +1,40 @@ +# Add Content Index + +- **Status:** implemented +- **Revision:** 1 +- **Approved scope:** Immediate implementation authorized by the user on 2026-07-24. + +## Objective + +Add an optional, first-class `content-index.json` layer for repositories that +contain recurring or numerous individual documents. + +## Decision + +Keep `repository.json` authoritative for repository identity, purpose, +capabilities, entry points, and major collections. Use `content-index.json` for +compact file-level discovery records. Keep each Markdown document authoritative +for its complete content. + +Small repositories may omit the content index and list their few major files +directly in `repository.json`. + +## Approved Actions + +- Add a working root content index. +- Add a JSON Schema, template, and synthetic example. +- Extend validators and tests. +- Update the reusable skill and repository standard. +- Update root documentation, retrieval order, manifest, version, citation, and + changelog. +- Do not add chunk IDs, knowledge IDs, `chunks.json`, or `qa.json`. +- Do not commit, push, publish, or modify hosting-platform settings. + +## Definition Of Done + +- Root validation passes. +- Unit tests pass. +- Skill/workflow profile audit passes. +- Skill validation passes. +- JSON files parse. +- `VERSION`, `repository.json`, and `CITATION.cff` agree. diff --git a/tasks/add-content-index/validation-results.md b/tasks/add-content-index/validation-results.md new file mode 100644 index 0000000..349fc13 --- /dev/null +++ b/tasks/add-content-index/validation-results.md @@ -0,0 +1,29 @@ +# Content Index Validation Results + +## Date + +2026-07-24 + +## Results + +- Python syntax compilation: PASS +- `python scripts/validate_repository.py .`: PASS +- `python -m unittest discover -s tests -p "test_*.py"`: PASS, 5 tests +- Skill/workflow profile audit: PASS +- Codex skill quick validation: PASS +- JSON parsing: PASS, 10 checked files +- Git diff whitespace check: PASS +- Version alignment: PASS at `0.3.0` + +## Validator Coverage + +- Required content-index fields +- Unique content IDs +- Unique paths +- Safe repository-relative paths +- Indexed-file existence +- Related-content reference resolution +- Declaration of `content-index.json` in `repository.json` + +External URLs and the semantic accuracy of descriptions were not +network-validated. diff --git a/templates/README.md b/templates/README.md index d939a44..fa41d8b 100644 --- a/templates/README.md +++ b/templates/README.md @@ -4,7 +4,12 @@ | --- | --- | | `repository.json.template` | Starting machine-readable repository manifest with visible placeholders. | | `repository-variables.json.template` | Starting verified identity, publication, rights, profile, and repository-skill defaults. | +| `content-index.json.template` | Starting file-level catalog for recurring or numerous individual documents. | | `AUTHOR.md.template` | Starting canonical author, publisher, maintainer, and attribution file. | | `UPDATES.md.template` | Starting notes file for future repository improvements. | Replace every `{{PLACEHOLDER}}` with a verified value before use. A template is not a completed artifact and should not be presented as valid project metadata. + +Use `content-index.json.template` only for a content-heavy repository. Small +repositories should list their few major documents directly in +`repository.json`. diff --git a/templates/content-index.json.template b/templates/content-index.json.template new file mode 100644 index 0000000..a455311 --- /dev/null +++ b/templates/content-index.json.template @@ -0,0 +1,24 @@ +{ + "$schema": "./schemas/content-index.schema.json", + "schema_version": "1.0", + "collection_id": "{{STABLE_COLLECTION_ID}}", + "title": "{{CONTENT_COLLECTION_TITLE}}", + "description": "{{CONTENT_COLLECTION_DESCRIPTION}}", + "updated_at": "{{YYYY-MM-DD}}", + "items": [ + { + "content_id": "{{STABLE_CONTENT_ID}}", + "title": "{{DOCUMENT_TITLE}}", + "description": "{{ONE_SENTENCE_DOCUMENT_DESCRIPTION}}", + "content_type": "{{CONTENT_TYPE}}", + "path": "{{RELATIVE_DOCUMENT_PATH}}", + "canonical_url": null, + "published_at": "{{YYYY-MM-DD}}", + "updated_at": "{{YYYY-MM-DD}}", + "status": "published", + "author": "{{AUTHOR_NAME}}", + "topics": [], + "related_content_ids": [] + } + ] +} diff --git a/tests/README.md b/tests/README.md index 810fe06..a089f6a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -8,4 +8,5 @@ python -m unittest discover -s tests -p "test_*.py" The tests validate the current repository and protect key failure cases in `scripts/validate_repository.py`, including mismatches between -`repository-variables.json` and `repository.json`. +`repository-variables.json` and `repository.json`, duplicate content IDs, and +missing files declared by `content-index.json`. diff --git a/tests/test_repository.py b/tests/test_repository.py index 286e7dc..c07ecf1 100644 --- a/tests/test_repository.py +++ b/tests/test_repository.py @@ -47,6 +47,42 @@ class RepositoryValidationTests(unittest.TestCase): ) ) + def test_duplicate_content_id_fails(self) -> None: + with tempfile.TemporaryDirectory() as directory: + copy = Path(directory) / "repository" + shutil.copytree(ROOT, copy, ignore=shutil.ignore_patterns(".git", "__pycache__")) + index_path = copy / "content-index.json" + index = json.loads(index_path.read_text(encoding="utf-8")) + duplicate = dict(index["items"][0]) + duplicate["path"] = "docs/README.md" + index["items"].append(duplicate) + index_path.write_text(json.dumps(index, indent=2) + "\n", encoding="utf-8") + result = VALIDATOR.validate(copy) + self.assertFalse(result["passed"]) + self.assertTrue( + any( + "Duplicate content_id in content-index.json" in item["message"] + for item in result["findings"] + ) + ) + + def test_missing_indexed_content_fails(self) -> None: + with tempfile.TemporaryDirectory() as directory: + copy = Path(directory) / "repository" + shutil.copytree(ROOT, copy, ignore=shutil.ignore_patterns(".git", "__pycache__")) + index_path = copy / "content-index.json" + index = json.loads(index_path.read_text(encoding="utf-8")) + index["items"][0]["path"] = "docs/missing-document.md" + index_path.write_text(json.dumps(index, indent=2) + "\n", encoding="utf-8") + result = VALIDATOR.validate(copy) + self.assertFalse(result["passed"]) + self.assertTrue( + any( + "Indexed content path does not exist" in item["message"] + for item in result["findings"] + ) + ) + if __name__ == "__main__": unittest.main()