@specforge/cli 0.1.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 +781 -0
- package/bin/specforge +21 -0
- package/dist/channel.d.ts +27 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +22 -0
- package/dist/channel.js.map +1 -0
- package/dist/cli/commands/configure.d.ts +16 -0
- package/dist/cli/commands/configure.d.ts.map +1 -0
- package/dist/cli/commands/configure.js +186 -0
- package/dist/cli/commands/configure.js.map +1 -0
- package/dist/cli/commands/configure.types.d.ts +110 -0
- package/dist/cli/commands/configure.types.d.ts.map +1 -0
- package/dist/cli/commands/configure.types.js +82 -0
- package/dist/cli/commands/configure.types.js.map +1 -0
- package/dist/cli/commands/debug/call.d.ts +14 -0
- package/dist/cli/commands/debug/call.d.ts.map +1 -0
- package/dist/cli/commands/debug/call.js +96 -0
- package/dist/cli/commands/debug/call.js.map +1 -0
- package/dist/cli/commands/debug/index.d.ts +12 -0
- package/dist/cli/commands/debug/index.d.ts.map +1 -0
- package/dist/cli/commands/debug/index.js +14 -0
- package/dist/cli/commands/debug/index.js.map +1 -0
- package/dist/cli/commands/debug/register.d.ts +11 -0
- package/dist/cli/commands/debug/register.d.ts.map +1 -0
- package/dist/cli/commands/debug/register.js +78 -0
- package/dist/cli/commands/debug/register.js.map +1 -0
- package/dist/cli/commands/debug/test.d.ts +13 -0
- package/dist/cli/commands/debug/test.d.ts.map +1 -0
- package/dist/cli/commands/debug/test.js +91 -0
- package/dist/cli/commands/debug/test.js.map +1 -0
- package/dist/cli/commands/debug/tools.d.ts +13 -0
- package/dist/cli/commands/debug/tools.d.ts.map +1 -0
- package/dist/cli/commands/debug/tools.js +86 -0
- package/dist/cli/commands/debug/tools.js.map +1 -0
- package/dist/cli/commands/debug/types.d.ts +119 -0
- package/dist/cli/commands/debug/types.d.ts.map +1 -0
- package/dist/cli/commands/debug/types.js +36 -0
- package/dist/cli/commands/debug/types.js.map +1 -0
- package/dist/cli/commands/debug/whoami.d.ts +13 -0
- package/dist/cli/commands/debug/whoami.d.ts.map +1 -0
- package/dist/cli/commands/debug/whoami.js +131 -0
- package/dist/cli/commands/debug/whoami.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +16 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +413 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/doctor.types.d.ts +180 -0
- package/dist/cli/commands/doctor.types.d.ts.map +1 -0
- package/dist/cli/commands/doctor.types.js +140 -0
- package/dist/cli/commands/doctor.types.js.map +1 -0
- package/dist/cli/commands/feedback.d.ts +27 -0
- package/dist/cli/commands/feedback.d.ts.map +1 -0
- package/dist/cli/commands/feedback.js +262 -0
- package/dist/cli/commands/feedback.js.map +1 -0
- package/dist/cli/commands/feedback.types.d.ts +116 -0
- package/dist/cli/commands/feedback.types.d.ts.map +1 -0
- package/dist/cli/commands/feedback.types.js +65 -0
- package/dist/cli/commands/feedback.types.js.map +1 -0
- package/dist/cli/commands/index.d.ts +15 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +21 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/init.d.ts +17 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +773 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/init.types.d.ts +193 -0
- package/dist/cli/commands/init.types.d.ts.map +1 -0
- package/dist/cli/commands/init.types.js +29 -0
- package/dist/cli/commands/init.types.js.map +1 -0
- package/dist/cli/commands/invitations.d.ts +31 -0
- package/dist/cli/commands/invitations.d.ts.map +1 -0
- package/dist/cli/commands/invitations.js +250 -0
- package/dist/cli/commands/invitations.js.map +1 -0
- package/dist/cli/commands/login.d.ts +40 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +139 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/members.d.ts +55 -0
- package/dist/cli/commands/members.d.ts.map +1 -0
- package/dist/cli/commands/members.js +296 -0
- package/dist/cli/commands/members.js.map +1 -0
- package/dist/cli/commands/scaffold/agent-types.d.ts +54 -0
- package/dist/cli/commands/scaffold/agent-types.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/agent-types.js +22 -0
- package/dist/cli/commands/scaffold/agent-types.js.map +1 -0
- package/dist/cli/commands/scaffold/display.d.ts +56 -0
- package/dist/cli/commands/scaffold/display.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/display.js +217 -0
- package/dist/cli/commands/scaffold/display.js.map +1 -0
- package/dist/cli/commands/scaffold/files.d.ts +99 -0
- package/dist/cli/commands/scaffold/files.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/files.js +122 -0
- package/dist/cli/commands/scaffold/files.js.map +1 -0
- package/dist/cli/commands/scaffold/index.d.ts +13 -0
- package/dist/cli/commands/scaffold/index.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/index.js +12 -0
- package/dist/cli/commands/scaffold/index.js.map +1 -0
- package/dist/cli/commands/scaffold/register.d.ts +11 -0
- package/dist/cli/commands/scaffold/register.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/register.js +11 -0
- package/dist/cli/commands/scaffold/register.js.map +1 -0
- package/dist/cli/commands/scaffold/scaffold.d.ts +11 -0
- package/dist/cli/commands/scaffold/scaffold.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/scaffold.js +728 -0
- package/dist/cli/commands/scaffold/scaffold.js.map +1 -0
- package/dist/cli/commands/scaffold/targets.d.ts +60 -0
- package/dist/cli/commands/scaffold/targets.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/targets.js +251 -0
- package/dist/cli/commands/scaffold/targets.js.map +1 -0
- package/dist/cli/commands/scaffold/types.d.ts +170 -0
- package/dist/cli/commands/scaffold/types.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/types.js +12 -0
- package/dist/cli/commands/scaffold/types.js.map +1 -0
- package/dist/cli/commands/scaffold/utils.d.ts +89 -0
- package/dist/cli/commands/scaffold/utils.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/utils.js +401 -0
- package/dist/cli/commands/scaffold/utils.js.map +1 -0
- package/dist/cli/commands/status.d.ts +19 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +124 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/status.types.d.ts +37 -0
- package/dist/cli/commands/status.types.d.ts.map +1 -0
- package/dist/cli/commands/status.types.js +7 -0
- package/dist/cli/commands/status.types.js.map +1 -0
- package/dist/cli/commands/switch.d.ts +18 -0
- package/dist/cli/commands/switch.d.ts.map +1 -0
- package/dist/cli/commands/switch.js +134 -0
- package/dist/cli/commands/switch.js.map +1 -0
- package/dist/cli/commands/switch.types.d.ts +123 -0
- package/dist/cli/commands/switch.types.d.ts.map +1 -0
- package/dist/cli/commands/switch.types.js +46 -0
- package/dist/cli/commands/switch.types.js.map +1 -0
- package/dist/cli/config/agent-teams.types.d.ts +120 -0
- package/dist/cli/config/agent-teams.types.d.ts.map +1 -0
- package/dist/cli/config/agent-teams.types.js +23 -0
- package/dist/cli/config/agent-teams.types.js.map +1 -0
- package/dist/cli/config/index.d.ts +13 -0
- package/dist/cli/config/index.d.ts.map +1 -0
- package/dist/cli/config/index.js +7 -0
- package/dist/cli/config/index.js.map +1 -0
- package/dist/cli/config/loader.d.ts +114 -0
- package/dist/cli/config/loader.d.ts.map +1 -0
- package/dist/cli/config/loader.js +198 -0
- package/dist/cli/config/loader.js.map +1 -0
- package/dist/cli/config/paths.d.ts +107 -0
- package/dist/cli/config/paths.d.ts.map +1 -0
- package/dist/cli/config/paths.js +79 -0
- package/dist/cli/config/paths.js.map +1 -0
- package/dist/cli/config/planning-sessions-registry.d.ts +52 -0
- package/dist/cli/config/planning-sessions-registry.d.ts.map +1 -0
- package/dist/cli/config/planning-sessions-registry.js +46 -0
- package/dist/cli/config/planning-sessions-registry.js.map +1 -0
- package/dist/cli/config/types.d.ts +186 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +27 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/config/validation.d.ts +62 -0
- package/dist/cli/config/validation.d.ts.map +1 -0
- package/dist/cli/config/validation.js +133 -0
- package/dist/cli/config/validation.js.map +1 -0
- package/dist/cli/config/writer.d.ts +153 -0
- package/dist/cli/config/writer.d.ts.map +1 -0
- package/dist/cli/config/writer.js +168 -0
- package/dist/cli/config/writer.js.map +1 -0
- package/dist/cli/index.d.ts +30 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +142 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/middleware/auth-guard.d.ts +107 -0
- package/dist/cli/middleware/auth-guard.d.ts.map +1 -0
- package/dist/cli/middleware/auth-guard.js +97 -0
- package/dist/cli/middleware/auth-guard.js.map +1 -0
- package/dist/cli/middleware/error-handler.d.ts +133 -0
- package/dist/cli/middleware/error-handler.d.ts.map +1 -0
- package/dist/cli/middleware/error-handler.js +139 -0
- package/dist/cli/middleware/error-handler.js.map +1 -0
- package/dist/cli/middleware/index.d.ts +6 -0
- package/dist/cli/middleware/index.d.ts.map +1 -0
- package/dist/cli/middleware/index.js +3 -0
- package/dist/cli/middleware/index.js.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-orchestrator.d.ts +9 -0
- package/dist/cli/templates/agents/content/core/sfag-orchestrator.d.ts.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-orchestrator.js +160 -0
- package/dist/cli/templates/agents/content/core/sfag-orchestrator.js.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-spec-creator.d.ts +9 -0
- package/dist/cli/templates/agents/content/core/sfag-spec-creator.d.ts.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-spec-creator.js +343 -0
- package/dist/cli/templates/agents/content/core/sfag-spec-creator.js.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-ticket-implementer.d.ts +9 -0
- package/dist/cli/templates/agents/content/core/sfag-ticket-implementer.d.ts.map +1 -0
- package/dist/cli/templates/agents/content/core/sfag-ticket-implementer.js +254 -0
- package/dist/cli/templates/agents/content/core/sfag-ticket-implementer.js.map +1 -0
- package/dist/cli/templates/agents/content/research/sfag-package-researcher.d.ts +8 -0
- package/dist/cli/templates/agents/content/research/sfag-package-researcher.d.ts.map +1 -0
- package/dist/cli/templates/agents/content/research/sfag-package-researcher.js +128 -0
- package/dist/cli/templates/agents/content/research/sfag-package-researcher.js.map +1 -0
- package/dist/cli/templates/agents/index.d.ts +23 -0
- package/dist/cli/templates/agents/index.d.ts.map +1 -0
- package/dist/cli/templates/agents/index.js +29 -0
- package/dist/cli/templates/agents/index.js.map +1 -0
- package/dist/cli/templates/commands.d.ts +17 -0
- package/dist/cli/templates/commands.d.ts.map +1 -0
- package/dist/cli/templates/commands.js +78 -0
- package/dist/cli/templates/commands.js.map +1 -0
- package/dist/cli/templates/content/sf-blockers.d.ts +7 -0
- package/dist/cli/templates/content/sf-blockers.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-blockers.js +69 -0
- package/dist/cli/templates/content/sf-blockers.js.map +1 -0
- package/dist/cli/templates/content/sf-commit.d.ts +7 -0
- package/dist/cli/templates/content/sf-commit.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-commit.js +79 -0
- package/dist/cli/templates/content/sf-commit.js.map +1 -0
- package/dist/cli/templates/content/sf-context.d.ts +7 -0
- package/dist/cli/templates/content/sf-context.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-context.js +63 -0
- package/dist/cli/templates/content/sf-context.js.map +1 -0
- package/dist/cli/templates/content/sf-help.d.ts +7 -0
- package/dist/cli/templates/content/sf-help.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-help.js +42 -0
- package/dist/cli/templates/content/sf-help.js.map +1 -0
- package/dist/cli/templates/content/sf-init.d.ts +7 -0
- package/dist/cli/templates/content/sf-init.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-init.js +62 -0
- package/dist/cli/templates/content/sf-init.js.map +1 -0
- package/dist/cli/templates/content/sf-reset.d.ts +7 -0
- package/dist/cli/templates/content/sf-reset.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-reset.js +67 -0
- package/dist/cli/templates/content/sf-reset.js.map +1 -0
- package/dist/cli/templates/content/sf-search.d.ts +7 -0
- package/dist/cli/templates/content/sf-search.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-search.js +63 -0
- package/dist/cli/templates/content/sf-search.js.map +1 -0
- package/dist/cli/templates/content/sf-status.d.ts +7 -0
- package/dist/cli/templates/content/sf-status.d.ts.map +1 -0
- package/dist/cli/templates/content/sf-status.js +62 -0
- package/dist/cli/templates/content/sf-status.js.map +1 -0
- package/dist/cli/templates/index.d.ts +8 -0
- package/dist/cli/templates/index.d.ts.map +1 -0
- package/dist/cli/templates/index.js +17 -0
- package/dist/cli/templates/index.js.map +1 -0
- package/dist/cli/ui/banner.d.ts +38 -0
- package/dist/cli/ui/banner.d.ts.map +1 -0
- package/dist/cli/ui/banner.js +89 -0
- package/dist/cli/ui/banner.js.map +1 -0
- package/dist/cli/ui/colors.d.ts +76 -0
- package/dist/cli/ui/colors.d.ts.map +1 -0
- package/dist/cli/ui/colors.js +67 -0
- package/dist/cli/ui/colors.js.map +1 -0
- package/dist/cli/ui/index.d.ts +7 -0
- package/dist/cli/ui/index.d.ts.map +1 -0
- package/dist/cli/ui/index.js +4 -0
- package/dist/cli/ui/index.js.map +1 -0
- package/dist/cli/ui/output.d.ts +117 -0
- package/dist/cli/ui/output.d.ts.map +1 -0
- package/dist/cli/ui/output.js +83 -0
- package/dist/cli/ui/output.js.map +1 -0
- package/dist/cli/ui/spinner.d.ts +120 -0
- package/dist/cli/ui/spinner.d.ts.map +1 -0
- package/dist/cli/ui/spinner.js +158 -0
- package/dist/cli/ui/spinner.js.map +1 -0
- package/dist/cli/ui/time.d.ts +54 -0
- package/dist/cli/ui/time.d.ts.map +1 -0
- package/dist/cli/ui/time.js +119 -0
- package/dist/cli/ui/time.js.map +1 -0
- package/dist/client/api-client.d.ts +123 -0
- package/dist/client/api-client.d.ts.map +1 -0
- package/dist/client/api-client.js +105 -0
- package/dist/client/api-client.js.map +1 -0
- package/dist/client/cli-client.d.ts +26 -0
- package/dist/client/cli-client.d.ts.map +1 -0
- package/dist/client/cli-client.js +20 -0
- package/dist/client/cli-client.js.map +1 -0
- package/dist/config/index.d.ts +78 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +79 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/format.d.ts +126 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +71 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +45 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/monorepo-detector.d.ts +31 -0
- package/dist/lib/monorepo-detector.d.ts.map +1 -0
- package/dist/lib/monorepo-detector.js +188 -0
- package/dist/lib/monorepo-detector.js.map +1 -0
- package/dist/lib/prompt-generator.d.ts +65 -0
- package/dist/lib/prompt-generator.d.ts.map +1 -0
- package/dist/lib/prompt-generator.js +162 -0
- package/dist/lib/prompt-generator.js.map +1 -0
- package/dist/lib/strategy-analyzer.d.ts +59 -0
- package/dist/lib/strategy-analyzer.d.ts.map +1 -0
- package/dist/lib/strategy-analyzer.js +91 -0
- package/dist/lib/strategy-analyzer.js.map +1 -0
- package/dist/lib/workflow-definitions.d.ts +41 -0
- package/dist/lib/workflow-definitions.d.ts.map +1 -0
- package/dist/lib/workflow-definitions.js +497 -0
- package/dist/lib/workflow-definitions.js.map +1 -0
- package/dist/patterns/index.d.ts +9 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +21 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/inheritance.d.ts +193 -0
- package/dist/patterns/inheritance.d.ts.map +1 -0
- package/dist/patterns/inheritance.js +125 -0
- package/dist/patterns/inheritance.js.map +1 -0
- package/dist/server.d.ts +44 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +91 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/core/context-helper.d.ts +50 -0
- package/dist/tools/core/context-helper.d.ts.map +1 -0
- package/dist/tools/core/context-helper.js +49 -0
- package/dist/tools/core/context-helper.js.map +1 -0
- package/dist/tools/core/index.d.ts +2 -0
- package/dist/tools/core/index.d.ts.map +1 -0
- package/dist/tools/core/index.js +2 -0
- package/dist/tools/core/index.js.map +1 -0
- package/dist/tools/index.d.ts +58 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +1499 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/transport/__tests__/resolve-endpoint.test.d.ts +6 -0
- package/dist/transport/__tests__/resolve-endpoint.test.d.ts.map +1 -0
- package/dist/transport/index.d.ts +6 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +5 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/interface.d.ts +25 -0
- package/dist/transport/interface.d.ts.map +1 -0
- package/dist/transport/interface.js +1 -0
- package/dist/transport/interface.js.map +1 -0
- package/dist/transport/remote.d.ts +38 -0
- package/dist/transport/remote.d.ts.map +1 -0
- package/dist/transport/remote.js +107 -0
- package/dist/transport/remote.js.map +1 -0
- package/dist/transport/resolve-endpoint.d.ts +58 -0
- package/dist/transport/resolve-endpoint.d.ts.map +1 -0
- package/dist/transport/resolve-endpoint.js +146 -0
- package/dist/transport/resolve-endpoint.js.map +1 -0
- package/dist/types/index.d.ts +212 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/validation/index.d.ts +86 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +392 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/ticket-validation.d.ts +162 -0
- package/dist/validation/ticket-validation.d.ts.map +1 -0
- package/dist/validation/ticket-validation.js +188 -0
- package/dist/validation/ticket-validation.js.map +1 -0
- package/package.json +69 -0
- package/src/cli/templates/agents/content/core/sfag-orchestrator.ts +165 -0
- package/src/cli/templates/agents/content/core/sfag-spec-creator.ts +348 -0
- package/src/cli/templates/agents/content/core/sfag-ticket-implementer.ts +259 -0
- package/src/cli/templates/agents/content/research/sfag-package-researcher.ts +132 -0
- package/src/cli/templates/agents/index.ts +47 -0
- package/src/cli/templates/commands.ts +90 -0
- package/src/cli/templates/content/sf-blockers.ts +71 -0
- package/src/cli/templates/content/sf-commit.ts +81 -0
- package/src/cli/templates/content/sf-context.ts +65 -0
- package/src/cli/templates/content/sf-help.ts +44 -0
- package/src/cli/templates/content/sf-init.ts +64 -0
- package/src/cli/templates/content/sf-reset.ts +69 -0
- package/src/cli/templates/content/sf-search.ts +65 -0
- package/src/cli/templates/content/sf-status.ts +64 -0
- package/src/cli/templates/index.ts +16 -0
- package/src/cli/templates/skills/specforge-conventions.md +114 -0
- package/src/cli/templates/skills/specforge-orchestrator.md +409 -0
- package/src/cli/templates/skills/specforge-validator.md +128 -0
- package/src/cli/templates/skills/specforge-worker.md +412 -0
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { COMMAND_CATEGORIES } from "./types.js";
|
|
4
|
+
import { AGENT_CATEGORIES } from "./agent-types.js";
|
|
5
|
+
import {
|
|
6
|
+
TARGETS,
|
|
7
|
+
isValidTarget,
|
|
8
|
+
resolveTargetAlias,
|
|
9
|
+
getSupportedTargets,
|
|
10
|
+
getTargetPath,
|
|
11
|
+
getAgentPath,
|
|
12
|
+
getSkillPath,
|
|
13
|
+
getAgentSupportedTargets
|
|
14
|
+
} from "./targets.js";
|
|
15
|
+
import {
|
|
16
|
+
scaffoldMultiCli
|
|
17
|
+
} from "./files.js";
|
|
18
|
+
import { loadGlobalConfig } from "../../config/index.js";
|
|
19
|
+
import { getCommandTemplates } from "../../templates/commands.js";
|
|
20
|
+
import { getAgentTemplates } from "../../templates/agents/index.js";
|
|
21
|
+
import {
|
|
22
|
+
detectInstalledTools,
|
|
23
|
+
generateCommandContent,
|
|
24
|
+
generateAgentContent,
|
|
25
|
+
ensureDirectory,
|
|
26
|
+
writeFile,
|
|
27
|
+
getCommandFilename,
|
|
28
|
+
getAgentFilename,
|
|
29
|
+
compareFiles,
|
|
30
|
+
generateDiff
|
|
31
|
+
} from "./utils.js";
|
|
32
|
+
import {
|
|
33
|
+
displayCommandList,
|
|
34
|
+
displayAgentList,
|
|
35
|
+
displayScaffoldHeader,
|
|
36
|
+
displayAgentScaffoldHeader,
|
|
37
|
+
displayFileOperation,
|
|
38
|
+
displayScaffoldSummary,
|
|
39
|
+
displayAgentScaffoldSummary,
|
|
40
|
+
displayTargetError,
|
|
41
|
+
displayAgentTargetError,
|
|
42
|
+
displayDiff,
|
|
43
|
+
displayCommandPreview,
|
|
44
|
+
displayAgentPreview
|
|
45
|
+
} from "./display.js";
|
|
46
|
+
import { colors } from "../../ui/colors.js";
|
|
47
|
+
async function selectTarget(mode = "command") {
|
|
48
|
+
const installed = detectInstalledTools();
|
|
49
|
+
const inquirer = await import("inquirer");
|
|
50
|
+
const availableTargets = Object.entries(TARGETS).filter(([_, config]) => {
|
|
51
|
+
if (mode === "agent") return config.supportsAgents;
|
|
52
|
+
if (mode === "skill") return config.supportsSkills;
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
const choices = availableTargets.map(([key, config]) => ({
|
|
56
|
+
name: `${config.name}${installed.includes(key) ? colors.success(" (detected)") : ""}`,
|
|
57
|
+
value: key
|
|
58
|
+
}));
|
|
59
|
+
const { target } = await inquirer.default.prompt([
|
|
60
|
+
{
|
|
61
|
+
type: "list",
|
|
62
|
+
name: "target",
|
|
63
|
+
message: mode === "agent" ? "Select target AI CLI tool (agent support):" : mode === "skill" ? "Select target AI CLI tool (skill support):" : "Select target AI CLI tool:",
|
|
64
|
+
choices
|
|
65
|
+
}
|
|
66
|
+
]);
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
async function interactivePreview(target) {
|
|
70
|
+
const inquirer = await import("inquirer");
|
|
71
|
+
const templates = getCommandTemplates();
|
|
72
|
+
const config = TARGETS[target];
|
|
73
|
+
const choices = [];
|
|
74
|
+
for (const [category, commandNames] of Object.entries(COMMAND_CATEGORIES)) {
|
|
75
|
+
choices.push(new inquirer.default.Separator(`\u2500\u2500 ${category} \u2500\u2500`));
|
|
76
|
+
for (const name of commandNames) {
|
|
77
|
+
const template = templates.find((t) => t.name === name);
|
|
78
|
+
if (template) {
|
|
79
|
+
choices.push({
|
|
80
|
+
name: `${name.padEnd(25)} ${colors.dim(template.description)}`,
|
|
81
|
+
value: name
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let continuePreview = true;
|
|
87
|
+
while (continuePreview) {
|
|
88
|
+
const { command } = await inquirer.default.prompt([{
|
|
89
|
+
type: "list",
|
|
90
|
+
name: "command",
|
|
91
|
+
message: "Select command to preview (Ctrl+C to exit):",
|
|
92
|
+
choices: [
|
|
93
|
+
...choices,
|
|
94
|
+
new inquirer.default.Separator(),
|
|
95
|
+
{ name: "Exit", value: null }
|
|
96
|
+
],
|
|
97
|
+
pageSize: 20
|
|
98
|
+
}]);
|
|
99
|
+
if (!command) {
|
|
100
|
+
continuePreview = false;
|
|
101
|
+
} else {
|
|
102
|
+
const template = templates.find((t) => t.name === command);
|
|
103
|
+
if (template) {
|
|
104
|
+
console.clear();
|
|
105
|
+
const content = generateCommandContent(template, config.needsFrontmatter, target);
|
|
106
|
+
displayCommandPreview(template.name, content);
|
|
107
|
+
await inquirer.default.prompt([{
|
|
108
|
+
type: "input",
|
|
109
|
+
name: "continue",
|
|
110
|
+
message: "Press Enter to continue..."
|
|
111
|
+
}]);
|
|
112
|
+
console.clear();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async function interactiveAgentPreview(target) {
|
|
118
|
+
const inquirer = await import("inquirer");
|
|
119
|
+
const templates = getAgentTemplates();
|
|
120
|
+
const config = TARGETS[target];
|
|
121
|
+
const choices = [];
|
|
122
|
+
for (const [category, agentNames] of Object.entries(AGENT_CATEGORIES)) {
|
|
123
|
+
choices.push(new inquirer.default.Separator(`\u2500\u2500 ${category} \u2500\u2500`));
|
|
124
|
+
for (const name of agentNames) {
|
|
125
|
+
const template = templates.find((t) => t.name === name);
|
|
126
|
+
if (template) {
|
|
127
|
+
choices.push({
|
|
128
|
+
name: `${name.padEnd(25)} ${colors.dim(`[${template.model}]`)} ${colors.dim(template.description)}`,
|
|
129
|
+
value: name
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
let continuePreview = true;
|
|
135
|
+
while (continuePreview) {
|
|
136
|
+
const { agent } = await inquirer.default.prompt([{
|
|
137
|
+
type: "list",
|
|
138
|
+
name: "agent",
|
|
139
|
+
message: "Select agent to preview (Ctrl+C to exit):",
|
|
140
|
+
choices: [
|
|
141
|
+
...choices,
|
|
142
|
+
new inquirer.default.Separator(),
|
|
143
|
+
{ name: "Exit", value: null }
|
|
144
|
+
],
|
|
145
|
+
pageSize: 20
|
|
146
|
+
}]);
|
|
147
|
+
if (!agent) {
|
|
148
|
+
continuePreview = false;
|
|
149
|
+
} else {
|
|
150
|
+
const template = templates.find((t) => t.name === agent);
|
|
151
|
+
if (template) {
|
|
152
|
+
console.clear();
|
|
153
|
+
const content = generateAgentContent(template, config.agentFrontmatter, target);
|
|
154
|
+
displayAgentPreview(template.name, content, template.model);
|
|
155
|
+
await inquirer.default.prompt([{
|
|
156
|
+
type: "input",
|
|
157
|
+
name: "continue",
|
|
158
|
+
message: "Press Enter to continue..."
|
|
159
|
+
}]);
|
|
160
|
+
console.clear();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function interactiveDiff(target) {
|
|
166
|
+
const inquirer = await import("inquirer");
|
|
167
|
+
const templates = getCommandTemplates();
|
|
168
|
+
const config = TARGETS[target];
|
|
169
|
+
const targetPath = getTargetPath(target, false);
|
|
170
|
+
const outdated = [];
|
|
171
|
+
for (const template of templates) {
|
|
172
|
+
const filename = getCommandFilename(template.name, config.fileExtension);
|
|
173
|
+
const filepath = path.join(targetPath, filename);
|
|
174
|
+
const content = generateCommandContent(template, config.needsFrontmatter, target);
|
|
175
|
+
const comparison = compareFiles(filepath, content);
|
|
176
|
+
if (comparison.status === "outdated") {
|
|
177
|
+
outdated.push({ name: template.name, template, kept: false });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (outdated.length === 0) {
|
|
181
|
+
console.log(colors.success("\nAll commands are up to date!"));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const buildChoices = () => outdated.map(({ name, template, kept }) => ({
|
|
185
|
+
name: `${kept ? colors.dim("\u25CB") : "\u26A0"} ${name.padEnd(23)} ${kept ? colors.dim("(keeping current)") : colors.dim(template.description)}`,
|
|
186
|
+
value: name
|
|
187
|
+
}));
|
|
188
|
+
let continueDiff = true;
|
|
189
|
+
while (continueDiff) {
|
|
190
|
+
const keptCount = outdated.filter((o) => o.kept).length;
|
|
191
|
+
const updateCount = outdated.length - keptCount;
|
|
192
|
+
const choices = buildChoices();
|
|
193
|
+
const { command } = await inquirer.default.prompt([{
|
|
194
|
+
type: "list",
|
|
195
|
+
name: "command",
|
|
196
|
+
message: `Select command to view diff (${updateCount} to update, ${keptCount} keeping):`,
|
|
197
|
+
choices: [
|
|
198
|
+
...choices,
|
|
199
|
+
new inquirer.default.Separator(),
|
|
200
|
+
{ name: "Apply changes & Exit", value: "apply" },
|
|
201
|
+
{ name: "Exit without changes", value: null }
|
|
202
|
+
],
|
|
203
|
+
pageSize: 15
|
|
204
|
+
}]);
|
|
205
|
+
if (!command) {
|
|
206
|
+
continueDiff = false;
|
|
207
|
+
} else if (command === "apply") {
|
|
208
|
+
const toUpdate = outdated.filter((o) => !o.kept);
|
|
209
|
+
if (toUpdate.length === 0) {
|
|
210
|
+
console.log(colors.dim("\nNo commands to update (all marked as keep)"));
|
|
211
|
+
} else {
|
|
212
|
+
console.log();
|
|
213
|
+
for (const item of toUpdate) {
|
|
214
|
+
const filename = getCommandFilename(item.name, config.fileExtension);
|
|
215
|
+
const filepath = path.join(targetPath, filename);
|
|
216
|
+
const content = generateCommandContent(item.template, config.needsFrontmatter, target);
|
|
217
|
+
writeFile(filepath, content);
|
|
218
|
+
console.log(colors.success(` \u2713 Updated ${filename}`));
|
|
219
|
+
}
|
|
220
|
+
console.log(colors.success(`
|
|
221
|
+
Updated ${toUpdate.length} commands`));
|
|
222
|
+
}
|
|
223
|
+
if (keptCount > 0) {
|
|
224
|
+
console.log(colors.dim(`Kept ${keptCount} commands unchanged`));
|
|
225
|
+
}
|
|
226
|
+
continueDiff = false;
|
|
227
|
+
} else {
|
|
228
|
+
console.clear();
|
|
229
|
+
const item = outdated.find((o) => o.name === command);
|
|
230
|
+
if (item) {
|
|
231
|
+
const filename = getCommandFilename(item.name, config.fileExtension);
|
|
232
|
+
const filepath = path.join(targetPath, filename);
|
|
233
|
+
const content = generateCommandContent(item.template, config.needsFrontmatter, target);
|
|
234
|
+
const comparison = compareFiles(filepath, content);
|
|
235
|
+
console.log(colors.bold(`
|
|
236
|
+
Diff: ${item.name}`));
|
|
237
|
+
console.log("\u2500".repeat(50));
|
|
238
|
+
if (comparison.existingContent) {
|
|
239
|
+
displayDiff(generateDiff(comparison.existingContent, content, filename));
|
|
240
|
+
}
|
|
241
|
+
const { action } = await inquirer.default.prompt([{
|
|
242
|
+
type: "list",
|
|
243
|
+
name: "action",
|
|
244
|
+
message: "What do you want to do?",
|
|
245
|
+
choices: [
|
|
246
|
+
{ name: item.kept ? "Mark for update" : "Keep current version (skip update)", value: "toggle" },
|
|
247
|
+
{ name: "Back to list", value: "back" }
|
|
248
|
+
]
|
|
249
|
+
}]);
|
|
250
|
+
if (action === "toggle") {
|
|
251
|
+
item.kept = !item.kept;
|
|
252
|
+
}
|
|
253
|
+
console.clear();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function interactiveAgentDiff(target) {
|
|
259
|
+
const inquirer = await import("inquirer");
|
|
260
|
+
const templates = getAgentTemplates();
|
|
261
|
+
const config = TARGETS[target];
|
|
262
|
+
const targetPath = getAgentPath(target, false);
|
|
263
|
+
const outdated = [];
|
|
264
|
+
for (const template of templates) {
|
|
265
|
+
const filename = getAgentFilename(template.name, target);
|
|
266
|
+
const filepath = path.join(targetPath, filename);
|
|
267
|
+
const content = generateAgentContent(template, config.agentFrontmatter, target);
|
|
268
|
+
const comparison = compareFiles(filepath, content);
|
|
269
|
+
if (comparison.status === "outdated") {
|
|
270
|
+
outdated.push({ name: template.name, template, kept: false });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (outdated.length === 0) {
|
|
274
|
+
console.log(colors.success("\nAll agents are up to date!"));
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const buildChoices = () => outdated.map(({ name, template, kept }) => ({
|
|
278
|
+
name: `${kept ? colors.dim("\u25CB") : "\u26A0"} ${name.padEnd(23)} ${kept ? colors.dim("(keeping current)") : colors.dim(template.description)}`,
|
|
279
|
+
value: name
|
|
280
|
+
}));
|
|
281
|
+
let continueDiff = true;
|
|
282
|
+
while (continueDiff) {
|
|
283
|
+
const keptCount = outdated.filter((o) => o.kept).length;
|
|
284
|
+
const updateCount = outdated.length - keptCount;
|
|
285
|
+
const choices = buildChoices();
|
|
286
|
+
const { agent } = await inquirer.default.prompt([{
|
|
287
|
+
type: "list",
|
|
288
|
+
name: "agent",
|
|
289
|
+
message: `Select agent to view diff (${updateCount} to update, ${keptCount} keeping):`,
|
|
290
|
+
choices: [
|
|
291
|
+
...choices,
|
|
292
|
+
new inquirer.default.Separator(),
|
|
293
|
+
{ name: "Apply changes & Exit", value: "apply" },
|
|
294
|
+
{ name: "Exit without changes", value: null }
|
|
295
|
+
],
|
|
296
|
+
pageSize: 15
|
|
297
|
+
}]);
|
|
298
|
+
if (!agent) {
|
|
299
|
+
continueDiff = false;
|
|
300
|
+
} else if (agent === "apply") {
|
|
301
|
+
const toUpdate = outdated.filter((o) => !o.kept);
|
|
302
|
+
if (toUpdate.length === 0) {
|
|
303
|
+
console.log(colors.dim("\nNo agents to update (all marked as keep)"));
|
|
304
|
+
} else {
|
|
305
|
+
console.log();
|
|
306
|
+
for (const item of toUpdate) {
|
|
307
|
+
const filename = getAgentFilename(item.name, target);
|
|
308
|
+
const filepath = path.join(targetPath, filename);
|
|
309
|
+
const content = generateAgentContent(item.template, config.agentFrontmatter, target);
|
|
310
|
+
writeFile(filepath, content);
|
|
311
|
+
console.log(colors.success(` \u2713 Updated ${filename}`));
|
|
312
|
+
}
|
|
313
|
+
console.log(colors.success(`
|
|
314
|
+
Updated ${toUpdate.length} agents`));
|
|
315
|
+
}
|
|
316
|
+
if (keptCount > 0) {
|
|
317
|
+
console.log(colors.dim(`Kept ${keptCount} agents unchanged`));
|
|
318
|
+
}
|
|
319
|
+
continueDiff = false;
|
|
320
|
+
} else {
|
|
321
|
+
console.clear();
|
|
322
|
+
const item = outdated.find((o) => o.name === agent);
|
|
323
|
+
if (item) {
|
|
324
|
+
const filename = getAgentFilename(item.name, target);
|
|
325
|
+
const filepath = path.join(targetPath, filename);
|
|
326
|
+
const content = generateAgentContent(item.template, config.agentFrontmatter, target);
|
|
327
|
+
const comparison = compareFiles(filepath, content);
|
|
328
|
+
console.log(colors.bold(`
|
|
329
|
+
Diff: ${item.name}`));
|
|
330
|
+
console.log("\u2500".repeat(50));
|
|
331
|
+
if (comparison.existingContent) {
|
|
332
|
+
displayDiff(generateDiff(comparison.existingContent, content, filename));
|
|
333
|
+
}
|
|
334
|
+
const { action } = await inquirer.default.prompt([{
|
|
335
|
+
type: "list",
|
|
336
|
+
name: "action",
|
|
337
|
+
message: "What do you want to do?",
|
|
338
|
+
choices: [
|
|
339
|
+
{ name: item.kept ? "Mark for update" : "Keep current version (skip update)", value: "toggle" },
|
|
340
|
+
{ name: "Back to list", value: "back" }
|
|
341
|
+
]
|
|
342
|
+
}]);
|
|
343
|
+
if (action === "toggle") {
|
|
344
|
+
item.kept = !item.kept;
|
|
345
|
+
}
|
|
346
|
+
console.clear();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async function scaffoldCommands(target, options) {
|
|
352
|
+
const config = TARGETS[target];
|
|
353
|
+
if (!config.supportsCommands) {
|
|
354
|
+
console.log(colors.warning(`
|
|
355
|
+
${config.name} does not support slash commands.`));
|
|
356
|
+
console.log(colors.dim("Commands will be generated as skills instead.\n"));
|
|
357
|
+
await scaffoldSkills(target, options);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const isProject = options.project === true;
|
|
361
|
+
const targetPath = getTargetPath(target, isProject);
|
|
362
|
+
const templates = getCommandTemplates();
|
|
363
|
+
displayScaffoldHeader(target, targetPath, options.dryRun === true);
|
|
364
|
+
if (!options.dryRun) {
|
|
365
|
+
ensureDirectory(targetPath);
|
|
366
|
+
}
|
|
367
|
+
const result = {
|
|
368
|
+
created: 0,
|
|
369
|
+
updated: 0,
|
|
370
|
+
skipped: 0,
|
|
371
|
+
outdated: 0,
|
|
372
|
+
targetPath
|
|
373
|
+
};
|
|
374
|
+
for (const template of templates) {
|
|
375
|
+
const filename = getCommandFilename(template.name, config.commandExtension);
|
|
376
|
+
const filepath = path.join(targetPath, filename);
|
|
377
|
+
const content = generateCommandContent(
|
|
378
|
+
template,
|
|
379
|
+
config.commandFrontmatter,
|
|
380
|
+
target
|
|
381
|
+
);
|
|
382
|
+
const comparison = compareFiles(filepath, content);
|
|
383
|
+
displayFileOperation(filename, comparison.status, options.dryRun === true, options.update === true);
|
|
384
|
+
if (options.diff && comparison.status === "outdated" && comparison.existingContent) {
|
|
385
|
+
const diff = generateDiff(comparison.existingContent, content, filename);
|
|
386
|
+
displayDiff(diff);
|
|
387
|
+
}
|
|
388
|
+
switch (comparison.status) {
|
|
389
|
+
case "new":
|
|
390
|
+
if (!options.dryRun) {
|
|
391
|
+
writeFile(filepath, content);
|
|
392
|
+
}
|
|
393
|
+
result.created++;
|
|
394
|
+
break;
|
|
395
|
+
case "identical":
|
|
396
|
+
result.skipped++;
|
|
397
|
+
break;
|
|
398
|
+
case "outdated":
|
|
399
|
+
if (options.update) {
|
|
400
|
+
if (!options.dryRun) {
|
|
401
|
+
writeFile(filepath, content);
|
|
402
|
+
}
|
|
403
|
+
result.updated++;
|
|
404
|
+
} else {
|
|
405
|
+
result.outdated++;
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
displayScaffoldSummary(result, target, options.dryRun === true);
|
|
411
|
+
}
|
|
412
|
+
async function scaffoldSkills(target, options) {
|
|
413
|
+
const config = TARGETS[target];
|
|
414
|
+
if (!config.supportsSkills) {
|
|
415
|
+
console.error(colors.error(`
|
|
416
|
+
${config.name} does not support skills.`));
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const isProject = options.project === true;
|
|
420
|
+
const targetPath = getSkillPath(target, isProject);
|
|
421
|
+
console.log(colors.bold(`
|
|
422
|
+
Scaffolding SpecForge skills for ${config.name}`));
|
|
423
|
+
console.log(`Target: ${colors.primary(targetPath)}
|
|
424
|
+
`);
|
|
425
|
+
if (options.dryRun) {
|
|
426
|
+
console.log(colors.warning("DRY RUN - No files will be written\n"));
|
|
427
|
+
}
|
|
428
|
+
const skillName = "specforge-conventions";
|
|
429
|
+
const skillDir = path.join(targetPath, skillName);
|
|
430
|
+
const skillFile = path.join(skillDir, "SKILL.md");
|
|
431
|
+
const { fileURLToPath } = await import("url");
|
|
432
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
433
|
+
const __dirname = path.dirname(__filename);
|
|
434
|
+
const packageRoot = path.resolve(__dirname, "..", "..", "..");
|
|
435
|
+
const templatePath = path.join(packageRoot, "src", "cli", "templates", "skills", "specforge-conventions.md");
|
|
436
|
+
if (!fs.existsSync(templatePath)) {
|
|
437
|
+
console.log(colors.warning("Skill template not found. Skipping."));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const templateContent = fs.readFileSync(templatePath, "utf-8");
|
|
441
|
+
const comparison = compareFiles(skillFile, templateContent);
|
|
442
|
+
displayFileOperation(`${skillName}/SKILL.md`, comparison.status, options.dryRun === true, options.update === true);
|
|
443
|
+
if (!options.dryRun) {
|
|
444
|
+
if (comparison.status === "new" || comparison.status === "outdated" && options.update) {
|
|
445
|
+
ensureDirectory(skillDir);
|
|
446
|
+
writeFile(skillFile, templateContent);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const created = comparison.status === "new" ? 1 : 0;
|
|
450
|
+
const updated = comparison.status === "outdated" && options.update ? 1 : 0;
|
|
451
|
+
const skipped = comparison.status === "identical" ? 1 : 0;
|
|
452
|
+
const outdated = comparison.status === "outdated" && !options.update ? 1 : 0;
|
|
453
|
+
console.log();
|
|
454
|
+
if (created > 0) console.log(colors.success(`\u2713 Created ${created} skill(s)`));
|
|
455
|
+
if (updated > 0) console.log(colors.secondary(`\u2713 Updated ${updated} skill(s)`));
|
|
456
|
+
if (skipped > 0) console.log(colors.dim(`\u25CB Skipped ${skipped} up-to-date skill(s)`));
|
|
457
|
+
if (outdated > 0) console.log(colors.warning(`\u26A0 ${outdated} outdated skill(s) (run with --update to update)`));
|
|
458
|
+
console.log();
|
|
459
|
+
}
|
|
460
|
+
async function scaffoldAgents(target, options) {
|
|
461
|
+
const config = TARGETS[target];
|
|
462
|
+
if (target === "codex") {
|
|
463
|
+
console.log(colors.warning("\nCodex CLI uses TOML agent roles, not markdown agent files."));
|
|
464
|
+
console.log(colors.dim("Agent scaffolding is not available for Codex. Configure roles in .codex/config.toml instead.\n"));
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const isProject = options.project === true;
|
|
468
|
+
const targetPath = getAgentPath(target, isProject);
|
|
469
|
+
let templates = getAgentTemplates();
|
|
470
|
+
if (options.category) {
|
|
471
|
+
const categoryLower = options.category.toLowerCase();
|
|
472
|
+
templates = templates.filter((t) => t.category.toLowerCase() === categoryLower);
|
|
473
|
+
if (templates.length === 0) {
|
|
474
|
+
console.error(colors.error(`
|
|
475
|
+
No agents found in category "${options.category}"`));
|
|
476
|
+
console.error(colors.dim(`Available categories: Orchestration, SpecForge, Research`));
|
|
477
|
+
process.exit(1);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
displayAgentScaffoldHeader(target, targetPath, options.dryRun === true);
|
|
482
|
+
if (target === "gemini") {
|
|
483
|
+
console.log(colors.warning("Note: Gemini CLI agents require experimental.enableAgents: true in .gemini/settings.json\n"));
|
|
484
|
+
}
|
|
485
|
+
if (!options.dryRun) {
|
|
486
|
+
ensureDirectory(targetPath);
|
|
487
|
+
}
|
|
488
|
+
const result = {
|
|
489
|
+
created: 0,
|
|
490
|
+
updated: 0,
|
|
491
|
+
skipped: 0,
|
|
492
|
+
outdated: 0,
|
|
493
|
+
targetPath
|
|
494
|
+
};
|
|
495
|
+
for (const template of templates) {
|
|
496
|
+
const filename = getAgentFilename(template.name, target);
|
|
497
|
+
const filepath = path.join(targetPath, filename);
|
|
498
|
+
const content = generateAgentContent(template, config.agentFrontmatter, target);
|
|
499
|
+
const comparison = compareFiles(filepath, content);
|
|
500
|
+
displayFileOperation(filename, comparison.status, options.dryRun === true, options.update === true);
|
|
501
|
+
if (options.diff && comparison.status === "outdated" && comparison.existingContent) {
|
|
502
|
+
const diff = generateDiff(comparison.existingContent, content, filename);
|
|
503
|
+
displayDiff(diff);
|
|
504
|
+
}
|
|
505
|
+
switch (comparison.status) {
|
|
506
|
+
case "new":
|
|
507
|
+
if (!options.dryRun) {
|
|
508
|
+
writeFile(filepath, content);
|
|
509
|
+
}
|
|
510
|
+
result.created++;
|
|
511
|
+
break;
|
|
512
|
+
case "identical":
|
|
513
|
+
result.skipped++;
|
|
514
|
+
break;
|
|
515
|
+
case "outdated":
|
|
516
|
+
if (options.update) {
|
|
517
|
+
if (!options.dryRun) {
|
|
518
|
+
writeFile(filepath, content);
|
|
519
|
+
}
|
|
520
|
+
result.updated++;
|
|
521
|
+
} else {
|
|
522
|
+
result.outdated++;
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
if (target === "claude" && isProject && template.memory === "project" && !options.dryRun) {
|
|
527
|
+
const claudeDir = path.dirname(targetPath);
|
|
528
|
+
const agentMemoryDir = path.join(claudeDir, "agent-memory", template.name);
|
|
529
|
+
ensureDirectory(agentMemoryDir);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
displayAgentScaffoldSummary(result, target, options.dryRun === true);
|
|
533
|
+
}
|
|
534
|
+
function renderWriteResult(w) {
|
|
535
|
+
const action = w.action;
|
|
536
|
+
switch (action) {
|
|
537
|
+
case "created":
|
|
538
|
+
console.log(colors.success(` + ${w.relPath} (created)`));
|
|
539
|
+
break;
|
|
540
|
+
case "overwrote":
|
|
541
|
+
console.log(colors.secondary(` \u21BB ${w.relPath} (overwrote)`));
|
|
542
|
+
break;
|
|
543
|
+
case "skipped":
|
|
544
|
+
console.log(colors.dim(` \u25CB ${w.relPath} (exists, skip \u2014 use --force)`));
|
|
545
|
+
break;
|
|
546
|
+
case "would-create":
|
|
547
|
+
console.log(colors.success(` + ${w.relPath} (would create)`));
|
|
548
|
+
break;
|
|
549
|
+
case "would-overwrite":
|
|
550
|
+
console.log(colors.secondary(` \u21BB ${w.relPath} (would overwrite)`));
|
|
551
|
+
break;
|
|
552
|
+
case "would-skip":
|
|
553
|
+
console.log(colors.dim(` \u25CB ${w.relPath} (exists, skip \u2014 use --force)`));
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function runMultiCli(label, subset, targets, options) {
|
|
558
|
+
const apiKey = loadGlobalConfig().apiKey;
|
|
559
|
+
const { detected, writes } = scaffoldMultiCli({
|
|
560
|
+
targets,
|
|
561
|
+
dryRun: options.dryRun === true,
|
|
562
|
+
force: options.force === true,
|
|
563
|
+
apiKey,
|
|
564
|
+
skipConfigs: !subset.configs,
|
|
565
|
+
skipInstructions: !subset.instructions,
|
|
566
|
+
skipSkills: !subset.skills
|
|
567
|
+
});
|
|
568
|
+
console.log(colors.bold(`
|
|
569
|
+
Scaffolding SpecForge ${label}`));
|
|
570
|
+
if (detected.length > 0) {
|
|
571
|
+
console.log(colors.dim(`Detected: ${detected.map((t) => TARGETS[t].name).join(", ")}`));
|
|
572
|
+
}
|
|
573
|
+
if (options.dryRun) {
|
|
574
|
+
console.log(colors.warning("\nDRY RUN \u2014 no files will be written"));
|
|
575
|
+
}
|
|
576
|
+
console.log();
|
|
577
|
+
for (const w of writes) {
|
|
578
|
+
renderWriteResult(w);
|
|
579
|
+
}
|
|
580
|
+
console.log();
|
|
581
|
+
return writes;
|
|
582
|
+
}
|
|
583
|
+
async function scaffoldCommand(options) {
|
|
584
|
+
if (options.target) {
|
|
585
|
+
options.target = resolveTargetAlias(options.target);
|
|
586
|
+
}
|
|
587
|
+
const isAgentMode = options.agents === true;
|
|
588
|
+
const isSkillMode = options.skills === true;
|
|
589
|
+
const isCommandMode = options.commands === true;
|
|
590
|
+
const isConfigsMode = options.configs === true;
|
|
591
|
+
const isInstructionsMode = options.instructions === true;
|
|
592
|
+
const anySubset = isAgentMode || isSkillMode || isCommandMode || isConfigsMode || isInstructionsMode;
|
|
593
|
+
const mode = isAgentMode ? "agent" : isSkillMode ? "skill" : "command";
|
|
594
|
+
if (options.list) {
|
|
595
|
+
if (isAgentMode) {
|
|
596
|
+
const templates = getAgentTemplates();
|
|
597
|
+
displayAgentList(templates, options.category);
|
|
598
|
+
} else {
|
|
599
|
+
const templates = getCommandTemplates();
|
|
600
|
+
displayCommandList(templates);
|
|
601
|
+
}
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
if (typeof options.preview === "string") {
|
|
605
|
+
if (isAgentMode) {
|
|
606
|
+
const templates = getAgentTemplates();
|
|
607
|
+
const template = templates.find((t) => t.name === options.preview);
|
|
608
|
+
if (!template) {
|
|
609
|
+
console.error(colors.error(`
|
|
610
|
+
Error: Unknown agent "${options.preview}"`));
|
|
611
|
+
console.error(`Run 'specforge scaffold --agents --list' to see available agents`);
|
|
612
|
+
process.exit(1);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const content = generateAgentContent(template, true);
|
|
616
|
+
displayAgentPreview(template.name, content, template.model);
|
|
617
|
+
} else {
|
|
618
|
+
const templates = getCommandTemplates();
|
|
619
|
+
const template = templates.find((t) => t.name === options.preview);
|
|
620
|
+
if (!template) {
|
|
621
|
+
console.error(colors.error(`
|
|
622
|
+
Error: Unknown command "${options.preview}"`));
|
|
623
|
+
console.error(`Run 'specforge scaffold --list' to see available commands`);
|
|
624
|
+
process.exit(1);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const content = generateCommandContent(template, true, "claude");
|
|
628
|
+
displayCommandPreview(template.name, content);
|
|
629
|
+
}
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (options.preview === true) {
|
|
633
|
+
let target2;
|
|
634
|
+
if (options.target && isValidTarget(options.target)) {
|
|
635
|
+
target2 = options.target;
|
|
636
|
+
} else {
|
|
637
|
+
target2 = await selectTarget(mode);
|
|
638
|
+
}
|
|
639
|
+
if (isAgentMode && !TARGETS[target2].supportsAgents) {
|
|
640
|
+
displayAgentTargetError(target2, getAgentSupportedTargets());
|
|
641
|
+
process.exit(1);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (isAgentMode) {
|
|
645
|
+
await interactiveAgentPreview(target2);
|
|
646
|
+
} else {
|
|
647
|
+
await interactivePreview(target2);
|
|
648
|
+
}
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (options.diff && !options.update) {
|
|
652
|
+
let target2;
|
|
653
|
+
if (options.target && isValidTarget(options.target)) {
|
|
654
|
+
target2 = options.target;
|
|
655
|
+
} else {
|
|
656
|
+
target2 = await selectTarget(mode);
|
|
657
|
+
}
|
|
658
|
+
if (isAgentMode && !TARGETS[target2].supportsAgents) {
|
|
659
|
+
displayAgentTargetError(target2, getAgentSupportedTargets());
|
|
660
|
+
process.exit(1);
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
if (isAgentMode) {
|
|
664
|
+
await interactiveAgentDiff(target2);
|
|
665
|
+
} else {
|
|
666
|
+
await interactiveDiff(target2);
|
|
667
|
+
}
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
let scopedTargets;
|
|
671
|
+
if (options.target) {
|
|
672
|
+
if (!isValidTarget(options.target)) {
|
|
673
|
+
displayTargetError(options.target, getSupportedTargets());
|
|
674
|
+
process.exit(1);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
scopedTargets = [options.target];
|
|
678
|
+
}
|
|
679
|
+
if (isConfigsMode && !isInstructionsMode && !isSkillMode && !isCommandMode && !isAgentMode) {
|
|
680
|
+
runMultiCli("MCP configs", { configs: true, instructions: false, skills: false }, scopedTargets, options);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (isInstructionsMode && !isConfigsMode && !isSkillMode && !isCommandMode && !isAgentMode) {
|
|
684
|
+
runMultiCli("instruction files", { configs: false, instructions: true, skills: false }, scopedTargets, options);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (!anySubset) {
|
|
688
|
+
const writes = runMultiCli(
|
|
689
|
+
"integration artifacts",
|
|
690
|
+
{ configs: true, instructions: true, skills: true },
|
|
691
|
+
scopedTargets,
|
|
692
|
+
options
|
|
693
|
+
);
|
|
694
|
+
const targetSet = scopedTargets ?? detectInstalledTools();
|
|
695
|
+
for (const t of targetSet) {
|
|
696
|
+
if (TARGETS[t].supportsCommands) {
|
|
697
|
+
await scaffoldCommands(t, options);
|
|
698
|
+
}
|
|
699
|
+
if (TARGETS[t].supportsAgents && t !== "codex") {
|
|
700
|
+
await scaffoldAgents(t, options);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
void writes;
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
let target;
|
|
707
|
+
if (options.target) {
|
|
708
|
+
target = options.target;
|
|
709
|
+
} else {
|
|
710
|
+
target = await selectTarget(mode);
|
|
711
|
+
}
|
|
712
|
+
if (isAgentMode && !TARGETS[target].supportsAgents && target !== "codex") {
|
|
713
|
+
displayAgentTargetError(target, getAgentSupportedTargets());
|
|
714
|
+
process.exit(1);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (isAgentMode) {
|
|
718
|
+
await scaffoldAgents(target, options);
|
|
719
|
+
} else if (isSkillMode) {
|
|
720
|
+
await scaffoldSkills(target, options);
|
|
721
|
+
} else {
|
|
722
|
+
await scaffoldCommands(target, options);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
export {
|
|
726
|
+
scaffoldCommand
|
|
727
|
+
};
|
|
728
|
+
//# sourceMappingURL=scaffold.js.map
|