codymaster 4.8.0 → 7.0.0
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/CHANGELOG.md +331 -7
- package/README.md +226 -296
- package/dist/advisory-handoff.js +89 -0
- package/dist/advisory-report.js +105 -0
- package/dist/agent/antigravity.js +152 -0
- package/dist/agent/backend.js +2 -0
- package/dist/agent/claude.js +196 -0
- package/dist/agent/codex.js +204 -0
- package/dist/agent/copilot.js +284 -0
- package/dist/agent/cursor.js +211 -0
- package/dist/agent/factory.js +30 -0
- package/dist/agent/gemini.js +142 -0
- package/dist/agent/opencode.js +205 -0
- package/dist/agent/spawn-helper.js +237 -0
- package/dist/agent/version.js +25 -0
- package/dist/browse/adapter-factory.js +69 -0
- package/dist/browse/adapters/agent-browser-adapter.js +305 -0
- package/dist/browse/adapters/playwright-adapter.js +309 -0
- package/dist/browse/adapters/types.js +6 -0
- package/dist/browse/error-collector.js +132 -0
- package/dist/browse/event-log.js +109 -0
- package/dist/browse/index.js +17 -0
- package/dist/browse-server.js +204 -120
- package/dist/cli/command-registry.js +20 -0
- package/dist/cli/commands/bench.js +69 -0
- package/dist/cli/commands/brain.js +108 -0
- package/dist/cli/commands/dashboard.js +76 -2
- package/dist/cli/commands/engineering.js +326 -4
- package/dist/cli/commands/evolve.js +123 -0
- package/dist/cli/commands/install.js +160 -0
- package/dist/cli/commands/learn.js +181 -0
- package/dist/cli/commands/mcp-serve.js +104 -0
- package/dist/cli/commands/parallel.js +138 -0
- package/dist/cli/commands/quality.js +105 -0
- package/dist/cli/commands/stack.js +49 -0
- package/dist/cli/commands/update.js +159 -0
- package/dist/cli/update-check.js +94 -10
- package/dist/cm-config.js +0 -18
- package/dist/codybench/judges/automated.js +31 -0
- package/dist/codybench/runners/claude-code.js +32 -0
- package/dist/codybench/suites/memory-retention.js +85 -0
- package/dist/codybench/suites/tdd-regression.js +35 -0
- package/dist/codybench/suites/token-efficiency.js +55 -0
- package/dist/codybench/types.js +2 -0
- package/dist/context-db.js +157 -0
- package/dist/continuity.js +5 -7
- package/dist/dashboard.js +47 -6
- package/dist/data.js +35 -0
- package/dist/execution/tdd-gate.js +113 -0
- package/dist/execution-analyzer.js +138 -0
- package/dist/executor/cancel.js +34 -0
- package/dist/executor/gc.js +74 -0
- package/dist/executor/index.js +14 -0
- package/dist/executor/runner.js +70 -0
- package/dist/executor/workdir.js +31 -0
- package/dist/handoff/contracts.js +22 -0
- package/dist/handoff/index.js +18 -0
- package/dist/handoff/io.js +121 -0
- package/dist/index.js +7 -3
- package/dist/indexer/skills-lib.js +533 -0
- package/dist/indexer/skills-map.js +1374 -0
- package/dist/indexer/skills.js +16 -0
- package/dist/indexer/stack-detect.js +219 -0
- package/dist/install/copy.js +98 -0
- package/dist/install/engine.js +42 -0
- package/dist/install/paths.js +70 -0
- package/dist/install/platforms/_simple.js +85 -0
- package/dist/install/platforms/antigravity.js +91 -0
- package/dist/install/platforms/claude-code.js +107 -0
- package/dist/install/platforms/cursor.js +77 -0
- package/dist/install/platforms/index.js +27 -0
- package/dist/install/platforms/simple.js +163 -0
- package/dist/install/profiles.js +75 -0
- package/dist/install/types.js +2 -0
- package/dist/learning-promoter.js +246 -0
- package/dist/learnings.js +208 -0
- package/dist/mcp-context-server.js +230 -1
- package/dist/middleware/metrics.js +30 -0
- package/dist/middleware/security-headers.js +14 -0
- package/dist/realtime/event-bus.js +29 -0
- package/dist/realtime/ws-hub.js +91 -0
- package/dist/schemas/task-schema.js +48 -0
- package/dist/schemas/validate.js +18 -0
- package/dist/skill-chain.js +63 -1
- package/dist/skill-evolver.js +456 -0
- package/dist/skill-execution-cache.js +254 -0
- package/dist/skills-lock.js +96 -0
- package/dist/smart-brain-router.js +184 -0
- package/dist/sprint-pipeline.js +26 -0
- package/dist/storage/index.js +21 -0
- package/dist/storage/repos/activity-repo.js +46 -0
- package/dist/storage/repos/message-repo.js +39 -0
- package/dist/storage/repos/project-repo.js +56 -0
- package/dist/storage/repos/task-repo.js +142 -0
- package/dist/storage/services/project-service.js +49 -0
- package/dist/storage/services/task-service.js +97 -0
- package/dist/storage/sqlite.js +113 -0
- package/dist/storage-backend.js +10 -8
- package/dist/tier-classify.js +131 -0
- package/dist/token-budget.js +88 -0
- package/dist/ui/onboarding.js +51 -15
- package/dist/utils/cli-utils.js +7 -2
- package/dist/utils/design-taste.js +108 -0
- package/dist/utils/output-compress.js +143 -0
- package/dist/vibecoding-index.js +126 -0
- package/package.json +20 -6
- package/public/dashboard/app.js +52 -1
- package/scripts/build-skills-lock.mjs +88 -0
- package/scripts/build-skills.mjs +187 -28
- package/scripts/compress-skill.mjs +73 -0
- package/scripts/deprecate-skill.mjs +72 -0
- package/scripts/install.sh +170 -0
- package/scripts/mcp-bridge.js +2 -2
- package/scripts/postinstall.js +53 -335
- package/scripts/update-changelog.sh +88 -0
- package/scripts/validate-skills.mjs +101 -4
- package/skills/CLAUDE.md +0 -5
- package/skills/_shared/SKILL_TEMPLATE.md +62 -0
- package/skills/_shared/helpers.md +2 -8
- package/skills/cm-autopilot/scripts/autopilot.py +19 -2
- package/skills/cm-brainstorm-idea/SKILL.md +9 -0
- package/skills/cm-browse/SKILL.md +6 -0
- package/skills/cm-clean-code/SKILL.md +20 -0
- package/skills/cm-code-review/SKILL.md +21 -0
- package/skills/cm-codeintell/SKILL.md +9 -0
- package/skills/cm-conductor-worktrees/SKILL.archive.md +28 -0
- package/skills/cm-conductor-worktrees/SKILL.md +20 -18
- package/skills/cm-continuity/SKILL.md +41 -33
- package/skills/cm-dashboard/SKILL.archive.md +15 -0
- package/skills/cm-dashboard/SKILL.md +20 -9
- package/skills/cm-dashboard/ui/app.js +9 -1
- package/skills/cm-debugging/SKILL.md +9 -0
- package/skills/cm-design-studio/SKILL.archive.md +34 -0
- package/skills/cm-design-studio/SKILL.md +20 -24
- package/skills/cm-design-system/SKILL.md +1 -0
- package/skills/cm-ecosystem-roadmap/SKILL.md +4 -0
- package/skills/cm-engineering-meta/SKILL.archive.md +73 -0
- package/skills/cm-engineering-meta/SKILL.md +19 -62
- package/skills/cm-execution/SKILL.md +98 -0
- package/skills/cm-git-worktrees/SKILL.archive.md +157 -0
- package/skills/cm-git-worktrees/SKILL.md +15 -146
- package/skills/cm-guardian-runtime/SKILL.md +5 -1
- package/skills/cm-identity-guard/SKILL.md +8 -0
- package/skills/cm-mcp-engineering/SKILL.md +4 -0
- package/skills/cm-planning/SKILL.md +63 -92
- package/skills/cm-post-deploy-canary/SKILL.archive.md +22 -0
- package/skills/cm-post-deploy-canary/SKILL.md +20 -12
- package/skills/cm-project-bootstrap/SKILL.md +11 -0
- package/skills/cm-qa-visual-cli/SKILL.archive.md +22 -0
- package/skills/cm-qa-visual-cli/SKILL.md +19 -11
- package/skills/cm-quality-gate/SKILL.md +38 -0
- package/skills/cm-retro-cli/SKILL.md +4 -0
- package/skills/cm-safe-deploy/SKILL.md +9 -0
- package/skills/cm-second-opinion-cli/SKILL.archive.md +23 -0
- package/skills/cm-second-opinion-cli/SKILL.md +20 -13
- package/skills/cm-secret-shield/SKILL.archive.md +580 -0
- package/skills/cm-secret-shield/SKILL.md +15 -569
- package/skills/cm-security-gate/SKILL.archive.md +239 -0
- package/skills/cm-security-gate/SKILL.md +16 -228
- package/skills/cm-skill-chain/SKILL.md +25 -4
- package/skills/cm-skill-evolution/SKILL.md +83 -0
- package/skills/cm-skill-health/SKILL.archive.md +83 -0
- package/skills/cm-skill-health/SKILL.md +26 -0
- package/skills/cm-skill-index/SKILL.md +19 -3
- package/skills/cm-skill-mastery/SKILL.archive.md +156 -0
- package/skills/cm-skill-mastery/SKILL.md +16 -146
- package/skills/cm-skill-search/SKILL.archive.md +49 -0
- package/skills/cm-skill-search/SKILL.md +26 -0
- package/skills/cm-skill-share/SKILL.archive.md +58 -0
- package/skills/cm-skill-share/SKILL.md +26 -0
- package/skills/cm-sprint-bus/SKILL.md +13 -0
- package/skills/cm-start/SKILL.md +17 -10
- package/skills/cm-tdd/SKILL.md +21 -2
- package/skills/cm-terminal/SKILL.md +15 -0
- package/skills/cm-test-gate/SKILL.archive.md +245 -0
- package/skills/cm-test-gate/SKILL.md +15 -234
- package/skills/cm-ui-preview/SKILL.archive.md +153 -0
- package/skills/cm-ui-preview/SKILL.md +16 -143
- package/skills/cm-ux-master/cli/uxmaster/commands/mcp.py +1 -1
- package/skills/cm-ux-master/mcp/mcp-config.json +1 -1
- package/skills/cm-ux-master/mcp/server.py +2 -2
- package/skills/profiles/design.txt +1 -1
- package/skills/profiles/full.txt +4 -10
- package/skills/profiles/growth.txt +8 -8
- package/skills/profiles/knowledge.txt +1 -1
- package/skills/profiles/top35.json +41 -0
- package/adapters/antigravity.js +0 -15
- package/adapters/claude-code.js +0 -17
- package/adapters/cursor.js +0 -16
- package/install.sh +0 -1125
- package/scripts/viking-demo.ts +0 -105
- package/skills/cm-ads-tracker/SKILL.md +0 -401
- package/skills/cm-ads-tracker/evals/evals.json +0 -55
- package/skills/cm-ads-tracker/references/gtm-architecture.md +0 -321
- package/skills/cm-ads-tracker/references/industry-events.md +0 -294
- package/skills/cm-ads-tracker/references/platforms-api.md +0 -238
- package/skills/cm-ads-tracker/templates/capi-payload.md +0 -79
- package/skills/cm-ads-tracker/templates/datalayer-push.js +0 -104
- package/skills/cm-ads-tracker/templates/gtm-variables.js +0 -56
- package/skills/cm-auto-publisher/SKILL.md +0 -81
- package/skills/cm-booking-calendar/SKILL.md +0 -521
- package/skills/cm-booking-calendar/references/industry-patterns.md +0 -527
- package/skills/cm-booking-calendar/templates/booking-form.css +0 -626
- package/skills/cm-booking-calendar/templates/booking-form.html +0 -477
- package/skills/cm-booking-calendar/templates/calendar-engine.js +0 -419
- package/skills/cm-booking-calendar/templates/calendar-export.js +0 -395
- package/skills/cm-booking-calendar/templates/reminder-config.js +0 -629
- package/skills/cm-content-factory/.content-factory-state.json +0 -132
- package/skills/cm-content-factory/.git 2/logs/refs/heads/main +0 -1
- package/skills/cm-content-factory/.git 2/logs/refs/remotes/origin/main +0 -1
- package/skills/cm-content-factory/.git 2/objects/02/fb0956734b5f8ba3f918b7defd04a89cfe0076 +0 -0
- package/skills/cm-content-factory/.git 2/objects/08/1e129d75dc6feac6c02037272e6bd1a04e3324 +0 -0
- package/skills/cm-content-factory/.git 2/objects/0c/5393416f3c5e01c9a655a802bff0dd52f76f0a +0 -0
- package/skills/cm-content-factory/.git 2/objects/10/0b9be46978a946a77188f68be725098a122001 +0 -0
- package/skills/cm-content-factory/.git 2/objects/10/cf041167fc9843610eb3d90259ef3396315fdc +0 -0
- package/skills/cm-content-factory/.git 2/objects/12/5e19538dd6e1338ffe74f6c4c165b00435bf48 +0 -0
- package/skills/cm-content-factory/.git 2/objects/16/a9b9d0088d5c1347628b45a2620b479d8ad57c +0 -0
- package/skills/cm-content-factory/.git 2/objects/17/8c2a9ef93c33ae4eec9d58e82321f9229843a1 +0 -0
- package/skills/cm-content-factory/.git 2/objects/25/397ae41d09104d763bdcac2695209d85cdea89 +0 -0
- package/skills/cm-content-factory/.git 2/objects/2f/a836b7947f2d458e1f639788bf4bb0983a3305 +0 -0
- package/skills/cm-content-factory/.git 2/objects/3a/baaaf0a1c0909c0828335791557125fba911e0 +0 -0
- package/skills/cm-content-factory/.git 2/objects/42/2924221b81f5ce3c4e4daac9a64a24f9b01f9a +0 -0
- package/skills/cm-content-factory/.git 2/objects/42/ec0ce707447dc11446a34c9995fb8533801731 +0 -0
- package/skills/cm-content-factory/.git 2/objects/46/e43ce92866d56ce74b1d750db307cfe6154a15 +0 -0
- package/skills/cm-content-factory/.git 2/objects/48/5e41b633c63f55b8277bcc59f44f67681f671a +0 -0
- package/skills/cm-content-factory/.git 2/objects/49/49c596a3a89fa240642acd95dd3258e261eb09 +0 -0
- package/skills/cm-content-factory/.git 2/objects/50/9d42d8412ef8eaf7f7e138476bac2e4d10ce60 +0 -0
- package/skills/cm-content-factory/.git 2/objects/55/0c8c389d981b463ef849aeb792d8be3ccb6ec8 +0 -0
- package/skills/cm-content-factory/.git 2/objects/5d/82d3b18410cdda3ace3677436f0cb599dbe2d2 +0 -0
- package/skills/cm-content-factory/.git 2/objects/60/0617c58e871a38b33bf29e282d132bb3c381ad +0 -0
- package/skills/cm-content-factory/.git 2/objects/6a/8369a99c687b7245c92ffaf0e0f0dab9014504 +0 -0
- package/skills/cm-content-factory/.git 2/objects/79/bea435d40ab531c1aaf6be0432c6a5b7aaed21 +0 -0
- package/skills/cm-content-factory/.git 2/objects/7e/5ebd79251c2f14e4aceb86c74b6b6daae6b500 +0 -0
- package/skills/cm-content-factory/.git 2/objects/81/98a822a60178d6d5023ddb3e222cddf048742e +0 -0
- package/skills/cm-content-factory/.git 2/objects/86/0a0e1943dfe53411d2e499a1f16f46a96ef758 +0 -0
- package/skills/cm-content-factory/.git 2/objects/86/971fb55fdc081fdbae52376f0f13e57a4e9b04 +0 -0
- package/skills/cm-content-factory/.git 2/objects/88/b89dd609a0a03f8d4fe8bfde20d5b8fc1d326d +0 -0
- package/skills/cm-content-factory/.git 2/objects/90/8737edb6b7809e32cc01590b4e08ba42a9d40d +0 -0
- package/skills/cm-content-factory/.git 2/objects/93/d5a8a9a7d4fb7f11491cb596a6880528725118 +0 -0
- package/skills/cm-content-factory/.git 2/objects/98/46a2ab81d0c3b3eb00ef88fc56989aa7e9f316 +0 -0
- package/skills/cm-content-factory/.git 2/objects/9b/d8dd1e49cf274eaf9c555f3ab39dce7af5715e +0 -0
- package/skills/cm-content-factory/.git 2/objects/a1/13329fb0cec96ae78b222d33a24c3b5bc7fa1f +0 -0
- package/skills/cm-content-factory/.git 2/objects/a9/e6effe626e8a3aea3a8fc3364b492191c6e7d0 +0 -0
- package/skills/cm-content-factory/.git 2/objects/ad/6de7e48d9782cca9353d1ff0aa1aab7fe1df85 +0 -0
- package/skills/cm-content-factory/.git 2/objects/af/54ae316f771ff692e299ffcd8bf2f06b413b59 +0 -0
- package/skills/cm-content-factory/.git 2/objects/b0/4cb8b0b00dad633e731c1472161419e738d674 +0 -0
- package/skills/cm-content-factory/.git 2/objects/b3/094abb0b9ed46419b269e4a4e36a459690e3b0 +0 -0
- package/skills/cm-content-factory/.git 2/objects/b9/435c5d4baac2cfc5c83009ddd27b46b60db5f1 +0 -0
- package/skills/cm-content-factory/.git 2/objects/ba/5da17dbaec5ec2dcfdfd126aead518d1171d5c +0 -0
- package/skills/cm-content-factory/.git 2/objects/c0/bf58703aa258ba5dd63083bebaec8f223d844c +0 -0
- package/skills/cm-content-factory/.git 2/objects/c4/701a34edf1fc1bad58ccc57bd03f9426acb59a +0 -0
- package/skills/cm-content-factory/.git 2/objects/c7/5ccce9a4e5cc74d9b3174550cf6d993ca43638 +0 -0
- package/skills/cm-content-factory/.git 2/objects/c7/710d59b5a35b0f1f0a0399386643a0bd94c929 +0 -0
- package/skills/cm-content-factory/.git 2/objects/d1/fe58237112e953e5fec52da22cf38e08be3df9 +0 -5
- package/skills/cm-content-factory/.git 2/objects/d2/2bbe9fd2f74c95bc5583e803f5e435f1e2cd86 +0 -0
- package/skills/cm-content-factory/.git 2/objects/d7/e72852ea2bff74581dbf247d400120086229f4 +0 -0
- package/skills/cm-content-factory/.git 2/objects/d8/d4c3b5553e4fd72807e1d4b49ef07d9ef3ac35 +0 -0
- package/skills/cm-content-factory/.git 2/objects/dc/75050c2876f6a02ae2a53a3c886f395b622977 +0 -0
- package/skills/cm-content-factory/.git 2/objects/ee/e8546f95acec500187c08a28a8b9ee02db0dec +0 -0
- package/skills/cm-content-factory/.git 2/objects/ef/263c059208b416c2146434f10cb2b9fabcba16 +0 -0
- package/skills/cm-content-factory/.git 2/objects/f3/ae597e84d9a59b88acd21c99bde2eaf686d785 +0 -0
- package/skills/cm-content-factory/.git 2/objects/f3/f6f5673c821d3d8e76fa267a9e882e7a5387ea +0 -0
- package/skills/cm-content-factory/.git 2/objects/f9/6e6d0ad02624dd11d5848594d056caef7a5e8b +0 -0
- package/skills/cm-content-factory/.git 2/objects/ff/278988fc1edf0db3abcf18de795f4cc0b4f3e1 +0 -0
- package/skills/cm-content-factory/.git 2/refs/heads/main +0 -1
- package/skills/cm-content-factory/.git 2/refs/remotes/origin/main +0 -1
- package/skills/cm-content-factory/.pytest_cache 2/v/cache/nodeids +0 -76
- package/skills/cm-content-factory/.pytest_cache 2/v/cache/stepwise +0 -1
- package/skills/cm-content-factory/AGENTS.md +0 -61
- package/skills/cm-content-factory/CLAUDE.md +0 -63
- package/skills/cm-content-factory/CURSOR.md +0 -43
- package/skills/cm-content-factory/Content Factory.zip +0 -0
- package/skills/cm-content-factory/SKILL.md +0 -416
- package/skills/cm-content-factory/cf +0 -313
- package/skills/cm-content-factory/config.schema.json +0 -397
- package/skills/cm-content-factory/dashboard/app.js +0 -556
- package/skills/cm-content-factory/dashboard/index.html +0 -397
- package/skills/cm-content-factory/dashboard/style.css +0 -1211
- package/skills/cm-content-factory/examples/01-real-estate.config.json +0 -146
- package/skills/cm-content-factory/examples/02-personal-finance.config.json +0 -146
- package/skills/cm-content-factory/examples/03-health-wellness.config.json +0 -147
- package/skills/cm-content-factory/examples/04-saas-software.config.json +0 -147
- package/skills/cm-content-factory/examples/05-legal-services.config.json +0 -147
- package/skills/cm-content-factory/examples/06-insurance.config.json +0 -146
- package/skills/cm-content-factory/examples/07-ecommerce-dropship.config.json +0 -146
- package/skills/cm-content-factory/examples/08-online-education.config.json +0 -147
- package/skills/cm-content-factory/examples/09-crypto-defi.config.json +0 -147
- package/skills/cm-content-factory/examples/10-beauty-skincare.config.json +0 -147
- package/skills/cm-content-factory/examples/11-home-services.config.json +0 -146
- package/skills/cm-content-factory/examples/12-dental-clinic.config.json +0 -147
- package/skills/cm-content-factory/examples/13-pet-care.config.json +0 -147
- package/skills/cm-content-factory/examples/14-travel-hospitality.config.json +0 -147
- package/skills/cm-content-factory/examples/15-ai-automation.config.json +0 -147
- package/skills/cm-content-factory/examples/16-wedding-events.config.json +0 -147
- package/skills/cm-content-factory/examples/17-fitness-coaching.config.json +0 -148
- package/skills/cm-content-factory/examples/18-cybersecurity.config.json +0 -147
- package/skills/cm-content-factory/examples/19-food-restaurant.config.json +0 -148
- package/skills/cm-content-factory/examples/20-solar-energy.config.json +0 -147
- package/skills/cm-content-factory/examples/fitness-blog.config.json +0 -116
- package/skills/cm-content-factory/examples/tech-blog.config.json +0 -107
- package/skills/cm-content-factory/extensions/EXTENSION_GUIDE.md +0 -72
- package/skills/cm-content-factory/extensions/hooks.py +0 -126
- package/skills/cm-content-factory/extensions/openclaw_adapter.py +0 -132
- package/skills/cm-content-factory/landing/docs/content/changelog.md +0 -36
- package/skills/cm-content-factory/landing/docs/content/deployment.md +0 -46
- package/skills/cm-content-factory/landing/docs/content/execution-flow.md +0 -67
- package/skills/cm-content-factory/landing/docs/content/openspace.md +0 -27
- package/skills/cm-content-factory/landing/docs/content/openviking.md +0 -33
- package/skills/cm-content-factory/landing/docs/content/use-cases.md +0 -26
- package/skills/cm-content-factory/landing/docs/content/v5-intro.md +0 -28
- package/skills/cm-content-factory/landing/docs/index.html +0 -240
- package/skills/cm-content-factory/landing/index.html +0 -680
- package/skills/cm-content-factory/landing/script.js +0 -143
- package/skills/cm-content-factory/landing/style.css +0 -1216
- package/skills/cm-content-factory/landing/translations.js +0 -508
- package/skills/cm-content-factory/logs/events.jsonl +0 -11
- package/skills/cm-content-factory/profiles/_template.profile.json +0 -231
- package/skills/cm-content-factory/profiles/finance.profile.json +0 -278
- package/skills/cm-content-factory/profiles/legal.profile.json +0 -263
- package/skills/cm-content-factory/profiles/medical-research.profile.json +0 -321
- package/skills/cm-content-factory/profiles/technology.profile.json +0 -275
- package/skills/cm-content-factory/scripts/agent_dispatcher.py +0 -266
- package/skills/cm-content-factory/scripts/audit.py +0 -106
- package/skills/cm-content-factory/scripts/dashboard_server.py +0 -225
- package/skills/cm-content-factory/scripts/deploy.py +0 -146
- package/skills/cm-content-factory/scripts/extract.py +0 -132
- package/skills/cm-content-factory/scripts/landing_generator.py +0 -459
- package/skills/cm-content-factory/scripts/memory.py +0 -521
- package/skills/cm-content-factory/scripts/monetize.py +0 -239
- package/skills/cm-content-factory/scripts/pipeline.py +0 -357
- package/skills/cm-content-factory/scripts/plan.py +0 -163
- package/skills/cm-content-factory/scripts/publish.py +0 -145
- package/skills/cm-content-factory/scripts/research.py +0 -337
- package/skills/cm-content-factory/scripts/scaffold.py +0 -464
- package/skills/cm-content-factory/scripts/scoreboard.py +0 -336
- package/skills/cm-content-factory/scripts/seo.py +0 -90
- package/skills/cm-content-factory/scripts/state_manager.py +0 -320
- package/skills/cm-content-factory/scripts/token_manager.py +0 -268
- package/skills/cm-content-factory/scripts/validate.py +0 -221
- package/skills/cm-content-factory/scripts/wizard.py +0 -329
- package/skills/cm-content-factory/scripts/write.py +0 -93
- package/skills/cm-content-factory/sites/docs-site/src/assets/houston.webp +0 -0
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/architecture.md +0 -90
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/data-flow.md +0 -54
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/deployment.md +0 -38
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/index.md +0 -65
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/lc-content-lifecycle.md +0 -48
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/seq-write-mode.md +0 -39
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/uj-first-batch.md +0 -42
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/wf-content-pipeline.md +0 -51
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/flows/wf-learning-cycle.md +0 -52
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/getting-started/configuration.md +0 -86
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/getting-started/installation.md +0 -80
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/getting-started/intro.md +0 -58
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/index.md +0 -102
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/jtbd/index.md +0 -45
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/jtbd/optimize-seo.md +0 -29
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/jtbd/scale-content-production.md +0 -55
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/jtbd/standardize-quality.md +0 -29
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/buyer-cmo-huong.md +0 -41
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/buyer-content-lead-khoa.md +0 -40
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/index.md +0 -56
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/user-content-manager-lan.md +0 -46
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/user-seo-minh.md +0 -45
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/personas/user-writer-tu.md +0 -45
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/sop/content-pipeline.md +0 -108
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/sop/index.md +0 -22
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/sop/memory-system.md +0 -52
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/sop/seo-optimization.md +0 -58
- package/skills/cm-content-factory/sites/docs-site/src/content/docs/sop/troubleshooting-guide.md +0 -92
- package/skills/cm-content-factory/sites/docs-site/src/styles/custom.css +0 -575
- package/skills/cm-content-factory/tests/conftest.py +0 -66
- package/skills/cm-content-factory/tests/test_agent_dispatcher.py +0 -125
- package/skills/cm-content-factory/tests/test_memory.py +0 -128
- package/skills/cm-content-factory/tests/test_pipeline.py +0 -107
- package/skills/cm-content-factory/tests/test_research.py +0 -56
- package/skills/cm-content-factory/tests/test_state_manager.py +0 -131
- package/skills/cm-content-factory/tests/test_token_manager.py +0 -110
- package/skills/cm-content-factory/tests/test_wizard.py +0 -121
- package/skills/cm-cro-methodology/SKILL.md +0 -290
- package/skills/cm-cro-methodology/references/COPYWRITING.md +0 -178
- package/skills/cm-cro-methodology/references/OBJECTIONS.md +0 -135
- package/skills/cm-cro-methodology/references/PERSUASION.md +0 -158
- package/skills/cm-cro-methodology/references/RESEARCH.md +0 -220
- package/skills/cm-cro-methodology/references/funnel-analysis.md +0 -365
- package/skills/cm-cro-methodology/references/testing-methodology.md +0 -330
- package/skills/cm-google-form/SKILL.md +0 -266
- package/skills/cm-google-form/templates/apps-script.js +0 -55
- package/skills/cm-google-form/templates/form-markup.html +0 -110
- package/skills/cm-google-form/templates/form-submit.js +0 -201
- package/skills/cm-google-form/templates/toast.css +0 -152
- package/skills/cm-growth-hacking/SKILL.md +0 -282
- package/skills/cm-growth-hacking/bottom-sheet-engine.md +0 -261
- package/skills/cm-growth-hacking/calendar-integration.md +0 -264
- package/skills/cm-growth-hacking/references/engagement-patterns.md +0 -346
- package/skills/cm-growth-hacking/templates/bottom-sheet.css +0 -528
- package/skills/cm-growth-hacking/templates/bottom-sheet.js +0 -269
- package/skills/cm-growth-hacking/templates/calendar-cta.js +0 -213
- package/skills/cm-growth-hacking/templates/tracking-events.js +0 -211
- package/skills/cm-growth-hacking/templates/trigger-manager.js +0 -254
- package/skills/cm-growth-hacking/tracking-events.md +0 -246
- package/skills/cm-growth-hacking/trigger-system.md +0 -342
- package/skills/cm-jtbd/SKILL.md +0 -98
- package/skills/cm-notebooklm/SKILL.md +0 -156
- package/skills/cm-notebooklm/references/command_reference.md +0 -94
- package/skills/cm-notebooklm/references/workflows.md +0 -60
- package/skills/cm-notebooklm/resources/knowledge_sources.md +0 -106
- package/skills/cm-notebooklm/scripts/brain-sync.sh +0 -453
- package/skills/cm-notebooklm/scripts/graduate_wisdom.py +0 -101
- package/skills/cm-readit/SKILL.md +0 -289
- package/skills/cm-readit/audio-player.md +0 -206
- package/skills/cm-readit/examples/blog-reader.js +0 -352
- package/skills/cm-readit/examples/voice-cro.js +0 -390
- package/skills/cm-readit/tts-engine.md +0 -262
- package/skills/cm-readit/ui-patterns.md +0 -362
- package/skills/cm-readit/voice-cro.md +0 -223
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LearningPromoter = void 0;
|
|
7
|
+
exports.formatPromotionCandidates = formatPromotionCandidates;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const storage_backend_1 = require("./storage-backend");
|
|
11
|
+
// ─── Constants ──────────────────────────────────────────────────────────────
|
|
12
|
+
const MIN_REINFORCEMENT = 3; // Minimum times a learning must be reinforced
|
|
13
|
+
const MIN_PROMOTION_SCORE = 0.50; // Minimum score to qualify for promotion
|
|
14
|
+
const PROMOTION_LOG = '.cm/evolution/promotions.jsonl';
|
|
15
|
+
// ─── Learning Promoter ──────────────────────────────────────────────────────
|
|
16
|
+
// TRIZ #22 "Blessing in Disguise" — failures become reusable knowledge
|
|
17
|
+
/**
|
|
18
|
+
* LearningPromoter — Promotes mature learnings into reusable skills.
|
|
19
|
+
*
|
|
20
|
+
* When a learning has been reinforced enough times (appearing in multiple
|
|
21
|
+
* execution analyses or being manually confirmed), it graduates from
|
|
22
|
+
* ephemeral memory into a permanent skill entry.
|
|
23
|
+
*
|
|
24
|
+
* Flow:
|
|
25
|
+
* 1. Scan learnings in SQLite for candidates with high reinforcement
|
|
26
|
+
* 2. Score each candidate based on: reinforcement count, recency, category
|
|
27
|
+
* 3. Generate a minimal SKILL.md from the learning content
|
|
28
|
+
* 4. Save to skills/ directory
|
|
29
|
+
*/
|
|
30
|
+
class LearningPromoter {
|
|
31
|
+
constructor(projectPath, backend) {
|
|
32
|
+
this.projectPath = projectPath;
|
|
33
|
+
this.backend = backend !== null && backend !== void 0 ? backend : (0, storage_backend_1.getBackend)(projectPath);
|
|
34
|
+
this.backend.initialize();
|
|
35
|
+
this.skillsDir = this.findSkillsDir();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Find learnings that qualify for promotion.
|
|
39
|
+
*/
|
|
40
|
+
findCandidates(limit = 10) {
|
|
41
|
+
var _a;
|
|
42
|
+
// Query all learnings and count reinforcement (same what_failed pattern)
|
|
43
|
+
const allLearnings = this.backend.queryLearnings('', undefined, 200);
|
|
44
|
+
const patternCounts = new Map();
|
|
45
|
+
for (const learning of allLearnings) {
|
|
46
|
+
const pattern = this.normalizePattern(learning.what_failed);
|
|
47
|
+
const existing = (_a = patternCounts.get(pattern)) !== null && _a !== void 0 ? _a : { count: 0, learnings: [] };
|
|
48
|
+
existing.count++;
|
|
49
|
+
existing.learnings.push(learning);
|
|
50
|
+
patternCounts.set(pattern, existing);
|
|
51
|
+
}
|
|
52
|
+
const candidates = [];
|
|
53
|
+
for (const [_pattern, { count, learnings }] of patternCounts) {
|
|
54
|
+
if (count < MIN_REINFORCEMENT)
|
|
55
|
+
continue;
|
|
56
|
+
// Use the most recent learning as the representative
|
|
57
|
+
const representative = learnings.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0];
|
|
58
|
+
const score = this.calculateScore(count, representative);
|
|
59
|
+
if (score >= MIN_PROMOTION_SCORE) {
|
|
60
|
+
candidates.push({
|
|
61
|
+
learning: representative,
|
|
62
|
+
reinforcementCount: count,
|
|
63
|
+
score,
|
|
64
|
+
reason: `Reinforced ${count}x, score ${(score * 100).toFixed(0)}%`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return candidates
|
|
69
|
+
.sort((a, b) => b.score - a.score)
|
|
70
|
+
.slice(0, limit);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Promote a specific learning to a skill.
|
|
74
|
+
*/
|
|
75
|
+
promote(learningId) {
|
|
76
|
+
const learning = this.backend.getLearningById(learningId);
|
|
77
|
+
if (!learning) {
|
|
78
|
+
return {
|
|
79
|
+
promoted: false,
|
|
80
|
+
skillName: '',
|
|
81
|
+
skillPath: '',
|
|
82
|
+
learningId,
|
|
83
|
+
reason: `Learning ${learningId} not found.`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Generate skill name from the learning content
|
|
87
|
+
const skillName = this.generateSkillName(learning);
|
|
88
|
+
const skillDir = path_1.default.join(this.skillsDir, skillName);
|
|
89
|
+
if (fs_1.default.existsSync(skillDir)) {
|
|
90
|
+
return {
|
|
91
|
+
promoted: false,
|
|
92
|
+
skillName,
|
|
93
|
+
skillPath: skillDir,
|
|
94
|
+
learningId,
|
|
95
|
+
reason: `Skill ${skillName} already exists.`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Generate the SKILL.md content
|
|
99
|
+
const skillContent = this.generateSkillContent(learning, skillName);
|
|
100
|
+
// Create the skill
|
|
101
|
+
fs_1.default.mkdirSync(skillDir, { recursive: true });
|
|
102
|
+
const skillPath = path_1.default.join(skillDir, 'SKILL.md');
|
|
103
|
+
fs_1.default.writeFileSync(skillPath, skillContent, 'utf-8');
|
|
104
|
+
// Log the promotion
|
|
105
|
+
this.logPromotion(learningId, skillName, skillPath);
|
|
106
|
+
return {
|
|
107
|
+
promoted: true,
|
|
108
|
+
skillName,
|
|
109
|
+
skillPath,
|
|
110
|
+
learningId,
|
|
111
|
+
reason: `Learning promoted to skill: ${skillName}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Auto-promote: find candidates and promote the top one.
|
|
116
|
+
*/
|
|
117
|
+
autoPromote() {
|
|
118
|
+
const candidates = this.findCandidates(1);
|
|
119
|
+
if (candidates.length === 0)
|
|
120
|
+
return null;
|
|
121
|
+
return this.promote(candidates[0].learning.id);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get promotion history.
|
|
125
|
+
*/
|
|
126
|
+
getPromotionHistory(limit = 20) {
|
|
127
|
+
const logPath = path_1.default.join(this.projectPath, PROMOTION_LOG);
|
|
128
|
+
if (!fs_1.default.existsSync(logPath))
|
|
129
|
+
return [];
|
|
130
|
+
const lines = fs_1.default.readFileSync(logPath, 'utf-8').trim().split('\n').filter(Boolean);
|
|
131
|
+
const entries = [];
|
|
132
|
+
for (const line of lines) {
|
|
133
|
+
try {
|
|
134
|
+
entries.push(JSON.parse(line));
|
|
135
|
+
}
|
|
136
|
+
catch ( /* skip */_a) { /* skip */ }
|
|
137
|
+
}
|
|
138
|
+
return entries.slice(-limit).reverse();
|
|
139
|
+
}
|
|
140
|
+
// ─── Private Helpers ────────────────────────────────────────────────────
|
|
141
|
+
findSkillsDir() {
|
|
142
|
+
const candidates = [
|
|
143
|
+
path_1.default.join(this.projectPath, 'skills'),
|
|
144
|
+
path_1.default.join(this.projectPath, '.agent', 'skills'),
|
|
145
|
+
];
|
|
146
|
+
for (const dir of candidates) {
|
|
147
|
+
if (fs_1.default.existsSync(dir))
|
|
148
|
+
return dir;
|
|
149
|
+
}
|
|
150
|
+
return path_1.default.join(this.projectPath, 'skills');
|
|
151
|
+
}
|
|
152
|
+
normalizePattern(text) {
|
|
153
|
+
return text
|
|
154
|
+
.toLowerCase()
|
|
155
|
+
.replace(/[^\w\s]/g, '')
|
|
156
|
+
.replace(/\s+/g, ' ')
|
|
157
|
+
.trim()
|
|
158
|
+
.split(' ')
|
|
159
|
+
.sort()
|
|
160
|
+
.join(' ');
|
|
161
|
+
}
|
|
162
|
+
calculateScore(reinforcementCount, learning) {
|
|
163
|
+
// Reinforcement factor (0-0.5): more reinforcement = higher score
|
|
164
|
+
const reinforcementFactor = Math.min(0.5, reinforcementCount / 10);
|
|
165
|
+
// Recency factor (0-0.3): newer learnings score higher
|
|
166
|
+
const daysSince = (Date.now() - new Date(learning.created_at).getTime()) / (1000 * 60 * 60 * 24);
|
|
167
|
+
const recencyFactor = Math.max(0, 0.3 - (daysSince / 365) * 0.3);
|
|
168
|
+
// Content quality factor (0-0.2): longer, more detailed = better
|
|
169
|
+
const contentLength = (learning.what_failed.length + learning.how_to_prevent.length);
|
|
170
|
+
const qualityFactor = Math.min(0.2, contentLength / 500 * 0.2);
|
|
171
|
+
return reinforcementFactor + recencyFactor + qualityFactor;
|
|
172
|
+
}
|
|
173
|
+
generateSkillName(learning) {
|
|
174
|
+
const words = learning.what_failed
|
|
175
|
+
.toLowerCase()
|
|
176
|
+
.replace(/[^\w\s]/g, '')
|
|
177
|
+
.split(/\s+/)
|
|
178
|
+
.filter(w => w.length > 3)
|
|
179
|
+
.slice(0, 3);
|
|
180
|
+
const base = words.length > 0 ? words.join('-') : 'promoted';
|
|
181
|
+
return `cm-learned-${base}`;
|
|
182
|
+
}
|
|
183
|
+
generateSkillContent(learning, skillName) {
|
|
184
|
+
return [
|
|
185
|
+
'---',
|
|
186
|
+
`name: ${skillName}`,
|
|
187
|
+
`description: Auto-promoted from reinforced learning`,
|
|
188
|
+
'---',
|
|
189
|
+
'',
|
|
190
|
+
`# ${skillName}`,
|
|
191
|
+
'',
|
|
192
|
+
`> 🎓 Auto-promoted from learning on ${new Date().toISOString().split('T')[0]}`,
|
|
193
|
+
`> Original module: ${learning.module}`,
|
|
194
|
+
`> Agent: ${learning.agent}`,
|
|
195
|
+
'',
|
|
196
|
+
'## Problem Pattern',
|
|
197
|
+
'',
|
|
198
|
+
learning.what_failed,
|
|
199
|
+
'',
|
|
200
|
+
'## Root Cause',
|
|
201
|
+
'',
|
|
202
|
+
learning.why_failed,
|
|
203
|
+
'',
|
|
204
|
+
'## Prevention / Solution',
|
|
205
|
+
'',
|
|
206
|
+
learning.how_to_prevent,
|
|
207
|
+
'',
|
|
208
|
+
'## When to Apply',
|
|
209
|
+
'',
|
|
210
|
+
`Apply this skill when encountering patterns similar to: "${learning.what_failed.slice(0, 100)}"`,
|
|
211
|
+
'',
|
|
212
|
+
'## Steps',
|
|
213
|
+
'',
|
|
214
|
+
`1. Recognize the problem pattern described above`,
|
|
215
|
+
`2. Apply the prevention strategy: ${learning.how_to_prevent.slice(0, 100)}`,
|
|
216
|
+
`3. Verify the fix resolves the root cause`,
|
|
217
|
+
'',
|
|
218
|
+
].join('\n');
|
|
219
|
+
}
|
|
220
|
+
logPromotion(learningId, skillName, skillPath) {
|
|
221
|
+
const logPath = path_1.default.join(this.projectPath, PROMOTION_LOG);
|
|
222
|
+
const dir = path_1.default.dirname(logPath);
|
|
223
|
+
if (!fs_1.default.existsSync(dir))
|
|
224
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
225
|
+
const entry = { learningId, skillName, skillPath, promotedAt: new Date().toISOString() };
|
|
226
|
+
fs_1.default.appendFileSync(logPath, JSON.stringify(entry) + '\n');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.LearningPromoter = LearningPromoter;
|
|
230
|
+
// ─── Display Helpers ─────────────────────────────────────────────────────────
|
|
231
|
+
function formatPromotionCandidates(candidates) {
|
|
232
|
+
if (candidates.length === 0)
|
|
233
|
+
return 'No learnings qualify for promotion yet. Need ≥3 reinforcements.';
|
|
234
|
+
const lines = [
|
|
235
|
+
'🎓 Learning → Skill Promotion Candidates',
|
|
236
|
+
'─'.repeat(70),
|
|
237
|
+
`${'Score'.padEnd(8)} ${'Reinf'.padEnd(8)} Pattern`,
|
|
238
|
+
'─'.repeat(70),
|
|
239
|
+
];
|
|
240
|
+
for (const c of candidates) {
|
|
241
|
+
const score = (c.score * 100).toFixed(0) + '%';
|
|
242
|
+
const pattern = c.learning.what_failed.slice(0, 50);
|
|
243
|
+
lines.push(`${score.padEnd(8)} ${(c.reinforcementCount + 'x').padEnd(8)} ${pattern}`);
|
|
244
|
+
}
|
|
245
|
+
return lines.join('\n');
|
|
246
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Per-project learnings — append-only JSONL log under `.cm/learnings.jsonl`.
|
|
4
|
+
*
|
|
5
|
+
* Each learning is a small structured note that future sessions read at start
|
|
6
|
+
* (via cm-continuity) so the agent doesn't repeat past pitfalls or forget
|
|
7
|
+
* preferences. Inspired by gstack `/learn` but simpler — no sync required.
|
|
8
|
+
*
|
|
9
|
+
* Format (one JSON object per line):
|
|
10
|
+
* { "ts": "2026-05-07T12:00:00Z",
|
|
11
|
+
* "type": "pitfall" | "preference" | "pattern" | "fact",
|
|
12
|
+
* "scope": "deploy" | "ui" | "test" | ...,
|
|
13
|
+
* "note": "human readable note",
|
|
14
|
+
* "source": "cm-retro-cli" | "manual" | ... }
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.LearningError = void 0;
|
|
21
|
+
exports.learningsPath = learningsPath;
|
|
22
|
+
exports.addLearning = addLearning;
|
|
23
|
+
exports.listLearnings = listLearnings;
|
|
24
|
+
exports.pruneLearnings = pruneLearnings;
|
|
25
|
+
exports.anonymize = anonymize;
|
|
26
|
+
exports.learningKey = learningKey;
|
|
27
|
+
exports.mergeLearnings = mergeLearnings;
|
|
28
|
+
exports.readLearningsFile = readLearningsFile;
|
|
29
|
+
exports.writeLearningsFile = writeLearningsFile;
|
|
30
|
+
exports.renderLearningsForContinuity = renderLearningsForContinuity;
|
|
31
|
+
const fs_1 = __importDefault(require("fs"));
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const LEARNING_TYPES = new Set(['pitfall', 'preference', 'pattern', 'fact']);
|
|
34
|
+
function learningsPath(projectPath) {
|
|
35
|
+
return path_1.default.join(projectPath, '.cm', 'learnings.jsonl');
|
|
36
|
+
}
|
|
37
|
+
function ensureDir(file) {
|
|
38
|
+
const d = path_1.default.dirname(file);
|
|
39
|
+
if (!fs_1.default.existsSync(d))
|
|
40
|
+
fs_1.default.mkdirSync(d, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
class LearningError extends Error {
|
|
43
|
+
}
|
|
44
|
+
exports.LearningError = LearningError;
|
|
45
|
+
function validate(input) {
|
|
46
|
+
if (!LEARNING_TYPES.has(input.type)) {
|
|
47
|
+
throw new LearningError(`invalid learning type: ${input.type}`);
|
|
48
|
+
}
|
|
49
|
+
if (!input.scope || typeof input.scope !== 'string') {
|
|
50
|
+
throw new LearningError('learning.scope is required (string)');
|
|
51
|
+
}
|
|
52
|
+
if (!input.note || typeof input.note !== 'string') {
|
|
53
|
+
throw new LearningError('learning.note is required (string)');
|
|
54
|
+
}
|
|
55
|
+
if (input.note.length > 500) {
|
|
56
|
+
throw new LearningError(`learning.note too long (${input.note.length} > 500)`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function addLearning(projectPath, input) {
|
|
60
|
+
var _a;
|
|
61
|
+
validate(input);
|
|
62
|
+
const learning = Object.assign({ ts: (_a = input.ts) !== null && _a !== void 0 ? _a : new Date().toISOString(), type: input.type, scope: input.scope, note: input.note }, (input.source ? { source: input.source } : {}));
|
|
63
|
+
const file = learningsPath(projectPath);
|
|
64
|
+
ensureDir(file);
|
|
65
|
+
fs_1.default.appendFileSync(file, JSON.stringify(learning) + '\n', 'utf8');
|
|
66
|
+
return learning;
|
|
67
|
+
}
|
|
68
|
+
function listLearnings(projectPath, query = {}) {
|
|
69
|
+
const file = learningsPath(projectPath);
|
|
70
|
+
if (!fs_1.default.existsSync(file))
|
|
71
|
+
return [];
|
|
72
|
+
const raw = fs_1.default.readFileSync(file, 'utf8');
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const line of raw.split('\n')) {
|
|
75
|
+
if (!line.trim())
|
|
76
|
+
continue;
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(line);
|
|
80
|
+
}
|
|
81
|
+
catch (_a) {
|
|
82
|
+
continue; // skip malformed lines
|
|
83
|
+
}
|
|
84
|
+
if (query.type && parsed.type !== query.type)
|
|
85
|
+
continue;
|
|
86
|
+
if (query.scope && parsed.scope !== query.scope)
|
|
87
|
+
continue;
|
|
88
|
+
if (query.since && parsed.ts < query.since)
|
|
89
|
+
continue;
|
|
90
|
+
out.push(parsed);
|
|
91
|
+
}
|
|
92
|
+
// Newest first.
|
|
93
|
+
out.reverse();
|
|
94
|
+
if (query.limit && out.length > query.limit)
|
|
95
|
+
return out.slice(0, query.limit);
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Remove learnings older than `maxAgeDays` (default 180).
|
|
100
|
+
* Returns the number of pruned entries.
|
|
101
|
+
*/
|
|
102
|
+
function pruneLearnings(projectPath, maxAgeDays = 180) {
|
|
103
|
+
const file = learningsPath(projectPath);
|
|
104
|
+
if (!fs_1.default.existsSync(file))
|
|
105
|
+
return 0;
|
|
106
|
+
const cutoff = new Date(Date.now() - maxAgeDays * 24 * 60 * 60 * 1000).toISOString();
|
|
107
|
+
const raw = fs_1.default.readFileSync(file, 'utf8');
|
|
108
|
+
const kept = [];
|
|
109
|
+
let pruned = 0;
|
|
110
|
+
for (const line of raw.split('\n')) {
|
|
111
|
+
if (!line.trim())
|
|
112
|
+
continue;
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(line);
|
|
115
|
+
if (parsed.ts >= cutoff) {
|
|
116
|
+
kept.push(line);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
pruned++;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
kept.push(line); // keep malformed lines as-is
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
fs_1.default.writeFileSync(file, kept.join('\n') + (kept.length ? '\n' : ''), 'utf8');
|
|
127
|
+
return pruned;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Strip user-identifying / token-looking material from a learning before it
|
|
131
|
+
* leaves the project. Used by `cm learn sync` to push to a shared remote
|
|
132
|
+
* without leaking absolute paths, emails, or long credentials.
|
|
133
|
+
*/
|
|
134
|
+
function anonymize(l) {
|
|
135
|
+
const stripPath = (s) => s
|
|
136
|
+
.replace(/\/Users\/[^/\s"']+/g, '~')
|
|
137
|
+
.replace(/\/home\/[^/\s"']+/g, '~')
|
|
138
|
+
.replace(/[A-Za-z]:\\Users\\[^\\\s"']+/g, '~');
|
|
139
|
+
const stripEmail = (s) => s.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, '<email>');
|
|
140
|
+
const stripToken = (s) =>
|
|
141
|
+
// Long opaque tokens — runs of 24+ url-safe chars without spaces.
|
|
142
|
+
s.replace(/[A-Za-z0-9_\-]{24,}/g, '<token>');
|
|
143
|
+
const clean = (s) => stripToken(stripEmail(stripPath(s)));
|
|
144
|
+
return Object.assign({ ts: l.ts, type: l.type, scope: clean(l.scope), note: clean(l.note) }, (l.source ? { source: clean(l.source) } : {}));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Stable identity hash for dedup across machines. Excludes `ts` so the same
|
|
148
|
+
* note appearing on two days collapses to one entry.
|
|
149
|
+
*/
|
|
150
|
+
function learningKey(l) {
|
|
151
|
+
return `${l.type}|${l.scope}|${l.note}`;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Merge two learning lists, dropping duplicates by `learningKey`. The earliest
|
|
155
|
+
* timestamp wins (we treat the original observation as canonical).
|
|
156
|
+
*/
|
|
157
|
+
function mergeLearnings(a, b) {
|
|
158
|
+
const map = new Map();
|
|
159
|
+
for (const l of [...a, ...b]) {
|
|
160
|
+
const k = learningKey(l);
|
|
161
|
+
const prev = map.get(k);
|
|
162
|
+
if (!prev || l.ts < prev.ts)
|
|
163
|
+
map.set(k, l);
|
|
164
|
+
}
|
|
165
|
+
return Array.from(map.values()).sort((x, y) => (x.ts < y.ts ? -1 : 1));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read the JSONL file at an arbitrary path (used by sync to read the remote
|
|
169
|
+
* mirror copy). Returns [] if the file is missing.
|
|
170
|
+
*/
|
|
171
|
+
function readLearningsFile(file) {
|
|
172
|
+
if (!fs_1.default.existsSync(file))
|
|
173
|
+
return [];
|
|
174
|
+
const out = [];
|
|
175
|
+
for (const line of fs_1.default.readFileSync(file, 'utf8').split('\n')) {
|
|
176
|
+
if (!line.trim())
|
|
177
|
+
continue;
|
|
178
|
+
try {
|
|
179
|
+
out.push(JSON.parse(line));
|
|
180
|
+
}
|
|
181
|
+
catch (_a) {
|
|
182
|
+
// skip malformed
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
function writeLearningsFile(file, list) {
|
|
188
|
+
const dir = path_1.default.dirname(file);
|
|
189
|
+
if (!fs_1.default.existsSync(dir))
|
|
190
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
191
|
+
const body = list.map(l => JSON.stringify(l)).join('\n');
|
|
192
|
+
fs_1.default.writeFileSync(file, list.length ? body + '\n' : '', 'utf8');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Render the most recent N learnings as a compact Markdown block, suitable
|
|
196
|
+
* for injection into CONTINUITY.md by cm-continuity at session start.
|
|
197
|
+
*/
|
|
198
|
+
function renderLearningsForContinuity(projectPath, limit = 10) {
|
|
199
|
+
const recent = listLearnings(projectPath, { limit });
|
|
200
|
+
if (recent.length === 0)
|
|
201
|
+
return '';
|
|
202
|
+
const lines = ['## Recent Learnings (auto-loaded)'];
|
|
203
|
+
for (const l of recent) {
|
|
204
|
+
const date = l.ts.slice(0, 10);
|
|
205
|
+
lines.push(`- [${date}] **${l.type}/${l.scope}**: ${l.note}`);
|
|
206
|
+
}
|
|
207
|
+
return lines.join('\n') + '\n';
|
|
208
|
+
}
|