tarsk 0.4.4 → 0.4.6
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/dist/index.js +447375 -37
- package/package.json +2 -2
- package/dist/agent/agent.error-utils.d.ts +0 -14
- package/dist/agent/agent.error-utils.js +0 -52
- package/dist/agent/agent.event-transformer.d.ts +0 -55
- package/dist/agent/agent.event-transformer.js +0 -175
- package/dist/agent/agent.executor.d.ts +0 -26
- package/dist/agent/agent.executor.js +0 -286
- package/dist/agent/agent.model-resolver.d.ts +0 -22
- package/dist/agent/agent.model-resolver.js +0 -67
- package/dist/agent/agent.process-manager.d.ts +0 -57
- package/dist/agent/agent.process-manager.js +0 -262
- package/dist/agent/agent.processing-state-manager.d.ts +0 -74
- package/dist/agent/agent.processing-state-manager.js +0 -87
- package/dist/agent/agent.prompt-loader.d.ts +0 -16
- package/dist/agent/agent.prompt-loader.js +0 -227
- package/dist/agent/agent.subagent-executor.d.ts +0 -35
- package/dist/agent/agent.subagent-executor.js +0 -135
- package/dist/bun/index.d.ts +0 -2
- package/dist/bun/index.js +0 -165
- package/dist/cli.d.ts +0 -3
- package/dist/cli.js +0 -22
- package/dist/core/crypto.d.ts +0 -29
- package/dist/core/crypto.js +0 -166
- package/dist/core/dev-server-cache.d.ts +0 -46
- package/dist/core/dev-server-cache.js +0 -59
- package/dist/core/env-manager.d.ts +0 -3
- package/dist/core/env-manager.js +0 -60
- package/dist/core/error-responses.d.ts +0 -61
- package/dist/core/error-responses.js +0 -64
- package/dist/core/logger.d.ts +0 -10
- package/dist/core/logger.js +0 -47
- package/dist/core/paths.d.ts +0 -22
- package/dist/core/paths.js +0 -26
- package/dist/core/random-words.d.ts +0 -18
- package/dist/core/random-words.js +0 -135
- package/dist/core/response-builder.d.ts +0 -50
- package/dist/core/response-builder.js +0 -56
- package/dist/core/route-helpers.d.ts +0 -47
- package/dist/core/route-helpers.js +0 -54
- package/dist/core/run-command-detector.d.ts +0 -26
- package/dist/core/run-command-detector.js +0 -98
- package/dist/core/stream-helper.d.ts +0 -44
- package/dist/core/stream-helper.js +0 -50
- package/dist/core/utils.d.ts +0 -43
- package/dist/core/utils.js +0 -113
- package/dist/core/validation.d.ts +0 -10
- package/dist/core/validation.js +0 -20
- package/dist/database/database.d.ts +0 -40
- package/dist/database/database.encryption.d.ts +0 -33
- package/dist/database/database.encryption.js +0 -62
- package/dist/database/database.js +0 -480
- package/dist/database/database.state.d.ts +0 -52
- package/dist/database/database.state.js +0 -119
- package/dist/database/database.test-utils.d.ts +0 -22
- package/dist/database/database.test-utils.js +0 -39
- package/dist/database/database.types.d.ts +0 -3
- package/dist/database/database.types.js +0 -2
- package/dist/features/agents/agents.manager.d.ts +0 -24
- package/dist/features/agents/agents.manager.js +0 -200
- package/dist/features/ask-user/ask-user.routes.d.ts +0 -9
- package/dist/features/ask-user/ask-user.routes.js +0 -35
- package/dist/features/chat/chat-delete.route.d.ts +0 -15
- package/dist/features/chat/chat-delete.route.js +0 -36
- package/dist/features/chat/chat-post.route.d.ts +0 -11
- package/dist/features/chat/chat-post.route.js +0 -270
- package/dist/features/chat/chat-stop.route.d.ts +0 -21
- package/dist/features/chat/chat-stop.route.js +0 -22
- package/dist/features/chat/chat-subscribe.route.d.ts +0 -9
- package/dist/features/chat/chat-subscribe.route.js +0 -71
- package/dist/features/chat/chat.routes.d.ts +0 -22
- package/dist/features/chat/chat.routes.js +0 -29
- package/dist/features/conversations/conversations-delete.route.d.ts +0 -16
- package/dist/features/conversations/conversations-delete.route.js +0 -34
- package/dist/features/conversations/conversations-get-all.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-all.route.js +0 -39
- package/dist/features/conversations/conversations-get-by-id.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-by-id.route.js +0 -38
- package/dist/features/conversations/conversations-get-deleted.route.d.ts +0 -15
- package/dist/features/conversations/conversations-get-deleted.route.js +0 -34
- package/dist/features/conversations/conversations-get-messages.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-messages.route.js +0 -49
- package/dist/features/conversations/conversations.content.d.ts +0 -28
- package/dist/features/conversations/conversations.content.js +0 -142
- package/dist/features/conversations/conversations.database.d.ts +0 -108
- package/dist/features/conversations/conversations.database.js +0 -373
- package/dist/features/conversations/conversations.manager.d.ts +0 -130
- package/dist/features/conversations/conversations.manager.js +0 -162
- package/dist/features/conversations/conversations.routes.d.ts +0 -21
- package/dist/features/conversations/conversations.routes.js +0 -38
- package/dist/features/conversations/token-usage.route.d.ts +0 -41
- package/dist/features/conversations/token-usage.route.js +0 -419
- package/dist/features/git/git-commit.route.d.ts +0 -12
- package/dist/features/git/git-commit.route.js +0 -39
- package/dist/features/git/git-create-branch.route.d.ts +0 -28
- package/dist/features/git/git-create-branch.route.js +0 -119
- package/dist/features/git/git-create-pr.route.d.ts +0 -13
- package/dist/features/git/git-create-pr.route.js +0 -50
- package/dist/features/git/git-create-repo.route.d.ts +0 -14
- package/dist/features/git/git-create-repo.route.js +0 -108
- package/dist/features/git/git-diff.route.d.ts +0 -30
- package/dist/features/git/git-diff.route.js +0 -189
- package/dist/features/git/git-fetch.route.d.ts +0 -12
- package/dist/features/git/git-fetch.route.js +0 -31
- package/dist/features/git/git-generate-commit-message.route.d.ts +0 -12
- package/dist/features/git/git-generate-commit-message.route.js +0 -76
- package/dist/features/git/git-generate-pr-info.route.d.ts +0 -13
- package/dist/features/git/git-generate-pr-info.route.js +0 -147
- package/dist/features/git/git-github-status.route.d.ts +0 -16
- package/dist/features/git/git-github-status.route.js +0 -68
- package/dist/features/git/git-log.route.d.ts +0 -17
- package/dist/features/git/git-log.route.js +0 -33
- package/dist/features/git/git-pr-status.route.d.ts +0 -15
- package/dist/features/git/git-pr-status.route.js +0 -33
- package/dist/features/git/git-pull.route.d.ts +0 -12
- package/dist/features/git/git-pull.route.js +0 -35
- package/dist/features/git/git-push.route.d.ts +0 -12
- package/dist/features/git/git-push.route.js +0 -46
- package/dist/features/git/git-status-cache.database.d.ts +0 -7
- package/dist/features/git/git-status-cache.database.js +0 -53
- package/dist/features/git/git-status.route.d.ts +0 -15
- package/dist/features/git/git-status.route.js +0 -62
- package/dist/features/git/git-sync-branch.route.d.ts +0 -4
- package/dist/features/git/git-sync-branch.route.js +0 -208
- package/dist/features/git/git-unified-status.route.d.ts +0 -30
- package/dist/features/git/git-unified-status.route.js +0 -165
- package/dist/features/git/git-username.route.d.ts +0 -3
- package/dist/features/git/git-username.route.js +0 -24
- package/dist/features/git/git.manager.d.ts +0 -139
- package/dist/features/git/git.manager.js +0 -352
- package/dist/features/git/git.routes.d.ts +0 -4
- package/dist/features/git/git.routes.js +0 -116
- package/dist/features/git/git.utils.d.ts +0 -82
- package/dist/features/git/git.utils.js +0 -1040
- package/dist/features/mcp/mcp.config.d.ts +0 -27
- package/dist/features/mcp/mcp.config.js +0 -148
- package/dist/features/mcp/mcp.manager.d.ts +0 -61
- package/dist/features/mcp/mcp.manager.js +0 -254
- package/dist/features/mcp/mcp.popular.json +0 -103
- package/dist/features/mcp/mcp.routes.d.ts +0 -13
- package/dist/features/mcp/mcp.routes.js +0 -159
- package/dist/features/mcp/mcp.types.d.ts +0 -80
- package/dist/features/mcp/mcp.types.js +0 -8
- package/dist/features/metadata/metadata.manager.d.ts +0 -126
- package/dist/features/metadata/metadata.manager.js +0 -423
- package/dist/features/models/model-info-aihubmix.d.ts +0 -25
- package/dist/features/models/model-info-aihubmix.js +0 -117
- package/dist/features/models/model-info-openrouter.d.ts +0 -25
- package/dist/features/models/model-info-openrouter.js +0 -104
- package/dist/features/models/model-info.d.ts +0 -37
- package/dist/features/models/model-info.js +0 -39
- package/dist/features/models/models-catalog.d.ts +0 -49
- package/dist/features/models/models-catalog.js +0 -80
- package/dist/features/models/models-catalog.route.d.ts +0 -43
- package/dist/features/models/models-catalog.route.js +0 -15
- package/dist/features/models/models-get-available.route.d.ts +0 -36
- package/dist/features/models/models-get-available.route.js +0 -66
- package/dist/features/models/models-get-enabled.route.d.ts +0 -33
- package/dist/features/models/models-get-enabled.route.js +0 -45
- package/dist/features/models/models-get-model-info.route.d.ts +0 -31
- package/dist/features/models/models-get-model-info.route.js +0 -84
- package/dist/features/models/models-model-disable.route.d.ts +0 -15
- package/dist/features/models/models-model-disable.route.js +0 -20
- package/dist/features/models/models-model-enable.route.d.ts +0 -13
- package/dist/features/models/models-model-enable.route.js +0 -20
- package/dist/features/models/models-provider-refresh.route.d.ts +0 -17
- package/dist/features/models/models-provider-refresh.route.js +0 -20
- package/dist/features/models/models.manager.d.ts +0 -58
- package/dist/features/models/models.manager.js +0 -138
- package/dist/features/models/models.routes.d.ts +0 -18
- package/dist/features/models/models.routes.js +0 -83
- package/dist/features/models/open-router-models.d.ts +0 -38
- package/dist/features/models/open-router-models.js +0 -73
- package/dist/features/models/openai-models.d.ts +0 -63
- package/dist/features/models/openai-models.js +0 -150
- package/dist/features/onboarding/onboarding-get-git-check.route.d.ts +0 -11
- package/dist/features/onboarding/onboarding-get-git-check.route.js +0 -28
- package/dist/features/onboarding/onboarding-get-status.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-get-status.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-complete.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-complete.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-reset.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-reset.route.js +0 -15
- package/dist/features/onboarding/onboarding.routes.d.ts +0 -18
- package/dist/features/onboarding/onboarding.routes.js +0 -28
- package/dist/features/project-todos/project-todos.database.d.ts +0 -38
- package/dist/features/project-todos/project-todos.database.js +0 -91
- package/dist/features/project-todos/project-todos.routes.d.ts +0 -4
- package/dist/features/project-todos/project-todos.routes.js +0 -94
- package/dist/features/projects/projects-ai-files.route.d.ts +0 -148
- package/dist/features/projects/projects-ai-files.route.js +0 -425
- package/dist/features/projects/projects-commands.route.d.ts +0 -27
- package/dist/features/projects/projects-commands.route.js +0 -39
- package/dist/features/projects/projects-create.route.d.ts +0 -19
- package/dist/features/projects/projects-create.route.js +0 -37
- package/dist/features/projects/projects-delete.route.d.ts +0 -24
- package/dist/features/projects/projects-delete.route.js +0 -34
- package/dist/features/projects/projects-get.route.d.ts +0 -47
- package/dist/features/projects/projects-get.route.js +0 -36
- package/dist/features/projects/projects-list.route.d.ts +0 -58
- package/dist/features/projects/projects-list.route.js +0 -59
- package/dist/features/projects/projects-open-folder.route.d.ts +0 -10
- package/dist/features/projects/projects-open-folder.route.js +0 -11
- package/dist/features/projects/projects-open.route.d.ts +0 -26
- package/dist/features/projects/projects-open.route.js +0 -49
- package/dist/features/projects/projects-package-scripts.route.d.ts +0 -15
- package/dist/features/projects/projects-package-scripts.route.js +0 -96
- package/dist/features/projects/projects-run-command.route.d.ts +0 -8
- package/dist/features/projects/projects-run-command.route.js +0 -21
- package/dist/features/projects/projects-run.route.d.ts +0 -51
- package/dist/features/projects/projects-run.route.js +0 -74
- package/dist/features/projects/projects-update.route.d.ts +0 -24
- package/dist/features/projects/projects-update.route.js +0 -81
- package/dist/features/projects/projects.creator.d.ts +0 -33
- package/dist/features/projects/projects.creator.js +0 -555
- package/dist/features/projects/projects.database.d.ts +0 -61
- package/dist/features/projects/projects.database.js +0 -212
- package/dist/features/projects/projects.manager.d.ts +0 -291
- package/dist/features/projects/projects.manager.js +0 -426
- package/dist/features/projects/projects.open-with.d.ts +0 -27
- package/dist/features/projects/projects.open-with.js +0 -156
- package/dist/features/projects/projects.routes.d.ts +0 -20
- package/dist/features/projects/projects.routes.js +0 -255
- package/dist/features/projects/terminal-session-manager.d.ts +0 -55
- package/dist/features/projects/terminal-session-manager.js +0 -90
- package/dist/features/providers/provider-resolver.d.ts +0 -13
- package/dist/features/providers/provider-resolver.js +0 -22
- package/dist/features/providers/providers-get-credits.route.d.ts +0 -15
- package/dist/features/providers/providers-get-credits.route.js +0 -51
- package/dist/features/providers/providers-get.route.d.ts +0 -16
- package/dist/features/providers/providers-get.route.js +0 -32
- package/dist/features/providers/providers-open-external.route.d.ts +0 -15
- package/dist/features/providers/providers-open-external.route.js +0 -49
- package/dist/features/providers/providers-post-bulk-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-bulk-keys.route.js +0 -31
- package/dist/features/providers/providers-post-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-keys.route.js +0 -25
- package/dist/features/providers/providers.routes.d.ts +0 -19
- package/dist/features/providers/providers.routes.js +0 -31
- package/dist/features/rules/rules-post.route.d.ts +0 -43
- package/dist/features/rules/rules-post.route.js +0 -89
- package/dist/features/rules/rules.manager.d.ts +0 -36
- package/dist/features/rules/rules.manager.js +0 -203
- package/dist/features/rules/rules.routes.d.ts +0 -12
- package/dist/features/rules/rules.routes.js +0 -13
- package/dist/features/run/run-get-running.route.d.ts +0 -15
- package/dist/features/run/run-get-running.route.js +0 -21
- package/dist/features/run/run-post-start.route.d.ts +0 -8
- package/dist/features/run/run-post-start.route.js +0 -21
- package/dist/features/run/run-post-stop.route.d.ts +0 -15
- package/dist/features/run/run-post-stop.route.js +0 -24
- package/dist/features/run/run-post-suggest.route.d.ts +0 -15
- package/dist/features/run/run-post-suggest.route.js +0 -21
- package/dist/features/run/run-put-command.route.d.ts +0 -15
- package/dist/features/run/run-put-command.route.js +0 -24
- package/dist/features/run/run.routes.d.ts +0 -19
- package/dist/features/run/run.routes.js +0 -31
- package/dist/features/scaffold/index.d.ts +0 -7
- package/dist/features/scaffold/index.js +0 -5
- package/dist/features/scaffold/scaffold-get-templates.route.d.ts +0 -27
- package/dist/features/scaffold/scaffold-get-templates.route.js +0 -17
- package/dist/features/scaffold/scaffold-post.route.d.ts +0 -8
- package/dist/features/scaffold/scaffold-post.route.js +0 -30
- package/dist/features/scaffold/scaffold.routes.d.ts +0 -10
- package/dist/features/scaffold/scaffold.routes.js +0 -16
- package/dist/features/scaffold/scaffold.runner.d.ts +0 -48
- package/dist/features/scaffold/scaffold.runner.js +0 -475
- package/dist/features/scaffold/scaffold.types.d.ts +0 -26
- package/dist/features/scaffold/scaffold.types.js +0 -5
- package/dist/features/skills/skills.activation.d.ts +0 -31
- package/dist/features/skills/skills.activation.js +0 -155
- package/dist/features/skills/skills.manager.d.ts +0 -35
- package/dist/features/skills/skills.manager.js +0 -251
- package/dist/features/slash-commands/slash-commands-delete.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-delete.route.js +0 -36
- package/dist/features/slash-commands/slash-commands-get.route.d.ts +0 -53
- package/dist/features/slash-commands/slash-commands-get.route.js +0 -54
- package/dist/features/slash-commands/slash-commands-post.route.d.ts +0 -39
- package/dist/features/slash-commands/slash-commands-post.route.js +0 -70
- package/dist/features/slash-commands/slash-commands-put.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-put.route.js +0 -36
- package/dist/features/slash-commands/slash-commands.manager.d.ts +0 -46
- package/dist/features/slash-commands/slash-commands.manager.js +0 -265
- package/dist/features/slash-commands/slash-commands.routes.d.ts +0 -13
- package/dist/features/slash-commands/slash-commands.routes.js +0 -20
- package/dist/features/threads/threads-ai-files.route.d.ts +0 -153
- package/dist/features/threads/threads-ai-files.route.js +0 -287
- package/dist/features/threads/threads-conversation-folder-path.route.d.ts +0 -14
- package/dist/features/threads/threads-conversation-folder-path.route.js +0 -23
- package/dist/features/threads/threads-create.route.d.ts +0 -22
- package/dist/features/threads/threads-create.route.js +0 -60
- package/dist/features/threads/threads-delete.route.d.ts +0 -25
- package/dist/features/threads/threads-delete.route.js +0 -35
- package/dist/features/threads/threads-files.route.d.ts +0 -15
- package/dist/features/threads/threads-files.route.js +0 -20
- package/dist/features/threads/threads-fix-comments.route.d.ts +0 -26
- package/dist/features/threads/threads-fix-comments.route.js +0 -45
- package/dist/features/threads/threads-get.route.d.ts +0 -30
- package/dist/features/threads/threads-get.route.js +0 -38
- package/dist/features/threads/threads-list.route.d.ts +0 -56
- package/dist/features/threads/threads-list.route.js +0 -58
- package/dist/features/threads/threads-messages.route.d.ts +0 -28
- package/dist/features/threads/threads-messages.route.js +0 -110
- package/dist/features/threads/threads-open.route.d.ts +0 -26
- package/dist/features/threads/threads-open.route.js +0 -62
- package/dist/features/threads/threads-select.route.d.ts +0 -25
- package/dist/features/threads/threads-select.route.js +0 -35
- package/dist/features/threads/threads-update.route.d.ts +0 -15
- package/dist/features/threads/threads-update.route.js +0 -30
- package/dist/features/threads/threads.database.d.ts +0 -68
- package/dist/features/threads/threads.database.js +0 -215
- package/dist/features/threads/threads.manager.d.ts +0 -204
- package/dist/features/threads/threads.manager.js +0 -505
- package/dist/features/threads/threads.routes.d.ts +0 -20
- package/dist/features/threads/threads.routes.js +0 -230
- package/dist/features/todos/todos.database.d.ts +0 -14
- package/dist/features/todos/todos.database.js +0 -31
- package/dist/features/updates/updates.routes.d.ts +0 -13
- package/dist/features/updates/updates.routes.js +0 -40
- package/dist/index.d.ts +0 -3
- package/dist/project-analyzer.d.ts +0 -26
- package/dist/project-analyzer.js +0 -307
- package/dist/server.d.ts +0 -12
- package/dist/server.js +0 -142
- package/dist/tools/agent-tool.d.ts +0 -49
- package/dist/tools/agent-tool.js +0 -131
- package/dist/tools/ask-user.d.ts +0 -25
- package/dist/tools/ask-user.js +0 -74
- package/dist/tools/ast-grep.d.ts +0 -28
- package/dist/tools/ast-grep.js +0 -273
- package/dist/tools/bash.d.ts +0 -33
- package/dist/tools/bash.js +0 -186
- package/dist/tools/edit-diff.d.ts +0 -24
- package/dist/tools/edit-diff.js +0 -136
- package/dist/tools/edit.d.ts +0 -28
- package/dist/tools/edit.js +0 -78
- package/dist/tools/find.d.ts +0 -31
- package/dist/tools/find.js +0 -117
- package/dist/tools/grep.d.ts +0 -37
- package/dist/tools/grep.js +0 -231
- package/dist/tools/index.d.ts +0 -93
- package/dist/tools/index.js +0 -110
- package/dist/tools/ls.d.ts +0 -31
- package/dist/tools/ls.js +0 -108
- package/dist/tools/mcp-tools.d.ts +0 -31
- package/dist/tools/mcp-tools.js +0 -59
- package/dist/tools/path-utils.d.ts +0 -14
- package/dist/tools/path-utils.js +0 -87
- package/dist/tools/read.d.ts +0 -27
- package/dist/tools/read.js +0 -86
- package/dist/tools/resolve-bin.d.ts +0 -5
- package/dist/tools/resolve-bin.js +0 -28
- package/dist/tools/shell.d.ts +0 -7
- package/dist/tools/shell.js +0 -143
- package/dist/tools/skill-reference-tool.d.ts +0 -30
- package/dist/tools/skill-reference-tool.js +0 -171
- package/dist/tools/skill-tool.d.ts +0 -33
- package/dist/tools/skill-tool.js +0 -213
- package/dist/tools/todo.d.ts +0 -20
- package/dist/tools/todo.js +0 -168
- package/dist/tools/tool-helpers.d.ts +0 -78
- package/dist/tools/tool-helpers.js +0 -109
- package/dist/tools/truncate.d.ts +0 -31
- package/dist/tools/truncate.js +0 -164
- package/dist/tools/write.d.ts +0 -21
- package/dist/tools/write.js +0 -65
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scaffold runner: creates projects from the template catalog
|
|
3
|
-
* with placeholder substitution, package manager rewriting, and optional handlers.
|
|
4
|
-
*/
|
|
5
|
-
import { existsSync } from "fs";
|
|
6
|
-
import { join } from "path";
|
|
7
|
-
import { mkdir, readdir, stat, rename, rm } from "fs/promises";
|
|
8
|
-
import { spawnSyncProcess, spawnProcess } from "../../core/utils.js";
|
|
9
|
-
import { createInterface } from "readline";
|
|
10
|
-
import embeddedTemplates from "../../scaffold-templates.json" with { type: "json" };
|
|
11
|
-
const HANDLERS = new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Register a handler for templates that use the given handler name.
|
|
14
|
-
* When a template has `handler` set, the runner calls this callback to get the command list.
|
|
15
|
-
*/
|
|
16
|
-
export function registerScaffoldHandler(handlerName, callback) {
|
|
17
|
-
HANDLERS.set(handlerName, callback);
|
|
18
|
-
}
|
|
19
|
-
function loadCatalog() {
|
|
20
|
-
return embeddedTemplates;
|
|
21
|
-
}
|
|
22
|
-
function getProjectName(name) {
|
|
23
|
-
return name
|
|
24
|
-
.toLowerCase()
|
|
25
|
-
.replace(/\s/g, "-")
|
|
26
|
-
.replace(/[^a-z0-9-]/g, "")
|
|
27
|
-
.replace(/-(\d)/g, "-a$1"); // Replace dash-number with dash-letter-number
|
|
28
|
-
}
|
|
29
|
-
function getPackageId(name) {
|
|
30
|
-
let packageId = name.replace(/\s/g, ".").replace(/-/g, ".");
|
|
31
|
-
if (!packageId.includes(".")) {
|
|
32
|
-
packageId = `ionic.${packageId}`;
|
|
33
|
-
}
|
|
34
|
-
const parts = packageId.split(".");
|
|
35
|
-
for (const part of parts) {
|
|
36
|
-
if (part.length > 0 && /^\d+$/.test(part)) {
|
|
37
|
-
packageId = packageId.replace(part, `v${part}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return packageId.trim();
|
|
41
|
-
}
|
|
42
|
-
function toTitleCase(s) {
|
|
43
|
-
return s.replace(/\w\S*/g, (w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase());
|
|
44
|
-
}
|
|
45
|
-
function capacitorPluginHandler(_template, options) {
|
|
46
|
-
const nm = options.projectName.replace(/\s/g, "").toLowerCase().replace(/-/g, "");
|
|
47
|
-
const nmp = options.projectName.replace(/\s/g, ".").replace(/-/g, ".");
|
|
48
|
-
const nmt = toTitleCase(options.projectName.replace(/-/g, " ")).replace(/\s/g, "");
|
|
49
|
-
return [
|
|
50
|
-
`npx @capacitor/create-plugin "${nm}" --name "${nm}" --package-id "com.mycompany.${nmp}" --class-name "${nmt}" --author "me" --license MIT --repo https://github.com --description "${nmt} Capacitor Plugin"`,
|
|
51
|
-
"#" + options.projectPath,
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
function substitutePlaceholders(command, options, template) {
|
|
55
|
-
return command
|
|
56
|
-
.replace(/\$\(project-name\)/g, options.projectName)
|
|
57
|
-
.replace(/\$\(package-id\)/g, options.packageId)
|
|
58
|
-
.replace(/\$\(project-folder\)/g, options.projectPath)
|
|
59
|
-
.replace(/\$\(template\)/g, template.variation)
|
|
60
|
-
.replace(/\$\(type\)/g, template.type);
|
|
61
|
-
}
|
|
62
|
-
function applyPackageManagerSubstitution(command, pm) {
|
|
63
|
-
const trimmed = command.trim();
|
|
64
|
-
if (trimmed.startsWith("npm create ")) {
|
|
65
|
-
const rest = trimmed.slice("npm create ".length);
|
|
66
|
-
switch (pm) {
|
|
67
|
-
case "bun":
|
|
68
|
-
return `bun create ${rest}`;
|
|
69
|
-
case "pnpm":
|
|
70
|
-
return `pnpm create ${rest}`;
|
|
71
|
-
case "yarn":
|
|
72
|
-
return `yarn create ${rest}`;
|
|
73
|
-
default:
|
|
74
|
-
return trimmed;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (trimmed.startsWith("npx ")) {
|
|
78
|
-
const rest = trimmed.slice(4);
|
|
79
|
-
switch (pm) {
|
|
80
|
-
case "bun":
|
|
81
|
-
return `bunx ${rest}`;
|
|
82
|
-
case "pnpm":
|
|
83
|
-
return `pnpm exec ${rest}`;
|
|
84
|
-
case "yarn":
|
|
85
|
-
return `yarn dlx ${rest}`;
|
|
86
|
-
default:
|
|
87
|
-
return trimmed;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return trimmed;
|
|
91
|
-
}
|
|
92
|
-
function getInstallCommand(pm) {
|
|
93
|
-
switch (pm) {
|
|
94
|
-
case "bun":
|
|
95
|
-
return "bun install";
|
|
96
|
-
case "pnpm":
|
|
97
|
-
return "pnpm install";
|
|
98
|
-
case "yarn":
|
|
99
|
-
return "yarn install";
|
|
100
|
-
default:
|
|
101
|
-
return "npm install";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function buildCommandList(template, options) {
|
|
105
|
-
if (template.handler) {
|
|
106
|
-
const handler = HANDLERS.get(template.handler);
|
|
107
|
-
if (!handler) {
|
|
108
|
-
throw new Error(`Unknown scaffold handler: ${template.handler}`);
|
|
109
|
-
}
|
|
110
|
-
const raw = handler(template, options);
|
|
111
|
-
const withPlaceholders = raw.map((c) => c.startsWith("#") ? c : substitutePlaceholders(c, options, template));
|
|
112
|
-
return withPlaceholders.map((c) => {
|
|
113
|
-
if (c.startsWith("#"))
|
|
114
|
-
return c;
|
|
115
|
-
return applyPackageManagerSubstitution(c, options.packageManager);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
const commands = template.commands ?? [];
|
|
119
|
-
const withPlaceholders = commands.map((c) => substitutePlaceholders(c, options, template));
|
|
120
|
-
const withPm = withPlaceholders.map((c) => {
|
|
121
|
-
if (c.startsWith("#"))
|
|
122
|
-
return c;
|
|
123
|
-
return applyPackageManagerSubstitution(c, options.packageManager);
|
|
124
|
-
});
|
|
125
|
-
const hasCd = withPm.some((c) => c.startsWith("#"));
|
|
126
|
-
if (!hasCd && withPm.length > 0) {
|
|
127
|
-
withPm.push("#" + options.projectPath);
|
|
128
|
-
}
|
|
129
|
-
return withPm;
|
|
130
|
-
}
|
|
131
|
-
function runCommand(cwd, command) {
|
|
132
|
-
const [bin, ...args] = command.split(/\s+/);
|
|
133
|
-
const result = spawnSyncProcess(bin, args, {
|
|
134
|
-
cwd,
|
|
135
|
-
shell: true,
|
|
136
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
137
|
-
encoding: "utf-8",
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
ok: result.status === 0,
|
|
141
|
-
stderr: (typeof result.stderr === "string"
|
|
142
|
-
? result.stderr
|
|
143
|
-
: result.stderr?.toString() || "").trim(),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Run a single command with streaming stdout/stderr. Yields each line, then yields done with exit status.
|
|
148
|
-
*/
|
|
149
|
-
async function* runCommandStreaming(cwd, command) {
|
|
150
|
-
const [bin, ...args] = command.split(/\s+/);
|
|
151
|
-
const child = spawnProcess(bin, args, {
|
|
152
|
-
cwd,
|
|
153
|
-
shell: true,
|
|
154
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
155
|
-
});
|
|
156
|
-
const queue = [];
|
|
157
|
-
let resolveWait = null;
|
|
158
|
-
const wait = () => new Promise((r) => {
|
|
159
|
-
resolveWait = r;
|
|
160
|
-
});
|
|
161
|
-
const push = (event) => {
|
|
162
|
-
queue.push(event);
|
|
163
|
-
if (resolveWait) {
|
|
164
|
-
resolveWait();
|
|
165
|
-
resolveWait = null;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const stderrChunks = [];
|
|
169
|
-
if (child.stdout) {
|
|
170
|
-
const rl = createInterface({ input: child.stdout, crlfDelay: Infinity });
|
|
171
|
-
rl.on("line", (line) => push({ type: "output", line: line ?? "" }));
|
|
172
|
-
}
|
|
173
|
-
if (child.stderr) {
|
|
174
|
-
const rl = createInterface({ input: child.stderr, crlfDelay: Infinity });
|
|
175
|
-
rl.on("line", (line) => {
|
|
176
|
-
const s = line ?? "";
|
|
177
|
-
stderrChunks.push(s);
|
|
178
|
-
push({ type: "output", line: s });
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
child.on("close", (code) => {
|
|
182
|
-
push({
|
|
183
|
-
type: "done",
|
|
184
|
-
ok: code === 0,
|
|
185
|
-
stderr: stderrChunks.join("\n").trim(),
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
while (true) {
|
|
189
|
-
while (queue.length > 0) {
|
|
190
|
-
const event = queue.shift();
|
|
191
|
-
yield event;
|
|
192
|
-
if (event.type === "done")
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
await wait();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Create a project from a template. Runs scaffold commands then install in the project folder.
|
|
200
|
-
*/
|
|
201
|
-
export async function createScaffoldedProject(options) {
|
|
202
|
-
const projectPath = join(options.parentDir, options.threadId);
|
|
203
|
-
if (!existsSync(options.parentDir)) {
|
|
204
|
-
return {
|
|
205
|
-
success: false,
|
|
206
|
-
projectPath,
|
|
207
|
-
error: `Parent directory does not exist: ${options.parentDir}`,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
// Create the thread directory first
|
|
211
|
-
try {
|
|
212
|
-
await mkdir(projectPath, { recursive: true });
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
return {
|
|
216
|
-
success: false,
|
|
217
|
-
projectPath,
|
|
218
|
-
error: `Failed to create thread directory: ${error instanceof Error ? error.message : String(error)}`,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
const catalog = loadCatalog();
|
|
222
|
-
const template = catalog.find((t) => t.id === options.templateId);
|
|
223
|
-
if (!template) {
|
|
224
|
-
return {
|
|
225
|
-
success: false,
|
|
226
|
-
projectPath,
|
|
227
|
-
error: `Unknown template id: ${options.templateId}`,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
const projectName = getProjectName(options.projectName);
|
|
231
|
-
const packageId = getPackageId(projectName);
|
|
232
|
-
const scaffoldOptions = {
|
|
233
|
-
parentDir: options.parentDir,
|
|
234
|
-
projectName,
|
|
235
|
-
projectPath,
|
|
236
|
-
threadId: options.threadId,
|
|
237
|
-
packageId,
|
|
238
|
-
packageManager: options.packageManager,
|
|
239
|
-
};
|
|
240
|
-
let commands;
|
|
241
|
-
try {
|
|
242
|
-
commands = buildCommandList(template, scaffoldOptions);
|
|
243
|
-
}
|
|
244
|
-
catch (err) {
|
|
245
|
-
return {
|
|
246
|
-
success: false,
|
|
247
|
-
projectPath: scaffoldOptions.projectPath,
|
|
248
|
-
error: err instanceof Error ? err.message : String(err),
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
let cwd = options.parentDir;
|
|
252
|
-
for (const raw of commands) {
|
|
253
|
-
if (raw.startsWith("#")) {
|
|
254
|
-
cwd = raw.slice(1).trim();
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
const cmd = raw.startsWith("npm ") || raw.startsWith("npx ")
|
|
258
|
-
? applyPackageManagerSubstitution(raw, options.packageManager)
|
|
259
|
-
: raw;
|
|
260
|
-
const { ok, stderr } = runCommand(cwd === options.parentDir ? projectPath : cwd, cmd);
|
|
261
|
-
if (!ok) {
|
|
262
|
-
return {
|
|
263
|
-
success: false,
|
|
264
|
-
projectPath: scaffoldOptions.projectPath,
|
|
265
|
-
error: stderr || `Command failed: ${cmd}`,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
// After scaffold commands complete, move project contents from subdirectory to thread folder
|
|
270
|
-
// Many CLI tools create a subdirectory with the project name
|
|
271
|
-
try {
|
|
272
|
-
const projectName = getProjectName(options.projectName);
|
|
273
|
-
const projectSubDir = join(projectPath, projectName);
|
|
274
|
-
// Check if project was created in a subdirectory
|
|
275
|
-
try {
|
|
276
|
-
const subDirStat = await stat(projectSubDir);
|
|
277
|
-
if (subDirStat.isDirectory()) {
|
|
278
|
-
// Move all contents from subdirectory to thread folder
|
|
279
|
-
const items = await readdir(projectSubDir);
|
|
280
|
-
for (const item of items) {
|
|
281
|
-
const oldPath = join(projectSubDir, item);
|
|
282
|
-
const newPath = join(projectPath, item);
|
|
283
|
-
await rename(oldPath, newPath);
|
|
284
|
-
}
|
|
285
|
-
// Remove the empty subdirectory
|
|
286
|
-
await rm(projectSubDir, { recursive: true, force: true });
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
// Subdirectory doesn't exist, which is fine - project was created directly
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
// Non-fatal error, continue with installation
|
|
295
|
-
console.warn(`Warning: Could not reorganize project files: ${error instanceof Error ? error.message : String(error)}`);
|
|
296
|
-
}
|
|
297
|
-
const installCwd = scaffoldOptions.projectPath;
|
|
298
|
-
if (existsSync(installCwd)) {
|
|
299
|
-
const installCmd = getInstallCommand(options.packageManager);
|
|
300
|
-
const { ok, stderr } = runCommand(installCwd, installCmd);
|
|
301
|
-
if (!ok) {
|
|
302
|
-
return {
|
|
303
|
-
success: true,
|
|
304
|
-
projectPath: installCwd,
|
|
305
|
-
error: `Scaffold completed but install failed: ${stderr || installCmd}`,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return {
|
|
310
|
-
success: true,
|
|
311
|
-
projectPath: scaffoldOptions.projectPath,
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Create a project from a template with streaming command output. Yields progress for each line of stdout/stderr, then result.
|
|
316
|
-
*/
|
|
317
|
-
export async function* createScaffoldedProjectStreaming(options) {
|
|
318
|
-
const projectPath = join(options.parentDir, options.threadId);
|
|
319
|
-
if (!existsSync(options.parentDir)) {
|
|
320
|
-
yield {
|
|
321
|
-
type: "result",
|
|
322
|
-
result: {
|
|
323
|
-
success: false,
|
|
324
|
-
projectPath,
|
|
325
|
-
error: `Parent directory does not exist: ${options.parentDir}`,
|
|
326
|
-
},
|
|
327
|
-
};
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
// Create the thread directory first
|
|
331
|
-
try {
|
|
332
|
-
await mkdir(projectPath, { recursive: true });
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
yield {
|
|
336
|
-
type: "result",
|
|
337
|
-
result: {
|
|
338
|
-
success: false,
|
|
339
|
-
projectPath,
|
|
340
|
-
error: `Failed to create thread directory: ${error instanceof Error ? error.message : String(error)}`,
|
|
341
|
-
},
|
|
342
|
-
};
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const catalog = loadCatalog();
|
|
346
|
-
const template = catalog.find((t) => t.id === options.templateId);
|
|
347
|
-
if (!template) {
|
|
348
|
-
yield {
|
|
349
|
-
type: "result",
|
|
350
|
-
result: { success: false, projectPath, error: `Unknown template id: ${options.templateId}` },
|
|
351
|
-
};
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
const projectName = getProjectName(options.projectName);
|
|
355
|
-
const packageId = getPackageId(projectName);
|
|
356
|
-
const scaffoldOptions = {
|
|
357
|
-
parentDir: options.parentDir,
|
|
358
|
-
projectName,
|
|
359
|
-
projectPath,
|
|
360
|
-
threadId: options.threadId,
|
|
361
|
-
packageId,
|
|
362
|
-
packageManager: options.packageManager,
|
|
363
|
-
};
|
|
364
|
-
let commands;
|
|
365
|
-
try {
|
|
366
|
-
commands = buildCommandList(template, scaffoldOptions);
|
|
367
|
-
}
|
|
368
|
-
catch (err) {
|
|
369
|
-
yield {
|
|
370
|
-
type: "result",
|
|
371
|
-
result: {
|
|
372
|
-
success: false,
|
|
373
|
-
projectPath: scaffoldOptions.projectPath,
|
|
374
|
-
error: err instanceof Error ? err.message : String(err),
|
|
375
|
-
},
|
|
376
|
-
};
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
let cwd = options.parentDir;
|
|
380
|
-
for (const raw of commands) {
|
|
381
|
-
if (raw.startsWith("#")) {
|
|
382
|
-
cwd = raw.slice(1).trim();
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
const cmd = raw.startsWith("npm ") || raw.startsWith("npx ")
|
|
386
|
-
? applyPackageManagerSubstitution(raw, options.packageManager)
|
|
387
|
-
: raw;
|
|
388
|
-
for await (const event of runCommandStreaming(cwd === options.parentDir ? projectPath : cwd, cmd)) {
|
|
389
|
-
if (event.type === "output") {
|
|
390
|
-
yield { type: "progress", message: event.line };
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
if (!event.ok) {
|
|
394
|
-
yield {
|
|
395
|
-
type: "result",
|
|
396
|
-
result: {
|
|
397
|
-
success: false,
|
|
398
|
-
projectPath: scaffoldOptions.projectPath,
|
|
399
|
-
error: event.stderr || `Command failed: ${cmd}`,
|
|
400
|
-
},
|
|
401
|
-
};
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
// After scaffold commands complete, move project contents from subdirectory to thread folder
|
|
408
|
-
// Many CLI tools create a subdirectory with the project name
|
|
409
|
-
try {
|
|
410
|
-
const projectName = getProjectName(options.projectName);
|
|
411
|
-
const projectSubDir = join(projectPath, projectName);
|
|
412
|
-
// Check if project was created in a subdirectory
|
|
413
|
-
try {
|
|
414
|
-
const subDirStat = await stat(projectSubDir);
|
|
415
|
-
if (subDirStat.isDirectory()) {
|
|
416
|
-
yield {
|
|
417
|
-
type: "progress",
|
|
418
|
-
message: `Moving project files from ${projectName}/ to thread folder...`,
|
|
419
|
-
};
|
|
420
|
-
// Move all contents from subdirectory to thread folder
|
|
421
|
-
const items = await readdir(projectSubDir);
|
|
422
|
-
for (const item of items) {
|
|
423
|
-
const oldPath = join(projectSubDir, item);
|
|
424
|
-
const newPath = join(projectPath, item);
|
|
425
|
-
await rename(oldPath, newPath);
|
|
426
|
-
}
|
|
427
|
-
// Remove the empty subdirectory
|
|
428
|
-
await rm(projectSubDir, { recursive: true, force: true });
|
|
429
|
-
yield { type: "progress", message: `Project files organized in thread folder` };
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
catch {
|
|
433
|
-
// Subdirectory doesn't exist, which is fine - project was created directly
|
|
434
|
-
yield { type: "progress", message: `Project already in correct location` };
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
catch (error) {
|
|
438
|
-
yield {
|
|
439
|
-
type: "progress",
|
|
440
|
-
message: `Warning: Could not reorganize project files: ${error instanceof Error ? error.message : String(error)}`,
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
const installCwd = scaffoldOptions.projectPath;
|
|
444
|
-
if (existsSync(installCwd)) {
|
|
445
|
-
const installCmd = getInstallCommand(options.packageManager);
|
|
446
|
-
for await (const event of runCommandStreaming(installCwd, installCmd)) {
|
|
447
|
-
if (event.type === "output") {
|
|
448
|
-
yield { type: "progress", message: event.line };
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
if (!event.ok) {
|
|
452
|
-
yield {
|
|
453
|
-
type: "result",
|
|
454
|
-
result: {
|
|
455
|
-
success: true,
|
|
456
|
-
projectPath: installCwd,
|
|
457
|
-
error: `Scaffold completed but install failed: ${event.stderr || installCmd}`,
|
|
458
|
-
},
|
|
459
|
-
};
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
yield { type: "result", result: { success: true, projectPath: scaffoldOptions.projectPath } };
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Load catalog and return all template entries (for API/UI listing).
|
|
469
|
-
*/
|
|
470
|
-
export function getScaffoldTemplates() {
|
|
471
|
-
return loadCatalog();
|
|
472
|
-
}
|
|
473
|
-
// Register built-in handlers
|
|
474
|
-
registerScaffoldHandler("capacitor-plugin", capacitorPluginHandler);
|
|
475
|
-
//# sourceMappingURL=scaffold.runner.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for scaffold (create project) feature
|
|
3
|
-
*/
|
|
4
|
-
import type { PackageManager } from "@tarsk/shared";
|
|
5
|
-
export interface TemplateEntry {
|
|
6
|
-
id: string;
|
|
7
|
-
type: string;
|
|
8
|
-
typeName: string;
|
|
9
|
-
variation: string;
|
|
10
|
-
variationName: string;
|
|
11
|
-
description: string;
|
|
12
|
-
url?: string;
|
|
13
|
-
commands?: string[];
|
|
14
|
-
handler?: string;
|
|
15
|
-
threadId?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ScaffoldOptions {
|
|
18
|
-
parentDir: string;
|
|
19
|
-
projectName: string;
|
|
20
|
-
threadId: string;
|
|
21
|
-
projectPath: string;
|
|
22
|
-
packageId: string;
|
|
23
|
-
packageManager: PackageManager;
|
|
24
|
-
}
|
|
25
|
-
export type ScaffoldHandler = (template: TemplateEntry, options: ScaffoldOptions) => string[];
|
|
26
|
-
//# sourceMappingURL=scaffold.types.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Activation Logic
|
|
3
|
-
*
|
|
4
|
-
* Determines which skills to activate for a given task/thread based on:
|
|
5
|
-
* 1. Manual overrides (enabledSkills/disabledSkills in thread metadata)
|
|
6
|
-
* 2. Auto-discovery (keyword matching between task and skill descriptions)
|
|
7
|
-
*/
|
|
8
|
-
import type { Skill, Thread } from "@tarsk/shared";
|
|
9
|
-
/**
|
|
10
|
-
* Activate skills for a task based on thread configuration and auto-discovery
|
|
11
|
-
*
|
|
12
|
-
* Activation rules:
|
|
13
|
-
* 1. If thread has enabledSkills, use only those
|
|
14
|
-
* 2. If thread has disabledSkills, auto-discover but exclude those
|
|
15
|
-
* 3. Otherwise, auto-discover based on keyword matching
|
|
16
|
-
*
|
|
17
|
-
* @param allSkills - All available skills (global + project)
|
|
18
|
-
* @param taskDescription - The user's task/message description
|
|
19
|
-
* @param thread - The current thread (may contain manual skill overrides)
|
|
20
|
-
* @param options - Optional configuration for auto-discovery
|
|
21
|
-
* @returns Array of activated skills
|
|
22
|
-
*/
|
|
23
|
-
export declare function activateSkills(allSkills: Skill[], taskDescription: string, thread?: Thread, options?: {
|
|
24
|
-
relevanceThreshold?: number;
|
|
25
|
-
maxSkills?: number;
|
|
26
|
-
}): Promise<Skill[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Get skill names from activated skills (utility function)
|
|
29
|
-
*/
|
|
30
|
-
export declare function getSkillNames(skills: Skill[]): string[];
|
|
31
|
-
//# sourceMappingURL=skills.activation.d.ts.map
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Activation Logic
|
|
3
|
-
*
|
|
4
|
-
* Determines which skills to activate for a given task/thread based on:
|
|
5
|
-
* 1. Manual overrides (enabledSkills/disabledSkills in thread metadata)
|
|
6
|
-
* 2. Auto-discovery (keyword matching between task and skill descriptions)
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Common stop words to filter out during keyword extraction
|
|
10
|
-
*/
|
|
11
|
-
const STOP_WORDS = new Set([
|
|
12
|
-
"a",
|
|
13
|
-
"an",
|
|
14
|
-
"and",
|
|
15
|
-
"are",
|
|
16
|
-
"as",
|
|
17
|
-
"at",
|
|
18
|
-
"be",
|
|
19
|
-
"by",
|
|
20
|
-
"for",
|
|
21
|
-
"from",
|
|
22
|
-
"has",
|
|
23
|
-
"he",
|
|
24
|
-
"in",
|
|
25
|
-
"is",
|
|
26
|
-
"it",
|
|
27
|
-
"its",
|
|
28
|
-
"of",
|
|
29
|
-
"on",
|
|
30
|
-
"that",
|
|
31
|
-
"the",
|
|
32
|
-
"to",
|
|
33
|
-
"was",
|
|
34
|
-
"will",
|
|
35
|
-
"with",
|
|
36
|
-
"when",
|
|
37
|
-
"where",
|
|
38
|
-
"which",
|
|
39
|
-
"who",
|
|
40
|
-
"use",
|
|
41
|
-
"used",
|
|
42
|
-
"using",
|
|
43
|
-
"this",
|
|
44
|
-
"can",
|
|
45
|
-
"do",
|
|
46
|
-
"does",
|
|
47
|
-
"how",
|
|
48
|
-
"what",
|
|
49
|
-
"i",
|
|
50
|
-
"you",
|
|
51
|
-
"we",
|
|
52
|
-
"they",
|
|
53
|
-
"them",
|
|
54
|
-
"their",
|
|
55
|
-
"my",
|
|
56
|
-
"your",
|
|
57
|
-
"our",
|
|
58
|
-
]);
|
|
59
|
-
/**
|
|
60
|
-
* Extract keywords from text for skill matching
|
|
61
|
-
* - Lowercase the text
|
|
62
|
-
* - Split by whitespace and punctuation
|
|
63
|
-
* - Remove stop words
|
|
64
|
-
* - Filter to words with 3+ characters
|
|
65
|
-
*/
|
|
66
|
-
function extractKeywords(text) {
|
|
67
|
-
const keywords = new Set();
|
|
68
|
-
// Lowercase and split by non-alphanumeric characters
|
|
69
|
-
const words = text
|
|
70
|
-
.toLowerCase()
|
|
71
|
-
.split(/[^a-z0-9]+/)
|
|
72
|
-
.filter((word) => word.length >= 3);
|
|
73
|
-
for (const word of words) {
|
|
74
|
-
if (!STOP_WORDS.has(word)) {
|
|
75
|
-
keywords.add(word);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return keywords;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Calculate relevance score between task and skill description
|
|
82
|
-
* Returns a score from 0 to 1 based on keyword overlap
|
|
83
|
-
*/
|
|
84
|
-
function calculateRelevanceScore(taskKeywords, skillDescription) {
|
|
85
|
-
const skillKeywords = extractKeywords(skillDescription);
|
|
86
|
-
if (skillKeywords.size === 0 || taskKeywords.size === 0) {
|
|
87
|
-
return 0;
|
|
88
|
-
}
|
|
89
|
-
// Count matching keywords
|
|
90
|
-
let matches = 0;
|
|
91
|
-
for (const keyword of taskKeywords) {
|
|
92
|
-
if (skillKeywords.has(keyword)) {
|
|
93
|
-
matches++;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Score is the ratio of matches to task keywords
|
|
97
|
-
// (How much of the task is covered by this skill?)
|
|
98
|
-
return matches / taskKeywords.size;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Auto-discover relevant skills based on task description
|
|
102
|
-
* Returns skills sorted by relevance (most relevant first)
|
|
103
|
-
*/
|
|
104
|
-
function autoDiscoverSkills(allSkills, taskDescription, relevanceThreshold = 0.1, maxSkills = 5) {
|
|
105
|
-
const taskKeywords = extractKeywords(taskDescription);
|
|
106
|
-
// Calculate relevance scores for all skills
|
|
107
|
-
const scoredSkills = allSkills.map((skill) => ({
|
|
108
|
-
skill,
|
|
109
|
-
score: calculateRelevanceScore(taskKeywords, skill.description),
|
|
110
|
-
}));
|
|
111
|
-
// Filter by threshold and sort by score (descending)
|
|
112
|
-
const relevantSkills = scoredSkills
|
|
113
|
-
.filter(({ score }) => score >= relevanceThreshold)
|
|
114
|
-
.sort((a, b) => b.score - a.score)
|
|
115
|
-
.slice(0, maxSkills)
|
|
116
|
-
.map(({ skill }) => skill);
|
|
117
|
-
return relevantSkills;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Activate skills for a task based on thread configuration and auto-discovery
|
|
121
|
-
*
|
|
122
|
-
* Activation rules:
|
|
123
|
-
* 1. If thread has enabledSkills, use only those
|
|
124
|
-
* 2. If thread has disabledSkills, auto-discover but exclude those
|
|
125
|
-
* 3. Otherwise, auto-discover based on keyword matching
|
|
126
|
-
*
|
|
127
|
-
* @param allSkills - All available skills (global + project)
|
|
128
|
-
* @param taskDescription - The user's task/message description
|
|
129
|
-
* @param thread - The current thread (may contain manual skill overrides)
|
|
130
|
-
* @param options - Optional configuration for auto-discovery
|
|
131
|
-
* @returns Array of activated skills
|
|
132
|
-
*/
|
|
133
|
-
export async function activateSkills(allSkills, taskDescription, thread, options) {
|
|
134
|
-
const { relevanceThreshold = 0.1, maxSkills = 5 } = options ?? {};
|
|
135
|
-
// Rule 1: If thread has explicitly enabled skills, use only those
|
|
136
|
-
if (thread?.enabledSkills && thread.enabledSkills.length > 0) {
|
|
137
|
-
const enabledSet = new Set(thread.enabledSkills);
|
|
138
|
-
return allSkills.filter((skill) => enabledSet.has(skill.name));
|
|
139
|
-
}
|
|
140
|
-
// Rule 2 & 3: Auto-discover, but respect disabled skills
|
|
141
|
-
const autoDiscovered = autoDiscoverSkills(allSkills, taskDescription, relevanceThreshold, maxSkills);
|
|
142
|
-
// Filter out disabled skills if specified
|
|
143
|
-
if (thread?.disabledSkills && thread.disabledSkills.length > 0) {
|
|
144
|
-
const disabledSet = new Set(thread.disabledSkills);
|
|
145
|
-
return autoDiscovered.filter((skill) => !disabledSet.has(skill.name));
|
|
146
|
-
}
|
|
147
|
-
return autoDiscovered;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get skill names from activated skills (utility function)
|
|
151
|
-
*/
|
|
152
|
-
export function getSkillNames(skills) {
|
|
153
|
-
return skills.map((skill) => skill.name);
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=skills.activation.js.map
|