agentera 3.0.0-dev.2 → 3.0.0-dev.21
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/README.md +84 -6
- package/bundle/.agentera-npx-bundle.json +1 -1
- package/bundle/.codex-plugin/plugin.json +92 -0
- package/bundle/.cursor/agents/agentera.md +7 -0
- package/bundle/.cursor/hooks.json +32 -0
- package/bundle/.cursor-plugin/plugin.json +34 -0
- package/bundle/.github/hooks/postToolUse.json +9 -0
- package/bundle/.github/hooks/preToolUse.json +8 -0
- package/bundle/.github/hooks/sessionEnd.json +8 -0
- package/bundle/.github/hooks/sessionStart.json +8 -0
- package/bundle/.github/plugin/plugin.json +7 -0
- package/bundle/.opencode/agents/agentera.md +12 -0
- package/bundle/.opencode/commands/agentera.md +5 -0
- package/bundle/.opencode/package.json +31 -0
- package/bundle/.opencode/plugins/agentera.js +820 -0
- package/bundle/CHANGELOG.md +1101 -0
- package/bundle/DESIGN.md +233 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +158 -0
- package/bundle/UPGRADE.md +265 -0
- package/bundle/agents/openai.yaml +87 -0
- package/bundle/extract-corpus-parity.json +21 -0
- package/bundle/hooks/codex-hooks.json +31 -0
- package/bundle/hooks/codex-plugin-hooks.json +31 -0
- package/bundle/plugin.json +13 -0
- package/bundle/references/adapters/cursor.md +53 -42
- package/bundle/references/adapters/opencode.md +46 -47
- package/bundle/references/adapters/package-manifest-interface-model.yaml +32 -43
- package/bundle/references/adapters/package-registry.yaml +19 -53
- package/bundle/references/adapters/package-surface-characterization.md +55 -35
- package/bundle/references/adapters/runtime-adapter-characterization.md +44 -79
- package/bundle/references/adapters/runtime-adapter-registry.yaml +21 -182
- package/bundle/references/adapters/runtime-feature-parity.md +114 -174
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +288 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +90 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +33 -0
- package/bundle/references/analysis/benchmark.md +6 -6
- package/bundle/references/analysis/startup-measurement-contract.yaml +37 -26
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +9 -8
- package/bundle/references/artifacts/state-storage-authority.yaml +1446 -0
- package/bundle/references/cli/agent-ready-state-contract.yaml +37 -62
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +4 -4
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +57 -28
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +4 -32
- package/bundle/references/cli/capability-instruction-contract.yaml +98 -57
- package/bundle/references/cli/capability-instruction-structure.md +144 -0
- package/bundle/references/cli/capability-tool-classification.yaml +12 -12
- package/bundle/references/cli/coexistence-probe.yaml +13 -0
- package/bundle/references/cli/parity-expected-actual-template.md +30 -0
- package/bundle/references/cli/routing-execution-vocabulary.yaml +12 -12
- package/bundle/references/cli/routing-model.md +94 -0
- package/bundle/references/cli/single-name-protocol.yaml +42 -0
- package/bundle/references/cli/trigger-schema-enrichment.md +136 -0
- package/bundle/references/cli/update-channels.yaml +43 -7
- package/bundle/references/cli/upgrade-repair-wording.md +45 -0
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +98 -0
- package/bundle/references/cli/vocabulary-index.yaml +20 -15
- package/bundle/references/cli/vocabulary.md +342 -326
- package/bundle/references/meta/documentation-inventory.md +10 -3
- package/bundle/registry.json +14 -14
- package/bundle/skills/agentera/SKILL.md +136 -408
- package/bundle/skills/agentera/agents/audit.toml +6 -0
- package/bundle/skills/agentera/agents/build.toml +6 -0
- package/bundle/skills/agentera/agents/design.toml +6 -0
- package/bundle/skills/agentera/agents/discuss.toml +6 -0
- package/bundle/skills/agentera/agents/document.toml +6 -0
- package/bundle/skills/agentera/agents/optimize.toml +6 -0
- package/bundle/skills/agentera/agents/orchestrate.toml +6 -0
- package/bundle/skills/agentera/agents/plan.toml +6 -0
- package/bundle/skills/agentera/agents/profile.toml +6 -0
- package/bundle/skills/agentera/agents/research.toml +6 -0
- package/bundle/skills/agentera/agents/status.toml +6 -0
- package/bundle/skills/agentera/agents/vision.toml +6 -0
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +84 -0
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/triggers.yaml +15 -6
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +20 -19
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/artifacts.yaml +22 -17
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/triggers.yaml +13 -3
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/validation.yaml +11 -11
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/triggers.yaml +15 -3
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/validation.yaml +7 -7
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +49 -0
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/triggers.yaml +11 -3
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/validation.yaml +9 -8
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/artifacts.yaml +23 -16
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/triggers.yaml +14 -4
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +18 -18
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +9 -9
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/triggers.yaml +11 -3
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +71 -0
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/triggers.yaml +16 -3
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +120 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +63 -0
- package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/triggers.yaml +15 -3
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +89 -0
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/artifacts.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/triggers.yaml +7 -3
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/triggers.yaml +9 -3
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/artifacts.yaml +14 -11
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/triggers.yaml +12 -8
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +8 -8
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/triggers.yaml +19 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
- package/bundle/skills/agentera/capability_schema_contract.yaml +201 -38
- package/bundle/skills/agentera/protocol.yaml +29 -29
- package/bundle/skills/agentera/references/contract.md +387 -329
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +4 -4
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +25 -20
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +4 -4
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +8 -7
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +139 -8
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +21 -15
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +22 -8
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +285 -11
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +36 -51
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +77 -24
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
- package/dist/analytics/extractCorpus/cli.js +163 -0
- package/dist/analytics/extractCorpus/cli.js.map +1 -0
- package/dist/analytics/extractCorpus/copilotSessions.js +276 -0
- package/dist/analytics/extractCorpus/copilotSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/core.js +393 -0
- package/dist/analytics/extractCorpus/core.js.map +1 -0
- package/dist/analytics/extractCorpus/corpus.js +168 -0
- package/dist/analytics/extractCorpus/corpus.js.map +1 -0
- package/dist/analytics/extractCorpus/coverageAudit.js +261 -0
- package/dist/analytics/extractCorpus/coverageAudit.js.map +1 -0
- package/dist/analytics/extractCorpus/cursorSessions.js +426 -0
- package/dist/analytics/extractCorpus/cursorSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +105 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js.map +1 -0
- package/dist/analytics/extractCorpus/filesystemSources.js +119 -0
- package/dist/analytics/extractCorpus/filesystemSources.js.map +1 -0
- package/dist/analytics/extractCorpus/index.js +12 -0
- package/dist/analytics/extractCorpus/index.js.map +1 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js +205 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/sqliteCaps.js +44 -0
- package/dist/analytics/extractCorpus/sqliteCaps.js.map +1 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js +368 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +1 -0
- package/dist/analytics/extractCorpus.js +2 -1790
- package/dist/analytics/extractCorpus.js.map +1 -1
- package/dist/analytics/usageStats.js +93 -27
- package/dist/analytics/usageStats.js.map +1 -1
- package/dist/bin/agentera.js +3 -1
- package/dist/bin/agentera.js.map +1 -1
- package/dist/capabilities/audit/instructions.js +4 -0
- package/dist/capabilities/audit/instructions.js.map +1 -0
- package/dist/capabilities/build/instructions.js +5 -0
- package/dist/capabilities/build/instructions.js.map +1 -0
- package/dist/capabilities/design/instructions.js +5 -0
- package/dist/capabilities/design/instructions.js.map +1 -0
- package/dist/capabilities/discuss/instructions.js +6 -0
- package/dist/capabilities/discuss/instructions.js.map +1 -0
- package/dist/capabilities/document/instructions.js +4 -0
- package/dist/capabilities/document/instructions.js.map +1 -0
- package/dist/capabilities/index.js +38 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/optimize/instructions.js +5 -0
- package/dist/capabilities/optimize/instructions.js.map +1 -0
- package/dist/capabilities/orchestrate/instructions.js +10 -0
- package/dist/capabilities/orchestrate/instructions.js.map +1 -0
- package/dist/capabilities/plan/instructions.js +6 -0
- package/dist/capabilities/plan/instructions.js.map +1 -0
- package/dist/capabilities/profile/instructions.js +5 -0
- package/dist/capabilities/profile/instructions.js.map +1 -0
- package/dist/capabilities/research/instructions.js +6 -0
- package/dist/capabilities/research/instructions.js.map +1 -0
- package/dist/capabilities/status/instructions.js +5 -0
- package/dist/capabilities/status/instructions.js.map +1 -0
- package/dist/capabilities/vision/instructions.js +5 -0
- package/dist/capabilities/vision/instructions.js.map +1 -0
- package/dist/cli/appContext.js +30 -23
- package/dist/cli/appContext.js.map +1 -1
- package/dist/cli/capabilityContext/benchmark.js +564 -0
- package/dist/cli/capabilityContext/benchmark.js.map +1 -0
- package/dist/cli/capabilityContext/bespoke.js +38 -0
- package/dist/cli/capabilityContext/bespoke.js.map +1 -0
- package/dist/cli/capabilityContext/build.js +191 -0
- package/dist/cli/capabilityContext/build.js.map +1 -0
- package/dist/cli/capabilityContext/closeout.js +231 -0
- package/dist/cli/capabilityContext/closeout.js.map +1 -0
- package/dist/cli/capabilityContext/contract.js +219 -0
- package/dist/cli/capabilityContext/contract.js.map +1 -0
- package/dist/cli/capabilityContext/evidence.js +457 -0
- package/dist/cli/capabilityContext/evidence.js.map +1 -0
- package/dist/cli/capabilityContext/index.js +4 -0
- package/dist/cli/capabilityContext/index.js.map +1 -0
- package/dist/cli/capabilityContext/orchestration.js +118 -0
- package/dist/cli/capabilityContext/orchestration.js.map +1 -0
- package/dist/cli/capabilityContext/planState.js +279 -0
- package/dist/cli/capabilityContext/planState.js.map +1 -0
- package/dist/cli/capabilityContext/progress.js +143 -0
- package/dist/cli/capabilityContext/progress.js.map +1 -0
- package/dist/cli/capabilityContext/shared.js +94 -0
- package/dist/cli/capabilityContext/shared.js.map +1 -0
- package/dist/cli/capabilityContext/slim.js +139 -0
- package/dist/cli/capabilityContext/slim.js.map +1 -0
- package/dist/cli/capabilityContext/startup.js +241 -0
- package/dist/cli/capabilityContext/startup.js.map +1 -0
- package/dist/cli/capabilityContext/types.js +51 -0
- package/dist/cli/capabilityContext/types.js.map +1 -0
- package/dist/cli/capabilityContext.js +1 -2420
- package/dist/cli/capabilityContext.js.map +1 -1
- package/dist/cli/commands/appHome.js +23 -0
- package/dist/cli/commands/appHome.js.map +1 -0
- package/dist/cli/commands/backfill.js +186 -76
- package/dist/cli/commands/backfill.js.map +1 -1
- package/dist/cli/commands/capability.js +3 -10
- package/dist/cli/commands/capability.js.map +1 -1
- package/dist/cli/commands/compact.js +41 -12
- package/dist/cli/commands/compact.js.map +1 -1
- package/dist/cli/commands/doctor.js +116 -96
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/durability.js +85 -0
- package/dist/cli/commands/durability.js.map +1 -0
- package/dist/cli/commands/lint.js +16 -41
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/migrate.js +677 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/prime/bundleStatus.js +185 -0
- package/dist/cli/commands/prime/bundleStatus.js.map +1 -0
- package/dist/cli/commands/prime/collectOrientationState.js +202 -0
- package/dist/cli/commands/prime/collectOrientationState.js.map +1 -0
- package/dist/cli/commands/prime/orientationOutput.js +235 -0
- package/dist/cli/commands/prime/orientationOutput.js.map +1 -0
- package/dist/cli/commands/prime/types.js +2 -0
- package/dist/cli/commands/prime/types.js.map +1 -0
- package/dist/cli/commands/prime/v1Migration.js +39 -0
- package/dist/cli/commands/prime/v1Migration.js.map +1 -0
- package/dist/cli/commands/prime.js +11 -519
- package/dist/cli/commands/prime.js.map +1 -1
- package/dist/cli/commands/query.js +25 -4
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/report.js +50 -14
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/schema.js +343 -76
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/state/decisions.js +421 -0
- package/dist/cli/commands/state/decisions.js.map +1 -0
- package/dist/cli/commands/state/docs.js +97 -0
- package/dist/cli/commands/state/docs.js.map +1 -0
- package/dist/cli/commands/state/experimentRecords.js +156 -0
- package/dist/cli/commands/state/experimentRecords.js.map +1 -0
- package/dist/cli/commands/state/experiments.js +68 -0
- package/dist/cli/commands/state/experiments.js.map +1 -0
- package/dist/cli/commands/state/get.js +141 -0
- package/dist/cli/commands/state/get.js.map +1 -0
- package/dist/cli/commands/state/health.js +116 -0
- package/dist/cli/commands/state/health.js.map +1 -0
- package/dist/cli/commands/state/index.js +51 -0
- package/dist/cli/commands/state/index.js.map +1 -0
- package/dist/cli/commands/state/list.js +159 -0
- package/dist/cli/commands/state/list.js.map +1 -0
- package/dist/cli/commands/state/objective.js +69 -0
- package/dist/cli/commands/state/objective.js.map +1 -0
- package/dist/cli/commands/state/plan.js +379 -0
- package/dist/cli/commands/state/plan.js.map +1 -0
- package/dist/cli/commands/state/planTasks.js +164 -0
- package/dist/cli/commands/state/planTasks.js.map +1 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/plans.js.map +1 -0
- package/dist/cli/commands/state/progress.js +47 -0
- package/dist/cli/commands/state/progress.js.map +1 -0
- package/dist/cli/commands/state/shared.js +15 -0
- package/dist/cli/commands/state/shared.js.map +1 -0
- package/dist/cli/commands/state/todo.js +121 -0
- package/dist/cli/commands/state/todo.js.map +1 -0
- package/dist/cli/commands/state/write.js +346 -0
- package/dist/cli/commands/state/write.js.map +1 -0
- package/dist/cli/commands/upgrade.js +79 -1
- package/dist/cli/commands/upgrade.js.map +1 -1
- package/dist/cli/commands/upgradeVerify.js +81 -0
- package/dist/cli/commands/upgradeVerify.js.map +1 -0
- package/dist/cli/commands/validate.js +56 -96
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/commands/verify.js +13 -7
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/contracts/bundleStatus.js +2 -0
- package/dist/cli/contracts/bundleStatus.js.map +1 -0
- package/dist/cli/contracts/orientationState.js +2 -0
- package/dist/cli/contracts/orientationState.js.map +1 -0
- package/dist/cli/dispatch/argvParser.js +33 -0
- package/dist/cli/dispatch/argvParser.js.map +1 -0
- package/dist/cli/dispatch/check.js +395 -0
- package/dist/cli/dispatch/check.js.map +1 -0
- package/dist/cli/dispatch/commands.js +27 -0
- package/dist/cli/dispatch/commands.js.map +1 -0
- package/dist/cli/dispatch/index.js +201 -0
- package/dist/cli/dispatch/index.js.map +1 -0
- package/dist/cli/dispatch/lifecycle.js +671 -0
- package/dist/cli/dispatch/lifecycle.js.map +1 -0
- package/dist/cli/dispatch/prime.js +104 -0
- package/dist/cli/dispatch/prime.js.map +1 -0
- package/dist/cli/dispatch/shared.js +64 -0
- package/dist/cli/dispatch/shared.js.map +1 -0
- package/dist/cli/dispatch/state.js +168 -0
- package/dist/cli/dispatch/state.js.map +1 -0
- package/dist/cli/dispatch.js +1 -957
- package/dist/cli/dispatch.js.map +1 -1
- package/dist/cli/errors.js +53 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/help.js +421 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/orientation/attention.js +163 -0
- package/dist/cli/orientation/attention.js.map +1 -0
- package/dist/cli/orientation/corpusCoverage.js +71 -0
- package/dist/cli/orientation/corpusCoverage.js.map +1 -0
- package/dist/cli/orientation.js +336 -144
- package/dist/cli/orientation.js.map +1 -1
- package/dist/cli/planArtifacts.js +201 -0
- package/dist/cli/planArtifacts.js.map +1 -0
- package/dist/cli/planEvidence.js +158 -0
- package/dist/cli/planEvidence.js.map +1 -0
- package/dist/cli/planLifecycleState.js +34 -0
- package/dist/cli/planLifecycleState.js.map +1 -0
- package/dist/cli/prime-blob.js +69 -2
- package/dist/cli/prime-blob.js.map +1 -1
- package/dist/cli/startupCompletenessContract.js +57 -0
- package/dist/cli/startupCompletenessContract.js.map +1 -0
- package/dist/cli/stateQuery.js +22 -5
- package/dist/cli/stateQuery.js.map +1 -1
- package/dist/cli/todoMarkdown.js +33 -0
- package/dist/cli/todoMarkdown.js.map +1 -0
- package/dist/cli/todoSeverity.js +19 -0
- package/dist/cli/todoSeverity.js.map +1 -0
- package/dist/core/atomicWriter.js +21 -0
- package/dist/core/atomicWriter.js.map +1 -0
- package/dist/core/envPaths.js +21 -0
- package/dist/core/envPaths.js.map +1 -0
- package/dist/core/jsonValue.js +6 -0
- package/dist/core/jsonValue.js.map +1 -0
- package/dist/core/pyjson.js +67 -2
- package/dist/core/pyjson.js.map +1 -1
- package/dist/core/text.js +11 -0
- package/dist/core/text.js.map +1 -0
- package/dist/core/yaml.js +8 -0
- package/dist/core/yaml.js.map +1 -1
- package/dist/eval/evalSkills.js +30 -25
- package/dist/eval/evalSkills.js.map +1 -1
- package/dist/eval/semanticEval.js +43 -19
- package/dist/eval/semanticEval.js.map +1 -1
- package/dist/eval/semanticFixtures.js +16 -4
- package/dist/eval/semanticFixtures.js.map +1 -1
- package/dist/hooks/common.js +9 -26
- package/dist/hooks/common.js.map +1 -1
- package/dist/hooks/compaction/apply.js +447 -0
- package/dist/hooks/compaction/apply.js.map +1 -0
- package/dist/hooks/compaction/dryRun.js +185 -0
- package/dist/hooks/compaction/dryRun.js.map +1 -0
- package/dist/hooks/compaction/index.js +23 -0
- package/dist/hooks/compaction/index.js.map +1 -0
- package/dist/hooks/compaction/parse.js +326 -0
- package/dist/hooks/compaction/parse.js.map +1 -0
- package/dist/hooks/compaction/retention.js +203 -0
- package/dist/hooks/compaction/retention.js.map +1 -0
- package/dist/hooks/compaction/status.js +336 -0
- package/dist/hooks/compaction/status.js.map +1 -0
- package/dist/hooks/compaction/types.js +6 -0
- package/dist/hooks/compaction/types.js.map +1 -0
- package/dist/hooks/cursorPreToolUse.js +1 -1
- package/dist/hooks/cursorPreToolUse.js.map +1 -1
- package/dist/hooks/cursorSessionStart.js +10 -2
- package/dist/hooks/cursorSessionStart.js.map +1 -1
- package/dist/hooks/sessionStart.js +57 -18
- package/dist/hooks/sessionStart.js.map +1 -1
- package/dist/hooks/sessionStop.js +8 -14
- package/dist/hooks/sessionStop.js.map +1 -1
- package/dist/hooks/validateArtifact/agentFacing.js +10 -0
- package/dist/hooks/validateArtifact/agentFacing.js.map +1 -0
- package/dist/hooks/validateArtifact/index.js +151 -0
- package/dist/hooks/validateArtifact/index.js.map +1 -0
- package/dist/hooks/validateArtifact/markdown.js +146 -0
- package/dist/hooks/validateArtifact/markdown.js.map +1 -0
- package/dist/hooks/validateArtifact/runtime.js +86 -0
- package/dist/hooks/validateArtifact/runtime.js.map +1 -0
- package/dist/hooks/validateArtifact/schema.js +541 -0
- package/dist/hooks/validateArtifact/schema.js.map +1 -0
- package/dist/hooks/validateArtifact/traversal.js +108 -0
- package/dist/hooks/validateArtifact/traversal.js.map +1 -0
- package/dist/hooks/validateArtifact/violations.js +108 -0
- package/dist/hooks/validateArtifact/violations.js.map +1 -0
- package/dist/migrate/v2HandoffManifest.js +455 -0
- package/dist/migrate/v2HandoffManifest.js.map +1 -0
- package/dist/registries/artifactProtocolIds.js +77 -0
- package/dist/registries/artifactProtocolIds.js.map +1 -0
- package/dist/registries/artifactRegistry.js +203 -53
- package/dist/registries/artifactRegistry.js.map +1 -1
- package/dist/registries/capabilityContract.js +156 -12
- package/dist/registries/capabilityContract.js.map +1 -1
- package/dist/registries/evaluatorHandoffContract.js +171 -0
- package/dist/registries/evaluatorHandoffContract.js.map +1 -0
- package/dist/registries/packageRegistry.js +40 -6
- package/dist/registries/packageRegistry.js.map +1 -1
- package/dist/registries/runtimeAdapterRegistry.js +30 -21
- package/dist/registries/runtimeAdapterRegistry.js.map +1 -1
- package/dist/registries/triggerLoader.js +211 -0
- package/dist/registries/triggerLoader.js.map +1 -0
- package/dist/release/releaseMetadata.js +329 -0
- package/dist/release/releaseMetadata.js.map +1 -0
- package/dist/runtime/lifecycleAdapterContract.js +458 -0
- package/dist/runtime/lifecycleAdapterContract.js.map +1 -0
- package/dist/runtime/lifecycleAdapters.js +766 -0
- package/dist/runtime/lifecycleAdapters.js.map +1 -0
- package/dist/runtime/lifecycleAuthority.js +493 -0
- package/dist/runtime/lifecycleAuthority.js.map +1 -0
- package/dist/runtime/lifecycleOperationContract.js +113 -0
- package/dist/runtime/lifecycleOperationContract.js.map +1 -0
- package/dist/runtime/lifecycleOperations.js +635 -0
- package/dist/runtime/lifecycleOperations.js.map +1 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +623 -0
- package/dist/runtime/lifecycleOwnershipJournal.js.map +1 -0
- package/dist/runtime/lifecyclePublication.js +395 -0
- package/dist/runtime/lifecyclePublication.js.map +1 -0
- package/dist/runtime/lifecycleSnapshot.js +439 -0
- package/dist/runtime/lifecycleSnapshot.js.map +1 -0
- package/dist/runtime/retiredRuntimeCleanup.js +238 -0
- package/dist/runtime/retiredRuntimeCleanup.js.map +1 -0
- package/dist/setup/codex/agents.js +96 -0
- package/dist/setup/codex/agents.js.map +1 -0
- package/dist/setup/codex/cli.js +161 -0
- package/dist/setup/codex/cli.js.map +1 -0
- package/dist/setup/codex/configToml.js +639 -0
- package/dist/setup/codex/configToml.js.map +1 -0
- package/dist/setup/codex/constants.js +29 -0
- package/dist/setup/codex/constants.js.map +1 -0
- package/dist/setup/codex/installRoot.js +64 -0
- package/dist/setup/codex/installRoot.js.map +1 -0
- package/dist/setup/codex/state.js +270 -0
- package/dist/setup/codex/state.js.map +1 -0
- package/dist/setup/codex.js +11 -1055
- package/dist/setup/codex.js.map +1 -1
- package/dist/setup/copilot.js +1 -1
- package/dist/setup/copilot.js.map +1 -1
- package/dist/setup/cursor.js +7 -5
- package/dist/setup/cursor.js.map +1 -1
- package/dist/setup/cursorSurfaces.js +67 -0
- package/dist/setup/cursorSurfaces.js.map +1 -0
- package/dist/setup/doctor/core.js +296 -0
- package/dist/setup/doctor/core.js.map +1 -0
- package/dist/setup/doctor/diagnostics.js +201 -0
- package/dist/setup/doctor/diagnostics.js.map +1 -0
- package/dist/setup/doctor/opencode.js +301 -0
- package/dist/setup/doctor/opencode.js.map +1 -0
- package/dist/setup/doctor/report.js +425 -0
- package/dist/setup/doctor/report.js.map +1 -0
- package/dist/setup/doctor.js +9 -1275
- package/dist/setup/doctor.js.map +1 -1
- package/dist/setup/opencode.js +13 -0
- package/dist/setup/opencode.js.map +1 -0
- package/dist/setup/opencodeConstants.js +2 -0
- package/dist/setup/opencodeConstants.js.map +1 -0
- package/dist/setup/smokeChecks.js +109 -0
- package/dist/setup/smokeChecks.js.map +1 -0
- package/dist/state/archiveDiscovery.js +589 -0
- package/dist/state/archiveDiscovery.js.map +1 -0
- package/dist/state/archivePublication.js +225 -0
- package/dist/state/archivePublication.js.map +1 -0
- package/dist/state/archiveRecovery.js +238 -0
- package/dist/state/archiveRecovery.js.map +1 -0
- package/dist/state/archiveReplay.js +54 -0
- package/dist/state/archiveReplay.js.map +1 -0
- package/dist/state/decisionOverlay.js +255 -0
- package/dist/state/decisionOverlay.js.map +1 -0
- package/dist/state/directRetrieval.js +322 -0
- package/dist/state/directRetrieval.js.map +1 -0
- package/dist/state/durability.js +451 -0
- package/dist/state/durability.js.map +1 -0
- package/dist/state/experimentArchive.js +64 -0
- package/dist/state/experimentArchive.js.map +1 -0
- package/dist/state/experimentIdentity.js +191 -0
- package/dist/state/experimentIdentity.js.map +1 -0
- package/dist/state/experimentRetrieval.js +447 -0
- package/dist/state/experimentRetrieval.js.map +1 -0
- package/dist/state/gitBackfill.js +561 -0
- package/dist/state/gitBackfill.js.map +1 -0
- package/dist/state/gitBackfillAuthority.js +141 -0
- package/dist/state/gitBackfillAuthority.js.map +1 -0
- package/dist/state/gitBackfillHistory.js +278 -0
- package/dist/state/gitBackfillHistory.js.map +1 -0
- package/dist/state/gitBackfillOutput.js +209 -0
- package/dist/state/gitBackfillOutput.js.map +1 -0
- package/dist/state/healthRepair.js +70 -0
- package/dist/state/healthRepair.js.map +1 -0
- package/dist/state/installRoot.js +64 -24
- package/dist/state/installRoot.js.map +1 -1
- package/dist/state/legacyIdentity.js +48 -0
- package/dist/state/legacyIdentity.js.map +1 -0
- package/dist/state/legacyMigration.js +516 -0
- package/dist/state/legacyMigration.js.map +1 -0
- package/dist/state/legacyMigrationParser.js +489 -0
- package/dist/state/legacyMigrationParser.js.map +1 -0
- package/dist/state/listAccounting.js +55 -0
- package/dist/state/listAccounting.js.map +1 -0
- package/dist/state/listClassification.js +18 -0
- package/dist/state/listClassification.js.map +1 -0
- package/dist/state/listRetrieval.js +782 -0
- package/dist/state/listRetrieval.js.map +1 -0
- package/dist/state/migrationAuthority.js +413 -0
- package/dist/state/migrationAuthority.js.map +1 -0
- package/dist/state/migrationEnrichment.js +35 -0
- package/dist/state/migrationEnrichment.js.map +1 -0
- package/dist/state/planIdentity.js +45 -0
- package/dist/state/planIdentity.js.map +1 -0
- package/dist/state/planRetrieval.js +314 -0
- package/dist/state/planRetrieval.js.map +1 -0
- package/dist/state/planTaskRetrieval.js +285 -0
- package/dist/state/planTaskRetrieval.js.map +1 -0
- package/dist/state/projectionPolicy.js +184 -0
- package/dist/state/projectionPolicy.js.map +1 -0
- package/dist/state/retrievalAuthority.js +326 -0
- package/dist/state/retrievalAuthority.js.map +1 -0
- package/dist/state/startupAnalysis/benchmark.js +371 -0
- package/dist/state/startupAnalysis/benchmark.js.map +1 -0
- package/dist/state/startupAnalysis/contract.js +126 -0
- package/dist/state/startupAnalysis/contract.js.map +1 -0
- package/dist/state/startupAnalysis/helpers.js +287 -0
- package/dist/state/startupAnalysis/helpers.js.map +1 -0
- package/dist/state/startupAnalysis/index.js +7 -0
- package/dist/state/startupAnalysis/index.js.map +1 -0
- package/dist/state/startupAnalysis/metrics.js +341 -0
- package/dist/state/startupAnalysis/metrics.js.map +1 -0
- package/dist/state/startupAnalysis/records.js +199 -0
- package/dist/state/startupAnalysis/records.js.map +1 -0
- package/dist/state/startupAnalysis/report.js +112 -0
- package/dist/state/startupAnalysis/report.js.map +1 -0
- package/dist/state/startupAnalysis/threshold.js +500 -0
- package/dist/state/startupAnalysis/threshold.js.map +1 -0
- package/dist/state/startupAnalysis.js +2 -1952
- package/dist/state/startupAnalysis.js.map +1 -1
- package/dist/state/startupProjection.js +498 -0
- package/dist/state/startupProjection.js.map +1 -0
- package/dist/state/write/assign.js +21 -0
- package/dist/state/write/assign.js.map +1 -0
- package/dist/state/write/errors.js +12 -0
- package/dist/state/write/errors.js.map +1 -0
- package/dist/state/write/experimentPublication.js +193 -0
- package/dist/state/write/experimentPublication.js.map +1 -0
- package/dist/state/write/explain.js +169 -0
- package/dist/state/write/explain.js.map +1 -0
- package/dist/state/write/fields.js +62 -0
- package/dist/state/write/fields.js.map +1 -0
- package/dist/state/write/helpers.js +8 -0
- package/dist/state/write/helpers.js.map +1 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/index.js.map +1 -0
- package/dist/state/write/input.js +22 -0
- package/dist/state/write/input.js.map +1 -0
- package/dist/state/write/lock.js +131 -0
- package/dist/state/write/lock.js.map +1 -0
- package/dist/state/write/mutation.js +190 -0
- package/dist/state/write/mutation.js.map +1 -0
- package/dist/state/write/operations.js +254 -0
- package/dist/state/write/operations.js.map +1 -0
- package/dist/state/write/planPublication.js +172 -0
- package/dist/state/write/planPublication.js.map +1 -0
- package/dist/state/write/serialize.js +2 -0
- package/dist/state/write/serialize.js.map +1 -0
- package/dist/state/write/transaction.js +800 -0
- package/dist/state/write/transaction.js.map +1 -0
- package/dist/state/write/validate.js +8 -0
- package/dist/state/write/validate.js.map +1 -0
- package/dist/upgrade/appContentRefresh.js +374 -0
- package/dist/upgrade/appContentRefresh.js.map +1 -0
- package/dist/upgrade/appModel.js +11 -6
- package/dist/upgrade/appModel.js.map +1 -1
- package/dist/upgrade/atomicWriter.js +2 -0
- package/dist/upgrade/atomicWriter.js.map +1 -0
- package/dist/upgrade/bundleEvidence.js +34 -0
- package/dist/upgrade/bundleEvidence.js.map +1 -0
- package/dist/upgrade/channels.js +27 -7
- package/dist/upgrade/channels.js.map +1 -1
- package/dist/upgrade/coexistenceProbe.js +105 -0
- package/dist/upgrade/coexistenceProbe.js.map +1 -0
- package/dist/upgrade/compatibility.js +52 -16
- package/dist/upgrade/compatibility.js.map +1 -1
- package/dist/upgrade/doctor.js +195 -193
- package/dist/upgrade/doctor.js.map +1 -1
- package/dist/upgrade/doctorClassifier.js +188 -0
- package/dist/upgrade/doctorClassifier.js.map +1 -0
- package/dist/upgrade/installedHooksRetirement.js +190 -0
- package/dist/upgrade/installedHooksRetirement.js.map +1 -0
- package/dist/upgrade/legacyAgentCleanup.js +183 -0
- package/dist/upgrade/legacyAgentCleanup.js.map +1 -0
- package/dist/upgrade/lifecycleUpgrade.js +427 -0
- package/dist/upgrade/lifecycleUpgrade.js.map +1 -0
- package/dist/upgrade/migrateArtifactsV1ToV2.js +568 -0
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +1 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +273 -144
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
- package/dist/upgrade/nextMajorDoctor.js +156 -0
- package/dist/upgrade/nextMajorDoctor.js.map +1 -0
- package/dist/upgrade/npxPlatformStatus.js +23 -0
- package/dist/upgrade/npxPlatformStatus.js.map +1 -0
- package/dist/upgrade/projectIntegration.js +259 -104
- package/dist/upgrade/projectIntegration.js.map +1 -1
- package/dist/upgrade/projectIntegrationDecision.js +141 -0
- package/dist/upgrade/projectIntegrationDecision.js.map +1 -0
- package/dist/upgrade/runtimeMigration.js +342 -89
- package/dist/upgrade/runtimeMigration.js.map +1 -1
- package/dist/upgrade/upgradeCommands.js +8 -0
- package/dist/upgrade/upgradeCommands.js.map +1 -1
- package/dist/upgrade/upgradeLock.js +54 -0
- package/dist/upgrade/upgradeLock.js.map +1 -0
- package/dist/upgrade/upgradeOrchestrator.js +170 -46
- package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
- package/dist/upgrade/upgradeSnapshot.js +93 -0
- package/dist/upgrade/upgradeSnapshot.js.map +1 -0
- package/dist/upgrade/v3CapabilitySurface.js +15 -0
- package/dist/upgrade/v3CapabilitySurface.js.map +1 -0
- package/dist/upgrade/versionResolution.js +12 -4
- package/dist/upgrade/versionResolution.js.map +1 -1
- package/dist/validate/appHomeContract.js +5 -5
- package/dist/validate/appHomeContract.js.map +1 -1
- package/dist/validate/capability.js +135 -14
- package/dist/validate/capability.js.map +1 -1
- package/dist/validate/crossCapability.js +10 -7
- package/dist/validate/crossCapability.js.map +1 -1
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js +93 -0
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +1 -0
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js +481 -0
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +1 -0
- package/dist/validate/lifecycleAdapters/shared.js +198 -0
- package/dist/validate/lifecycleAdapters/shared.js.map +1 -0
- package/dist/validate/lifecycleAdapters.js +91 -702
- package/dist/validate/lifecycleAdapters.js.map +1 -1
- package/dist/validate/selfAudit.js +63 -21
- package/dist/validate/selfAudit.js.map +1 -1
- package/dist/validate/vocabularyAuthority.js +303 -0
- package/dist/validate/vocabularyAuthority.js.map +1 -0
- package/package.json +30 -27
- package/bundle/references/v1-section-mapping.md +0 -47
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/dokumentera.toml +0 -6
- package/bundle/skills/agentera/agents/hej.toml +0 -6
- package/bundle/skills/agentera/agents/inspektera.toml +0 -6
- package/bundle/skills/agentera/agents/inspirera.toml +0 -6
- package/bundle/skills/agentera/agents/optimera.toml +0 -6
- package/bundle/skills/agentera/agents/orkestrera.toml +0 -6
- package/bundle/skills/agentera/agents/planera.toml +0 -6
- package/bundle/skills/agentera/agents/profilera.toml +0 -6
- package/bundle/skills/agentera/agents/realisera.toml +0 -6
- package/bundle/skills/agentera/agents/resonera.toml +0 -6
- package/bundle/skills/agentera/agents/visionera.toml +0 -6
- package/bundle/skills/agentera/agents/visualisera.toml +0 -6
- package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +0 -428
- package/bundle/skills/agentera/capabilities/hej/instructions.md +0 -331
- package/bundle/skills/agentera/capabilities/inspektera/instructions.md +0 -514
- package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +0 -76
- package/bundle/skills/agentera/capabilities/inspirera/instructions.md +0 -280
- package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +0 -24
- package/bundle/skills/agentera/capabilities/optimera/instructions.md +0 -437
- package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +0 -433
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +0 -64
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +0 -107
- package/bundle/skills/agentera/capabilities/planera/instructions.md +0 -368
- package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +0 -62
- package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +0 -61
- package/bundle/skills/agentera/capabilities/profilera/instructions.md +0 -419
- package/bundle/skills/agentera/capabilities/realisera/instructions.md +0 -403
- package/bundle/skills/agentera/capabilities/resonera/instructions.md +0 -329
- package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +0 -47
- package/bundle/skills/agentera/capabilities/visionera/instructions.md +0 -309
- package/bundle/skills/agentera/capabilities/visualisera/instructions.md +0 -400
- package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
- package/bundle/skills/hej/SKILL.md +0 -69
- package/bundle/skills/hej/agents/hej.toml +0 -11
- package/bundle/skills/hej/agents/openai.yaml +0 -8
- package/dist/cli/commands/state.js +0 -1012
- package/dist/cli/commands/state.js.map +0 -1
- package/dist/core/git.js +0 -43
- package/dist/core/git.js.map +0 -1
- package/dist/hooks/compaction.js +0 -935
- package/dist/hooks/compaction.js.map +0 -1
- package/dist/hooks/validateArtifact.js +0 -933
- package/dist/hooks/validateArtifact.js.map +0 -1
- package/dist/state/progressCommit.js +0 -289
- package/dist/state/progressCommit.js.map +0 -1
- /package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{hej → status}/schemas/exit.yaml +0 -0
package/dist/hooks/compaction.js
DELETED
|
@@ -1,935 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import YAML from "yaml";
|
|
4
|
-
import { loadYamlMapping } from "../core/yaml.js";
|
|
5
|
-
import { DEFAULT_ARTIFACT_PATHS, MAX_FULL_ENTRIES, MAX_ONELINE_ENTRIES, MAX_TOTAL_ENTRIES, applyRetentionCaps, parseDocsYamlMapping, } from "./common.js";
|
|
6
|
-
// --- body field helpers ----------------------------------------------------
|
|
7
|
-
function extractField(body, label) {
|
|
8
|
-
const pattern = new RegExp(`^\\*\\*${escapeRe(label)}\\*\\*:\\s*(.+?)$`, "m");
|
|
9
|
-
const m = pattern.exec(body);
|
|
10
|
-
return m ? m[1].trim() : "";
|
|
11
|
-
}
|
|
12
|
-
function escapeRe(s) {
|
|
13
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
|
-
}
|
|
15
|
-
function firstNonEmpty(body) {
|
|
16
|
-
for (const line of body.split(/\r\n|\r|\n/)) {
|
|
17
|
-
if (line.trim())
|
|
18
|
-
return line.trim();
|
|
19
|
-
}
|
|
20
|
-
return "";
|
|
21
|
-
}
|
|
22
|
-
function truncateWords(text, limit = 15) {
|
|
23
|
-
const words = text.split(/\s+/).filter((w) => w.length > 0);
|
|
24
|
-
// Match Python str.split() token count but preserve original spacing on no-trunc.
|
|
25
|
-
const tokenCount = (text.match(/\S+/g) ?? []).length;
|
|
26
|
-
if (tokenCount <= limit)
|
|
27
|
-
return text;
|
|
28
|
-
return words.slice(0, limit).join(" ") + "...";
|
|
29
|
-
}
|
|
30
|
-
const HEADER_NUM_RE = /(?:Cycle|Decision|Audit|Experiment)\s+(\d+)/;
|
|
31
|
-
const HEADER_DATE_RE = /(\d{4}-\d{2}-\d{2})/;
|
|
32
|
-
const NUMBER_RE = /(?:Cycle|Decision|Audit|Experiment|EXP-)\s*(\d+)/;
|
|
33
|
-
function parseHeader(header) {
|
|
34
|
-
const numMatch = HEADER_NUM_RE.exec(header);
|
|
35
|
-
const dateMatch = HEADER_DATE_RE.exec(header);
|
|
36
|
-
const number = numMatch ? numMatch[1] : "";
|
|
37
|
-
const date = dateMatch ? dateMatch[1] : "";
|
|
38
|
-
const parts = header.split(" · ");
|
|
39
|
-
let title = parts.length >= 2 ? parts[parts.length - 1].trim() : "";
|
|
40
|
-
if (title === date) {
|
|
41
|
-
title = parts.length >= 3 ? parts[parts.length - 2].trim() : "";
|
|
42
|
-
}
|
|
43
|
-
return [number, date, title];
|
|
44
|
-
}
|
|
45
|
-
// --- one-line formatters ---------------------------------------------------
|
|
46
|
-
function formatProgressOneline(entry) {
|
|
47
|
-
let [number, date, title] = parseHeader(entry.header);
|
|
48
|
-
if (!title) {
|
|
49
|
-
title = extractField(entry.body, "What") || firstNonEmpty(entry.body);
|
|
50
|
-
}
|
|
51
|
-
title = truncateWords(title || "(no summary)", 20);
|
|
52
|
-
const numberPart = number ? `Cycle ${number}` : "Cycle ?";
|
|
53
|
-
const datePart = date ? ` (${date})` : "";
|
|
54
|
-
return `- ${numberPart}${datePart}: ${title}`;
|
|
55
|
-
}
|
|
56
|
-
function formatDecisionOneline(entry) {
|
|
57
|
-
const [number, date] = parseHeader(entry.header);
|
|
58
|
-
let chosen = extractField(entry.body, "Chosen alternative");
|
|
59
|
-
if (!chosen)
|
|
60
|
-
chosen = extractField(entry.body, "Chosen");
|
|
61
|
-
if (!chosen)
|
|
62
|
-
chosen = firstNonEmpty(entry.body);
|
|
63
|
-
chosen = truncateWords(chosen || "(no rationale)", 20);
|
|
64
|
-
const numberPart = number ? `Decision ${number}` : "Decision ?";
|
|
65
|
-
const datePart = date ? ` (${date})` : "";
|
|
66
|
-
return `- ${numberPart}${datePart}: ${chosen}`;
|
|
67
|
-
}
|
|
68
|
-
function formatHealthOneline(entry) {
|
|
69
|
-
const [number, date] = parseHeader(entry.header);
|
|
70
|
-
let grade = extractField(entry.body, "Overall");
|
|
71
|
-
if (!grade)
|
|
72
|
-
grade = extractField(entry.body, "Grade");
|
|
73
|
-
let trajectory = extractField(entry.body, "Overall trajectory");
|
|
74
|
-
if (!trajectory)
|
|
75
|
-
trajectory = "";
|
|
76
|
-
const summaryBits = [];
|
|
77
|
-
if (grade)
|
|
78
|
-
summaryBits.push(truncateWords(grade, 10));
|
|
79
|
-
if (trajectory && trajectory !== grade)
|
|
80
|
-
summaryBits.push(truncateWords(trajectory, 10));
|
|
81
|
-
const summary = summaryBits.length > 0 ? summaryBits.join(" | ") : "no summary";
|
|
82
|
-
const numberPart = number ? `Audit ${number}` : "Audit ?";
|
|
83
|
-
const datePart = date ? ` · ${date}` : "";
|
|
84
|
-
return `### ${numberPart}${datePart} (${summary})`;
|
|
85
|
-
}
|
|
86
|
-
function formatExperimentOneline(entry) {
|
|
87
|
-
const [number] = parseHeader(entry.header);
|
|
88
|
-
let summary = extractField(entry.body, "Metric");
|
|
89
|
-
if (!summary)
|
|
90
|
-
summary = extractField(entry.body, "Conclusion");
|
|
91
|
-
if (!summary)
|
|
92
|
-
summary = extractField(entry.body, "Result");
|
|
93
|
-
if (!summary)
|
|
94
|
-
summary = firstNonEmpty(entry.body);
|
|
95
|
-
summary = truncateWords(summary || "(no result)", 15);
|
|
96
|
-
const numberPart = number ? `EXP-${number}` : "EXP-?";
|
|
97
|
-
return `- ${numberPart}: ${summary}`;
|
|
98
|
-
}
|
|
99
|
-
const TODO_CHECKBOX_RE = /^-\s*\[x\]\s*/;
|
|
100
|
-
const TODO_ISS_LABEL_RE = /ISS-\d+:?\s*/;
|
|
101
|
-
function isTodoOnelinePassthrough(entry) {
|
|
102
|
-
return entry.kind === "oneline" && String(entry.header).includes("~~");
|
|
103
|
-
}
|
|
104
|
-
function stripTodoMetadata(header) {
|
|
105
|
-
let stripped = header.replace(TODO_CHECKBOX_RE, "");
|
|
106
|
-
stripped = stripped.replace(/~~/g, "").trim();
|
|
107
|
-
stripped = stripped.split(" · ")[0].trim();
|
|
108
|
-
stripped = stripped.replace(TODO_ISS_LABEL_RE, "").trim();
|
|
109
|
-
return stripped;
|
|
110
|
-
}
|
|
111
|
-
function formatTodoOneline(entry) {
|
|
112
|
-
const header = String(entry.header).trim();
|
|
113
|
-
if (isTodoOnelinePassthrough(entry)) {
|
|
114
|
-
return header.startsWith("- ") ? header : `- ${header}`;
|
|
115
|
-
}
|
|
116
|
-
const summary = truncateWords(stripTodoMetadata(header) || "(resolved)", 15);
|
|
117
|
-
return `- [x] ~~${summary}~~`;
|
|
118
|
-
}
|
|
119
|
-
export const SPECS = {
|
|
120
|
-
progress: {
|
|
121
|
-
name: "progress",
|
|
122
|
-
entryHeadingRe: /^■?\s*##\s+Cycle\s+\d+/m,
|
|
123
|
-
onelineHeadingRe: /^-\s+Cycle\s+\d+/m,
|
|
124
|
-
archiveHeading: "## Archived Cycles",
|
|
125
|
-
formatOneline: formatProgressOneline,
|
|
126
|
-
scopedSection: null,
|
|
127
|
-
},
|
|
128
|
-
decisions: {
|
|
129
|
-
name: "decisions",
|
|
130
|
-
entryHeadingRe: /^##\s+Decision\s+\d+/m,
|
|
131
|
-
onelineHeadingRe: /^-\s+Decision\s+\d+/m,
|
|
132
|
-
archiveHeading: "## Archived Decisions",
|
|
133
|
-
formatOneline: formatDecisionOneline,
|
|
134
|
-
scopedSection: null,
|
|
135
|
-
},
|
|
136
|
-
health: {
|
|
137
|
-
name: "health",
|
|
138
|
-
entryHeadingRe: /^##\s+Audit\s+\d+/m,
|
|
139
|
-
onelineHeadingRe: /^###\s+Audit\s+\d+/m,
|
|
140
|
-
archiveHeading: "## Archived Audits",
|
|
141
|
-
formatOneline: formatHealthOneline,
|
|
142
|
-
scopedSection: null,
|
|
143
|
-
},
|
|
144
|
-
experiments: {
|
|
145
|
-
name: "experiments",
|
|
146
|
-
entryHeadingRe: /^##\s+Experiment\s+\d+/m,
|
|
147
|
-
onelineHeadingRe: /^-\s+EXP-\d+/m,
|
|
148
|
-
archiveHeading: "## Archived Experiments",
|
|
149
|
-
formatOneline: formatExperimentOneline,
|
|
150
|
-
scopedSection: null,
|
|
151
|
-
},
|
|
152
|
-
"todo-resolved": {
|
|
153
|
-
name: "todo-resolved",
|
|
154
|
-
entryHeadingRe: /^-\s+\[x\]\s+/m,
|
|
155
|
-
onelineHeadingRe: null,
|
|
156
|
-
archiveHeading: null,
|
|
157
|
-
formatOneline: formatTodoOneline,
|
|
158
|
-
scopedSection: "## Resolved",
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
export const COMPACTABLE_YAML_ARTIFACTS = {
|
|
162
|
-
"PROGRESS.md": ["cycles", "archive"],
|
|
163
|
-
"DECISIONS.md": ["decisions", "archive"],
|
|
164
|
-
"HEALTH.md": ["audits", "archive"],
|
|
165
|
-
};
|
|
166
|
-
const YAML_SPEC_BY_ARTIFACT = {
|
|
167
|
-
"PROGRESS.md": "progress",
|
|
168
|
-
"DECISIONS.md": "decisions",
|
|
169
|
-
"HEALTH.md": "health",
|
|
170
|
-
};
|
|
171
|
-
const NON_COMPACTABLE_ARTIFACTS = {
|
|
172
|
-
"CHANGELOG.md": ["exempt", "public release history is not compacted"],
|
|
173
|
-
"PLAN.md": ["unsupported", "active plan is lifecycle state, not a uniform retained-entry log"],
|
|
174
|
-
"DOCS.md": ["unsupported", "docs owns artifact mapping and schema metadata"],
|
|
175
|
-
"VISION.md": ["protected", "vision state is protected during execution cycles"],
|
|
176
|
-
"DESIGN.md": ["unsupported", "design is a human-facing identity artifact, not a uniform retained-entry log"],
|
|
177
|
-
};
|
|
178
|
-
function overLimitCount(activeCount, archiveCount) {
|
|
179
|
-
const totalCount = activeCount + archiveCount;
|
|
180
|
-
return Math.max(Math.max(activeCount - MAX_FULL_ENTRIES, 0), Math.max(archiveCount - MAX_ONELINE_ENTRIES, 0), Math.max(totalCount - MAX_TOTAL_ENTRIES, 0));
|
|
181
|
-
}
|
|
182
|
-
function artifactPaths(projectRoot) {
|
|
183
|
-
const paths = { ...DEFAULT_ARTIFACT_PATHS };
|
|
184
|
-
const docsPath = path.join(projectRoot, ".agentera", "docs.yaml");
|
|
185
|
-
if (fs.existsSync(docsPath)) {
|
|
186
|
-
Object.assign(paths, parseDocsYamlMapping(fs.readFileSync(docsPath, "utf8")));
|
|
187
|
-
}
|
|
188
|
-
const resolved = {};
|
|
189
|
-
for (const [artifact, rel] of Object.entries(paths)) {
|
|
190
|
-
resolved[artifact] = path.join(projectRoot, rel);
|
|
191
|
-
}
|
|
192
|
-
return resolved;
|
|
193
|
-
}
|
|
194
|
-
function missingStatus(artifact, p, classification) {
|
|
195
|
-
return {
|
|
196
|
-
artifact,
|
|
197
|
-
path: p,
|
|
198
|
-
classification,
|
|
199
|
-
active_count: 0,
|
|
200
|
-
archive_count: 0,
|
|
201
|
-
total_count: 0,
|
|
202
|
-
over_limit_count: 0,
|
|
203
|
-
reason: "artifact path is not present",
|
|
204
|
-
protected_overflow_count: 0,
|
|
205
|
-
exists: false,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function yamlErrorStatus(artifact, p, message) {
|
|
209
|
-
return {
|
|
210
|
-
artifact,
|
|
211
|
-
path: p,
|
|
212
|
-
classification: "error",
|
|
213
|
-
active_count: null,
|
|
214
|
-
archive_count: null,
|
|
215
|
-
total_count: null,
|
|
216
|
-
over_limit_count: null,
|
|
217
|
-
reason: message.trim() || "invalid YAML mapping root",
|
|
218
|
-
protected_overflow_count: 0,
|
|
219
|
-
exists: true,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function yamlCounts(p, activeKey, archiveKey) {
|
|
223
|
-
const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
|
|
224
|
-
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
225
|
-
return [0, 0];
|
|
226
|
-
const active = data[activeKey] || [];
|
|
227
|
-
const archive = data[archiveKey] || [];
|
|
228
|
-
return [Array.isArray(active) ? active.length : 0, Array.isArray(archive) ? archive.length : 0];
|
|
229
|
-
}
|
|
230
|
-
function yamlLists(p, activeKey, archiveKey) {
|
|
231
|
-
const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
|
|
232
|
-
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
233
|
-
return [[], []];
|
|
234
|
-
const active = data[activeKey] || [];
|
|
235
|
-
const archive = data[archiveKey] || [];
|
|
236
|
-
return [Array.isArray(active) ? active : [], Array.isArray(archive) ? archive : []];
|
|
237
|
-
}
|
|
238
|
-
function yamlEntryNumber(entry) {
|
|
239
|
-
let summary;
|
|
240
|
-
if (entry && typeof entry === "object" && !Array.isArray(entry)) {
|
|
241
|
-
const number = entry.number;
|
|
242
|
-
if (typeof number === "number" && Number.isInteger(number))
|
|
243
|
-
return number;
|
|
244
|
-
if (typeof number === "string" && /^\d+$/.test(number))
|
|
245
|
-
return parseInt(number, 10);
|
|
246
|
-
summary = String(entry.summary ?? "");
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
summary = String(entry);
|
|
250
|
-
}
|
|
251
|
-
const match = NUMBER_RE.exec(summary);
|
|
252
|
-
return match ? parseInt(match[1], 10) : 0;
|
|
253
|
-
}
|
|
254
|
-
function yamlEntryTimestamp(entry) {
|
|
255
|
-
if (entry && typeof entry === "object" && !Array.isArray(entry)) {
|
|
256
|
-
return String(entry.timestamp || entry.date || "");
|
|
257
|
-
}
|
|
258
|
-
return "";
|
|
259
|
-
}
|
|
260
|
-
function yamlSummaryText(entry, ...fields) {
|
|
261
|
-
for (const field of fields) {
|
|
262
|
-
const value = entry[field];
|
|
263
|
-
if (typeof value === "string" && value.trim()) {
|
|
264
|
-
return truncateWords(value.trim(), 15);
|
|
265
|
-
}
|
|
266
|
-
if (value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0) {
|
|
267
|
-
return truncateWords(Object.entries(value).map(([k, v]) => `${k}: ${v}`).join(", "), 15);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return "no summary";
|
|
271
|
-
}
|
|
272
|
-
function isEmptyish(v) {
|
|
273
|
-
return (v === null ||
|
|
274
|
-
v === undefined ||
|
|
275
|
-
v === "" ||
|
|
276
|
-
(Array.isArray(v) && v.length === 0) ||
|
|
277
|
-
(typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 0));
|
|
278
|
-
}
|
|
279
|
-
function yamlArchiveEntry(specName, entry) {
|
|
280
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
281
|
-
return { summary: String(entry) };
|
|
282
|
-
}
|
|
283
|
-
const e = entry;
|
|
284
|
-
if (specName === "progress") {
|
|
285
|
-
const number = e.number ?? "?";
|
|
286
|
-
const date = String(e.timestamp ?? "").split(/\s+/)[0] || "";
|
|
287
|
-
const datePart = date ? ` (${date})` : "";
|
|
288
|
-
const summary = yamlSummaryText(e, "what", "type");
|
|
289
|
-
return { summary: `Cycle ${number}${datePart}: ${summary}` };
|
|
290
|
-
}
|
|
291
|
-
if (specName === "decisions") {
|
|
292
|
-
const number = e.number ?? "?";
|
|
293
|
-
const date = String(e.date ?? "");
|
|
294
|
-
const datePart = date ? ` (${date})` : "";
|
|
295
|
-
const choice = yamlSummaryText(e, "choice", "question");
|
|
296
|
-
const archiveEntry = { summary: `Decision ${number}${datePart}: ${choice}` };
|
|
297
|
-
for (const field of ["number", "date", "choice", "outcome", "feeds_into", "satisfaction"]) {
|
|
298
|
-
const value = e[field];
|
|
299
|
-
if (!isEmptyish(value))
|
|
300
|
-
archiveEntry[field] = value;
|
|
301
|
-
}
|
|
302
|
-
if (!("outcome" in archiveEntry) && !isEmptyish(archiveEntry.choice)) {
|
|
303
|
-
archiveEntry.outcome = archiveEntry.choice;
|
|
304
|
-
}
|
|
305
|
-
return archiveEntry;
|
|
306
|
-
}
|
|
307
|
-
if (specName === "health") {
|
|
308
|
-
const number = e.number ?? "?";
|
|
309
|
-
const date = String(e.date ?? "");
|
|
310
|
-
const datePart = date ? ` (${date})` : "";
|
|
311
|
-
const summary = yamlSummaryText(e, "trajectory", "grades");
|
|
312
|
-
return { summary: `Audit ${number}${datePart}: ${summary}` };
|
|
313
|
-
}
|
|
314
|
-
if (specName === "session") {
|
|
315
|
-
return { timestamp: String(e.timestamp ?? ""), summary: yamlSummaryText(e, "summary") };
|
|
316
|
-
}
|
|
317
|
-
return { summary: yamlSummaryText(e, "summary") };
|
|
318
|
-
}
|
|
319
|
-
function stableSortBy(arr, key, reverse = false) {
|
|
320
|
-
return arr
|
|
321
|
-
.map((x, i) => [x, i])
|
|
322
|
-
.sort((a, b) => {
|
|
323
|
-
const ka = key(a[0]);
|
|
324
|
-
const kb = key(b[0]);
|
|
325
|
-
let cmp = ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
326
|
-
if (reverse)
|
|
327
|
-
cmp = -cmp;
|
|
328
|
-
return cmp !== 0 ? cmp : a[1] - b[1];
|
|
329
|
-
})
|
|
330
|
-
.map(([x]) => x);
|
|
331
|
-
}
|
|
332
|
-
function yamlSortEntries(entries, specName) {
|
|
333
|
-
if (specName === "decisions" || specName === "health") {
|
|
334
|
-
return stableSortBy(entries, yamlEntryNumber);
|
|
335
|
-
}
|
|
336
|
-
if (specName === "session") {
|
|
337
|
-
return stableSortBy(entries, yamlEntryTimestamp, true);
|
|
338
|
-
}
|
|
339
|
-
return stableSortBy(entries, yamlEntryNumber, true);
|
|
340
|
-
}
|
|
341
|
-
function yamlRecentFullAndOlder(entries, specName) {
|
|
342
|
-
const newestFirst = specName === "session"
|
|
343
|
-
? stableSortBy(entries, yamlEntryTimestamp, true)
|
|
344
|
-
: stableSortBy(entries, yamlEntryNumber, true);
|
|
345
|
-
const recent = newestFirst.slice(0, MAX_FULL_ENTRIES);
|
|
346
|
-
const older = newestFirst.slice(MAX_FULL_ENTRIES);
|
|
347
|
-
return [yamlSortEntries(recent, specName), older];
|
|
348
|
-
}
|
|
349
|
-
function yamlArchiveSortKey(entry) {
|
|
350
|
-
const timestamp = yamlEntryTimestamp(entry);
|
|
351
|
-
if (timestamp)
|
|
352
|
-
return ["timestamp", timestamp];
|
|
353
|
-
return ["number", yamlEntryNumber(entry)];
|
|
354
|
-
}
|
|
355
|
-
function yamlArchiveEntries(entries) {
|
|
356
|
-
// Sort by (tag, value) descending, mirroring Python tuple comparison.
|
|
357
|
-
return entries
|
|
358
|
-
.map((x, i) => [x, i])
|
|
359
|
-
.sort((a, b) => {
|
|
360
|
-
const ka = yamlArchiveSortKey(a[0]);
|
|
361
|
-
const kb = yamlArchiveSortKey(b[0]);
|
|
362
|
-
let cmp = 0;
|
|
363
|
-
if (ka[0] !== kb[0])
|
|
364
|
-
cmp = ka[0] < kb[0] ? -1 : 1;
|
|
365
|
-
else
|
|
366
|
-
cmp = ka[1] < kb[1] ? -1 : ka[1] > kb[1] ? 1 : 0;
|
|
367
|
-
cmp = -cmp;
|
|
368
|
-
return cmp !== 0 ? cmp : a[1] - b[1];
|
|
369
|
-
})
|
|
370
|
-
.map(([x]) => x);
|
|
371
|
-
}
|
|
372
|
-
function decisionSatisfactionState(entry) {
|
|
373
|
-
if (!entry || typeof entry !== "object")
|
|
374
|
-
return null;
|
|
375
|
-
const satisfaction = entry.satisfaction;
|
|
376
|
-
if (!satisfaction || typeof satisfaction !== "object")
|
|
377
|
-
return null;
|
|
378
|
-
const state = satisfaction.state;
|
|
379
|
-
return typeof state === "string" ? state : null;
|
|
380
|
-
}
|
|
381
|
-
function decisionRequiresUserReview(entry) {
|
|
382
|
-
if (!entry || typeof entry !== "object")
|
|
383
|
-
return true;
|
|
384
|
-
const satisfaction = entry.satisfaction;
|
|
385
|
-
if (!satisfaction || typeof satisfaction !== "object")
|
|
386
|
-
return true;
|
|
387
|
-
const confirmation = satisfaction.user_confirmation;
|
|
388
|
-
return (decisionSatisfactionState(entry) !== "user_confirmed_satisfied" ||
|
|
389
|
-
!confirmation ||
|
|
390
|
-
typeof confirmation !== "object" ||
|
|
391
|
-
Object.keys(confirmation).length === 0);
|
|
392
|
-
}
|
|
393
|
-
function decisionProtectedOverflowCount(active, archive) {
|
|
394
|
-
const protectedActive = active.filter((e) => decisionRequiresUserReview(e)).length;
|
|
395
|
-
const protectedArchive = archive.filter((e) => decisionRequiresUserReview(e)).length;
|
|
396
|
-
return Math.max(protectedActive - MAX_FULL_ENTRIES, protectedArchive - MAX_ONELINE_ENTRIES, protectedActive + protectedArchive - MAX_TOTAL_ENTRIES, 0);
|
|
397
|
-
}
|
|
398
|
-
function selectDecisionActiveEntries(active) {
|
|
399
|
-
const protectedEntries = active.filter((e) => decisionRequiresUserReview(e));
|
|
400
|
-
if (protectedEntries.length > MAX_FULL_ENTRIES) {
|
|
401
|
-
throw new Error("DECISIONS.md: protected-overflow review pressure; " +
|
|
402
|
-
`${protectedEntries.length} protected active decision(s) exceed ${MAX_FULL_ENTRIES} full-detail slots`);
|
|
403
|
-
}
|
|
404
|
-
const satisfied = active.filter((e) => !decisionRequiresUserReview(e));
|
|
405
|
-
const newestSatisfied = stableSortBy(satisfied, yamlEntryNumber, true);
|
|
406
|
-
const keepSatisfied = newestSatisfied.slice(0, MAX_FULL_ENTRIES - protectedEntries.length);
|
|
407
|
-
const compactSatisfied = newestSatisfied.slice(MAX_FULL_ENTRIES - protectedEntries.length);
|
|
408
|
-
return [yamlSortEntries([...protectedEntries, ...keepSatisfied], "decisions"), compactSatisfied];
|
|
409
|
-
}
|
|
410
|
-
function selectDecisionArchiveEntries(archiveCandidates) {
|
|
411
|
-
const protectedEntries = archiveCandidates.filter((e) => decisionRequiresUserReview(e));
|
|
412
|
-
if (protectedEntries.length > MAX_ONELINE_ENTRIES) {
|
|
413
|
-
throw new Error("DECISIONS.md: protected-overflow review pressure; " +
|
|
414
|
-
`${protectedEntries.length} protected archived decision(s) exceed ${MAX_ONELINE_ENTRIES} archive slots`);
|
|
415
|
-
}
|
|
416
|
-
const satisfied = archiveCandidates.filter((e) => !decisionRequiresUserReview(e));
|
|
417
|
-
const keepSatisfied = yamlArchiveEntries(satisfied).slice(0, MAX_ONELINE_ENTRIES - protectedEntries.length);
|
|
418
|
-
return yamlArchiveEntries([...protectedEntries, ...keepSatisfied]);
|
|
419
|
-
}
|
|
420
|
-
export function compactYamlFile(p, artifact) {
|
|
421
|
-
if (!(artifact in COMPACTABLE_YAML_ARTIFACTS)) {
|
|
422
|
-
throw new Error(`unsupported YAML artifact: ${artifact}`);
|
|
423
|
-
}
|
|
424
|
-
if (!fs.existsSync(p)) {
|
|
425
|
-
throw new Error(p);
|
|
426
|
-
}
|
|
427
|
-
const [activeKey, archiveKey] = COMPACTABLE_YAML_ARTIFACTS[artifact];
|
|
428
|
-
const specName = YAML_SPEC_BY_ARTIFACT[artifact];
|
|
429
|
-
const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
|
|
430
|
-
let active = data[activeKey] || [];
|
|
431
|
-
let archive = data[archiveKey] || [];
|
|
432
|
-
if (!Array.isArray(active))
|
|
433
|
-
active = [];
|
|
434
|
-
if (!Array.isArray(archive))
|
|
435
|
-
archive = [];
|
|
436
|
-
const fullBefore = active.length;
|
|
437
|
-
const onelineBefore = archive.length;
|
|
438
|
-
if (overLimitCount(fullBefore, onelineBefore) === 0) {
|
|
439
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
|
|
440
|
-
}
|
|
441
|
-
let recentFull;
|
|
442
|
-
let olderActive;
|
|
443
|
-
if (specName === "decisions") {
|
|
444
|
-
[recentFull, olderActive] = selectDecisionActiveEntries(active);
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
[recentFull, olderActive] = yamlRecentFullAndOlder(active, specName);
|
|
448
|
-
}
|
|
449
|
-
const compactedFromActive = olderActive.map((entry) => yamlArchiveEntry(specName, entry));
|
|
450
|
-
const archiveCandidates = yamlArchiveEntries([...compactedFromActive, ...archive]);
|
|
451
|
-
let archiveAfter;
|
|
452
|
-
if (specName === "decisions") {
|
|
453
|
-
archiveAfter = selectDecisionArchiveEntries(archiveCandidates);
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
const merged = applyRetentionCaps(recentFull, archiveCandidates);
|
|
457
|
-
archiveAfter = merged.slice(recentFull.length);
|
|
458
|
-
}
|
|
459
|
-
data[activeKey] = recentFull;
|
|
460
|
-
data[archiveKey] = archiveAfter;
|
|
461
|
-
fs.writeFileSync(p, YAML.stringify(data));
|
|
462
|
-
const fullAfter = recentFull.length;
|
|
463
|
-
const onelineAfter = archiveAfter.length;
|
|
464
|
-
const dropped = fullBefore + onelineBefore - fullAfter - onelineAfter;
|
|
465
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
|
|
466
|
-
}
|
|
467
|
-
function countStatus(artifact, p, activeCount, archiveCount, protectedOverflowCount = 0) {
|
|
468
|
-
const totalCount = activeCount + archiveCount;
|
|
469
|
-
return {
|
|
470
|
-
artifact,
|
|
471
|
-
path: p,
|
|
472
|
-
classification: "compactable",
|
|
473
|
-
active_count: activeCount,
|
|
474
|
-
archive_count: archiveCount,
|
|
475
|
-
total_count: totalCount,
|
|
476
|
-
over_limit_count: overLimitCount(activeCount, archiveCount),
|
|
477
|
-
reason: protectedOverflowCount ? "protected-overflow review pressure" : "uniform_10_40_50",
|
|
478
|
-
protected_overflow_count: protectedOverflowCount,
|
|
479
|
-
exists: true,
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
export function computeCompactionStatus(projectRoot) {
|
|
483
|
-
const paths = artifactPaths(projectRoot);
|
|
484
|
-
const statuses = [];
|
|
485
|
-
const todoPath = paths["TODO.md"];
|
|
486
|
-
if (fs.existsSync(todoPath)) {
|
|
487
|
-
const entries = parseEntries(fs.readFileSync(todoPath, "utf8"), "todo-resolved");
|
|
488
|
-
const activeCount = entries.filter((e) => e.kind === "full").length;
|
|
489
|
-
const archiveCount = entries.filter((e) => e.kind === "oneline").length;
|
|
490
|
-
statuses.push(countStatus("TODO.md#Resolved", todoPath, activeCount, archiveCount));
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
statuses.push(missingStatus("TODO.md#Resolved", todoPath, "compactable"));
|
|
494
|
-
}
|
|
495
|
-
for (const [artifact, [activeKey, archiveKey]] of Object.entries(COMPACTABLE_YAML_ARTIFACTS)) {
|
|
496
|
-
const p = paths[artifact];
|
|
497
|
-
if (fs.existsSync(p)) {
|
|
498
|
-
let active;
|
|
499
|
-
let archive;
|
|
500
|
-
try {
|
|
501
|
-
[active, archive] = yamlLists(p, activeKey, archiveKey);
|
|
502
|
-
}
|
|
503
|
-
catch (exc) {
|
|
504
|
-
statuses.push(yamlErrorStatus(artifact, p, exc.message));
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
const protectedOverflowCount = artifact === "DECISIONS.md" ? decisionProtectedOverflowCount(active, archive) : 0;
|
|
508
|
-
statuses.push(countStatus(artifact, p, active.length, archive.length, protectedOverflowCount));
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
statuses.push(missingStatus(artifact, p, "compactable"));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
for (const [artifact, [classification, reason]] of Object.entries(NON_COMPACTABLE_ARTIFACTS)) {
|
|
515
|
-
const p = paths[artifact];
|
|
516
|
-
statuses.push({
|
|
517
|
-
artifact,
|
|
518
|
-
path: p,
|
|
519
|
-
classification,
|
|
520
|
-
active_count: null,
|
|
521
|
-
archive_count: null,
|
|
522
|
-
total_count: null,
|
|
523
|
-
over_limit_count: null,
|
|
524
|
-
reason,
|
|
525
|
-
protected_overflow_count: 0,
|
|
526
|
-
exists: fs.existsSync(p),
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
const optimeraDir = path.join(projectRoot, ".agentera", "optimera");
|
|
530
|
-
if (fs.existsSync(optimeraDir) && fs.statSync(optimeraDir).isDirectory()) {
|
|
531
|
-
const experimentPaths = [];
|
|
532
|
-
for (const sub of fs.readdirSync(optimeraDir).sort()) {
|
|
533
|
-
const expPath = path.join(optimeraDir, sub, "experiments.yaml");
|
|
534
|
-
if (fs.existsSync(expPath))
|
|
535
|
-
experimentPaths.push(expPath);
|
|
536
|
-
}
|
|
537
|
-
for (const expPath of experimentPaths) {
|
|
538
|
-
let activeCount;
|
|
539
|
-
let archiveCount;
|
|
540
|
-
try {
|
|
541
|
-
[activeCount, archiveCount] = yamlCounts(expPath, "experiments", "archive");
|
|
542
|
-
}
|
|
543
|
-
catch (exc) {
|
|
544
|
-
statuses.push(yamlErrorStatus("EXPERIMENTS.md", expPath, exc.message));
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
statuses.push({
|
|
548
|
-
artifact: "EXPERIMENTS.md",
|
|
549
|
-
path: expPath,
|
|
550
|
-
classification: "protected",
|
|
551
|
-
active_count: activeCount,
|
|
552
|
-
archive_count: archiveCount,
|
|
553
|
-
total_count: activeCount + archiveCount,
|
|
554
|
-
over_limit_count: overLimitCount(activeCount, archiveCount),
|
|
555
|
-
reason: "objective-state experiment files are classified but skipped by default",
|
|
556
|
-
protected_overflow_count: 0,
|
|
557
|
-
exists: true,
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return statuses;
|
|
562
|
-
}
|
|
563
|
-
function operationForStatus(status, mode) {
|
|
564
|
-
const base = (action, message) => ({
|
|
565
|
-
status,
|
|
566
|
-
mode,
|
|
567
|
-
action,
|
|
568
|
-
changed: false,
|
|
569
|
-
result: null,
|
|
570
|
-
message,
|
|
571
|
-
});
|
|
572
|
-
if (!status.exists)
|
|
573
|
-
return base("missing", status.reason);
|
|
574
|
-
if (status.classification === "error")
|
|
575
|
-
return base("error", status.reason);
|
|
576
|
-
if (status.classification !== "compactable")
|
|
577
|
-
return base("skipped", status.reason);
|
|
578
|
-
if (status.protected_overflow_count) {
|
|
579
|
-
return base("protected_overflow", `protected-overflow review pressure by ${status.protected_overflow_count}`);
|
|
580
|
-
}
|
|
581
|
-
if (!status.over_limit_count)
|
|
582
|
-
return base("ok", "within uniform_10_40_50 limits");
|
|
583
|
-
return base(mode === "check" ? "over_limit" : "pending_fix", `over uniform_10_40_50 limit by ${status.over_limit_count}`);
|
|
584
|
-
}
|
|
585
|
-
export function checkCompaction(projectRoot) {
|
|
586
|
-
return computeCompactionStatus(projectRoot).map((status) => operationForStatus(status, "check"));
|
|
587
|
-
}
|
|
588
|
-
export function fixCompaction(projectRoot) {
|
|
589
|
-
const operations = [];
|
|
590
|
-
for (const status of computeCompactionStatus(projectRoot)) {
|
|
591
|
-
const baseline = operationForStatus(status, "fix");
|
|
592
|
-
if (baseline.action !== "pending_fix") {
|
|
593
|
-
operations.push(baseline);
|
|
594
|
-
continue;
|
|
595
|
-
}
|
|
596
|
-
const p = status.path;
|
|
597
|
-
let result;
|
|
598
|
-
try {
|
|
599
|
-
if (status.artifact === "TODO.md#Resolved") {
|
|
600
|
-
result = compactFile(p, "todo-resolved");
|
|
601
|
-
}
|
|
602
|
-
else if (status.artifact in YAML_SPEC_BY_ARTIFACT) {
|
|
603
|
-
result = compactYamlFile(p, status.artifact);
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
operations.push({ status, mode: "fix", action: "skipped", changed: false, result: null, message: `no fixer registered for ${status.artifact}` });
|
|
607
|
-
continue;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
catch (exc) {
|
|
611
|
-
operations.push({ status, mode: "fix", action: "error", changed: false, result: null, message: exc.message });
|
|
612
|
-
continue;
|
|
613
|
-
}
|
|
614
|
-
operations.push({
|
|
615
|
-
status,
|
|
616
|
-
mode: "fix",
|
|
617
|
-
action: result.changed ? "compacted" : "ok",
|
|
618
|
-
changed: result.changed,
|
|
619
|
-
result,
|
|
620
|
-
message: `full ${result.full_before}->${result.full_after}; ` +
|
|
621
|
-
`archive ${result.oneline_before}->${result.oneline_after}; ` +
|
|
622
|
-
`dropped ${result.dropped}`,
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
return operations;
|
|
626
|
-
}
|
|
627
|
-
export function runCompaction(projectRoot, mode = "check") {
|
|
628
|
-
if (mode === "check")
|
|
629
|
-
return checkCompaction(projectRoot);
|
|
630
|
-
if (mode === "fix")
|
|
631
|
-
return fixCompaction(projectRoot);
|
|
632
|
-
throw new Error(`unknown compaction mode: ${mode}`);
|
|
633
|
-
}
|
|
634
|
-
// --- markdown parse + compaction -------------------------------------------
|
|
635
|
-
function splitArchive(text, archiveHeading) {
|
|
636
|
-
if (!archiveHeading)
|
|
637
|
-
return [text, ""];
|
|
638
|
-
const pattern = new RegExp(`^${escapeRe(archiveHeading)}\\s*$`, "m");
|
|
639
|
-
const match = pattern.exec(text);
|
|
640
|
-
if (!match)
|
|
641
|
-
return [text, ""];
|
|
642
|
-
const pre = text.slice(0, match.index).replace(/\s+$/, "");
|
|
643
|
-
const after = text.slice(match.index + match[0].length);
|
|
644
|
-
const nextSection = /^##\s/m.exec(after);
|
|
645
|
-
if (nextSection) {
|
|
646
|
-
const archiveBody = after.slice(0, nextSection.index);
|
|
647
|
-
const trailing = after.slice(nextSection.index);
|
|
648
|
-
return [pre, archiveBody.trim() + (trailing ? "\n\n" + trailing : "")];
|
|
649
|
-
}
|
|
650
|
-
return [pre, after.trim()];
|
|
651
|
-
}
|
|
652
|
-
function parseFullEntries(text, spec) {
|
|
653
|
-
const entries = [];
|
|
654
|
-
const re = new RegExp(spec.entryHeadingRe.source, "gm");
|
|
655
|
-
const matches = [...text.matchAll(re)];
|
|
656
|
-
for (let i = 0; i < matches.length; i++) {
|
|
657
|
-
const m = matches[i];
|
|
658
|
-
const lineStart = text.lastIndexOf("\n", m.index - 1) + 1;
|
|
659
|
-
let lineEnd = text.indexOf("\n", m.index);
|
|
660
|
-
if (lineEnd === -1)
|
|
661
|
-
lineEnd = text.length;
|
|
662
|
-
const headerLine = text.slice(lineStart, lineEnd).trim();
|
|
663
|
-
const glyphMatch = /^(■)\s*/.exec(headerLine);
|
|
664
|
-
const glyph = glyphMatch ? glyphMatch[1] + " " : "";
|
|
665
|
-
const remainder = glyphMatch ? headerLine.slice(glyphMatch[0].length) : headerLine;
|
|
666
|
-
const header = glyph + remainder.replace(/^#+/, "").trim();
|
|
667
|
-
const bodyStart = lineEnd + 1;
|
|
668
|
-
let bodyEnd;
|
|
669
|
-
if (i + 1 < matches.length) {
|
|
670
|
-
bodyEnd = text.lastIndexOf("\n", matches[i + 1].index - 1) + 1;
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
bodyEnd = text.length;
|
|
674
|
-
}
|
|
675
|
-
const body = text.slice(bodyStart, bodyEnd).trim();
|
|
676
|
-
entries.push({ header, body, kind: "full" });
|
|
677
|
-
}
|
|
678
|
-
return entries;
|
|
679
|
-
}
|
|
680
|
-
function parseOnelineEntries(text, spec) {
|
|
681
|
-
if (spec.onelineHeadingRe === null)
|
|
682
|
-
return [];
|
|
683
|
-
const entries = [];
|
|
684
|
-
const re = new RegExp(spec.onelineHeadingRe.source);
|
|
685
|
-
for (const line of text.split(/\r\n|\r|\n/)) {
|
|
686
|
-
if (re.test(line)) {
|
|
687
|
-
entries.push({ header: line.replace(/\s+$/, ""), body: "", kind: "oneline" });
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return entries;
|
|
691
|
-
}
|
|
692
|
-
export function parseEntries(text, specName) {
|
|
693
|
-
const spec = SPECS[specName];
|
|
694
|
-
if (spec.name === "todo-resolved") {
|
|
695
|
-
return parseTodoResolved(text, spec);
|
|
696
|
-
}
|
|
697
|
-
const [pre, archiveBody] = splitArchive(text, spec.archiveHeading || "");
|
|
698
|
-
const fullEntries = parseFullEntries(pre, spec);
|
|
699
|
-
const onelineEntries = parseOnelineEntries(archiveBody, spec);
|
|
700
|
-
return [...fullEntries, ...onelineEntries];
|
|
701
|
-
}
|
|
702
|
-
function extractResolvedSection(text) {
|
|
703
|
-
const m = /^##\s+(?:✓\s+)?Resolved\s*$/m.exec(text);
|
|
704
|
-
if (!m)
|
|
705
|
-
return [-1, -1, ""];
|
|
706
|
-
const bodyStart = m.index + m[0].length + 1;
|
|
707
|
-
const nextSection = /^##\s/m.exec(text.slice(bodyStart));
|
|
708
|
-
const bodyEnd = nextSection ? bodyStart + nextSection.index : text.length;
|
|
709
|
-
return [m.index, bodyEnd, text.slice(bodyStart, bodyEnd)];
|
|
710
|
-
}
|
|
711
|
-
function parseTodoResolved(text, spec) {
|
|
712
|
-
const [, , body] = extractResolvedSection(text);
|
|
713
|
-
if (!body)
|
|
714
|
-
return [];
|
|
715
|
-
const entries = [];
|
|
716
|
-
const lines = body.split(/\r\n|\r|\n/);
|
|
717
|
-
const headRe = new RegExp(spec.entryHeadingRe.source);
|
|
718
|
-
let i = 0;
|
|
719
|
-
while (i < lines.length) {
|
|
720
|
-
const line = lines[i];
|
|
721
|
-
if (headRe.test(line)) {
|
|
722
|
-
const detailLines = [];
|
|
723
|
-
let j = i + 1;
|
|
724
|
-
while (j < lines.length) {
|
|
725
|
-
const nxt = lines[j];
|
|
726
|
-
if (nxt.startsWith(" ") || nxt.startsWith("\t")) {
|
|
727
|
-
detailLines.push(nxt);
|
|
728
|
-
j += 1;
|
|
729
|
-
}
|
|
730
|
-
else if (nxt.trim() === "") {
|
|
731
|
-
if (j + 1 < lines.length && (lines[j + 1].startsWith(" ") || lines[j + 1].startsWith("\t"))) {
|
|
732
|
-
detailLines.push(nxt);
|
|
733
|
-
j += 1;
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
break;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
else {
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
const bodyText = detailLines.join("\n").trim();
|
|
744
|
-
entries.push({ header: line.replace(/\s+$/, ""), body: bodyText, kind: bodyText ? "full" : "oneline" });
|
|
745
|
-
i = j;
|
|
746
|
-
}
|
|
747
|
-
else {
|
|
748
|
-
i += 1;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
return entries;
|
|
752
|
-
}
|
|
753
|
-
function entryNumber(entry) {
|
|
754
|
-
const m = NUMBER_RE.exec(entry.header);
|
|
755
|
-
return m ? parseInt(m[1], 10) : 0;
|
|
756
|
-
}
|
|
757
|
-
function detectDirection(entries) {
|
|
758
|
-
let asc = 0;
|
|
759
|
-
let desc = 0;
|
|
760
|
-
for (let i = 0; i < entries.length - 1; i++) {
|
|
761
|
-
const a = entryNumber(entries[i]);
|
|
762
|
-
const b = entryNumber(entries[i + 1]);
|
|
763
|
-
if (a === 0 || b === 0 || a === b)
|
|
764
|
-
continue;
|
|
765
|
-
if (a < b)
|
|
766
|
-
asc += 1;
|
|
767
|
-
else
|
|
768
|
-
desc += 1;
|
|
769
|
-
}
|
|
770
|
-
if (asc === 0 && desc === 0)
|
|
771
|
-
return "descending";
|
|
772
|
-
return asc > desc ? "ascending" : "descending";
|
|
773
|
-
}
|
|
774
|
-
export function compactEntries(entries, maxFull = MAX_FULL_ENTRIES, maxOneline = MAX_ONELINE_ENTRIES, formatOneline = null) {
|
|
775
|
-
const maxTotal = maxFull + maxOneline;
|
|
776
|
-
if (entries.length === 0)
|
|
777
|
-
return [];
|
|
778
|
-
const ascending = detectDirection(entries) === "ascending";
|
|
779
|
-
const newestFirst = stableSortBy(entries, entryNumber, true);
|
|
780
|
-
const full = [];
|
|
781
|
-
const archive = [];
|
|
782
|
-
newestFirst.forEach((entry, i) => {
|
|
783
|
-
if (i < maxFull) {
|
|
784
|
-
full.push(entry);
|
|
785
|
-
}
|
|
786
|
-
else if (i < maxTotal) {
|
|
787
|
-
if (entry.kind === "full" && formatOneline !== null) {
|
|
788
|
-
archive.push({ header: formatOneline(entry), body: "", kind: "oneline" });
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
archive.push(entry);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
const result = applyRetentionCaps(full, archive, { maxFull, maxOneline, maxTotal });
|
|
796
|
-
if (ascending)
|
|
797
|
-
result.reverse();
|
|
798
|
-
return result;
|
|
799
|
-
}
|
|
800
|
-
function compactTodoEntries(entries) {
|
|
801
|
-
const result = [];
|
|
802
|
-
let fullCount = 0;
|
|
803
|
-
let onelineCount = 0;
|
|
804
|
-
for (const entry of entries) {
|
|
805
|
-
if (entry.kind === "full" && fullCount < MAX_FULL_ENTRIES) {
|
|
806
|
-
result.push(entry);
|
|
807
|
-
fullCount += 1;
|
|
808
|
-
continue;
|
|
809
|
-
}
|
|
810
|
-
if (onelineCount < MAX_ONELINE_ENTRIES) {
|
|
811
|
-
if (entry.kind === "full") {
|
|
812
|
-
result.push({ header: formatTodoOneline(entry), body: "", kind: "oneline" });
|
|
813
|
-
}
|
|
814
|
-
else {
|
|
815
|
-
result.push(entry);
|
|
816
|
-
}
|
|
817
|
-
onelineCount += 1;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return result;
|
|
821
|
-
}
|
|
822
|
-
function formatProgressLike(headerPrefix, entries, spec) {
|
|
823
|
-
const lines = [];
|
|
824
|
-
if (headerPrefix.trim()) {
|
|
825
|
-
lines.push(headerPrefix.replace(/\s+$/, ""));
|
|
826
|
-
lines.push("");
|
|
827
|
-
}
|
|
828
|
-
const fullEntries = entries.filter((e) => e.kind === "full");
|
|
829
|
-
const onelineEntries = entries.filter((e) => e.kind === "oneline");
|
|
830
|
-
for (const entry of fullEntries) {
|
|
831
|
-
const header = entry.header;
|
|
832
|
-
const glyphMatch = /^(■)\s+(.*)$/.exec(header);
|
|
833
|
-
if (glyphMatch) {
|
|
834
|
-
lines.push(`${glyphMatch[1]} ## ${glyphMatch[2]}`);
|
|
835
|
-
}
|
|
836
|
-
else {
|
|
837
|
-
lines.push(`## ${header}`);
|
|
838
|
-
}
|
|
839
|
-
if (entry.body) {
|
|
840
|
-
lines.push("");
|
|
841
|
-
lines.push(entry.body);
|
|
842
|
-
}
|
|
843
|
-
lines.push("");
|
|
844
|
-
}
|
|
845
|
-
if (onelineEntries.length > 0 && spec.archiveHeading) {
|
|
846
|
-
lines.push(spec.archiveHeading);
|
|
847
|
-
lines.push("");
|
|
848
|
-
for (const entry of onelineEntries) {
|
|
849
|
-
lines.push(entry.header);
|
|
850
|
-
}
|
|
851
|
-
lines.push("");
|
|
852
|
-
}
|
|
853
|
-
return lines.join("\n").replace(/\s+$/, "") + "\n";
|
|
854
|
-
}
|
|
855
|
-
function extractHeaderPrefix(text, spec) {
|
|
856
|
-
const firstEntry = new RegExp(spec.entryHeadingRe.source, "m").exec(text);
|
|
857
|
-
let firstArchiveIdx = -1;
|
|
858
|
-
if (spec.archiveHeading) {
|
|
859
|
-
const archiveMatch = new RegExp(`^${escapeRe(spec.archiveHeading)}\\s*$`, "m").exec(text);
|
|
860
|
-
if (archiveMatch)
|
|
861
|
-
firstArchiveIdx = archiveMatch.index;
|
|
862
|
-
}
|
|
863
|
-
const candidates = [firstEntry ? firstEntry.index : -1, firstArchiveIdx].filter((c) => c >= 0);
|
|
864
|
-
if (candidates.length === 0)
|
|
865
|
-
return text.replace(/\s+$/, "");
|
|
866
|
-
return text.slice(0, Math.min(...candidates)).replace(/\s+$/, "");
|
|
867
|
-
}
|
|
868
|
-
function compactTodoResolved(p) {
|
|
869
|
-
const spec = SPECS["todo-resolved"];
|
|
870
|
-
const text = fs.readFileSync(p, "utf8");
|
|
871
|
-
const [start, end, body] = extractResolvedSection(text);
|
|
872
|
-
if (start < 0)
|
|
873
|
-
return { full_before: 0, oneline_before: 0, full_after: 0, oneline_after: 0, dropped: 0, changed: false };
|
|
874
|
-
const entries = parseTodoResolved(text, spec);
|
|
875
|
-
const fullBefore = entries.filter((e) => e.kind === "full").length;
|
|
876
|
-
const onelineBefore = entries.filter((e) => e.kind === "oneline").length;
|
|
877
|
-
const totalBefore = entries.length;
|
|
878
|
-
if (totalBefore <= MAX_TOTAL_ENTRIES && fullBefore <= MAX_FULL_ENTRIES && onelineBefore <= MAX_ONELINE_ENTRIES) {
|
|
879
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
|
|
880
|
-
}
|
|
881
|
-
const compacted = compactTodoEntries(entries);
|
|
882
|
-
const fullAfter = compacted.filter((e) => e.kind === "full").length;
|
|
883
|
-
const onelineAfter = compacted.filter((e) => e.kind === "oneline").length;
|
|
884
|
-
const dropped = totalBefore - compacted.length;
|
|
885
|
-
const newLines = [];
|
|
886
|
-
for (const entry of compacted) {
|
|
887
|
-
if (entry.kind === "full") {
|
|
888
|
-
newLines.push(entry.header);
|
|
889
|
-
if (entry.body)
|
|
890
|
-
newLines.push(entry.body);
|
|
891
|
-
}
|
|
892
|
-
else {
|
|
893
|
-
newLines.push(spec.formatOneline(entry));
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
const newBody = newLines.join("\n") + "\n";
|
|
897
|
-
const headingEnd = text.indexOf("\n", start) + 1;
|
|
898
|
-
const newText = text.slice(0, headingEnd) + "\n" + newBody + text.slice(end);
|
|
899
|
-
fs.writeFileSync(p, newText);
|
|
900
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
|
|
901
|
-
}
|
|
902
|
-
export function compactFile(p, specName) {
|
|
903
|
-
if (!(specName in SPECS))
|
|
904
|
-
throw new Error(`unknown spec: ${specName}`);
|
|
905
|
-
if (!fs.existsSync(p))
|
|
906
|
-
throw new Error(p);
|
|
907
|
-
const spec = SPECS[specName];
|
|
908
|
-
if (spec.name === "todo-resolved") {
|
|
909
|
-
return compactTodoResolved(p);
|
|
910
|
-
}
|
|
911
|
-
const text = fs.readFileSync(p, "utf8");
|
|
912
|
-
const entries = parseEntries(text, specName);
|
|
913
|
-
const fullBefore = entries.filter((e) => e.kind === "full").length;
|
|
914
|
-
const onelineBefore = entries.filter((e) => e.kind === "oneline").length;
|
|
915
|
-
const totalBefore = fullBefore + onelineBefore;
|
|
916
|
-
const needsCompact = fullBefore > MAX_FULL_ENTRIES || onelineBefore > MAX_ONELINE_ENTRIES || totalBefore > MAX_FULL_ENTRIES + MAX_ONELINE_ENTRIES;
|
|
917
|
-
if (!needsCompact) {
|
|
918
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
|
|
919
|
-
}
|
|
920
|
-
const compacted = compactEntries(entries, MAX_FULL_ENTRIES, MAX_ONELINE_ENTRIES, spec.formatOneline);
|
|
921
|
-
const fullAfter = compacted.filter((e) => e.kind === "full").length;
|
|
922
|
-
const onelineAfter = compacted.filter((e) => e.kind === "oneline").length;
|
|
923
|
-
const dropped = totalBefore - compacted.length;
|
|
924
|
-
const headerPrefix = extractHeaderPrefix(text, spec);
|
|
925
|
-
const newText = formatProgressLike(headerPrefix, compacted, spec);
|
|
926
|
-
fs.writeFileSync(p, newText);
|
|
927
|
-
return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
|
|
928
|
-
}
|
|
929
|
-
export function detectOverflow(text, specName) {
|
|
930
|
-
const entries = parseEntries(text, specName);
|
|
931
|
-
const fullCount = entries.filter((e) => e.kind === "full").length;
|
|
932
|
-
const onelineCount = entries.filter((e) => e.kind === "oneline").length;
|
|
933
|
-
return [fullCount, onelineCount];
|
|
934
|
-
}
|
|
935
|
-
//# sourceMappingURL=compaction.js.map
|