@kynetic-ai/spec 0.1.2 → 0.4.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/README.md +250 -17
- package/dist/acp/client.d.ts +18 -4
- package/dist/acp/client.d.ts.map +1 -1
- package/dist/acp/client.js +44 -26
- package/dist/acp/client.js.map +1 -1
- package/dist/acp/framing.d.ts +2 -2
- package/dist/acp/framing.d.ts.map +1 -1
- package/dist/acp/framing.js +37 -29
- package/dist/acp/framing.js.map +1 -1
- package/dist/acp/index.d.ts +6 -7
- package/dist/acp/index.d.ts.map +1 -1
- package/dist/acp/index.js +3 -3
- package/dist/acp/index.js.map +1 -1
- package/dist/acp/types.d.ts +5 -5
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js +18 -18
- package/dist/acp/types.js.map +1 -1
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/adapters.js +24 -13
- package/dist/agents/adapters.js.map +1 -1
- package/dist/agents/index.d.ts +2 -2
- package/dist/agents/index.js +2 -2
- package/dist/agents/spawner.d.ts +4 -4
- package/dist/agents/spawner.d.ts.map +1 -1
- package/dist/agents/spawner.js +6 -6
- package/dist/agents/spawner.js.map +1 -1
- package/dist/cli/batch-context.d.ts +43 -0
- package/dist/cli/batch-context.d.ts.map +1 -0
- package/dist/cli/batch-context.js +93 -0
- package/dist/cli/batch-context.js.map +1 -0
- package/dist/cli/batch-exec.d.ts +107 -0
- package/dist/cli/batch-exec.d.ts.map +1 -0
- package/dist/cli/batch-exec.js +706 -0
- package/dist/cli/batch-exec.js.map +1 -0
- package/dist/cli/batch.d.ts +4 -2
- package/dist/cli/batch.d.ts.map +1 -1
- package/dist/cli/batch.js +15 -14
- package/dist/cli/batch.js.map +1 -1
- package/dist/cli/command-annotations.d.ts +23 -0
- package/dist/cli/command-annotations.d.ts.map +1 -0
- package/dist/cli/command-annotations.js +27 -0
- package/dist/cli/command-annotations.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +46 -0
- package/dist/cli/commands/agents.d.ts.map +1 -0
- package/dist/cli/commands/agents.js +377 -0
- package/dist/cli/commands/agents.js.map +1 -0
- package/dist/cli/commands/batch.d.ts +20 -0
- package/dist/cli/commands/batch.d.ts.map +1 -0
- package/dist/cli/commands/batch.js +214 -0
- package/dist/cli/commands/batch.js.map +1 -0
- package/dist/cli/commands/clone-for-testing.d.ts +1 -1
- package/dist/cli/commands/clone-for-testing.d.ts.map +1 -1
- package/dist/cli/commands/clone-for-testing.js +37 -47
- package/dist/cli/commands/clone-for-testing.js.map +1 -1
- package/dist/cli/commands/derive.d.ts +1 -1
- package/dist/cli/commands/derive.d.ts.map +1 -1
- package/dist/cli/commands/derive.js +141 -88
- package/dist/cli/commands/derive.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +11 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +152 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/export.d.ts +12 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +134 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/help.d.ts +1 -1
- package/dist/cli/commands/help.d.ts.map +1 -1
- package/dist/cli/commands/help.js +163 -37
- package/dist/cli/commands/help.js.map +1 -1
- package/dist/cli/commands/inbox.d.ts +1 -1
- package/dist/cli/commands/inbox.d.ts.map +1 -1
- package/dist/cli/commands/inbox.js +178 -56
- package/dist/cli/commands/inbox.js.map +1 -1
- package/dist/cli/commands/index.d.ts +31 -19
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +31 -19
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +5 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +108 -57
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/item.d.ts +1 -1
- package/dist/cli/commands/item.d.ts.map +1 -1
- package/dist/cli/commands/item.js +557 -274
- package/dist/cli/commands/item.js.map +1 -1
- package/dist/cli/commands/link.d.ts +1 -1
- package/dist/cli/commands/link.d.ts.map +1 -1
- package/dist/cli/commands/link.js +55 -46
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/log.d.ts +1 -1
- package/dist/cli/commands/log.d.ts.map +1 -1
- package/dist/cli/commands/log.js +58 -51
- package/dist/cli/commands/log.js.map +1 -1
- package/dist/cli/commands/merge-driver.d.ts +19 -0
- package/dist/cli/commands/merge-driver.d.ts.map +1 -0
- package/dist/cli/commands/merge-driver.js +398 -0
- package/dist/cli/commands/merge-driver.js.map +1 -0
- package/dist/cli/commands/meta.d.ts +1 -1
- package/dist/cli/commands/meta.d.ts.map +1 -1
- package/dist/cli/commands/meta.js +534 -399
- package/dist/cli/commands/meta.js.map +1 -1
- package/dist/cli/commands/module.d.ts +1 -1
- package/dist/cli/commands/module.d.ts.map +1 -1
- package/dist/cli/commands/module.js +30 -25
- package/dist/cli/commands/module.js.map +1 -1
- package/dist/cli/commands/plan-import.d.ts +11 -0
- package/dist/cli/commands/plan-import.d.ts.map +1 -0
- package/dist/cli/commands/plan-import.js +547 -0
- package/dist/cli/commands/plan-import.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +10 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +421 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/ralph.d.ts +1 -1
- package/dist/cli/commands/ralph.d.ts.map +1 -1
- package/dist/cli/commands/ralph.js +1109 -170
- package/dist/cli/commands/ralph.js.map +1 -1
- package/dist/cli/commands/refs.d.ts +13 -0
- package/dist/cli/commands/refs.d.ts.map +1 -0
- package/dist/cli/commands/refs.js +283 -0
- package/dist/cli/commands/refs.js.map +1 -0
- package/dist/cli/commands/search.d.ts +1 -1
- package/dist/cli/commands/search.d.ts.map +1 -1
- package/dist/cli/commands/search.js +199 -37
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/serve.d.ts +10 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +491 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/session.d.ts +25 -6
- package/dist/cli/commands/session.d.ts.map +1 -1
- package/dist/cli/commands/session.js +810 -127
- package/dist/cli/commands/session.js.map +1 -1
- package/dist/cli/commands/setup-seeding.d.ts +81 -0
- package/dist/cli/commands/setup-seeding.d.ts.map +1 -0
- package/dist/cli/commands/setup-seeding.js +292 -0
- package/dist/cli/commands/setup-seeding.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +77 -3
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +1267 -274
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/shadow.d.ts +1 -1
- package/dist/cli/commands/shadow.d.ts.map +1 -1
- package/dist/cli/commands/shadow.js +70 -50
- package/dist/cli/commands/shadow.js.map +1 -1
- package/dist/cli/commands/skill-crud.d.ts +58 -0
- package/dist/cli/commands/skill-crud.d.ts.map +1 -0
- package/dist/cli/commands/skill-crud.js +753 -0
- package/dist/cli/commands/skill-crud.js.map +1 -0
- package/dist/cli/commands/skill-diff.d.ts +27 -0
- package/dist/cli/commands/skill-diff.d.ts.map +1 -0
- package/dist/cli/commands/skill-diff.js +840 -0
- package/dist/cli/commands/skill-diff.js.map +1 -0
- package/dist/cli/commands/skill-install.d.ts +56 -0
- package/dist/cli/commands/skill-install.d.ts.map +1 -0
- package/dist/cli/commands/skill-install.js +509 -0
- package/dist/cli/commands/skill-install.js.map +1 -0
- package/dist/cli/commands/skill.d.ts +20 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +36 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/task.d.ts +1 -1
- package/dist/cli/commands/task.d.ts.map +1 -1
- package/dist/cli/commands/task.js +584 -350
- package/dist/cli/commands/task.js.map +1 -1
- package/dist/cli/commands/tasks.d.ts +26 -1
- package/dist/cli/commands/tasks.d.ts.map +1 -1
- package/dist/cli/commands/tasks.js +225 -122
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/commands/trait.d.ts +1 -1
- package/dist/cli/commands/trait.d.ts.map +1 -1
- package/dist/cli/commands/trait.js +166 -101
- package/dist/cli/commands/trait.js.map +1 -1
- package/dist/cli/commands/triage.d.ts +7 -0
- package/dist/cli/commands/triage.d.ts.map +1 -0
- package/dist/cli/commands/triage.js +483 -0
- package/dist/cli/commands/triage.js.map +1 -0
- package/dist/cli/commands/util.d.ts +7 -0
- package/dist/cli/commands/util.d.ts.map +1 -0
- package/dist/cli/commands/util.js +30 -0
- package/dist/cli/commands/util.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +264 -83
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/commands/workflow.d.ts +16 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +851 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/exit-codes.d.ts +7 -0
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +26 -18
- package/dist/cli/exit-codes.js.map +1 -1
- package/dist/cli/help/content.d.ts.map +1 -1
- package/dist/cli/help/content.js +86 -71
- package/dist/cli/help/content.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +131 -19
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/introspection.d.ts +6 -2
- package/dist/cli/introspection.d.ts.map +1 -1
- package/dist/cli/introspection.js +11 -8
- package/dist/cli/introspection.js.map +1 -1
- package/dist/cli/output.d.ts +64 -4
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +237 -85
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/parse-utils.d.ts +21 -0
- package/dist/cli/parse-utils.d.ts.map +1 -0
- package/dist/cli/parse-utils.js +32 -0
- package/dist/cli/parse-utils.js.map +1 -0
- package/dist/cli/pid-utils.d.ts +72 -0
- package/dist/cli/pid-utils.d.ts.map +1 -0
- package/dist/cli/pid-utils.js +174 -0
- package/dist/cli/pid-utils.js.map +1 -0
- package/dist/cli/suggest.d.ts.map +1 -1
- package/dist/cli/suggest.js +1 -2
- package/dist/cli/suggest.js.map +1 -1
- package/dist/cli/validators.d.ts +43 -0
- package/dist/cli/validators.d.ts.map +1 -0
- package/dist/cli/validators.js +84 -0
- package/dist/cli/validators.js.map +1 -0
- package/dist/daemon/index.ts +52 -0
- package/dist/daemon/middleware/project-context.ts +126 -0
- package/dist/daemon/pid.ts +179 -0
- package/dist/daemon/project-context.ts +343 -0
- package/dist/daemon/routes/inbox.ts +164 -0
- package/dist/daemon/routes/items.ts +322 -0
- package/dist/daemon/routes/meta.ts +118 -0
- package/dist/daemon/routes/projects.ts +162 -0
- package/dist/daemon/routes/tasks.ts +327 -0
- package/dist/daemon/routes/triage.ts +402 -0
- package/dist/daemon/routes/validation.ts +248 -0
- package/dist/daemon/server.ts +408 -0
- package/dist/daemon/watcher.ts +195 -0
- package/dist/daemon/websocket/handler.ts +138 -0
- package/dist/daemon/websocket/heartbeat.ts +71 -0
- package/dist/daemon/websocket/pubsub.ts +125 -0
- package/dist/daemon/websocket/types.ts +66 -0
- package/dist/export/html.d.ts +19 -0
- package/dist/export/html.d.ts.map +1 -0
- package/dist/export/html.js +239 -0
- package/dist/export/html.js.map +1 -0
- package/dist/export/index.d.ts +10 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/index.js +10 -0
- package/dist/export/index.js.map +1 -0
- package/dist/export/json.d.ts +24 -0
- package/dist/export/json.d.ts.map +1 -0
- package/dist/export/json.js +198 -0
- package/dist/export/json.js.map +1 -0
- package/dist/export/triage.d.ts +51 -0
- package/dist/export/triage.d.ts.map +1 -0
- package/dist/export/triage.js +83 -0
- package/dist/export/triage.js.map +1 -0
- package/dist/export/types.d.ts +122 -0
- package/dist/export/types.d.ts.map +1 -0
- package/dist/export/types.js +9 -0
- package/dist/export/types.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lib/claude-plugin-registry.d.ts +66 -0
- package/dist/lib/claude-plugin-registry.d.ts.map +1 -0
- package/dist/lib/claude-plugin-registry.js +318 -0
- package/dist/lib/claude-plugin-registry.js.map +1 -0
- package/dist/merge/arrays.d.ts +87 -0
- package/dist/merge/arrays.d.ts.map +1 -0
- package/dist/merge/arrays.js +164 -0
- package/dist/merge/arrays.js.map +1 -0
- package/dist/merge/file-type.d.ts +32 -0
- package/dist/merge/file-type.d.ts.map +1 -0
- package/dist/merge/file-type.js +70 -0
- package/dist/merge/file-type.js.map +1 -0
- package/dist/merge/index.d.ts +14 -0
- package/dist/merge/index.d.ts.map +1 -0
- package/dist/merge/index.js +11 -0
- package/dist/merge/index.js.map +1 -0
- package/dist/merge/objects.d.ts +46 -0
- package/dist/merge/objects.d.ts.map +1 -0
- package/dist/merge/objects.js +193 -0
- package/dist/merge/objects.js.map +1 -0
- package/dist/merge/parse.d.ts +23 -0
- package/dist/merge/parse.d.ts.map +1 -0
- package/dist/merge/parse.js +78 -0
- package/dist/merge/parse.js.map +1 -0
- package/dist/merge/resolve.d.ts +66 -0
- package/dist/merge/resolve.d.ts.map +1 -0
- package/dist/merge/resolve.js +189 -0
- package/dist/merge/resolve.js.map +1 -0
- package/dist/merge/types.d.ts +82 -0
- package/dist/merge/types.d.ts.map +1 -0
- package/dist/merge/types.js +8 -0
- package/dist/merge/types.js.map +1 -0
- package/dist/parser/agent-data-sections.d.ts +53 -0
- package/dist/parser/agent-data-sections.d.ts.map +1 -0
- package/dist/parser/agent-data-sections.js +118 -0
- package/dist/parser/agent-data-sections.js.map +1 -0
- package/dist/parser/alignment.d.ts +4 -4
- package/dist/parser/alignment.d.ts.map +1 -1
- package/dist/parser/alignment.js +27 -22
- package/dist/parser/alignment.js.map +1 -1
- package/dist/parser/assess.d.ts +5 -5
- package/dist/parser/assess.d.ts.map +1 -1
- package/dist/parser/assess.js +36 -32
- package/dist/parser/assess.js.map +1 -1
- package/dist/parser/config.d.ts +457 -0
- package/dist/parser/config.d.ts.map +1 -0
- package/dist/parser/config.js +373 -0
- package/dist/parser/config.js.map +1 -0
- package/dist/parser/convention-validation.d.ts +1 -1
- package/dist/parser/convention-validation.d.ts.map +1 -1
- package/dist/parser/convention-validation.js +21 -16
- package/dist/parser/convention-validation.js.map +1 -1
- package/dist/parser/coverage-cache.d.ts +49 -0
- package/dist/parser/coverage-cache.d.ts.map +1 -0
- package/dist/parser/coverage-cache.js +123 -0
- package/dist/parser/coverage-cache.js.map +1 -0
- package/dist/parser/daemon-status.d.ts +37 -0
- package/dist/parser/daemon-status.d.ts.map +1 -0
- package/dist/parser/daemon-status.js +67 -0
- package/dist/parser/daemon-status.js.map +1 -0
- package/dist/parser/doctor.d.ts +107 -0
- package/dist/parser/doctor.d.ts.map +1 -0
- package/dist/parser/doctor.js +366 -0
- package/dist/parser/doctor.js.map +1 -0
- package/dist/parser/fix.d.ts +1 -1
- package/dist/parser/fix.d.ts.map +1 -1
- package/dist/parser/fix.js +31 -27
- package/dist/parser/fix.js.map +1 -1
- package/dist/parser/index.d.ts +16 -11
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +16 -11
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/items.d.ts +8 -2
- package/dist/parser/items.d.ts.map +1 -1
- package/dist/parser/items.js +71 -35
- package/dist/parser/items.js.map +1 -1
- package/dist/parser/meta.d.ts +167 -9
- package/dist/parser/meta.d.ts.map +1 -1
- package/dist/parser/meta.js +379 -46
- package/dist/parser/meta.js.map +1 -1
- package/dist/parser/plan-document.d.ts +197 -0
- package/dist/parser/plan-document.d.ts.map +1 -0
- package/dist/parser/plan-document.js +341 -0
- package/dist/parser/plan-document.js.map +1 -0
- package/dist/parser/plans.d.ts +59 -0
- package/dist/parser/plans.d.ts.map +1 -0
- package/dist/parser/plans.js +239 -0
- package/dist/parser/plans.js.map +1 -0
- package/dist/parser/refs.d.ts +22 -9
- package/dist/parser/refs.d.ts.map +1 -1
- package/dist/parser/refs.js +102 -50
- package/dist/parser/refs.js.map +1 -1
- package/dist/parser/setup-status.d.ts +71 -0
- package/dist/parser/setup-status.d.ts.map +1 -0
- package/dist/parser/setup-status.js +269 -0
- package/dist/parser/setup-status.js.map +1 -0
- package/dist/parser/shadow.d.ts +150 -19
- package/dist/parser/shadow.d.ts.map +1 -1
- package/dist/parser/shadow.js +548 -187
- package/dist/parser/shadow.js.map +1 -1
- package/dist/parser/skill-render.d.ts +317 -0
- package/dist/parser/skill-render.d.ts.map +1 -0
- package/dist/parser/skill-render.js +943 -0
- package/dist/parser/skill-render.js.map +1 -0
- package/dist/parser/traits.d.ts +3 -3
- package/dist/parser/traits.d.ts.map +1 -1
- package/dist/parser/traits.js +2 -2
- package/dist/parser/traits.js.map +1 -1
- package/dist/parser/validate-skills.d.ts +32 -0
- package/dist/parser/validate-skills.d.ts.map +1 -0
- package/dist/parser/validate-skills.js +202 -0
- package/dist/parser/validate-skills.js.map +1 -0
- package/dist/parser/validate.d.ts +45 -3
- package/dist/parser/validate.d.ts.map +1 -1
- package/dist/parser/validate.js +622 -105
- package/dist/parser/validate.js.map +1 -1
- package/dist/parser/yaml.d.ts +83 -19
- package/dist/parser/yaml.d.ts.map +1 -1
- package/dist/parser/yaml.js +478 -173
- package/dist/parser/yaml.js.map +1 -1
- package/dist/ralph/cli-renderer.d.ts +8 -1
- package/dist/ralph/cli-renderer.d.ts.map +1 -1
- package/dist/ralph/cli-renderer.js +105 -34
- package/dist/ralph/cli-renderer.js.map +1 -1
- package/dist/ralph/events.d.ts +10 -10
- package/dist/ralph/events.d.ts.map +1 -1
- package/dist/ralph/events.js +301 -98
- package/dist/ralph/events.js.map +1 -1
- package/dist/ralph/index.d.ts +5 -2
- package/dist/ralph/index.d.ts.map +1 -1
- package/dist/ralph/index.js +9 -3
- package/dist/ralph/index.js.map +1 -1
- package/dist/ralph/loop-errors.d.ts +83 -0
- package/dist/ralph/loop-errors.d.ts.map +1 -0
- package/dist/ralph/loop-errors.js +150 -0
- package/dist/ralph/loop-errors.js.map +1 -0
- package/dist/ralph/subagent.d.ts +94 -0
- package/dist/ralph/subagent.d.ts.map +1 -0
- package/dist/ralph/subagent.js +193 -0
- package/dist/ralph/subagent.js.map +1 -0
- package/dist/ralph/wrap-up.d.ts +125 -0
- package/dist/ralph/wrap-up.d.ts.map +1 -0
- package/dist/ralph/wrap-up.js +270 -0
- package/dist/ralph/wrap-up.js.map +1 -0
- package/dist/schema/batch.d.ts +97 -0
- package/dist/schema/batch.d.ts.map +1 -0
- package/dist/schema/batch.js +24 -0
- package/dist/schema/batch.js.map +1 -0
- package/dist/schema/common.d.ts +8 -2
- package/dist/schema/common.d.ts.map +1 -1
- package/dist/schema/common.js +42 -31
- package/dist/schema/common.js.map +1 -1
- package/dist/schema/inbox.d.ts +12 -12
- package/dist/schema/inbox.js +4 -4
- package/dist/schema/inbox.js.map +1 -1
- package/dist/schema/index.d.ts +8 -5
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +8 -5
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/meta.d.ts +1454 -27
- package/dist/schema/meta.d.ts.map +1 -1
- package/dist/schema/meta.js +198 -21
- package/dist/schema/meta.js.map +1 -1
- package/dist/schema/plan.d.ts +285 -0
- package/dist/schema/plan.d.ts.map +1 -0
- package/dist/schema/plan.js +81 -0
- package/dist/schema/plan.js.map +1 -0
- package/dist/schema/spec.d.ts +72 -33
- package/dist/schema/spec.d.ts.map +1 -1
- package/dist/schema/spec.js +22 -9
- package/dist/schema/spec.js.map +1 -1
- package/dist/schema/task.d.ts +172 -161
- package/dist/schema/task.d.ts.map +1 -1
- package/dist/schema/task.js +21 -12
- package/dist/schema/task.js.map +1 -1
- package/dist/schema/triage.d.ts +266 -0
- package/dist/schema/triage.d.ts.map +1 -0
- package/dist/schema/triage.js +134 -0
- package/dist/schema/triage.js.map +1 -0
- package/dist/sessions/index.d.ts +2 -2
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +3 -3
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/store.d.ts +241 -1
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +810 -31
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +10 -10
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js +10 -9
- package/dist/sessions/types.js.map +1 -1
- package/dist/strings/errors.d.ts +55 -0
- package/dist/strings/errors.d.ts.map +1 -1
- package/dist/strings/errors.js +138 -106
- package/dist/strings/errors.js.map +1 -1
- package/dist/strings/guidance.d.ts.map +1 -1
- package/dist/strings/guidance.js +16 -16
- package/dist/strings/guidance.js.map +1 -1
- package/dist/strings/index.d.ts +4 -4
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +4 -4
- package/dist/strings/index.js.map +1 -1
- package/dist/strings/labels.d.ts +4 -0
- package/dist/strings/labels.d.ts.map +1 -1
- package/dist/strings/labels.js +45 -41
- package/dist/strings/labels.js.map +1 -1
- package/dist/strings/validation.d.ts.map +1 -1
- package/dist/strings/validation.js +71 -71
- package/dist/strings/validation.js.map +1 -1
- package/dist/triage/actions.d.ts +27 -0
- package/dist/triage/actions.d.ts.map +1 -0
- package/dist/triage/actions.js +95 -0
- package/dist/triage/actions.js.map +1 -0
- package/dist/triage/constants.d.ts +6 -0
- package/dist/triage/constants.d.ts.map +1 -0
- package/dist/triage/constants.js +7 -0
- package/dist/triage/constants.js.map +1 -0
- package/dist/triage/index.d.ts +3 -0
- package/dist/triage/index.d.ts.map +1 -0
- package/dist/triage/index.js +3 -0
- package/dist/triage/index.js.map +1 -0
- package/dist/utils/commit.d.ts +1 -1
- package/dist/utils/commit.d.ts.map +1 -1
- package/dist/utils/commit.js +28 -26
- package/dist/utils/commit.js.map +1 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +40 -38
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/grep.js +11 -11
- package/dist/utils/grep.js.map +1 -1
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/time.js +10 -10
- package/dist/utils/time.js.map +1 -1
- package/package.json +28 -5
- package/plugin/.claude-plugin/marketplace.json +17 -0
- package/plugin/.claude-plugin/plugin.json +5 -0
- package/plugin/plugins/kspec/skills/create-workflow/SKILL.md +235 -0
- package/plugin/plugins/kspec/skills/help/SKILL.md +42 -0
- package/plugin/plugins/kspec/skills/observations/SKILL.md +143 -0
- package/plugin/plugins/kspec/skills/plan/SKILL.md +343 -0
- package/plugin/plugins/kspec/skills/reflect/SKILL.md +161 -0
- package/plugin/plugins/kspec/skills/review/SKILL.md +193 -0
- package/plugin/plugins/kspec/skills/task-work/SKILL.md +303 -0
- package/plugin/plugins/kspec/skills/triage/SKILL.md +206 -0
- package/plugin/plugins/kspec/skills/triage/docs/automation.md +120 -0
- package/plugin/plugins/kspec/skills/triage/docs/inbox.md +144 -0
- package/plugin/plugins/kspec/skills/triage/docs/observations.md +85 -0
- package/plugin/plugins/kspec/skills/triage-automation/SKILL.md +140 -0
- package/plugin/plugins/kspec/skills/triage-inbox/SKILL.md +232 -0
- package/plugin/plugins/kspec/skills/writing-specs/SKILL.md +340 -0
- package/templates/agents-sections/01-quick-start.md +22 -0
- package/templates/agents-sections/02-shadow-branch.md +34 -0
- package/templates/agents-sections/03-task-lifecycle.md +48 -0
- package/templates/agents-sections/04-pr-workflow.md +17 -0
- package/templates/agents-sections/05-commit-convention.md +27 -0
- package/templates/agents-sections/06-ralph-loop.md +45 -0
- package/templates/hooks/pre-commit +34 -0
- package/templates/skills/create-workflow/SKILL.md +228 -0
- package/templates/skills/help/SKILL.md +37 -0
- package/templates/skills/manifest.yaml +60 -0
- package/templates/skills/observations/SKILL.md +137 -0
- package/templates/skills/plan/SKILL.md +336 -0
- package/templates/skills/reflect/SKILL.md +155 -0
- package/templates/skills/review/SKILL.md +186 -0
- package/templates/skills/task-work/SKILL.md +296 -0
- package/templates/skills/triage/SKILL.md +199 -0
- package/templates/skills/triage/docs/automation.md +120 -0
- package/templates/skills/triage/docs/inbox.md +144 -0
- package/templates/skills/triage/docs/observations.md +85 -0
- package/templates/skills/triage-automation/SKILL.md +134 -0
- package/templates/skills/triage-inbox/SKILL.md +225 -0
- package/templates/skills/writing-specs/SKILL.md +333 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code plugin marketplace registry library.
|
|
3
|
+
*
|
|
4
|
+
* Shared by setup.ts and skill-install.ts for registering the kspec core
|
|
5
|
+
* skills plugin with Claude Code's global state.
|
|
6
|
+
*
|
|
7
|
+
* AC: @core-skill-install ac-6, ac-7, ac-8
|
|
8
|
+
* AC: @enhanced-setup ac-7, ac-8
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from "node:fs/promises";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import * as os from "node:os";
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Path Resolution
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Get the Claude Code plugins directory.
|
|
18
|
+
* Respects KSPEC_CLAUDE_HOME env override for test isolation.
|
|
19
|
+
*/
|
|
20
|
+
export function getClaudePluginsDir() {
|
|
21
|
+
const home = process.env.KSPEC_CLAUDE_HOME || path.join(os.homedir(), ".claude");
|
|
22
|
+
return path.join(home, "plugins");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the absolute path to the pre-built plugin directory in the npm package.
|
|
26
|
+
* Uses fs.realpath for symlink/pnpm stability.
|
|
27
|
+
*/
|
|
28
|
+
export async function getPackagePluginDir() {
|
|
29
|
+
// Resolve relative to this file: src/lib/ -> ../../plugin
|
|
30
|
+
const rawPath = path.resolve(import.meta.dirname || path.dirname(new URL(import.meta.url).pathname), "../../plugin");
|
|
31
|
+
try {
|
|
32
|
+
return await fs.realpath(rawPath);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return rawPath;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Atomic JSON Operations
|
|
40
|
+
// ============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Tolerant JSON read — returns default if missing, empty, or corrupt.
|
|
43
|
+
* Only use for files owned by this module (known_marketplaces.json).
|
|
44
|
+
*/
|
|
45
|
+
async function readJsonSafe(filePath, defaultValue) {
|
|
46
|
+
try {
|
|
47
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
48
|
+
if (!content.trim())
|
|
49
|
+
return defaultValue;
|
|
50
|
+
return JSON.parse(content);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return defaultValue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Strict JSON read — throws on corrupt JSON.
|
|
58
|
+
* Use for files with critical config (settings.json) to avoid silent data loss.
|
|
59
|
+
*/
|
|
60
|
+
async function readJsonStrict(filePath, defaultValue) {
|
|
61
|
+
try {
|
|
62
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
63
|
+
if (!content.trim())
|
|
64
|
+
return defaultValue;
|
|
65
|
+
return JSON.parse(content);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
// ENOENT = file doesn't exist -> return default
|
|
69
|
+
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
70
|
+
return defaultValue;
|
|
71
|
+
}
|
|
72
|
+
// Parse errors or permission errors -> throw
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Atomic JSON write — temp file + rename in same directory.
|
|
78
|
+
* Creates parent directory if needed.
|
|
79
|
+
*/
|
|
80
|
+
async function writeJsonAtomic(filePath, data) {
|
|
81
|
+
const dir = path.dirname(filePath);
|
|
82
|
+
await fs.mkdir(dir, { recursive: true });
|
|
83
|
+
const tmpPath = `${filePath}.${Date.now()}.tmp`;
|
|
84
|
+
const content = JSON.stringify(data, null, 2) + "\n";
|
|
85
|
+
await fs.writeFile(tmpPath, content, "utf-8");
|
|
86
|
+
await fs.rename(tmpPath, filePath);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Read-modify-write with optimistic retry (3 attempts).
|
|
90
|
+
* Best-effort concurrent safety, not lock-based.
|
|
91
|
+
*/
|
|
92
|
+
async function modifyJsonAtomic(filePath, defaultValue, mutator, options) {
|
|
93
|
+
const maxAttempts = 3;
|
|
94
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
95
|
+
const data = options?.strict
|
|
96
|
+
? await readJsonStrict(filePath, defaultValue)
|
|
97
|
+
: await readJsonSafe(filePath, defaultValue);
|
|
98
|
+
const modified = mutator(data);
|
|
99
|
+
await writeJsonAtomic(filePath, modified);
|
|
100
|
+
// Verify write
|
|
101
|
+
try {
|
|
102
|
+
const readBack = options?.strict
|
|
103
|
+
? await readJsonStrict(filePath, defaultValue)
|
|
104
|
+
: await readJsonSafe(filePath, defaultValue);
|
|
105
|
+
const expected = JSON.stringify(modified);
|
|
106
|
+
const actual = JSON.stringify(readBack);
|
|
107
|
+
if (expected === actual) {
|
|
108
|
+
return modified;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// Read-back failed, retry
|
|
113
|
+
}
|
|
114
|
+
if (attempt < maxAttempts - 1) {
|
|
115
|
+
// Brief delay before retry
|
|
116
|
+
await new Promise((r) => setTimeout(r, 50 * (attempt + 1)));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Final attempt without verification
|
|
120
|
+
const data = options?.strict
|
|
121
|
+
? await readJsonStrict(filePath, defaultValue)
|
|
122
|
+
: await readJsonSafe(filePath, defaultValue);
|
|
123
|
+
const modified = mutator(data);
|
|
124
|
+
await writeJsonAtomic(filePath, modified);
|
|
125
|
+
return modified;
|
|
126
|
+
}
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Registration Functions
|
|
129
|
+
// ============================================================================
|
|
130
|
+
const MARKETPLACE_KEY = "kspec-plugins";
|
|
131
|
+
/**
|
|
132
|
+
* Register the kspec core plugin marketplace in Claude Code's global state.
|
|
133
|
+
* Writes kspec-plugins entry to known_marketplaces.json.
|
|
134
|
+
* Only updates lastUpdated when path actually changes (idempotent).
|
|
135
|
+
* Validates plugin/.claude-plugin/plugin.json exists before registering.
|
|
136
|
+
*
|
|
137
|
+
* AC: @core-skill-install ac-6, ac-8
|
|
138
|
+
*/
|
|
139
|
+
export async function registerCorePluginMarketplace(opts) {
|
|
140
|
+
const dryRun = opts?.dryRun ?? false;
|
|
141
|
+
try {
|
|
142
|
+
const pluginDir = await getPackagePluginDir();
|
|
143
|
+
// Validate plugin directory has the manifest
|
|
144
|
+
const manifestPath = path.join(pluginDir, ".claude-plugin", "plugin.json");
|
|
145
|
+
try {
|
|
146
|
+
await fs.access(manifestPath);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
action: "error",
|
|
152
|
+
message: `Plugin manifest not found at ${manifestPath}. Run 'npm run build' first.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (dryRun) {
|
|
156
|
+
return {
|
|
157
|
+
success: true,
|
|
158
|
+
action: "skipped",
|
|
159
|
+
message: `Would register marketplace at ${pluginDir}`,
|
|
160
|
+
registeredPath: pluginDir,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const marketplacesPath = path.join(getClaudePluginsDir(), "known_marketplaces.json");
|
|
164
|
+
const existing = await readJsonSafe(marketplacesPath, {});
|
|
165
|
+
// Check if already registered with same path
|
|
166
|
+
const currentEntry = existing[MARKETPLACE_KEY];
|
|
167
|
+
if (currentEntry && currentEntry.installLocation === pluginDir) {
|
|
168
|
+
return {
|
|
169
|
+
success: true,
|
|
170
|
+
action: "unchanged",
|
|
171
|
+
message: "Marketplace already registered with correct path",
|
|
172
|
+
registeredPath: pluginDir,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Register or update
|
|
176
|
+
const action = currentEntry ? "updated" : "registered";
|
|
177
|
+
await modifyJsonAtomic(marketplacesPath, {}, (data) => ({
|
|
178
|
+
...data,
|
|
179
|
+
[MARKETPLACE_KEY]: {
|
|
180
|
+
...data[MARKETPLACE_KEY],
|
|
181
|
+
source: { source: "directory", path: pluginDir },
|
|
182
|
+
installLocation: pluginDir,
|
|
183
|
+
lastUpdated: new Date().toISOString(),
|
|
184
|
+
autoUpdate: false,
|
|
185
|
+
},
|
|
186
|
+
}));
|
|
187
|
+
return {
|
|
188
|
+
success: true,
|
|
189
|
+
action,
|
|
190
|
+
message: `Marketplace ${action} at ${pluginDir}`,
|
|
191
|
+
registeredPath: pluginDir,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
196
|
+
return {
|
|
197
|
+
success: false,
|
|
198
|
+
action: "error",
|
|
199
|
+
message: `Registration failed: ${msg}`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Enable the kspec plugin in a project's .claude/settings.json.
|
|
205
|
+
* Uses strict JSON read to avoid silently discarding hooks config.
|
|
206
|
+
*
|
|
207
|
+
* AC: @core-skill-install ac-7
|
|
208
|
+
*/
|
|
209
|
+
export async function enablePluginInProject(projectDir, opts) {
|
|
210
|
+
const dryRun = opts?.dryRun ?? false;
|
|
211
|
+
try {
|
|
212
|
+
const settingsPath = path.join(projectDir, ".claude", "settings.json");
|
|
213
|
+
if (dryRun) {
|
|
214
|
+
return {
|
|
215
|
+
success: true,
|
|
216
|
+
action: "unchanged",
|
|
217
|
+
message: "Would enable kspec@kspec-plugins in project settings",
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const settings = await readJsonStrict(settingsPath, {});
|
|
221
|
+
const enabledPlugins = (settings.enabledPlugins || {});
|
|
222
|
+
if (enabledPlugins["kspec@kspec-plugins"] === true) {
|
|
223
|
+
return {
|
|
224
|
+
success: true,
|
|
225
|
+
action: "unchanged",
|
|
226
|
+
message: "Plugin already enabled in project",
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
await modifyJsonAtomic(settingsPath, {}, (data) => ({
|
|
230
|
+
...data,
|
|
231
|
+
enabledPlugins: {
|
|
232
|
+
...(data.enabledPlugins || {}),
|
|
233
|
+
"kspec@kspec-plugins": true,
|
|
234
|
+
},
|
|
235
|
+
}), { strict: true });
|
|
236
|
+
return {
|
|
237
|
+
success: true,
|
|
238
|
+
action: "enabled",
|
|
239
|
+
message: "Plugin enabled in project settings",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
244
|
+
return {
|
|
245
|
+
success: false,
|
|
246
|
+
action: "error",
|
|
247
|
+
message: `Enablement failed: ${msg}`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Check the health of the kspec marketplace registration.
|
|
253
|
+
* Returns status and details for setup --status reporting.
|
|
254
|
+
*
|
|
255
|
+
* AC: @enhanced-setup ac-7, ac-8
|
|
256
|
+
*/
|
|
257
|
+
export async function checkMarketplaceHealth() {
|
|
258
|
+
try {
|
|
259
|
+
const marketplacesPath = path.join(getClaudePluginsDir(), "known_marketplaces.json");
|
|
260
|
+
const marketplaces = await readJsonSafe(marketplacesPath, {});
|
|
261
|
+
const entry = marketplaces[MARKETPLACE_KEY];
|
|
262
|
+
if (!entry) {
|
|
263
|
+
return {
|
|
264
|
+
status: "missing",
|
|
265
|
+
message: "kspec-plugins marketplace not registered. Run 'kspec setup' to register.",
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const registeredPath = entry.installLocation;
|
|
269
|
+
// Check if the path is valid
|
|
270
|
+
const manifestPath = path.join(registeredPath, ".claude-plugin", "plugin.json");
|
|
271
|
+
try {
|
|
272
|
+
const content = await fs.readFile(manifestPath, "utf-8");
|
|
273
|
+
const manifest = JSON.parse(content);
|
|
274
|
+
// Read current package version for comparison
|
|
275
|
+
let packageVersion;
|
|
276
|
+
try {
|
|
277
|
+
const pkgPath = path.resolve(import.meta.dirname || path.dirname(new URL(import.meta.url).pathname), "../../package.json");
|
|
278
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
|
|
279
|
+
packageVersion = pkg.version;
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
// Can't determine package version
|
|
283
|
+
}
|
|
284
|
+
const pluginVersion = manifest.version;
|
|
285
|
+
if (packageVersion && pluginVersion && pluginVersion !== packageVersion) {
|
|
286
|
+
return {
|
|
287
|
+
status: "version-mismatch",
|
|
288
|
+
registeredPath,
|
|
289
|
+
pluginVersion,
|
|
290
|
+
packageVersion,
|
|
291
|
+
message: `Plugin version ${pluginVersion} doesn't match package version ${packageVersion}`,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
status: "healthy",
|
|
296
|
+
registeredPath,
|
|
297
|
+
pluginVersion,
|
|
298
|
+
packageVersion,
|
|
299
|
+
message: "Marketplace registered and healthy",
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return {
|
|
304
|
+
status: "path-broken",
|
|
305
|
+
registeredPath,
|
|
306
|
+
message: `Registered path is invalid: ${registeredPath}. Run 'kspec setup' to re-register.`,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
312
|
+
return {
|
|
313
|
+
status: "error",
|
|
314
|
+
message: `Health check failed: ${msg}`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=claude-plugin-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-plugin-registry.js","sourceRoot":"","sources":["../../src/lib/claude-plugin-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AA8C9B,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IACjF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,0DAA0D;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EACtE,cAAc,CACf,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,yBAAyB;AACz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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array merging algorithms for semantic YAML merge.
|
|
3
|
+
*
|
|
4
|
+
* Handles different types of arrays:
|
|
5
|
+
* - ULID-based entity arrays (tasks, notes, inbox items)
|
|
6
|
+
* - Set-like arrays (tags, depends_on)
|
|
7
|
+
* - Append-only arrays (notes, todos)
|
|
8
|
+
*/
|
|
9
|
+
import type { ReferenceIndex } from "../parser/refs.js";
|
|
10
|
+
/**
|
|
11
|
+
* Merge arrays that contain entities with _ulid fields.
|
|
12
|
+
*
|
|
13
|
+
* AC: @yaml-merge-driver ac-2
|
|
14
|
+
* Union merge: both additions included, identified by ULID.
|
|
15
|
+
*
|
|
16
|
+
* AC: @yaml-merge-driver ac-5
|
|
17
|
+
* Append-only arrays (notes, todos) are union merged by ULID.
|
|
18
|
+
*
|
|
19
|
+
* Strategy:
|
|
20
|
+
* 1. Start with all items from base (common ancestor)
|
|
21
|
+
* 2. Add items from ours that aren't in base (new in our branch)
|
|
22
|
+
* 3. Add items from theirs that aren't in base (new in their branch)
|
|
23
|
+
* 4. For items in base that were modified, prefer the modified version
|
|
24
|
+
*
|
|
25
|
+
* @param base Array from common ancestor
|
|
26
|
+
* @param ours Array from current branch
|
|
27
|
+
* @param theirs Array from incoming branch
|
|
28
|
+
* @returns Merged array with all items
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergeUlidArrays<T extends {
|
|
31
|
+
_ulid: string;
|
|
32
|
+
}>(base: T[] | undefined, ours: T[] | undefined, theirs: T[] | undefined): T[];
|
|
33
|
+
/**
|
|
34
|
+
* Normalize a kspec reference to its canonical ULID form if possible.
|
|
35
|
+
* Returns the original value if not a ref or resolution fails.
|
|
36
|
+
*
|
|
37
|
+
* AC: @merge-ref-normalization ac-2
|
|
38
|
+
* Graceful degradation: unresolvable refs kept as-is.
|
|
39
|
+
*
|
|
40
|
+
* @param value The value to potentially normalize
|
|
41
|
+
* @param refIndex Optional reference index for resolution
|
|
42
|
+
* @returns Canonical form (@ULID) or original value
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeRef<T extends string | number>(value: T, refIndex?: ReferenceIndex): string | number;
|
|
45
|
+
/**
|
|
46
|
+
* Merge set-like arrays (tags, depends_on, etc).
|
|
47
|
+
*
|
|
48
|
+
* AC: @yaml-merge-driver ac-6
|
|
49
|
+
* Set union: combine both arrays, remove duplicates.
|
|
50
|
+
*
|
|
51
|
+
* AC: @merge-ref-normalization ac-1
|
|
52
|
+
* For arrays containing kspec refs (depends_on, blocked_by, etc),
|
|
53
|
+
* normalizes refs to canonical ULID form before comparison to
|
|
54
|
+
* prevent duplicates when same item is referenced differently.
|
|
55
|
+
*
|
|
56
|
+
* Strategy:
|
|
57
|
+
* 1. Start with items from ours
|
|
58
|
+
* 2. Add items from theirs that aren't in ours
|
|
59
|
+
* 3. Remove duplicates (using normalized form for refs)
|
|
60
|
+
* 4. Preserve original representation (ours takes precedence)
|
|
61
|
+
*
|
|
62
|
+
* @param base Array from common ancestor (not used for set merge)
|
|
63
|
+
* @param ours Array from current branch
|
|
64
|
+
* @param theirs Array from incoming branch
|
|
65
|
+
* @param refIndex Optional reference index for normalizing refs
|
|
66
|
+
* @returns Merged array with unique items
|
|
67
|
+
*/
|
|
68
|
+
export declare function mergeSetArray<T extends string | number>(base: T[] | undefined, ours: T[] | undefined, theirs: T[] | undefined, refIndex?: ReferenceIndex): T[];
|
|
69
|
+
/**
|
|
70
|
+
* Detect if an item was deleted in one branch.
|
|
71
|
+
*
|
|
72
|
+
* Helper for AC: @yaml-merge-driver ac-8
|
|
73
|
+
* Detect when one version deletes an item while other modifies it.
|
|
74
|
+
*
|
|
75
|
+
* @param ulid ULID to check
|
|
76
|
+
* @param base Base version map
|
|
77
|
+
* @param ours Ours version map
|
|
78
|
+
* @param theirs Theirs version map
|
|
79
|
+
* @returns Whether item was deleted in ours or theirs
|
|
80
|
+
*/
|
|
81
|
+
export declare function detectDeletion(ulid: string, base: Map<string, unknown>, ours: Map<string, unknown>, theirs: Map<string, unknown>): {
|
|
82
|
+
deletedInOurs: boolean;
|
|
83
|
+
deletedInTheirs: boolean;
|
|
84
|
+
modifiedInOurs: boolean;
|
|
85
|
+
modifiedInTheirs: boolean;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=arrays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/merge/arrays.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACzD,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,EACrB,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,EACrB,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,GACtB,CAAC,EAAE,CA4CL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACpD,KAAK,EAAE,CAAC,EACR,QAAQ,CAAC,EAAE,cAAc,GACxB,MAAM,GAAG,MAAM,CAoBjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACrD,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,EACrB,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,EACrB,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EACvB,QAAQ,CAAC,EAAE,cAAc,GACxB,CAAC,EAAE,CA0BL;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B;IACD,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAWA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array merging algorithms for semantic YAML merge.
|
|
3
|
+
*
|
|
4
|
+
* Handles different types of arrays:
|
|
5
|
+
* - ULID-based entity arrays (tasks, notes, inbox items)
|
|
6
|
+
* - Set-like arrays (tags, depends_on)
|
|
7
|
+
* - Append-only arrays (notes, todos)
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Merge arrays that contain entities with _ulid fields.
|
|
11
|
+
*
|
|
12
|
+
* AC: @yaml-merge-driver ac-2
|
|
13
|
+
* Union merge: both additions included, identified by ULID.
|
|
14
|
+
*
|
|
15
|
+
* AC: @yaml-merge-driver ac-5
|
|
16
|
+
* Append-only arrays (notes, todos) are union merged by ULID.
|
|
17
|
+
*
|
|
18
|
+
* Strategy:
|
|
19
|
+
* 1. Start with all items from base (common ancestor)
|
|
20
|
+
* 2. Add items from ours that aren't in base (new in our branch)
|
|
21
|
+
* 3. Add items from theirs that aren't in base (new in their branch)
|
|
22
|
+
* 4. For items in base that were modified, prefer the modified version
|
|
23
|
+
*
|
|
24
|
+
* @param base Array from common ancestor
|
|
25
|
+
* @param ours Array from current branch
|
|
26
|
+
* @param theirs Array from incoming branch
|
|
27
|
+
* @returns Merged array with all items
|
|
28
|
+
*/
|
|
29
|
+
export function mergeUlidArrays(base, ours, theirs) {
|
|
30
|
+
const baseArr = base ?? [];
|
|
31
|
+
const oursArr = ours ?? [];
|
|
32
|
+
const theirsArr = theirs ?? [];
|
|
33
|
+
// Build lookup maps by ULID
|
|
34
|
+
const baseMap = new Map(baseArr.map((item) => [item._ulid, item]));
|
|
35
|
+
const oursMap = new Map(oursArr.map((item) => [item._ulid, item]));
|
|
36
|
+
const theirsMap = new Map(theirsArr.map((item) => [item._ulid, item]));
|
|
37
|
+
// Result map - track all unique ULIDs
|
|
38
|
+
const resultMap = new Map();
|
|
39
|
+
// Add all items from ours (includes base items that may be modified)
|
|
40
|
+
for (const item of oursArr) {
|
|
41
|
+
resultMap.set(item._ulid, item);
|
|
42
|
+
}
|
|
43
|
+
// Add items from theirs that aren't in ours
|
|
44
|
+
for (const item of theirsArr) {
|
|
45
|
+
if (!oursMap.has(item._ulid)) {
|
|
46
|
+
// Item was added in theirs - include it
|
|
47
|
+
resultMap.set(item._ulid, item);
|
|
48
|
+
}
|
|
49
|
+
// If item exists in both ours and theirs but differs, we have a conflict
|
|
50
|
+
// That will be handled by field-level merge (separate function)
|
|
51
|
+
}
|
|
52
|
+
// Convert back to array, preserving order (ours first, then theirs additions)
|
|
53
|
+
const result = [];
|
|
54
|
+
// Add all items from ours in original order
|
|
55
|
+
for (const item of oursArr) {
|
|
56
|
+
result.push(resultMap.get(item._ulid));
|
|
57
|
+
}
|
|
58
|
+
// Add new items from theirs that weren't in ours
|
|
59
|
+
for (const item of theirsArr) {
|
|
60
|
+
if (!oursMap.has(item._ulid)) {
|
|
61
|
+
result.push(resultMap.get(item._ulid));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize a kspec reference to its canonical ULID form if possible.
|
|
68
|
+
* Returns the original value if not a ref or resolution fails.
|
|
69
|
+
*
|
|
70
|
+
* AC: @merge-ref-normalization ac-2
|
|
71
|
+
* Graceful degradation: unresolvable refs kept as-is.
|
|
72
|
+
*
|
|
73
|
+
* @param value The value to potentially normalize
|
|
74
|
+
* @param refIndex Optional reference index for resolution
|
|
75
|
+
* @returns Canonical form (@ULID) or original value
|
|
76
|
+
*/
|
|
77
|
+
export function normalizeRef(value, refIndex) {
|
|
78
|
+
// Only process strings that look like refs
|
|
79
|
+
if (typeof value !== "string" || !value.startsWith("@")) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
// No index available - keep as-is
|
|
83
|
+
if (!refIndex) {
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
// Try to resolve
|
|
87
|
+
const result = refIndex.resolve(value);
|
|
88
|
+
if (result.ok) {
|
|
89
|
+
// Return canonical ULID form with @ prefix
|
|
90
|
+
return `@${result.ulid}`;
|
|
91
|
+
}
|
|
92
|
+
// AC: @merge-ref-normalization ac-2 - Resolution failed, keep original
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Merge set-like arrays (tags, depends_on, etc).
|
|
97
|
+
*
|
|
98
|
+
* AC: @yaml-merge-driver ac-6
|
|
99
|
+
* Set union: combine both arrays, remove duplicates.
|
|
100
|
+
*
|
|
101
|
+
* AC: @merge-ref-normalization ac-1
|
|
102
|
+
* For arrays containing kspec refs (depends_on, blocked_by, etc),
|
|
103
|
+
* normalizes refs to canonical ULID form before comparison to
|
|
104
|
+
* prevent duplicates when same item is referenced differently.
|
|
105
|
+
*
|
|
106
|
+
* Strategy:
|
|
107
|
+
* 1. Start with items from ours
|
|
108
|
+
* 2. Add items from theirs that aren't in ours
|
|
109
|
+
* 3. Remove duplicates (using normalized form for refs)
|
|
110
|
+
* 4. Preserve original representation (ours takes precedence)
|
|
111
|
+
*
|
|
112
|
+
* @param base Array from common ancestor (not used for set merge)
|
|
113
|
+
* @param ours Array from current branch
|
|
114
|
+
* @param theirs Array from incoming branch
|
|
115
|
+
* @param refIndex Optional reference index for normalizing refs
|
|
116
|
+
* @returns Merged array with unique items
|
|
117
|
+
*/
|
|
118
|
+
export function mergeSetArray(base, ours, theirs, refIndex) {
|
|
119
|
+
const oursArr = ours ?? [];
|
|
120
|
+
const theirsArr = theirs ?? [];
|
|
121
|
+
// Build a map from normalized form -> original value
|
|
122
|
+
// This preserves the original form while deduplicating by canonical meaning
|
|
123
|
+
// AC: @merge-ref-normalization ac-1
|
|
124
|
+
const normalizedToOriginal = new Map();
|
|
125
|
+
// Add ours first (ours takes precedence for representation)
|
|
126
|
+
for (const item of oursArr) {
|
|
127
|
+
const normalized = normalizeRef(item, refIndex);
|
|
128
|
+
if (!normalizedToOriginal.has(normalized)) {
|
|
129
|
+
normalizedToOriginal.set(normalized, item);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Add theirs (only if not already present in normalized form)
|
|
133
|
+
for (const item of theirsArr) {
|
|
134
|
+
const normalized = normalizeRef(item, refIndex);
|
|
135
|
+
if (!normalizedToOriginal.has(normalized)) {
|
|
136
|
+
normalizedToOriginal.set(normalized, item);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return Array.from(normalizedToOriginal.values());
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Detect if an item was deleted in one branch.
|
|
143
|
+
*
|
|
144
|
+
* Helper for AC: @yaml-merge-driver ac-8
|
|
145
|
+
* Detect when one version deletes an item while other modifies it.
|
|
146
|
+
*
|
|
147
|
+
* @param ulid ULID to check
|
|
148
|
+
* @param base Base version map
|
|
149
|
+
* @param ours Ours version map
|
|
150
|
+
* @param theirs Theirs version map
|
|
151
|
+
* @returns Whether item was deleted in ours or theirs
|
|
152
|
+
*/
|
|
153
|
+
export function detectDeletion(ulid, base, ours, theirs) {
|
|
154
|
+
const inBase = base.has(ulid);
|
|
155
|
+
const inOurs = ours.has(ulid);
|
|
156
|
+
const inTheirs = theirs.has(ulid);
|
|
157
|
+
return {
|
|
158
|
+
deletedInOurs: inBase && !inOurs && inTheirs,
|
|
159
|
+
deletedInTheirs: inBase && inOurs && !inTheirs,
|
|
160
|
+
modifiedInOurs: inBase && inOurs,
|
|
161
|
+
modifiedInTheirs: inBase && inTheirs,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.js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AAQ;QAC5C,eAAe,EAAE,MAAM,IAAI,MAAM,IAAI,CAAC,QAAQ;QAC9C,cAAc,EAAE,MAAM,IAAI,MAAM;QAChC,gBAAgB,EAAE,MAAM,IAAI,QAAQ;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File type detection for kspec merge driver.
|
|
3
|
+
*
|
|
4
|
+
* Determines which merge strategy to apply based on file path patterns.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Types of kspec files that require different merge strategies
|
|
8
|
+
*/
|
|
9
|
+
export declare enum FileType {
|
|
10
|
+
/** Task files: *.tasks.yaml */
|
|
11
|
+
Tasks = "tasks",
|
|
12
|
+
/** Inbox files: *.inbox.yaml */
|
|
13
|
+
Inbox = "inbox",
|
|
14
|
+
/** Spec module files: modules/*.yaml */
|
|
15
|
+
SpecModules = "spec_modules",
|
|
16
|
+
/** Manifest file: kynetic.yaml */
|
|
17
|
+
Manifest = "manifest",
|
|
18
|
+
/** Meta file: kynetic.meta.yaml */
|
|
19
|
+
Meta = "meta",
|
|
20
|
+
/** Unrecognized files (fallback to default behavior) */
|
|
21
|
+
Unknown = "unknown"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Detect the type of a kspec file based on its path.
|
|
25
|
+
*
|
|
26
|
+
* Supports both explicit names (kynetic.yaml) and slug-based names ({slug}.yaml).
|
|
27
|
+
*
|
|
28
|
+
* @param filePath - Path to the file (can be relative or absolute)
|
|
29
|
+
* @returns The detected file type
|
|
30
|
+
*/
|
|
31
|
+
export declare function detectFileType(filePath: string): FileType;
|
|
32
|
+
//# sourceMappingURL=file-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-type.d.ts","sourceRoot":"","sources":["../../src/merge/file-type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,oBAAY,QAAQ;IAClB,+BAA+B;IAC/B,KAAK,UAAU;IACf,gCAAgC;IAChC,KAAK,UAAU;IACf,wCAAwC;IACxC,WAAW,iBAAiB;IAC5B,kCAAkC;IAClC,QAAQ,aAAa;IACrB,mCAAmC;IACnC,IAAI,SAAS;IACb,wDAAwD;IACxD,OAAO,YAAY;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CA+CzD"}
|