create-yss-spec 3.5.2 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/template/asset-runtime.js +3 -1
- package/template/.agents/skills/.strategic-design-skills-manifest.json +1 -1
- package/template/.agents/skills/codebase-design/SKILL.md +4 -0
- package/template/{.codex/skills/improve-codebase-architecture/SKILL.md → .agents/skills/codebase-design/references/architecture-audit.md} +3 -9
- package/template/.agents/skills/frontend-commit/SKILL.md +4 -93
- package/template/.agents/skills/git-commit-core/SKILL.md +18 -0
- package/template/.agents/skills/java-backend-commit/SKILL.md +4 -96
- package/template/.agents/skills/llm-wiki/SKILL.md +12 -13
- package/template/.agents/skills/llm-wiki/assets/CLAUDE.md.template +7 -1
- package/template/.agents/skills/llm-wiki/references/compile.md +21 -114
- package/template/.agents/skills/llm-wiki/references/ingest.md +8 -33
- package/template/.agents/skills/llm-wiki/references/lint.md +9 -46
- package/template/.agents/skills/llm-wiki/references/query.md +9 -18
- package/template/.agents/skills/llm-wiki/references/schema.md +56 -29
- package/template/.agents/skills/llm-wiki/references/transactions.md +48 -0
- package/template/.agents/skills/llm-wiki/references/writing.md +4 -4
- package/template/.agents/skills/llm-wiki/scripts/advise.mjs +46 -58
- package/template/.agents/skills/llm-wiki/scripts/advise.test.mjs +11 -16
- package/template/.agents/skills/llm-wiki/scripts/core.mjs +262 -0
- package/template/.agents/skills/llm-wiki/scripts/extract.mjs +35 -18
- package/template/.agents/skills/llm-wiki/scripts/extract.test.mjs +5 -8
- package/template/.agents/skills/llm-wiki/scripts/feedback.mjs +51 -0
- package/template/.agents/skills/llm-wiki/scripts/inventory.mjs +43 -171
- package/template/.agents/skills/llm-wiki/scripts/inventory.test.mjs +25 -18
- package/template/.agents/skills/llm-wiki/scripts/lint-wikilinks.mjs +69 -92
- package/template/.agents/skills/llm-wiki/scripts/lint-wikilinks.test.mjs +25 -37
- package/template/.agents/skills/llm-wiki/scripts/migrate.mjs +51 -0
- package/template/.agents/skills/llm-wiki/scripts/query.mjs +149 -0
- package/template/.agents/skills/llm-wiki/scripts/regressions.test.mjs +101 -0
- package/template/.agents/skills/llm-wiki/scripts/sources.mjs +166 -0
- package/template/.agents/skills/llm-wiki/scripts/transaction.mjs +384 -0
- package/template/.agents/skills/llm-wiki/scripts/v2.test.mjs +354 -0
- package/template/.agents/skills/prototype/LOGIC.md +1 -1
- package/template/.agents/skills/prototype/SKILL.md +5 -19
- package/template/.agents/skills/setup-matt-pocock-skills/SKILL.md +3 -3
- package/template/.agents/skills/yss-implementation-contract-compiler/SKILL.md +2 -0
- package/template/.agents/skills/yss-implementation-contract-compiler/references/boundaries.md +2 -3
- package/template/.agents/skills/yss-implementation-contract-compiler/references/yss-skill-execution-result.md +14 -0
- package/template/.agents/skills/yss-product-lifecycle/SKILL.md +8 -8
- package/template/.agents/skills/yss-product-lifecycle/references/external-input-questionnaire.md +19 -0
- package/template/.agents/skills/yss-product-lifecycle/references/matt-yss-adapter.md +5 -5
- package/template/.agents/skills/yss-product-lifecycle/references/orchestration-contract.yaml +20 -4
- package/template/.agents/skills/yss-product-lifecycle/references/orchestration.md +2 -2
- package/template/.agents/skills/yss-product-lifecycle/references/plan-requirements.md +10 -0
- package/template/.agents/skills/yss-product-lifecycle/references/state-model.md +1 -1
- package/template/.agents/skills/yss-research/SKILL.md +4 -0
- package/template/.codex/skills/codebase-design/SKILL.md +4 -0
- package/template/{.pi/skills/improve-codebase-architecture/SKILL.md → .codex/skills/codebase-design/references/architecture-audit.md} +3 -9
- package/template/.codex/skills/frontend-commit/SKILL.md +4 -93
- package/template/.codex/skills/git-commit-core/SKILL.md +18 -0
- package/template/.codex/skills/java-backend-commit/SKILL.md +4 -96
- package/template/.codex/skills/llm-wiki/SKILL.md +12 -13
- package/template/.codex/skills/llm-wiki/assets/CLAUDE.md.template +7 -1
- package/template/.codex/skills/llm-wiki/references/compile.md +21 -114
- package/template/.codex/skills/llm-wiki/references/ingest.md +8 -33
- package/template/.codex/skills/llm-wiki/references/lint.md +9 -46
- package/template/.codex/skills/llm-wiki/references/query.md +9 -18
- package/template/.codex/skills/llm-wiki/references/schema.md +56 -29
- package/template/.codex/skills/llm-wiki/references/transactions.md +48 -0
- package/template/.codex/skills/llm-wiki/references/writing.md +4 -4
- package/template/.codex/skills/llm-wiki/scripts/advise.mjs +46 -58
- package/template/.codex/skills/llm-wiki/scripts/advise.test.mjs +11 -16
- package/template/.codex/skills/llm-wiki/scripts/core.mjs +262 -0
- package/template/.codex/skills/llm-wiki/scripts/extract.mjs +35 -18
- package/template/.codex/skills/llm-wiki/scripts/extract.test.mjs +5 -8
- package/template/.codex/skills/llm-wiki/scripts/feedback.mjs +51 -0
- package/template/.codex/skills/llm-wiki/scripts/inventory.mjs +43 -171
- package/template/.codex/skills/llm-wiki/scripts/inventory.test.mjs +25 -18
- package/template/.codex/skills/llm-wiki/scripts/lint-wikilinks.mjs +69 -92
- package/template/.codex/skills/llm-wiki/scripts/lint-wikilinks.test.mjs +25 -37
- package/template/.codex/skills/llm-wiki/scripts/migrate.mjs +51 -0
- package/template/.codex/skills/llm-wiki/scripts/query.mjs +149 -0
- package/template/.codex/skills/llm-wiki/scripts/regressions.test.mjs +101 -0
- package/template/.codex/skills/llm-wiki/scripts/sources.mjs +166 -0
- package/template/.codex/skills/llm-wiki/scripts/transaction.mjs +384 -0
- package/template/.codex/skills/llm-wiki/scripts/v2.test.mjs +354 -0
- package/template/.codex/skills/prototype/LOGIC.md +1 -1
- package/template/.codex/skills/prototype/SKILL.md +5 -19
- package/template/.codex/skills/setup-matt-pocock-skills/SKILL.md +3 -3
- package/template/.codex/skills/yss-implementation-contract-compiler/SKILL.md +2 -0
- package/template/.codex/skills/yss-implementation-contract-compiler/references/boundaries.md +2 -3
- package/template/.codex/skills/yss-implementation-contract-compiler/references/yss-skill-execution-result.md +14 -0
- package/template/.codex/skills/yss-product-lifecycle/SKILL.md +8 -8
- package/template/.codex/skills/yss-product-lifecycle/references/external-input-questionnaire.md +19 -0
- package/template/.codex/skills/yss-product-lifecycle/references/matt-yss-adapter.md +5 -5
- package/template/.codex/skills/yss-product-lifecycle/references/orchestration-contract.yaml +20 -4
- package/template/.codex/skills/yss-product-lifecycle/references/orchestration.md +2 -2
- package/template/.codex/skills/yss-product-lifecycle/references/plan-requirements.md +10 -0
- package/template/.codex/skills/yss-product-lifecycle/references/state-model.md +1 -1
- package/template/.codex/skills/yss-research/SKILL.md +4 -0
- package/template/.cursor/skills/codebase-design/SKILL.md +4 -0
- package/template/.cursor/skills/{improve-codebase-architecture/SKILL.md → codebase-design/references/architecture-audit.md} +3 -9
- package/template/.cursor/skills/frontend-commit/SKILL.md +4 -93
- package/template/.cursor/skills/git-commit-core/SKILL.md +18 -0
- package/template/.cursor/skills/java-backend-commit/SKILL.md +4 -96
- package/template/.cursor/skills/llm-wiki/SKILL.md +12 -13
- package/template/.cursor/skills/llm-wiki/assets/CLAUDE.md.template +7 -1
- package/template/.cursor/skills/llm-wiki/references/compile.md +21 -114
- package/template/.cursor/skills/llm-wiki/references/ingest.md +8 -33
- package/template/.cursor/skills/llm-wiki/references/lint.md +9 -46
- package/template/.cursor/skills/llm-wiki/references/query.md +9 -18
- package/template/.cursor/skills/llm-wiki/references/schema.md +56 -29
- package/template/.cursor/skills/llm-wiki/references/transactions.md +48 -0
- package/template/.cursor/skills/llm-wiki/references/writing.md +4 -4
- package/template/.cursor/skills/llm-wiki/scripts/advise.mjs +46 -58
- package/template/.cursor/skills/llm-wiki/scripts/advise.test.mjs +11 -16
- package/template/.cursor/skills/llm-wiki/scripts/core.mjs +262 -0
- package/template/.cursor/skills/llm-wiki/scripts/extract.mjs +35 -18
- package/template/.cursor/skills/llm-wiki/scripts/extract.test.mjs +5 -8
- package/template/.cursor/skills/llm-wiki/scripts/feedback.mjs +51 -0
- package/template/.cursor/skills/llm-wiki/scripts/inventory.mjs +43 -171
- package/template/.cursor/skills/llm-wiki/scripts/inventory.test.mjs +25 -18
- package/template/.cursor/skills/llm-wiki/scripts/lint-wikilinks.mjs +69 -92
- package/template/.cursor/skills/llm-wiki/scripts/lint-wikilinks.test.mjs +25 -37
- package/template/.cursor/skills/llm-wiki/scripts/migrate.mjs +51 -0
- package/template/.cursor/skills/llm-wiki/scripts/query.mjs +149 -0
- package/template/.cursor/skills/llm-wiki/scripts/regressions.test.mjs +101 -0
- package/template/.cursor/skills/llm-wiki/scripts/sources.mjs +166 -0
- package/template/.cursor/skills/llm-wiki/scripts/transaction.mjs +384 -0
- package/template/.cursor/skills/llm-wiki/scripts/v2.test.mjs +354 -0
- package/template/.cursor/skills/prototype/LOGIC.md +1 -1
- package/template/.cursor/skills/prototype/SKILL.md +5 -19
- package/template/.cursor/skills/setup-matt-pocock-skills/SKILL.md +3 -3
- package/template/.cursor/skills/yss-implementation-contract-compiler/SKILL.md +2 -0
- package/template/.cursor/skills/yss-implementation-contract-compiler/references/boundaries.md +2 -3
- package/template/.cursor/skills/yss-implementation-contract-compiler/references/yss-skill-execution-result.md +14 -0
- package/template/.cursor/skills/yss-product-lifecycle/SKILL.md +8 -8
- package/template/.cursor/skills/yss-product-lifecycle/references/external-input-questionnaire.md +19 -0
- package/template/.cursor/skills/yss-product-lifecycle/references/matt-yss-adapter.md +5 -5
- package/template/.cursor/skills/yss-product-lifecycle/references/orchestration-contract.yaml +20 -4
- package/template/.cursor/skills/yss-product-lifecycle/references/orchestration.md +2 -2
- package/template/.cursor/skills/yss-product-lifecycle/references/plan-requirements.md +10 -0
- package/template/.cursor/skills/yss-product-lifecycle/references/state-model.md +1 -1
- package/template/.cursor/skills/yss-research/SKILL.md +4 -0
- package/template/.pi/skills/codebase-design/SKILL.md +4 -0
- package/template/{.agents/skills/improve-codebase-architecture/SKILL.md → .pi/skills/codebase-design/references/architecture-audit.md} +3 -9
- package/template/.pi/skills/frontend-commit/SKILL.md +4 -93
- package/template/.pi/skills/git-commit-core/SKILL.md +18 -0
- package/template/.pi/skills/java-backend-commit/SKILL.md +4 -96
- package/template/.pi/skills/llm-wiki/SKILL.md +12 -13
- package/template/.pi/skills/llm-wiki/assets/CLAUDE.md.template +7 -1
- package/template/.pi/skills/llm-wiki/references/compile.md +21 -114
- package/template/.pi/skills/llm-wiki/references/ingest.md +8 -33
- package/template/.pi/skills/llm-wiki/references/lint.md +9 -46
- package/template/.pi/skills/llm-wiki/references/query.md +9 -18
- package/template/.pi/skills/llm-wiki/references/schema.md +56 -29
- package/template/.pi/skills/llm-wiki/references/transactions.md +48 -0
- package/template/.pi/skills/llm-wiki/references/writing.md +4 -4
- package/template/.pi/skills/llm-wiki/scripts/advise.mjs +46 -58
- package/template/.pi/skills/llm-wiki/scripts/advise.test.mjs +11 -16
- package/template/.pi/skills/llm-wiki/scripts/core.mjs +262 -0
- package/template/.pi/skills/llm-wiki/scripts/extract.mjs +35 -18
- package/template/.pi/skills/llm-wiki/scripts/extract.test.mjs +5 -8
- package/template/.pi/skills/llm-wiki/scripts/feedback.mjs +51 -0
- package/template/.pi/skills/llm-wiki/scripts/inventory.mjs +43 -171
- package/template/.pi/skills/llm-wiki/scripts/inventory.test.mjs +25 -18
- package/template/.pi/skills/llm-wiki/scripts/lint-wikilinks.mjs +69 -92
- package/template/.pi/skills/llm-wiki/scripts/lint-wikilinks.test.mjs +25 -37
- package/template/.pi/skills/llm-wiki/scripts/migrate.mjs +51 -0
- package/template/.pi/skills/llm-wiki/scripts/query.mjs +149 -0
- package/template/.pi/skills/llm-wiki/scripts/regressions.test.mjs +101 -0
- package/template/.pi/skills/llm-wiki/scripts/sources.mjs +166 -0
- package/template/.pi/skills/llm-wiki/scripts/transaction.mjs +384 -0
- package/template/.pi/skills/llm-wiki/scripts/v2.test.mjs +354 -0
- package/template/.pi/skills/prototype/LOGIC.md +1 -1
- package/template/.pi/skills/prototype/SKILL.md +5 -19
- package/template/.pi/skills/setup-matt-pocock-skills/SKILL.md +3 -3
- package/template/.pi/skills/yss-implementation-contract-compiler/SKILL.md +2 -0
- package/template/.pi/skills/yss-implementation-contract-compiler/references/boundaries.md +2 -3
- package/template/.pi/skills/yss-implementation-contract-compiler/references/yss-skill-execution-result.md +14 -0
- package/template/.pi/skills/yss-product-lifecycle/SKILL.md +8 -8
- package/template/.pi/skills/yss-product-lifecycle/references/external-input-questionnaire.md +19 -0
- package/template/.pi/skills/yss-product-lifecycle/references/matt-yss-adapter.md +5 -5
- package/template/.pi/skills/yss-product-lifecycle/references/orchestration-contract.yaml +20 -4
- package/template/.pi/skills/yss-product-lifecycle/references/orchestration.md +2 -2
- package/template/.pi/skills/yss-product-lifecycle/references/plan-requirements.md +10 -0
- package/template/.pi/skills/yss-product-lifecycle/references/state-model.md +1 -1
- package/template/.pi/skills/yss-research/SKILL.md +4 -0
- package/template/.template-spec/agents/README.md +1 -1
- package/template/.template-spec/agents/digital-human-roles.yaml +1 -1
- package/template/.template-spec/agents/skill-migrations.md +15 -0
- package/template/.template-spec/agents/yss-skill-registry.yaml +10 -29
- package/template/.template-spec/architecture/README.md +3 -34
- package/template/.template-spec/plan/templates/competitive-analysis-template.md +2 -2
- package/template/.template-spec/process/contract-reading.md +24 -0
- package/template/.template-spec/process/lifecycle-registry-baseline.json +3 -1
- package/template/.template-spec/process/lifecycle-registry.yaml +6 -0
- package/template/.template-spec/process/research-completion.md +23 -0
- package/template/.template-spec/process/schemas/digital-human-task-package.schema.json +202 -12
- package/template/.template-spec/process/schemas/frontend-implementation-evidence.schema.json +7 -15
- package/template/.template-spec/process/subagent-collaboration.md +8 -0
- package/template/.template-spec/process/templates/frontend-implementation-verification-template.yaml +15 -1
- package/template/AGENTS.md +1 -1
- package/template/CONTEXT.md +5 -1
- package/template/README.md +12 -24
- package/template/scripts/contract +5 -5
- package/template/scripts/lib/contract-views.mjs +57 -2
- package/template/scripts/lib/execution-evidence.mjs +51 -0
- package/template/scripts/lib/harness-execution-scope.mjs +1 -1
- package/template/scripts/lib/implementation-contract-compiler.mjs +2 -0
- package/template/scripts/lib/lifecycle-context-query.mjs +15 -3
- package/template/scripts/lib/lifecycle-status.mjs +32 -6
- package/template/scripts/lib/lifecycle-transition.mjs +19 -1
- package/template/scripts/lib/maintenance-research.mjs +63 -0
- package/template/scripts/lib/read-only-intake.mjs +132 -0
- package/template/scripts/lib/skill-registry.mjs +2 -1
- package/template/scripts/lib/skill-supply-chain.mjs +4 -0
- package/template/scripts/lib/slice-task-package.mjs +1 -1
- package/template/scripts/lib/task-package.mjs +9 -2
- package/template/scripts/lifecycle-status +2 -2
- package/template/scripts/prepare-read-only-intake +16 -0
- package/template/scripts/run-read-only-intake +14 -0
- package/template/scripts/verify-digital-human-task-package +2 -2
- package/template/scripts/verify-frontend-implementation-evidence +24 -1
- package/template/scripts/verify-maintenance-research +13 -0
- package/template/skills-lock.json +19 -76
- package/template.manifest.json +118 -29
- package/template.snapshot.json +5 -6
- package/template/.agents/skills/grill-with-docs/SKILL.md +0 -20
- package/template/.agents/skills/grill-with-docs/agents/openai.yaml +0 -5
- package/template/.agents/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/template/.agents/skills/prototype/UI.md +0 -112
- package/template/.agents/skills/setup-matt-pocock-skills/domain.md +0 -37
- package/template/.agents/skills/to-questionnaire/SKILL.md +0 -55
- package/template/.agents/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/template/.agents/skills/wait-what/SKILL.md +0 -7
- package/template/.agents/skills/wait-what/agents/openai.yaml +0 -5
- package/template/.codex/skills/data-analytics/.app.json +0 -84
- package/template/.codex/skills/data-analytics/.codex-plugin/plugin.json +0 -66
- package/template/.codex/skills/data-analytics/.mcp.json +0 -30
- package/template/.codex/skills/data-analytics/AGENTS.md +0 -20
- package/template/.codex/skills/data-analytics/DEPENDENCIES.MD +0 -27
- package/template/.codex/skills/data-analytics/README.md +0 -60
- package/template/.codex/skills/data-analytics/__yss_dotfile__.gitignore +0 -2
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html +0 -16
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part001 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part002 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part003 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part004 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part005 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-artifact-widget.html.gz.b64.part006 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html +0 -16
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part001 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part002 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part003 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part004 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part005 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part006 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-chart-widget.html.gz.b64.part007 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-small.svg +0 -5
- package/template/.codex/skills/data-analytics/assets/datascience-table-widget.html +0 -16
- package/template/.codex/skills/data-analytics/assets/datascience-table-widget.html.gz.b64.part001 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-table-widget.html.gz.b64.part002 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-table-widget.html.gz.b64.part003 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience-table-widget.html.gz.b64.part004 +0 -1
- package/template/.codex/skills/data-analytics/assets/datascience.png +0 -0
- package/template/.codex/skills/data-analytics/assets/datascience.svg +0 -10
- package/template/.codex/skills/data-analytics/mcp/server.cjs +0 -2964
- package/template/.codex/skills/data-analytics/package-lock.json +0 -3048
- package/template/.codex/skills/data-analytics/package.json +0 -43
- package/template/.codex/skills/data-analytics/scripts/normalize-widget-assets.mjs +0 -75
- package/template/.codex/skills/data-analytics/skills/analyze-data-quality/SKILL.md +0 -137
- package/template/.codex/skills/data-analytics/skills/analyze-data-quality/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/analyze-data-quality/references/quality-checks.md +0 -29
- package/template/.codex/skills/data-analytics/skills/build-dashboard/SKILL.md +0 -148
- package/template/.codex/skills/data-analytics/skills/build-dashboard/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/build-dashboard/specifications/bi-platform-dashboard.md +0 -18
- package/template/.codex/skills/data-analytics/skills/build-dashboard/specifications/html-dashboard.md +0 -24
- package/template/.codex/skills/data-analytics/skills/build-dashboard/specifications/mcp-artifact-dashboard.md +0 -71
- package/template/.codex/skills/data-analytics/skills/build-dashboard/specifications/streamlit-dashboard.md +0 -85
- package/template/.codex/skills/data-analytics/skills/build-report/SKILL.md +0 -207
- package/template/.codex/skills/data-analytics/skills/build-report/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/build-report/assets/executive-report-shell.html +0 -70
- package/template/.codex/skills/data-analytics/skills/build-report/assets/technical-report-shell.html +0 -66
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/SKILL.md +0 -108
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/__init__.py +0 -1
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/cli.py +0 -52
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/constants.py +0 -61
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/docx_writer.py +0 -362
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/html_parser.py +0 -829
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/model.py +0 -30
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/plan.py +0 -127
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/quality.py +0 -374
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/rendering.py +0 -613
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/table_utils.py +0 -54
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc/utils.py +0 -16
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/scripts/report_to_google_doc_plan.py +0 -9
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-doc/tests/test_delivery_plan.py +0 -45
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-slides/SKILL.md +0 -77
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-slides/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-google-slides/scripts/report_to_google_slides.py +0 -2379
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-pdf/SKILL.md +0 -88
- package/template/.codex/skills/data-analytics/skills/build-report/report-to-pdf/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/build-report/specifications/executive-report.md +0 -97
- package/template/.codex/skills/data-analytics/skills/build-report/specifications/mcp-app-report.md +0 -59
- package/template/.codex/skills/data-analytics/skills/build-report/specifications/technical-report.md +0 -75
- package/template/.codex/skills/data-analytics/skills/design-kpis/SKILL.md +0 -103
- package/template/.codex/skills/data-analytics/skills/design-kpis/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/gather-business-context/SKILL.md +0 -68
- package/template/.codex/skills/data-analytics/skills/gather-business-context/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/index/SKILL.md +0 -251
- package/template/.codex/skills/data-analytics/skills/index/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/jupyter-notebooks/SKILL.md +0 -131
- package/template/.codex/skills/data-analytics/skills/jupyter-notebooks/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/kpi-reporting/SKILL.md +0 -141
- package/template/.codex/skills/data-analytics/skills/kpi-reporting/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/kpi-reporting/references/report-templates.md +0 -32
- package/template/.codex/skills/data-analytics/skills/market-sizing/SKILL.md +0 -106
- package/template/.codex/skills/data-analytics/skills/market-sizing/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/metric-diagnostics/SKILL.md +0 -130
- package/template/.codex/skills/data-analytics/skills/metric-diagnostics/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/product-business-analysis/SKILL.md +0 -141
- package/template/.codex/skills/data-analytics/skills/product-business-analysis/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/spreadsheets/SKILL.md +0 -178
- package/template/.codex/skills/data-analytics/skills/spreadsheets/agents/openai.yaml +0 -9
- package/template/.codex/skills/data-analytics/skills/spreadsheets/assets/file-spreadsheet.png +0 -0
- package/template/.codex/skills/data-analytics/skills/spreadsheets/charts.md +0 -31
- package/template/.codex/skills/data-analytics/skills/spreadsheets/references/artifact_tool_api.md +0 -466
- package/template/.codex/skills/data-analytics/skills/spreadsheets/style_guidelines.md +0 -99
- package/template/.codex/skills/data-analytics/skills/user-context/SKILL.md +0 -197
- package/template/.codex/skills/data-analytics/skills/user-context/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/user-context/plugin-author-config/automation-config.md +0 -26
- package/template/.codex/skills/data-analytics/skills/user-context/plugin-author-config/source-category-config.json +0 -51
- package/template/.codex/skills/data-analytics/skills/user-context/plugin-author-config/user-context-config.md +0 -66
- package/template/.codex/skills/data-analytics/skills/user-context/references/automation.md +0 -69
- package/template/.codex/skills/data-analytics/skills/user-context/references/onboarding-examples.md +0 -204
- package/template/.codex/skills/data-analytics/skills/user-context/references/onboarding-state-template.json +0 -87
- package/template/.codex/skills/data-analytics/skills/user-context/references/onboarding.md +0 -497
- package/template/.codex/skills/data-analytics/skills/user-context/references/semantic-layer/connector-playbook.md +0 -74
- package/template/.codex/skills/data-analytics/skills/user-context/references/semantic-layer/setup.md +0 -65
- package/template/.codex/skills/data-analytics/skills/user-context/references/semantic-layer/skill-template.md +0 -160
- package/template/.codex/skills/data-analytics/skills/user-context/references/semantic-layer/source-intake.md +0 -75
- package/template/.codex/skills/data-analytics/skills/user-context/references/semantic-layer/weekly-polling-automation.md +0 -96
- package/template/.codex/skills/data-analytics/skills/user-context/references/source-category-runtime.md +0 -263
- package/template/.codex/skills/data-analytics/skills/user-context/scripts/data_analytics_preflight.py +0 -1462
- package/template/.codex/skills/data-analytics/skills/user-context/scripts/init_user_context_state.py +0 -128
- package/template/.codex/skills/data-analytics/skills/user-context/scripts/reset_user_context_state.py +0 -101
- package/template/.codex/skills/data-analytics/skills/user-context/scripts/validate_user_context_preflight.py +0 -499
- package/template/.codex/skills/data-analytics/skills/user-context/tests/test_state_helpers.py +0 -978
- package/template/.codex/skills/data-analytics/skills/validate-data/SKILL.md +0 -126
- package/template/.codex/skills/data-analytics/skills/validate-data/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/validate-data/references/validation-methods.md +0 -70
- package/template/.codex/skills/data-analytics/skills/visualize-data/SKILL.md +0 -157
- package/template/.codex/skills/data-analytics/skills/visualize-data/agents/openai.yaml +0 -6
- package/template/.codex/skills/data-analytics/skills/visualize-data/references/seaborn-templates.md +0 -774
- package/template/.codex/skills/data-analytics/src/DESIGN.md +0 -222
- package/template/.codex/skills/data-analytics/src/analytics-app/App.tsx +0 -3666
- package/template/.codex/skills/data-analytics/src/analytics-app/analytics-layout.test.mjs +0 -136
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/ChartFrame.tsx +0 -54
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/ChartLegend.tsx +0 -96
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/ChartRenderer.tsx +0 -1647
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/ChartTooltip.tsx +0 -245
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-app-helpers.tsx +0 -462
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-capabilities.ts +0 -107
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-compatibility.ts +0 -164
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-contract.ts +0 -192
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-theme.ts +0 -203
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-tokens.css +0 -619
- package/template/.codex/skills/data-analytics/src/analytics-app/charting/chart-transforms.ts +0 -402
- package/template/.codex/skills/data-analytics/src/analytics-app/fonts/SystemSansVariableVF.woff2 +0 -0
- package/template/.codex/skills/data-analytics/src/analytics-app/imageExport.ts +0 -370
- package/template/.codex/skills/data-analytics/src/analytics-app/layout/AnalyticsLayoutCanvas.tsx +0 -536
- package/template/.codex/skills/data-analytics/src/analytics-app/layout/RichMarkdown.tsx +0 -681
- package/template/.codex/skills/data-analytics/src/analytics-app/layout/analyticsLayoutCore.ts +0 -164
- package/template/.codex/skills/data-analytics/src/analytics-app/main.tsx +0 -21
- package/template/.codex/skills/data-analytics/src/analytics-app/scripts/chart_contract.py +0 -472
- package/template/.codex/skills/data-analytics/src/analytics-app/scripts/check_analytics_app_runtime_links.py +0 -75
- package/template/.codex/skills/data-analytics/src/analytics-app/scripts/design_contract.py +0 -142
- package/template/.codex/skills/data-analytics/src/analytics-app/scripts/package_utils.py +0 -142
- package/template/.codex/skills/data-analytics/src/analytics-app/scripts/tests/test_package_utils.py +0 -377
- package/template/.codex/skills/data-analytics/src/analytics-app/styles.css +0 -3468
- package/template/.codex/skills/data-analytics/src/analytics-app/tables/DataTable.d.ts +0 -44
- package/template/.codex/skills/data-analytics/src/analytics-app/tables/DataTable.jsx +0 -639
- package/template/.codex/skills/data-analytics/src/analytics-app/tables/data-table.css +0 -327
- package/template/.codex/skills/data-analytics/src/analytics-app/tokens.css +0 -225
- package/template/.codex/skills/data-analytics/src/analytics-app/types.ts +0 -204
- package/template/.codex/skills/data-analytics/src/analytics-app-core.md +0 -85
- package/template/.codex/skills/data-analytics/src/codex-style-contract.md +0 -30
- package/template/.codex/skills/data-analytics/src/datascience-artifact-widget.html +0 -12
- package/template/.codex/skills/data-analytics/src/datascience-artifact-widget.jsx +0 -1008
- package/template/.codex/skills/data-analytics/src/datascience-chart-widget.css +0 -2117
- package/template/.codex/skills/data-analytics/src/datascience-chart-widget.html +0 -122
- package/template/.codex/skills/data-analytics/src/datascience-chart-widget.js +0 -3588
- package/template/.codex/skills/data-analytics/src/datascience-table-widget.css +0 -483
- package/template/.codex/skills/data-analytics/src/datascience-table-widget.html +0 -32
- package/template/.codex/skills/data-analytics/src/datascience-table-widget.js +0 -333
- package/template/.codex/skills/data-analytics/src/mcp-host.js +0 -153
- package/template/.codex/skills/data-analytics/src/recharts-config.js +0 -315
- package/template/.codex/skills/data-analytics/src/recharts-renderer.jsx +0 -294
- package/template/.codex/skills/data-analytics/src/sql-source-view.css +0 -33
- package/template/.codex/skills/data-analytics/src/sql-source-view.js +0 -157
- package/template/.codex/skills/data-analytics/src/styles/codex-theme.css +0 -121
- package/template/.codex/skills/data-analytics/src/table-renderer.jsx +0 -28
- package/template/.codex/skills/data-analytics/tests/chart-transforms.test.mjs +0 -87
- package/template/.codex/skills/data-analytics/tests/funnel-smoke.html +0 -105
- package/template/.codex/skills/data-analytics/tests/inline-widget-compare.html +0 -233
- package/template/.codex/skills/data-analytics/tests/mcp-server.test.mjs +0 -1500
- package/template/.codex/skills/data-analytics/tests/native-style-contract.test.mjs +0 -219
- package/template/.codex/skills/data-analytics/tests/recharts-config.test.mjs +0 -144
- package/template/.codex/skills/data-analytics/tests/recharts-renderer.test.mjs +0 -11
- package/template/.codex/skills/data-analytics/tests/rich-markdown.test.mjs +0 -54
- package/template/.codex/skills/data-analytics/tests/widget-render-harness.html +0 -321
- package/template/.codex/skills/data-analytics/tsconfig.json +0 -19
- package/template/.codex/skills/data-analytics/vite.config.ts +0 -46
- package/template/.codex/skills/grill-with-docs/SKILL.md +0 -20
- package/template/.codex/skills/grill-with-docs/agents/openai.yaml +0 -5
- package/template/.codex/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/template/.codex/skills/prototype/UI.md +0 -112
- package/template/.codex/skills/setup-matt-pocock-skills/domain.md +0 -37
- package/template/.codex/skills/to-questionnaire/SKILL.md +0 -55
- package/template/.codex/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/template/.codex/skills/wait-what/SKILL.md +0 -7
- package/template/.codex/skills/wait-what/agents/openai.yaml +0 -5
- package/template/.cursor/skills/grill-with-docs/SKILL.md +0 -20
- package/template/.cursor/skills/grill-with-docs/agents/openai.yaml +0 -5
- package/template/.cursor/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/template/.cursor/skills/prototype/UI.md +0 -112
- package/template/.cursor/skills/setup-matt-pocock-skills/domain.md +0 -37
- package/template/.cursor/skills/to-questionnaire/SKILL.md +0 -55
- package/template/.cursor/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/template/.cursor/skills/wait-what/SKILL.md +0 -7
- package/template/.cursor/skills/wait-what/agents/openai.yaml +0 -5
- package/template/.pi/skills/grill-with-docs/SKILL.md +0 -20
- package/template/.pi/skills/grill-with-docs/agents/openai.yaml +0 -5
- package/template/.pi/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/template/.pi/skills/prototype/UI.md +0 -112
- package/template/.pi/skills/setup-matt-pocock-skills/domain.md +0 -37
- package/template/.pi/skills/to-questionnaire/SKILL.md +0 -55
- package/template/.pi/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/template/.pi/skills/wait-what/SKILL.md +0 -7
- package/template/.pi/skills/wait-what/agents/openai.yaml +0 -5
- package/template/.template-spec/agents/domain.md +0 -31
- /package/template/.agents/skills/{improve-codebase-architecture → codebase-design/references}/HTML-REPORT.md +0 -0
- /package/template/.codex/skills/{improve-codebase-architecture → codebase-design/references}/HTML-REPORT.md +0 -0
- /package/template/.cursor/skills/{improve-codebase-architecture → codebase-design/references}/HTML-REPORT.md +0 -0
- /package/template/.pi/skills/{improve-codebase-architecture → codebase-design/references}/HTML-REPORT.md +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile, rename, lstat, realpath, mkdir, access } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const STATES = ["current", "stale", "missing", "unverified", "archived"];
|
|
5
|
+
const INFRA = /* @__PURE__ */ new Set(["index.md", "log.md", "claude.md", "agents.md", "soul.md", "concept-table.md"]);
|
|
6
|
+
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
7
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}
|
|
8
|
+
`;
|
|
9
|
+
class WikiError extends Error {
|
|
10
|
+
constructor(code, message) {
|
|
11
|
+
super(`${code}: ${message}`);
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function fail(code, message) {
|
|
16
|
+
throw new WikiError(code, message);
|
|
17
|
+
}
|
|
18
|
+
async function exists(file) {
|
|
19
|
+
try {
|
|
20
|
+
await access(file);
|
|
21
|
+
return true;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
if (e.code === "ENOENT") return false;
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function digestFile(file) {
|
|
28
|
+
try {
|
|
29
|
+
return sha256(await readFile(file));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e.code === "ENOENT") return null;
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function inside(root, target) {
|
|
36
|
+
const r = path.relative(root, target);
|
|
37
|
+
return r === "" || !r.startsWith(`..${path.sep}`) && r !== ".." && !path.isAbsolute(r);
|
|
38
|
+
}
|
|
39
|
+
async function safePath(root, ref, { write = false } = {}) {
|
|
40
|
+
if (typeof ref !== "string" || !ref || ref.includes("\\") || ref.includes("\0") || path.isAbsolute(ref) || ref.split("/").some((x) => ["..", ".", ""].includes(x))) fail("PATH_INVALID", String(ref));
|
|
41
|
+
const base = path.resolve(root), target = path.resolve(base, ref);
|
|
42
|
+
if (!inside(base, target) || target === base) fail("PATH_ESCAPE", ref);
|
|
43
|
+
let baseReal;
|
|
44
|
+
try {
|
|
45
|
+
baseReal = await realpath(base);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e.code !== "ENOENT") throw e;
|
|
48
|
+
const parent = path.dirname(base);
|
|
49
|
+
baseReal = path.join(await realpath(parent), path.basename(base));
|
|
50
|
+
}
|
|
51
|
+
let current = base;
|
|
52
|
+
for (const part of ref.split("/")) {
|
|
53
|
+
current = path.join(current, part);
|
|
54
|
+
let st;
|
|
55
|
+
try {
|
|
56
|
+
st = await lstat(current);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (e.code === "ENOENT") continue;
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
if (st.isSymbolicLink() && write) fail("SYMLINK_WRITE", ref);
|
|
62
|
+
let resolved;
|
|
63
|
+
try {
|
|
64
|
+
resolved = await realpath(current);
|
|
65
|
+
} catch {
|
|
66
|
+
fail("PATH_ESCAPE", `unresolved symlink ${ref}`);
|
|
67
|
+
}
|
|
68
|
+
if (!inside(baseReal, resolved)) fail("PATH_ESCAPE", ref);
|
|
69
|
+
}
|
|
70
|
+
return target;
|
|
71
|
+
}
|
|
72
|
+
async function atomicWrite(file, content) {
|
|
73
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
74
|
+
const temp = `${file}.${randomUUID()}.tmp`;
|
|
75
|
+
await writeFile(temp, content, { flag: "wx" });
|
|
76
|
+
await rename(temp, file);
|
|
77
|
+
}
|
|
78
|
+
function frontmatter(text) {
|
|
79
|
+
if (!text.startsWith("---\n") && !text.startsWith("---\r\n")) return { humanOwned: false, body: text, fields: {} };
|
|
80
|
+
const m = text.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
81
|
+
if (!m) fail("FRONTMATTER_INVALID", "unterminated header");
|
|
82
|
+
const fields = {};
|
|
83
|
+
for (const line of m[1].split(/\r?\n/)) {
|
|
84
|
+
if (!line.trim() || line.trim().startsWith("#")) continue;
|
|
85
|
+
const pair = line.match(/^([\w-]+):\s*(.*?)\s*$/);
|
|
86
|
+
if (!pair) fail("FRONTMATTER_INVALID", "use flat scalar fields");
|
|
87
|
+
if (Object.hasOwn(fields, pair[1])) fail("FRONTMATTER_INVALID", `duplicate ${pair[1]}`);
|
|
88
|
+
fields[pair[1]] = pair[2];
|
|
89
|
+
}
|
|
90
|
+
if (fields["human-owned"] !== void 0 && !["true", "false"].includes(fields["human-owned"])) fail("FRONTMATTER_INVALID", "human-owned must be a boolean");
|
|
91
|
+
return { humanOwned: fields["human-owned"] === "true", fields, body: text.slice(m[0].length) };
|
|
92
|
+
}
|
|
93
|
+
function sourceSection(text) {
|
|
94
|
+
return text.match(/^##\s+来源\s*\r?\n([\s\S]*)/m)?.[1]?.trim() || "";
|
|
95
|
+
}
|
|
96
|
+
function ownership(article, text) {
|
|
97
|
+
const fm = frontmatter(text);
|
|
98
|
+
return { protected: article.humanOwned === true || fm.humanOwned, conflict: article.humanOwned !== void 0 && fm.fields["human-owned"] !== void 0 && article.humanOwned !== fm.humanOwned };
|
|
99
|
+
}
|
|
100
|
+
const array = (v) => Array.isArray(v);
|
|
101
|
+
const unique = (v) => new Set(v).size === v.length;
|
|
102
|
+
const digest = (v) => v === null || /^[a-f0-9]{64}$/.test(v);
|
|
103
|
+
function validateManifest(m) {
|
|
104
|
+
const errors = [];
|
|
105
|
+
const check = (ok, code, detail) => {
|
|
106
|
+
if (!ok) errors.push(`${code}: ${detail}`);
|
|
107
|
+
};
|
|
108
|
+
if (!m || typeof m !== "object" || array(m)) return ["MANIFEST_INVALID: expected object"];
|
|
109
|
+
check([1, 2].includes(m.schemaVersion), "SCHEMA_UNSUPPORTED", m.schemaVersion);
|
|
110
|
+
check(m.profile === void 0 && m.schemaVersion === 1 || ["mixed", "documents", "code"].includes(m.profile), "PROFILE_INVALID", m.profile);
|
|
111
|
+
if (!array(m.sources) || !array(m.articles)) return [...errors, "MANIFEST_INVALID: sources and articles must be arrays"];
|
|
112
|
+
for (const [group, rows] of [["source", m.sources], ["article", m.articles]]) {
|
|
113
|
+
check(rows.every((x) => x && typeof x.id === "string" && x.id.trim() && (group === "source" || !/[\[\]#|/\\]/.test(x.id))), "ID_INVALID", group);
|
|
114
|
+
check(unique(rows.map((x) => x?.id)), "DUPLICATE_ID", group);
|
|
115
|
+
}
|
|
116
|
+
const sources = new Set(m.sources.map((x) => x?.id)), articles = new Set(m.articles.map((x) => x?.id));
|
|
117
|
+
check(unique(m.articles.map((x) => x?.file)), "DUPLICATE_FILE", "articles");
|
|
118
|
+
for (const s of m.sources) {
|
|
119
|
+
if (!s || typeof s !== "object") continue;
|
|
120
|
+
check(["document", "derived", "code-surface"].includes(s.kind), "SOURCE_KIND", s.id);
|
|
121
|
+
if (s.kind === "code-surface") check(typeof s.livePath === "string" && s.livePath.length > 0, "LIVE_PATH_REQUIRED", s.id);
|
|
122
|
+
check(!(m.profile === "documents" && s.kind === "code-surface"), "PROFILE KIND", s.id + " code-surface");
|
|
123
|
+
check(s.kind === "code-surface" ? s.rawPath == null : typeof s.rawPath === "string" && s.rawPath.length > 0, s.kind === "code-surface" ? "RAW PATH FORBIDDEN" : "RAW PATH REQUIRED", s.id);
|
|
124
|
+
if (s.kind === "derived") {
|
|
125
|
+
if (m.schemaVersion === 2 && s.extract?.kind === "prose-note") check(typeof s.extract.rules === "string" && s.extract.rules.length > 0 && s.extract.inputDigests && typeof s.extract.inputDigests === "object", "EXTRACT_RULES", s.id);
|
|
126
|
+
check(!!s.extract?.kind, "EXTRACT REQUIRED", s.id);
|
|
127
|
+
if (s.extract?.kind) check(["skill-names", "heading-list", "prose-note"].includes(s.extract.kind), "EXTRACT KIND", `${s.id} ${s.extract.kind}`);
|
|
128
|
+
if (m.schemaVersion === 2) {
|
|
129
|
+
check(typeof s.extract?.version === "string" && !!s.extract.version, "EXTRACT_VERSION", s.id);
|
|
130
|
+
check(array(s.extract?.inputs) && s.extract.inputs.length > 0 && unique(s.extract.inputs), "EXTRACT_INPUTS", s.id);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (s.status !== void 0) check(STATES.includes(s.status), "STATUS_INVALID", s.id);
|
|
134
|
+
if (m.schemaVersion === 2) {
|
|
135
|
+
for (const k of ["originalDigest", "effectiveDigest", "rawDigest"]) check(Object.hasOwn(s, k) && digest(s[k]), "DIGEST_INVALID", `${s.id}.${k}`);
|
|
136
|
+
check(typeof s.location === "string" && s.location.length > 0, "LOCATION_REQUIRED", s.id);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const a of m.articles) {
|
|
140
|
+
if (!a || typeof a !== "object") continue;
|
|
141
|
+
check(a.file === `wiki/${a.id}.md` && !INFRA.has(`${a.id}.md`.toLowerCase()), "MANIFEST ID MISMATCH", a.id);
|
|
142
|
+
check(array(a.sourceIds) && unique(a.sourceIds), "SOURCE_REFS_INVALID", a.id);
|
|
143
|
+
check(array(a.sourceIds) && (a.sourceIds.length > 0 || array(a.dependsOnArticles) && a.dependsOnArticles.length > 0), "EMPTY_SOURCE_REFS", a.id);
|
|
144
|
+
for (const id of array(a.sourceIds) ? a.sourceIds : []) check(sources.has(id), "UNKNOWN SOURCE ID", `${a.id} -> ${id}`);
|
|
145
|
+
if (a.dependsOnArticles !== void 0) check(array(a.dependsOnArticles) && unique(a.dependsOnArticles), "DEPENDENCIES_INVALID", a.id);
|
|
146
|
+
for (const id of array(a.dependsOnArticles) ? a.dependsOnArticles : []) check(articles.has(id), "UNKNOWN_ARTICLE_ID", `${a.id} -> ${id}`);
|
|
147
|
+
if (a.aliases !== void 0) check(array(a.aliases) && a.aliases.every((x) => typeof x === "string" && x.trim()), "ALIASES_INVALID", a.id);
|
|
148
|
+
if (a.humanOwned !== void 0) check(typeof a.humanOwned === "boolean", "OWNERSHIP_INVALID", a.id);
|
|
149
|
+
if (a.verification !== void 0 && a.verification !== null) check(a.verification && typeof a.verification === "object" && array(a.verification.evidence) && a.verification.evidence.every((e) => e && typeof e === "object" && sources.has(e.sourceId) && ["general", "critical"].includes(e.risk) && typeof e.claim === "string" && e.claim.length > 0 && digest(e.excerptDigest) && e.excerptDigest !== null && typeof e.inputPath === "string" && Number.isInteger(e.startLine) && e.startLine > 0 && Number.isInteger(e.endLine) && e.endLine >= e.startLine) && digest(a.verification.articleDigest) && a.verification.articleDigest !== null, "EVIDENCE_INVALID", a.id);
|
|
150
|
+
if (a.status !== void 0) check(STATES.includes(a.status), "STATUS_INVALID", a.id);
|
|
151
|
+
if (m.schemaVersion === 2) {
|
|
152
|
+
check(digest(a.articleDigest) && Object.hasOwn(a, "articleDigest"), "DIGEST_INVALID", a.id);
|
|
153
|
+
check(a.compiledFrom && typeof a.compiledFrom === "object" && !array(a.compiledFrom), "COMPILED_FROM_INVALID", a.id);
|
|
154
|
+
for (const [id, binding] of Object.entries(a.compiledFrom || {})) {
|
|
155
|
+
check(sources.has(id) && binding && digest(binding.effectiveDigest) && binding.effectiveDigest !== null, "COMPILED_FROM_INVALID", `${a.id}:${id}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (errors.length === 0) {
|
|
160
|
+
try {
|
|
161
|
+
for (const a of m.articles) sourceClosure(m, a.id);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
errors.push(e.message);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (m.feedback !== void 0) {
|
|
167
|
+
check(array(m.feedback), "FEEDBACK_INVALID", "expected array");
|
|
168
|
+
if (array(m.feedback)) {
|
|
169
|
+
check(unique(m.feedback.map((f) => f?.id)), "DUPLICATE_ID", "feedback");
|
|
170
|
+
for (const f of m.feedback) {
|
|
171
|
+
if (!f || typeof f !== "object") {
|
|
172
|
+
errors.push("FEEDBACK_INVALID: expected object");
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
check(typeof f.id === "string" && f.id.length > 0 && articles.has(f.articleId) && digest(f.targetDigest) && f.targetDigest !== null && typeof f.issue === "string" && f.issue.trim() && f.locator && typeof f.locator.quote === "string" && f.locator.quote.length > 0, "FEEDBACK_INVALID", f.id);
|
|
176
|
+
check(["open", "accepted", "partial", "rejected", "deferred"].includes(f.status), "FEEDBACK_STATUS", f.id);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return errors;
|
|
181
|
+
}
|
|
182
|
+
function sourceClosure(m, id, trail = []) {
|
|
183
|
+
if (trail.includes(id)) fail("DEPENDENCY_CYCLE", [...trail, id].join(" -> "));
|
|
184
|
+
const a = m.articles.find((x) => x.id === id);
|
|
185
|
+
if (!a) fail("UNKNOWN_ARTICLE_ID", id);
|
|
186
|
+
return [.../* @__PURE__ */ new Set([...a.sourceIds || [], ...(a.dependsOnArticles || []).flatMap((dep) => sourceClosure(m, dep, [...trail, id]))])].sort();
|
|
187
|
+
}
|
|
188
|
+
async function checkPaths(m, { wikiRoot, repoRoot }) {
|
|
189
|
+
for (const s of m.sources) {
|
|
190
|
+
for (const ref of [s.livePath, ...s.extract?.inputs || []].filter(Boolean)) await safePath(repoRoot, ref);
|
|
191
|
+
if (s.rawPath) await safePath(wikiRoot, s.rawPath);
|
|
192
|
+
}
|
|
193
|
+
for (const a of m.articles) await safePath(wikiRoot, a.file);
|
|
194
|
+
}
|
|
195
|
+
async function loadManifest(wikiRoot, { repoRoot = process.cwd(), validate = true } = {}) {
|
|
196
|
+
const m = JSON.parse(await readFile(await safePath(wikiRoot, ".wiki-manifest.json"), "utf8"));
|
|
197
|
+
if (validate) {
|
|
198
|
+
const errors = validateManifest(m);
|
|
199
|
+
if (errors.length) fail("MANIFEST_INVALID", errors.join("\n"));
|
|
200
|
+
await checkPaths(m, { wikiRoot, repoRoot });
|
|
201
|
+
}
|
|
202
|
+
return m;
|
|
203
|
+
}
|
|
204
|
+
async function transactionState(wikiRoot, { reader } = {}) {
|
|
205
|
+
// A writer claims the lock before replacing an earlier finalized journal.
|
|
206
|
+
// That interval must also block readers.
|
|
207
|
+
if (await exists(await safePath(wikiRoot, ".wiki-lock"))) return { state: "locked", incomplete: true };
|
|
208
|
+
const file = await safePath(wikiRoot, ".wiki-transaction.json");
|
|
209
|
+
if (!await exists(file)) return { state: "none" };
|
|
210
|
+
const j = JSON.parse(reader ? (await reader(file)).toString() : await readFile(file, "utf8"));
|
|
211
|
+
return { id: j.id, state: j.phase, incomplete: !["finalized", "aborted"].includes(j.phase) };
|
|
212
|
+
}
|
|
213
|
+
async function assertReadable(wikiRoot, reader) {
|
|
214
|
+
const tx = await transactionState(wikiRoot, { reader });
|
|
215
|
+
if (tx.incomplete || tx.state === "locked") fail("TRANSACTION_INCOMPLETE", "explicit resume or abort required; query never recovers");
|
|
216
|
+
return tx;
|
|
217
|
+
}
|
|
218
|
+
function cliError(e) {
|
|
219
|
+
process.stderr.write(`${JSON.stringify({ ok: false, code: e.code || "EXECUTION_ERROR", message: e.message })}
|
|
220
|
+
`);
|
|
221
|
+
process.exitCode = 2;
|
|
222
|
+
}
|
|
223
|
+
function args(argv, commands = []) {
|
|
224
|
+
const result = { command: commands.length ? argv.shift() : void 0, repo: process.cwd() };
|
|
225
|
+
if (commands.length && !commands.includes(result.command)) fail("USAGE", commands.join("|"));
|
|
226
|
+
while (argv.length) {
|
|
227
|
+
const a = argv.shift();
|
|
228
|
+
if (a === "--apply" || a === "--structure-only") {
|
|
229
|
+
result[a.slice(2)] = true;
|
|
230
|
+
} else if (a.startsWith("--")) {
|
|
231
|
+
if (!argv.length || argv[0].startsWith("--")) fail("USAGE", `value required ${a}`);
|
|
232
|
+
const key = a.slice(2);
|
|
233
|
+
if (key === "candidate") (result.candidates ??= []).push(argv.shift());
|
|
234
|
+
else result[key] = argv.shift();
|
|
235
|
+
} else if (!result.wiki) result.wiki = a;
|
|
236
|
+
else fail("USAGE", a);
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
INFRA,
|
|
242
|
+
STATES,
|
|
243
|
+
WikiError,
|
|
244
|
+
args,
|
|
245
|
+
assertReadable,
|
|
246
|
+
atomicWrite,
|
|
247
|
+
checkPaths,
|
|
248
|
+
cliError,
|
|
249
|
+
digestFile,
|
|
250
|
+
exists,
|
|
251
|
+
fail,
|
|
252
|
+
frontmatter,
|
|
253
|
+
json,
|
|
254
|
+
loadManifest,
|
|
255
|
+
ownership,
|
|
256
|
+
safePath,
|
|
257
|
+
sha256,
|
|
258
|
+
sourceClosure,
|
|
259
|
+
sourceSection,
|
|
260
|
+
transactionState,
|
|
261
|
+
validateManifest
|
|
262
|
+
};
|
|
@@ -2,15 +2,27 @@
|
|
|
2
2
|
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { safePath, cliError } from "./core.mjs";
|
|
6
|
+
const EXTRACT_KINDS = Object.freeze(["skill-names", "heading-list", "prose-note"]);
|
|
7
|
+
function extractHeadings(text, input = "") {
|
|
8
|
+
const lines = [`# heading-list${input ? `: ${input}` : ""}`, ""];
|
|
9
|
+
let fence = null;
|
|
10
|
+
for (const [index, line] of text.split(/\r?\n/).entries()) {
|
|
11
|
+
const marker = line.match(/^\s*(`{3,}|~{3,})/);
|
|
12
|
+
if (marker) {
|
|
13
|
+
if (!fence) fence = marker[1][0];
|
|
14
|
+
else if (fence === marker[1][0]) fence = null;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!fence && /^#{1,6}\s+\S/.test(line)) lines.push(`- L${index + 1}: ${line.trim()}`);
|
|
18
|
+
}
|
|
19
|
+
return lines.join("\n") + "\n";
|
|
20
|
+
}
|
|
8
21
|
function namesOf(value) {
|
|
9
22
|
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
10
23
|
return Object.keys(value).sort((a, b) => a.localeCompare(b));
|
|
11
24
|
}
|
|
12
|
-
|
|
13
|
-
export function extractSkillNames(lock) {
|
|
25
|
+
function extractSkillNames(lock) {
|
|
14
26
|
if (!lock || typeof lock !== "object" || Array.isArray(lock)) {
|
|
15
27
|
throw new TypeError("skill-names input must be a lock object");
|
|
16
28
|
}
|
|
@@ -27,9 +39,9 @@ export function extractSkillNames(lock) {
|
|
|
27
39
|
lines.push("");
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
|
-
return `${lines.join("\n").replace(/\n+$/, "")}
|
|
42
|
+
return `${lines.join("\n").replace(/\n+$/, "")}
|
|
43
|
+
`;
|
|
31
44
|
}
|
|
32
|
-
|
|
33
45
|
async function main(argv = process.argv.slice(2)) {
|
|
34
46
|
const kind = argv[0];
|
|
35
47
|
let input;
|
|
@@ -38,18 +50,23 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
38
50
|
if (argv[i] === "--in") input = argv[++i];
|
|
39
51
|
else if (argv[i] === "--out") output = argv[++i];
|
|
40
52
|
}
|
|
41
|
-
if (
|
|
42
|
-
throw new Error("usage: extract.mjs skill-names --in <lock.json> --out <raw.md>");
|
|
53
|
+
if (!["skill-names", "heading-list"].includes(kind) || !input || !output) {
|
|
54
|
+
throw new Error("usage: extract.mjs skill-names|heading-list --in <lock.json> --out <raw.md>");
|
|
43
55
|
}
|
|
44
|
-
const
|
|
45
|
-
await
|
|
46
|
-
await
|
|
47
|
-
|
|
56
|
+
const inputFile = await safePath(process.cwd(), input);
|
|
57
|
+
const outputFile = await safePath(process.cwd(), output, { write: true });
|
|
58
|
+
const content = await readFile(inputFile, "utf8");
|
|
59
|
+
const text = kind === "skill-names" ? extractSkillNames(JSON.parse(content)) : extractHeadings(content, input);
|
|
60
|
+
await mkdir(path.dirname(outputFile), { recursive: true });
|
|
61
|
+
await writeFile(outputFile, text, "utf8");
|
|
62
|
+
process.stdout.write(`${output}
|
|
63
|
+
`);
|
|
48
64
|
}
|
|
49
|
-
|
|
50
65
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
51
|
-
main().catch(
|
|
52
|
-
process.stderr.write(`${error.message}\n`);
|
|
53
|
-
process.exitCode = 2;
|
|
54
|
-
});
|
|
66
|
+
main().catch(cliError);
|
|
55
67
|
}
|
|
68
|
+
export {
|
|
69
|
+
EXTRACT_KINDS,
|
|
70
|
+
extractHeadings,
|
|
71
|
+
extractSkillNames
|
|
72
|
+
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { EXTRACT_KINDS, extractSkillNames } from "./extract.mjs";
|
|
4
|
-
|
|
5
4
|
test("skill-names lists shared and platform keys, sorted, without hashes", () => {
|
|
6
5
|
const text = extractSkillNames({
|
|
7
6
|
skills: {
|
|
8
7
|
shared: {
|
|
9
8
|
zeta: { effectiveHash: "aaa", skillPath: "hidden" },
|
|
10
|
-
alpha: { effectiveHash: "bbb" }
|
|
9
|
+
alpha: { effectiveHash: "bbb" }
|
|
11
10
|
},
|
|
12
11
|
platform: {
|
|
13
12
|
".codex/skills": {
|
|
14
13
|
"product-design": { effectiveHash: "ccc" },
|
|
15
|
-
"data-analytics": { effectiveHash: "ddd" }
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
14
|
+
"data-analytics": { effectiveHash: "ddd" }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
19
18
|
});
|
|
20
19
|
assert.match(text, /## shared/);
|
|
21
20
|
assert.match(text, /## platform/);
|
|
@@ -24,11 +23,9 @@ test("skill-names lists shared and platform keys, sorted, without hashes", () =>
|
|
|
24
23
|
assert.doesNotMatch(text, /aaa|bbb|ccc|ddd|skillPath|effectiveHash/);
|
|
25
24
|
assert.doesNotMatch(text, /"version"|canonicalRoot/);
|
|
26
25
|
});
|
|
27
|
-
|
|
28
26
|
test("skill-names rejects a whole-file dump of a non-object", () => {
|
|
29
27
|
assert.throws(() => extractSkillNames("not-json-object"), /lock object/);
|
|
30
28
|
});
|
|
31
|
-
|
|
32
29
|
test("declared extract kinds stay the documented set", () => {
|
|
33
30
|
assert.deepEqual([...EXTRACT_KINDS], ["skill-names", "heading-list", "prose-note"]);
|
|
34
31
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { loadManifest, safePath, sha256, json, fail, args, cliError, assertReadable } from "./core.mjs";
|
|
6
|
+
import { createPlan, applyPlan } from "./transaction.mjs";
|
|
7
|
+
async function feedbackPlan({ wikiRoot, repoRoot = process.cwd(), request }) {
|
|
8
|
+
await assertReadable(wikiRoot);
|
|
9
|
+
const manifest = await loadManifest(wikiRoot, { repoRoot });
|
|
10
|
+
if (manifest.schemaVersion !== 2) fail("MIGRATION_REQUIRED", "feedback requires v2");
|
|
11
|
+
manifest.feedback ||= [];
|
|
12
|
+
const a = manifest.articles.find((a2) => a2.id === request.articleId);
|
|
13
|
+
if (!a) fail("UNKNOWN_ARTICLE_ID", request.articleId);
|
|
14
|
+
const text = await readFile(await safePath(wikiRoot, a.file), "utf8"), digest = sha256(text), existing = manifest.feedback.find((f) => f.id === request.id);
|
|
15
|
+
if (!request.id || !request.issue || !request.locator?.quote) fail("FEEDBACK_INVALID", "id, issue and quoted locator required");
|
|
16
|
+
if (request.targetDigest !== digest) fail("FEEDBACK_REANCHOR_REQUIRED", "target changed; locate quoted text on current version");
|
|
17
|
+
const index = text.indexOf(request.locator.quote);
|
|
18
|
+
if (index < 0 || text.indexOf(request.locator.quote, index + 1) >= 0) fail("FEEDBACK_REANCHOR_REQUIRED", "quote must match exactly once");
|
|
19
|
+
const state = request.status || "open";
|
|
20
|
+
if (!["open", "accepted", "partial", "rejected", "deferred"].includes(state)) fail("FEEDBACK_INVALID", "status");
|
|
21
|
+
const record = { id: request.id, articleId: a.id, targetDigest: digest, locator: { quote: request.locator.quote, startLine: text.slice(0, index).split("\n").length }, issue: request.issue, status: state, history: existing?.history || [] };
|
|
22
|
+
if (existing && existing.articleId !== a.id) fail("FEEDBACK_ID_CONFLICT", request.id);
|
|
23
|
+
if (["accepted", "partial"].includes(state)) {
|
|
24
|
+
const r = request.resolution;
|
|
25
|
+
if (!existing || !r?.transactionId || r.beforeDigest !== existing.targetDigest || r.afterDigest !== digest || r.beforeDigest === r.afterDigest || !r.note) fail("FEEDBACK_EVIDENCE_REQUIRED", "actual change and verification required");
|
|
26
|
+
const j = JSON.parse(await readFile(await safePath(wikiRoot, `.wiki-staging/${r.transactionId}/completed.json`), "utf8"));
|
|
27
|
+
if (j.phase !== "finalized" || !j.writes?.some((w) => w.path === a.file && w.before === r.beforeDigest && w.after === r.afterDigest) || a.verification?.articleDigest !== digest) fail("FEEDBACK_EVIDENCE_REQUIRED", "completed article modification and verified compilation required");
|
|
28
|
+
record.resolution = r;
|
|
29
|
+
} else if (state !== "open") {
|
|
30
|
+
if (!request.resolution?.note) fail("FEEDBACK_EVIDENCE_REQUIRED", "disposition reason required");
|
|
31
|
+
record.resolution = request.resolution;
|
|
32
|
+
}
|
|
33
|
+
const comparable = (f) => JSON.stringify({ ...f, history: void 0 });
|
|
34
|
+
if (existing && comparable(existing) === comparable(record)) return { duplicate: true, id: record.id };
|
|
35
|
+
if (existing && existing.status === "open" && state === "open" && existing.issue !== record.issue) fail("FEEDBACK_ID_CONFLICT", "existing feedback differs");
|
|
36
|
+
record.history = [...record.history, { at: request.at || (/* @__PURE__ */ new Date()).toISOString(), status: state, targetDigest: digest }];
|
|
37
|
+
if (existing) manifest.feedback[manifest.feedback.indexOf(existing)] = record;
|
|
38
|
+
else manifest.feedback.push(record);
|
|
39
|
+
return createPlan({ wikiRoot, repoRoot, request: { operation: "feedback", manifest, authorization: { confirmed: request.confirmed === true, paths: [".wiki-manifest.json", "wiki/log.md"] } } });
|
|
40
|
+
}
|
|
41
|
+
async function main() {
|
|
42
|
+
const a = args(process.argv.slice(2));
|
|
43
|
+
if (!a.wiki || !a.request) fail("USAGE", "--wiki --request [--apply]");
|
|
44
|
+
const options = { wikiRoot: path.resolve(a.repo, a.wiki), repoRoot: path.resolve(a.repo) };
|
|
45
|
+
const plan = await feedbackPlan({ ...options, request: JSON.parse(await readFile(a.request, "utf8")) });
|
|
46
|
+
process.stdout.write(json(a.apply && !plan.duplicate ? await applyPlan({ ...options, plan }) : plan));
|
|
47
|
+
}
|
|
48
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) main().catch(cliError);
|
|
49
|
+
export {
|
|
50
|
+
feedbackPlan
|
|
51
|
+
};
|
|
@@ -1,174 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { execFileSync } from "node:child_process";
|
|
4
|
-
import { readFile, writeFile, access } from "node:fs/promises";
|
|
5
2
|
import path from "node:path";
|
|
6
3
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} catch {
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function hashSources({ wikiRoot, repoRoot, now = new Date().toISOString() }) {
|
|
56
|
-
const manifest = await loadManifest(wikiRoot);
|
|
57
|
-
const missing = [];
|
|
58
|
-
for (const source of manifest.sources || []) {
|
|
59
|
-
if (!source.livePath) {
|
|
60
|
-
source.sha256 = "";
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const live = path.resolve(repoRoot, source.livePath);
|
|
64
|
-
if (!(await exists(live))) {
|
|
65
|
-
missing.push(source.id);
|
|
66
|
-
source.sha256 = "";
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
source.sha256 = sha256(await readFile(live));
|
|
70
|
-
}
|
|
71
|
-
manifest.compiledAt = now;
|
|
72
|
-
manifest.gitCommit = gitCommit(repoRoot);
|
|
73
|
-
await saveManifest(wikiRoot, manifest);
|
|
74
|
-
return { manifest, missing };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function normalizeLivePath(livePath) {
|
|
78
|
-
return String(livePath || "").replace(/\\/g, "/").replace(/^\.\/+/, "");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function unmappedCandidates(sources, candidates = []) {
|
|
82
|
-
const mapped = new Set(
|
|
83
|
-
(sources || []).map((source) => normalizeLivePath(source.livePath)).filter(Boolean),
|
|
84
|
-
);
|
|
85
|
-
const unmapped = [];
|
|
86
|
-
const seen = new Set();
|
|
87
|
-
for (const candidate of candidates) {
|
|
88
|
-
const livePath = normalizeLivePath(candidate);
|
|
89
|
-
if (!livePath || mapped.has(livePath) || seen.has(livePath)) continue;
|
|
90
|
-
seen.add(livePath);
|
|
91
|
-
unmapped.push(livePath);
|
|
92
|
-
}
|
|
93
|
-
return unmapped;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function drift({ wikiRoot, repoRoot, candidates = [] }) {
|
|
97
|
-
const manifest = await loadManifest(wikiRoot);
|
|
98
|
-
const changed = [];
|
|
99
|
-
const missing = [];
|
|
100
|
-
const unchanged = [];
|
|
101
|
-
for (const source of manifest.sources || []) {
|
|
102
|
-
if (!source.livePath) {
|
|
103
|
-
unchanged.push(source.id);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const live = path.resolve(repoRoot, source.livePath);
|
|
107
|
-
if (!(await exists(live))) {
|
|
108
|
-
missing.push(source.id);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const current = sha256(await readFile(live));
|
|
112
|
-
if (current !== source.sha256) changed.push(source.id);
|
|
113
|
-
else unchanged.push(source.id);
|
|
114
|
-
}
|
|
115
|
-
const hit = new Set([...changed, ...missing]);
|
|
116
|
-
const articles = [];
|
|
117
|
-
const humanOwned = [];
|
|
118
|
-
for (const article of manifest.articles || []) {
|
|
119
|
-
const impacted = (article.sourceIds || []).some((id) => hit.has(id));
|
|
120
|
-
if (!impacted) continue;
|
|
121
|
-
articles.push(article.id);
|
|
122
|
-
if (article.humanOwned === true) humanOwned.push(article.id);
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
changed,
|
|
126
|
-
missing,
|
|
127
|
-
unchanged,
|
|
128
|
-
articles,
|
|
129
|
-
unmapped: unmappedCandidates(manifest.sources, candidates),
|
|
130
|
-
humanOwned,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function parseArgs(argv) {
|
|
135
|
-
const args = { command: argv[0], wiki: null, repo: process.cwd(), candidates: [] };
|
|
136
|
-
for (let i = 1; i < argv.length; i += 1) {
|
|
137
|
-
if (argv[i] === "--wiki") args.wiki = argv[++i];
|
|
138
|
-
else if (argv[i] === "--repo") args.repo = argv[++i];
|
|
139
|
-
else if (argv[i] === "--candidate") args.candidates.push(argv[++i]);
|
|
140
|
-
else if (!args.wiki && !argv[i].startsWith("-")) args.wiki = argv[i];
|
|
141
|
-
}
|
|
142
|
-
return args;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async function main(argv = process.argv.slice(2)) {
|
|
146
|
-
const args = parseArgs(argv);
|
|
147
|
-
if (!args.command || !["hash", "drift", "status"].includes(args.command)) {
|
|
148
|
-
throw new Error(
|
|
149
|
-
"usage: inventory.mjs hash|drift|status --wiki <wiki-root> [--repo <repo-root>] [--candidate <livePath>]",
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
const wikiRoot = resolveWikiRoot(args.wiki, args.repo);
|
|
153
|
-
const repoRoot = path.resolve(args.repo);
|
|
154
|
-
if (!(await exists(manifestPath(wikiRoot)))) {
|
|
155
|
-
throw new Error(`manifest not found: ${manifestPath(wikiRoot)}`);
|
|
156
|
-
}
|
|
157
|
-
if (args.command === "hash") {
|
|
158
|
-
const result = await hashSources({ wikiRoot, repoRoot });
|
|
159
|
-
process.stdout.write(
|
|
160
|
-
`${JSON.stringify({ hashed: (result.manifest.sources || []).length, missing: result.missing }, null, 2)}\n`,
|
|
161
|
-
);
|
|
162
|
-
if (result.missing.length) process.exitCode = 1;
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const report = await drift({ wikiRoot, repoRoot, candidates: args.candidates });
|
|
166
|
-
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
170
|
-
main().catch((error) => {
|
|
171
|
-
process.stderr.write(`${error.message}\n`);
|
|
172
|
-
process.exitCode = 2;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
4
|
+
import { sha256, exists, loadManifest, args, cliError, transactionState } from "./core.mjs";
|
|
5
|
+
import { observeSource, inspectArticles } from "./sources.mjs";
|
|
6
|
+
const resolveWikiRoot = (arg, cwd = process.cwd()) => {
|
|
7
|
+
if (!arg) throw new Error("missing --wiki");
|
|
8
|
+
return path.resolve(cwd, arg);
|
|
9
|
+
};
|
|
10
|
+
const manifestPath = (root) => path.join(root, ".wiki-manifest.json");
|
|
11
|
+
const normalizeLivePath = (p) => String(p || "").replace(/\\/g, "/").replace(/^\.\/+/, "");
|
|
12
|
+
function unmappedCandidates(sources, candidates = []) {
|
|
13
|
+
const mapped = new Set(sources.map((s) => normalizeLivePath(s.livePath)));
|
|
14
|
+
return [...new Set(candidates.map(normalizeLivePath).filter((p) => p && !mapped.has(p)))];
|
|
15
|
+
}
|
|
16
|
+
async function hashSources({ wikiRoot, repoRoot = process.cwd() }) {
|
|
17
|
+
const manifest = await loadManifest(wikiRoot, { repoRoot });
|
|
18
|
+
const observations = [];
|
|
19
|
+
for (const s of manifest.sources) observations.push(await observeSource(s, { wikiRoot, repoRoot }));
|
|
20
|
+
return { manifest, observations, hashed: observations.length, missing: observations.filter((s) => s.state === "missing").map((s) => s.id), readOnly: true, transaction: await transactionState(wikiRoot) };
|
|
21
|
+
}
|
|
22
|
+
async function drift({ wikiRoot, repoRoot = process.cwd(), candidates = [], articleIds, reader }) {
|
|
23
|
+
const manifest = await loadManifest(wikiRoot, { repoRoot });
|
|
24
|
+
const report = await inspectArticles(manifest, { wikiRoot, repoRoot, articleIds, reader });
|
|
25
|
+
const select = (state) => report.sourceStates.filter((s) => s.state === state).map((s) => s.id);
|
|
26
|
+
return { changed: select("stale"), missing: select("missing"), unchanged: select("current"), unverified: select("unverified"), archived: select("archived"), articles: report.articleStates.filter((a) => a.state !== "current" && a.state !== "archived").map((a) => a.id), unmapped: unmappedCandidates(manifest.sources, candidates), humanOwned: report.articleStates.filter((a) => a.humanOwned).map((a) => a.id), ...report };
|
|
27
|
+
}
|
|
28
|
+
async function main() {
|
|
29
|
+
const a = args(process.argv.slice(2), ["hash", "drift", "status"]);
|
|
30
|
+
const options = { wikiRoot: resolveWikiRoot(a.wiki, a.repo), repoRoot: path.resolve(a.repo), candidates: a.candidates };
|
|
31
|
+
const result = a.command === "hash" ? await hashSources(options) : await drift(options);
|
|
32
|
+
if (a.command === "hash") delete result.manifest;
|
|
33
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
34
|
+
}
|
|
35
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) main().catch(cliError);
|
|
36
|
+
export {
|
|
37
|
+
drift,
|
|
38
|
+
exists,
|
|
39
|
+
hashSources,
|
|
40
|
+
loadManifest,
|
|
41
|
+
manifestPath,
|
|
42
|
+
normalizeLivePath,
|
|
43
|
+
resolveWikiRoot,
|
|
44
|
+
sha256,
|
|
45
|
+
unmappedCandidates
|
|
46
|
+
};
|