From 53482cb0c8748c72b6bf4ed97dea73edc3540cdd Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 18 Mar 2026 14:03:06 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20workspace=20templates=20via=20Extract?= =?UTF-8?q?=20=E2=80=94=20Gosod=20pattern=20for=20agent=20dispatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move pkg/prompts/lib → pkg/lib (prompt, task, flow, persona, workspace) - New lib.go: unified package with ExtractWorkspace() using text/template - Workspace templates: default, security, review — .tmpl files with data injection - prep.go: uses lib.ExtractWorkspace() + detect helpers for language/build/test - prompts.go: thin re-export wrapper for backwards compat Co-Authored-By: Virgil --- pkg/agentic/prep.go | 109 +++++++-- pkg/{prompts => }/lib/flow/cpp.md | 0 pkg/{prompts => }/lib/flow/docker.md | 0 pkg/{prompts => }/lib/flow/git.md | 0 pkg/{prompts => }/lib/flow/go.md | 0 pkg/{prompts => }/lib/flow/npm.md | 0 pkg/{prompts => }/lib/flow/php.md | 0 .../lib/flow/prod-push-polish.md | 0 pkg/{prompts => }/lib/flow/py.md | 0 pkg/{prompts => }/lib/flow/release.md | 0 pkg/{prompts => }/lib/flow/ts.md | 0 pkg/lib/lib.go | 229 ++++++++++++++++++ pkg/{prompts => }/lib/persona/ads/auditor.md | 0 .../lib/persona/ads/creative-strategist.md | 0 .../lib/persona/ads/paid-social-strategist.md | 0 .../lib/persona/ads/ppc-strategist.md | 0 .../lib/persona/ads/programmatic-buyer.md | 0 .../lib/persona/ads/search-query-analyst.md | 0 .../lib/persona/ads/tracking-specialist.md | 0 .../blockchain/identity-graph-operator.md | 0 .../lib/persona/blockchain/identity-trust.md | 0 .../persona/blockchain/security-auditor.md | 0 .../lib/persona/blockchain/zk-steward.md | 0 .../lib/persona/code/agents-orchestrator.md | 0 .../lib/persona/code/ai-engineer.md | 0 .../code/autonomous-optimization-architect.md | 0 .../lib/persona/code/backend-architect.md | 0 .../lib/persona/code/data-engineer.md | 0 .../lib/persona/code/developer-advocate.md | 0 .../lib/persona/code/frontend-developer.md | 0 .../lib/persona/code/lsp-index-engineer.md | 0 .../lib/persona/code/rapid-prototyper.md | 0 .../lib/persona/code/senior-developer.md | 0 .../lib/persona/code/technical-writer.md | 0 .../lib/persona/design/brand-guardian.md | 0 .../persona/design/image-prompt-engineer.md | 0 .../design/inclusive-visuals-specialist.md | 0 .../lib/persona/design/security-developer.md | 0 .../lib/persona/design/ui-designer.md | 0 .../lib/persona/design/ux-architect.md | 0 .../lib/persona/design/ux-researcher.md | 0 .../lib/persona/design/visual-storyteller.md | 0 .../lib/persona/design/whimsy-injector.md | 0 .../lib/persona/devops/automator.md | 0 .../lib/persona/devops/junior.md | 0 .../lib/persona/devops/security-developer.md | 0 .../lib/persona/devops/senior.md | 0 .../lib/persona/plan/EXECUTIVE-BRIEF.md | 0 .../lib/persona/plan/QUICKSTART.md | 0 .../coordination/agent-activation-prompts.md | 0 .../plan/coordination/handoff-templates.md | 0 .../lib/persona/plan/experiment-tracker.md | 0 .../lib/persona/plan/nexus-strategy.md | 0 .../plan/playbooks/phase-0-discovery.md | 0 .../plan/playbooks/phase-1-strategy.md | 0 .../plan/playbooks/phase-2-foundation.md | 0 .../persona/plan/playbooks/phase-3-build.md | 0 .../plan/playbooks/phase-4-hardening.md | 0 .../persona/plan/playbooks/phase-5-launch.md | 0 .../persona/plan/playbooks/phase-6-operate.md | 0 .../lib/persona/plan/project-shepherd.md | 0 .../runbooks/scenario-enterprise-feature.md | 0 .../runbooks/scenario-incident-response.md | 0 .../runbooks/scenario-marketing-campaign.md | 0 .../plan/runbooks/scenario-startup-mvp.md | 0 pkg/{prompts => }/lib/persona/plan/senior.md | 0 .../lib/persona/plan/studio-operations.md | 0 .../lib/persona/plan/studio-producer.md | 0 .../product/behavioral-nudge-engine.md | 0 .../persona/product/feedback-synthesizer.md | 0 .../lib/persona/product/security-developer.md | 0 .../lib/persona/product/sprint-prioritizer.md | 0 .../lib/persona/product/trend-researcher.md | 0 .../lib/persona/sales/account-strategist.md | 0 pkg/{prompts => }/lib/persona/sales/coach.md | 0 .../lib/persona/sales/deal-strategist.md | 0 .../lib/persona/sales/discovery-coach.md | 0 .../lib/persona/sales/engineer.md | 0 .../lib/persona/sales/outbound-strategist.md | 0 .../lib/persona/sales/pipeline-analyst.md | 0 .../lib/persona/sales/proposal-strategist.md | 0 .../lib/persona/secops/architect.md | 0 .../lib/persona/secops/developer.md | 0 .../lib/persona/secops/devops.md | 0 .../lib/persona/secops/incident-commander.md | 0 .../lib/persona/secops/junior.md | 0 .../lib/persona/secops/operations.md | 0 .../lib/persona/secops/senior.md | 0 .../lib/persona/smm/carousel-growth-engine.md | 0 .../lib/persona/smm/content-creator.md | 0 .../lib/persona/smm/cultural-intelligence.md | 0 .../lib/persona/smm/growth-hacker.md | 0 .../lib/persona/smm/instagram-curator.md | 0 .../persona/smm/linkedin-content-creator.md | 0 .../persona/smm/reddit-community-builder.md | 0 .../lib/persona/smm/security-developer.md | 0 .../lib/persona/smm/security-secops.md | 0 .../lib/persona/smm/seo-specialist.md | 0 .../persona/smm/social-media-strategist.md | 0 .../lib/persona/smm/tiktok-strategist.md | 0 .../lib/persona/smm/twitter-engager.md | 0 .../spatial/macos-spatial-metal-engineer.md | 0 .../terminal-integration-specialist.md | 0 .../lib/persona/support/accounts-payable.md | 0 .../lib/persona/support/analytics-reporter.md | 0 .../lib/persona/support/compliance-auditor.md | 0 .../support/executive-summary-generator.md | 0 .../lib/persona/support/finance-tracker.md | 0 .../support/infrastructure-maintainer.md | 0 .../support/legal-compliance-checker.md | 0 .../lib/persona/support/responder.md | 0 .../lib/persona/support/security-developer.md | 0 .../lib/persona/support/security-secops.md | 0 .../persona/testing/accessibility-auditor.md | 0 .../lib/persona/testing/api-tester.md | 0 .../lib/persona/testing/evidence-collector.md | 0 .../lib/persona/testing/model-qa.md | 0 .../testing/performance-benchmarker.md | 0 .../lib/persona/testing/reality-checker.md | 0 .../lib/persona/testing/security-developer.md | 0 .../persona/testing/test-results-analyzer.md | 0 .../lib/persona/testing/tool-evaluator.md | 0 .../lib/persona/testing/workflow-optimizer.md | 0 pkg/{prompts => }/lib/prompt/coding.md | 0 pkg/{prompts => }/lib/prompt/conventions.md | 0 pkg/{prompts => }/lib/prompt/default.md | 0 pkg/{prompts => }/lib/prompt/security.md | 0 pkg/{prompts => }/lib/prompt/verify.md | 0 .../lib/task/api-consistency.yaml | 0 pkg/{prompts => }/lib/task/bug-fix.yaml | 0 pkg/{prompts => }/lib/task/code/dead-code.md | 0 pkg/{prompts => }/lib/task/code/refactor.md | 0 pkg/{prompts => }/lib/task/code/review.md | 0 .../lib/task/code/review/conventions.md | 0 .../lib/task/code/review/plan.yaml | 0 .../lib/task/code/review/severity.md | 0 pkg/{prompts => }/lib/task/code/simplifier.md | 0 .../lib/task/code/simplifier/patterns.md | 0 pkg/{prompts => }/lib/task/code/test-gaps.md | 0 .../lib/task/dependency-audit.yaml | 0 pkg/{prompts => }/lib/task/doc-sync.yaml | 0 pkg/{prompts => }/lib/task/feature-port.yaml | 0 pkg/{prompts => }/lib/task/new-feature.yaml | 0 pkg/lib/workspace/default/.gitignore | 4 + pkg/lib/workspace/default/CLAUDE.md.tmpl | 25 ++ pkg/lib/workspace/default/CONTEXT.md.tmpl | 13 + pkg/lib/workspace/default/PROMPT.md.tmpl | 11 + pkg/lib/workspace/default/TODO.md.tmpl | 14 ++ pkg/lib/workspace/review/CLAUDE.md.tmpl | 24 ++ pkg/lib/workspace/review/REVIEW.md.tmpl | 16 ++ pkg/lib/workspace/security/CLAUDE.md.tmpl | 22 ++ pkg/lib/workspace/security/FINDINGS.md.tmpl | 13 + pkg/lib/workspace/security/TODO.md.tmpl | 13 + pkg/prompts/prompts.go | 196 ++------------- 154 files changed, 491 insertions(+), 198 deletions(-) rename pkg/{prompts => }/lib/flow/cpp.md (100%) rename pkg/{prompts => }/lib/flow/docker.md (100%) rename pkg/{prompts => }/lib/flow/git.md (100%) rename pkg/{prompts => }/lib/flow/go.md (100%) rename pkg/{prompts => }/lib/flow/npm.md (100%) rename pkg/{prompts => }/lib/flow/php.md (100%) rename pkg/{prompts => }/lib/flow/prod-push-polish.md (100%) rename pkg/{prompts => }/lib/flow/py.md (100%) rename pkg/{prompts => }/lib/flow/release.md (100%) rename pkg/{prompts => }/lib/flow/ts.md (100%) create mode 100644 pkg/lib/lib.go rename pkg/{prompts => }/lib/persona/ads/auditor.md (100%) rename pkg/{prompts => }/lib/persona/ads/creative-strategist.md (100%) rename pkg/{prompts => }/lib/persona/ads/paid-social-strategist.md (100%) rename pkg/{prompts => }/lib/persona/ads/ppc-strategist.md (100%) rename pkg/{prompts => }/lib/persona/ads/programmatic-buyer.md (100%) rename pkg/{prompts => }/lib/persona/ads/search-query-analyst.md (100%) rename pkg/{prompts => }/lib/persona/ads/tracking-specialist.md (100%) rename pkg/{prompts => }/lib/persona/blockchain/identity-graph-operator.md (100%) rename pkg/{prompts => }/lib/persona/blockchain/identity-trust.md (100%) rename pkg/{prompts => }/lib/persona/blockchain/security-auditor.md (100%) rename pkg/{prompts => }/lib/persona/blockchain/zk-steward.md (100%) rename pkg/{prompts => }/lib/persona/code/agents-orchestrator.md (100%) rename pkg/{prompts => }/lib/persona/code/ai-engineer.md (100%) rename pkg/{prompts => }/lib/persona/code/autonomous-optimization-architect.md (100%) rename pkg/{prompts => }/lib/persona/code/backend-architect.md (100%) rename pkg/{prompts => }/lib/persona/code/data-engineer.md (100%) rename pkg/{prompts => }/lib/persona/code/developer-advocate.md (100%) rename pkg/{prompts => }/lib/persona/code/frontend-developer.md (100%) rename pkg/{prompts => }/lib/persona/code/lsp-index-engineer.md (100%) rename pkg/{prompts => }/lib/persona/code/rapid-prototyper.md (100%) rename pkg/{prompts => }/lib/persona/code/senior-developer.md (100%) rename pkg/{prompts => }/lib/persona/code/technical-writer.md (100%) rename pkg/{prompts => }/lib/persona/design/brand-guardian.md (100%) rename pkg/{prompts => }/lib/persona/design/image-prompt-engineer.md (100%) rename pkg/{prompts => }/lib/persona/design/inclusive-visuals-specialist.md (100%) rename pkg/{prompts => }/lib/persona/design/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/design/ui-designer.md (100%) rename pkg/{prompts => }/lib/persona/design/ux-architect.md (100%) rename pkg/{prompts => }/lib/persona/design/ux-researcher.md (100%) rename pkg/{prompts => }/lib/persona/design/visual-storyteller.md (100%) rename pkg/{prompts => }/lib/persona/design/whimsy-injector.md (100%) rename pkg/{prompts => }/lib/persona/devops/automator.md (100%) rename pkg/{prompts => }/lib/persona/devops/junior.md (100%) rename pkg/{prompts => }/lib/persona/devops/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/devops/senior.md (100%) rename pkg/{prompts => }/lib/persona/plan/EXECUTIVE-BRIEF.md (100%) rename pkg/{prompts => }/lib/persona/plan/QUICKSTART.md (100%) rename pkg/{prompts => }/lib/persona/plan/coordination/agent-activation-prompts.md (100%) rename pkg/{prompts => }/lib/persona/plan/coordination/handoff-templates.md (100%) rename pkg/{prompts => }/lib/persona/plan/experiment-tracker.md (100%) rename pkg/{prompts => }/lib/persona/plan/nexus-strategy.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-0-discovery.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-1-strategy.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-2-foundation.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-3-build.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-4-hardening.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-5-launch.md (100%) rename pkg/{prompts => }/lib/persona/plan/playbooks/phase-6-operate.md (100%) rename pkg/{prompts => }/lib/persona/plan/project-shepherd.md (100%) rename pkg/{prompts => }/lib/persona/plan/runbooks/scenario-enterprise-feature.md (100%) rename pkg/{prompts => }/lib/persona/plan/runbooks/scenario-incident-response.md (100%) rename pkg/{prompts => }/lib/persona/plan/runbooks/scenario-marketing-campaign.md (100%) rename pkg/{prompts => }/lib/persona/plan/runbooks/scenario-startup-mvp.md (100%) rename pkg/{prompts => }/lib/persona/plan/senior.md (100%) rename pkg/{prompts => }/lib/persona/plan/studio-operations.md (100%) rename pkg/{prompts => }/lib/persona/plan/studio-producer.md (100%) rename pkg/{prompts => }/lib/persona/product/behavioral-nudge-engine.md (100%) rename pkg/{prompts => }/lib/persona/product/feedback-synthesizer.md (100%) rename pkg/{prompts => }/lib/persona/product/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/product/sprint-prioritizer.md (100%) rename pkg/{prompts => }/lib/persona/product/trend-researcher.md (100%) rename pkg/{prompts => }/lib/persona/sales/account-strategist.md (100%) rename pkg/{prompts => }/lib/persona/sales/coach.md (100%) rename pkg/{prompts => }/lib/persona/sales/deal-strategist.md (100%) rename pkg/{prompts => }/lib/persona/sales/discovery-coach.md (100%) rename pkg/{prompts => }/lib/persona/sales/engineer.md (100%) rename pkg/{prompts => }/lib/persona/sales/outbound-strategist.md (100%) rename pkg/{prompts => }/lib/persona/sales/pipeline-analyst.md (100%) rename pkg/{prompts => }/lib/persona/sales/proposal-strategist.md (100%) rename pkg/{prompts => }/lib/persona/secops/architect.md (100%) rename pkg/{prompts => }/lib/persona/secops/developer.md (100%) rename pkg/{prompts => }/lib/persona/secops/devops.md (100%) rename pkg/{prompts => }/lib/persona/secops/incident-commander.md (100%) rename pkg/{prompts => }/lib/persona/secops/junior.md (100%) rename pkg/{prompts => }/lib/persona/secops/operations.md (100%) rename pkg/{prompts => }/lib/persona/secops/senior.md (100%) rename pkg/{prompts => }/lib/persona/smm/carousel-growth-engine.md (100%) rename pkg/{prompts => }/lib/persona/smm/content-creator.md (100%) rename pkg/{prompts => }/lib/persona/smm/cultural-intelligence.md (100%) rename pkg/{prompts => }/lib/persona/smm/growth-hacker.md (100%) rename pkg/{prompts => }/lib/persona/smm/instagram-curator.md (100%) rename pkg/{prompts => }/lib/persona/smm/linkedin-content-creator.md (100%) rename pkg/{prompts => }/lib/persona/smm/reddit-community-builder.md (100%) rename pkg/{prompts => }/lib/persona/smm/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/smm/security-secops.md (100%) rename pkg/{prompts => }/lib/persona/smm/seo-specialist.md (100%) rename pkg/{prompts => }/lib/persona/smm/social-media-strategist.md (100%) rename pkg/{prompts => }/lib/persona/smm/tiktok-strategist.md (100%) rename pkg/{prompts => }/lib/persona/smm/twitter-engager.md (100%) rename pkg/{prompts => }/lib/persona/spatial/macos-spatial-metal-engineer.md (100%) rename pkg/{prompts => }/lib/persona/spatial/terminal-integration-specialist.md (100%) rename pkg/{prompts => }/lib/persona/support/accounts-payable.md (100%) rename pkg/{prompts => }/lib/persona/support/analytics-reporter.md (100%) rename pkg/{prompts => }/lib/persona/support/compliance-auditor.md (100%) rename pkg/{prompts => }/lib/persona/support/executive-summary-generator.md (100%) rename pkg/{prompts => }/lib/persona/support/finance-tracker.md (100%) rename pkg/{prompts => }/lib/persona/support/infrastructure-maintainer.md (100%) rename pkg/{prompts => }/lib/persona/support/legal-compliance-checker.md (100%) rename pkg/{prompts => }/lib/persona/support/responder.md (100%) rename pkg/{prompts => }/lib/persona/support/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/support/security-secops.md (100%) rename pkg/{prompts => }/lib/persona/testing/accessibility-auditor.md (100%) rename pkg/{prompts => }/lib/persona/testing/api-tester.md (100%) rename pkg/{prompts => }/lib/persona/testing/evidence-collector.md (100%) rename pkg/{prompts => }/lib/persona/testing/model-qa.md (100%) rename pkg/{prompts => }/lib/persona/testing/performance-benchmarker.md (100%) rename pkg/{prompts => }/lib/persona/testing/reality-checker.md (100%) rename pkg/{prompts => }/lib/persona/testing/security-developer.md (100%) rename pkg/{prompts => }/lib/persona/testing/test-results-analyzer.md (100%) rename pkg/{prompts => }/lib/persona/testing/tool-evaluator.md (100%) rename pkg/{prompts => }/lib/persona/testing/workflow-optimizer.md (100%) rename pkg/{prompts => }/lib/prompt/coding.md (100%) rename pkg/{prompts => }/lib/prompt/conventions.md (100%) rename pkg/{prompts => }/lib/prompt/default.md (100%) rename pkg/{prompts => }/lib/prompt/security.md (100%) rename pkg/{prompts => }/lib/prompt/verify.md (100%) rename pkg/{prompts => }/lib/task/api-consistency.yaml (100%) rename pkg/{prompts => }/lib/task/bug-fix.yaml (100%) rename pkg/{prompts => }/lib/task/code/dead-code.md (100%) rename pkg/{prompts => }/lib/task/code/refactor.md (100%) rename pkg/{prompts => }/lib/task/code/review.md (100%) rename pkg/{prompts => }/lib/task/code/review/conventions.md (100%) rename pkg/{prompts => }/lib/task/code/review/plan.yaml (100%) rename pkg/{prompts => }/lib/task/code/review/severity.md (100%) rename pkg/{prompts => }/lib/task/code/simplifier.md (100%) rename pkg/{prompts => }/lib/task/code/simplifier/patterns.md (100%) rename pkg/{prompts => }/lib/task/code/test-gaps.md (100%) rename pkg/{prompts => }/lib/task/dependency-audit.yaml (100%) rename pkg/{prompts => }/lib/task/doc-sync.yaml (100%) rename pkg/{prompts => }/lib/task/feature-port.yaml (100%) rename pkg/{prompts => }/lib/task/new-feature.yaml (100%) create mode 100644 pkg/lib/workspace/default/.gitignore create mode 100644 pkg/lib/workspace/default/CLAUDE.md.tmpl create mode 100644 pkg/lib/workspace/default/CONTEXT.md.tmpl create mode 100644 pkg/lib/workspace/default/PROMPT.md.tmpl create mode 100644 pkg/lib/workspace/default/TODO.md.tmpl create mode 100644 pkg/lib/workspace/review/CLAUDE.md.tmpl create mode 100644 pkg/lib/workspace/review/REVIEW.md.tmpl create mode 100644 pkg/lib/workspace/security/CLAUDE.md.tmpl create mode 100644 pkg/lib/workspace/security/FINDINGS.md.tmpl create mode 100644 pkg/lib/workspace/security/TODO.md.tmpl diff --git a/pkg/agentic/prep.go b/pkg/agentic/prep.go index 389f722..0b8b0d6 100644 --- a/pkg/agentic/prep.go +++ b/pkg/agentic/prep.go @@ -17,6 +17,7 @@ import ( "strings" "time" + "forge.lthn.ai/core/agent/pkg/lib" "forge.lthn.ai/core/agent/pkg/prompts" coreio "forge.lthn.ai/core/go-io" coreerr "forge.lthn.ai/core/go-log" @@ -200,32 +201,51 @@ func (s *PrepSubsystem) prepWorkspace(ctx context.Context, _ *mcp.CallToolReques // Remote stays as local clone origin — agent cannot push to forge. // Reviewer pulls changes from workspace and pushes after verification. - // 2. Copy CLAUDE.md and GEMINI.md to workspace + // 2. Extract workspace template + wsTmpl := "default" + if input.Template == "security" { + wsTmpl = "security" + } else if input.Template == "verify" || input.Template == "conventions" { + wsTmpl = "review" + } + + promptContent, _ := prompts.Prompt(input.Template) + personaContent := "" + if input.Persona != "" { + personaContent, _ = prompts.Persona(input.Persona) + } + flowContent, _ := prompts.Flow(detectLanguage(repoPath)) + + wsData := &lib.WorkspaceData{ + Repo: input.Repo, + Branch: branchName, + Task: input.Task, + Agent: "agent", + Language: detectLanguage(repoPath), + Prompt: promptContent, + Persona: personaContent, + Flow: flowContent, + BuildCmd: detectBuildCmd(repoPath), + TestCmd: detectTestCmd(repoPath), + } + + lib.ExtractWorkspace(wsTmpl, srcDir, wsData) + out.ClaudeMd = true + + // Copy repo's own CLAUDE.md over template if it exists claudeMdPath := filepath.Join(repoPath, "CLAUDE.md") if data, err := coreio.Local.Read(claudeMdPath); err == nil { - coreio.Local.Write(filepath.Join(wsDir, "src", "CLAUDE.md"), data) - out.ClaudeMd = true + coreio.Local.Write(filepath.Join(srcDir, "CLAUDE.md"), data) } // Copy GEMINI.md from core/agent (ethics framework for all agents) agentGeminiMd := filepath.Join(s.codePath, "core", "agent", "GEMINI.md") if data, err := coreio.Local.Read(agentGeminiMd); err == nil { - coreio.Local.Write(filepath.Join(wsDir, "src", "GEMINI.md"), data) + coreio.Local.Write(filepath.Join(srcDir, "GEMINI.md"), data) } - // Copy persona if specified - if input.Persona != "" { - if data, err := prompts.Persona(input.Persona); err == nil { - coreio.Local.Write(filepath.Join(wsDir, "src", "PERSONA.md"), data) - } - } - - // 3. Generate TODO.md + // 3. Generate TODO.md from issue (overrides template) if input.Issue > 0 { s.generateTodo(ctx, input.Org, input.Repo, input.Issue, wsDir) - } else if input.Task != "" { - todo := fmt.Sprintf("# TASK: %s\n\n**Repo:** %s/%s\n**Status:** ready\n\n## Objective\n\n%s\n", - input.Task, input.Org, input.Repo, input.Task) - coreio.Local.Write(filepath.Join(wsDir, "src", "TODO.md"), todo) } // 4. Generate CONTEXT.md from OpenBrain @@ -565,3 +585,60 @@ func (s *PrepSubsystem) generateTodo(ctx context.Context, org, repo string, issu coreio.Local.Write(filepath.Join(wsDir, "src", "TODO.md"), content) } + +// detectLanguage guesses the primary language from repo contents. +func detectLanguage(repoPath string) string { + checks := map[string]string{ + "go.mod": "go", + "composer.json": "php", + "package.json": "ts", + "Cargo.toml": "rust", + "requirements.txt": "py", + "CMakeLists.txt": "cpp", + "Dockerfile": "docker", + } + for file, lang := range checks { + if _, err := os.Stat(filepath.Join(repoPath, file)); err == nil { + return lang + } + } + return "go" +} + +func detectBuildCmd(repoPath string) string { + switch detectLanguage(repoPath) { + case "go": + return "go build ./..." + case "php": + return "composer install" + case "ts": + return "npm run build" + case "py": + return "pip install -e ." + case "rust": + return "cargo build" + case "cpp": + return "cmake --build ." + default: + return "go build ./..." + } +} + +func detectTestCmd(repoPath string) string { + switch detectLanguage(repoPath) { + case "go": + return "go test ./..." + case "php": + return "composer test" + case "ts": + return "npm test" + case "py": + return "pytest" + case "rust": + return "cargo test" + case "cpp": + return "ctest" + default: + return "go test ./..." + } +} diff --git a/pkg/prompts/lib/flow/cpp.md b/pkg/lib/flow/cpp.md similarity index 100% rename from pkg/prompts/lib/flow/cpp.md rename to pkg/lib/flow/cpp.md diff --git a/pkg/prompts/lib/flow/docker.md b/pkg/lib/flow/docker.md similarity index 100% rename from pkg/prompts/lib/flow/docker.md rename to pkg/lib/flow/docker.md diff --git a/pkg/prompts/lib/flow/git.md b/pkg/lib/flow/git.md similarity index 100% rename from pkg/prompts/lib/flow/git.md rename to pkg/lib/flow/git.md diff --git a/pkg/prompts/lib/flow/go.md b/pkg/lib/flow/go.md similarity index 100% rename from pkg/prompts/lib/flow/go.md rename to pkg/lib/flow/go.md diff --git a/pkg/prompts/lib/flow/npm.md b/pkg/lib/flow/npm.md similarity index 100% rename from pkg/prompts/lib/flow/npm.md rename to pkg/lib/flow/npm.md diff --git a/pkg/prompts/lib/flow/php.md b/pkg/lib/flow/php.md similarity index 100% rename from pkg/prompts/lib/flow/php.md rename to pkg/lib/flow/php.md diff --git a/pkg/prompts/lib/flow/prod-push-polish.md b/pkg/lib/flow/prod-push-polish.md similarity index 100% rename from pkg/prompts/lib/flow/prod-push-polish.md rename to pkg/lib/flow/prod-push-polish.md diff --git a/pkg/prompts/lib/flow/py.md b/pkg/lib/flow/py.md similarity index 100% rename from pkg/prompts/lib/flow/py.md rename to pkg/lib/flow/py.md diff --git a/pkg/prompts/lib/flow/release.md b/pkg/lib/flow/release.md similarity index 100% rename from pkg/prompts/lib/flow/release.md rename to pkg/lib/flow/release.md diff --git a/pkg/prompts/lib/flow/ts.md b/pkg/lib/flow/ts.md similarity index 100% rename from pkg/prompts/lib/flow/ts.md rename to pkg/lib/flow/ts.md diff --git a/pkg/lib/lib.go b/pkg/lib/lib.go new file mode 100644 index 0000000..387d1a2 --- /dev/null +++ b/pkg/lib/lib.go @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: EUPL-1.2 + +// Package lib provides embedded content for agent dispatch. +// Prompts, tasks, flows, personas, and workspace templates. +// +// Structure: +// +// prompt/ — System prompts (HOW to work) +// task/ — Structured task plans (WHAT to do) +// task/code/ — Code-specific tasks (review, refactor, etc.) +// flow/ — Build/release workflows per language/tool +// persona/ — Domain/role system prompts (WHO you are) +// workspace/ — Agent workspace templates (WHERE to work) +// +// Usage: +// +// prompt, _ := lib.Prompt("coding") +// task, _ := lib.Task("code/review") +// persona, _ := lib.Persona("secops/developer") +// flow, _ := lib.Flow("go") +// lib.ExtractWorkspace("default", "/tmp/ws", data) +package lib + +import ( + "bytes" + "embed" + "io/fs" + "os" + "path/filepath" + "strings" + "text/template" +) + +//go:embed prompt/*.md +var promptFS embed.FS + +//go:embed all:task +var taskFS embed.FS + +//go:embed flow/*.md +var flowFS embed.FS + +//go:embed persona +var personaFS embed.FS + +//go:embed all:workspace +var workspaceFS embed.FS + +// --- Prompts --- + +func Prompt(slug string) (string, error) { + data, err := promptFS.ReadFile("prompt/" + slug + ".md") + if err != nil { + return "", err + } + return string(data), nil +} + +func Task(slug string) (string, error) { + for _, ext := range []string{".md", ".yaml", ".yml"} { + data, err := taskFS.ReadFile("task/" + slug + ext) + if err == nil { + return string(data), nil + } + } + return "", fs.ErrNotExist +} + +func TaskBundle(slug string) (string, map[string]string, error) { + main, err := Task(slug) + if err != nil { + return "", nil, err + } + bundleDir := "task/" + slug + entries, err := fs.ReadDir(taskFS, bundleDir) + if err != nil { + return main, nil, nil + } + bundle := make(map[string]string) + for _, e := range entries { + if e.IsDir() { + continue + } + data, err := taskFS.ReadFile(bundleDir + "/" + e.Name()) + if err == nil { + bundle[e.Name()] = string(data) + } + } + return main, bundle, nil +} + +func Flow(slug string) (string, error) { + data, err := flowFS.ReadFile("flow/" + slug + ".md") + if err != nil { + return "", err + } + return string(data), nil +} + +func Persona(path string) (string, error) { + data, err := personaFS.ReadFile("persona/" + path + ".md") + if err != nil { + return "", err + } + return string(data), nil +} + +// --- Workspace Templates --- + +// WorkspaceData is the data passed to workspace templates. +type WorkspaceData struct { + Repo string + Branch string + Task string + Agent string + Language string + Prompt string + Persona string + Flow string + Context string + Recent string + Dependencies string + Conventions string + RepoDescription string + BuildCmd string + TestCmd string +} + +// ExtractWorkspace creates an agent workspace from a template. +// Template names: "default", "security", "review". +func ExtractWorkspace(tmplName, targetDir string, data *WorkspaceData) error { + wsDir := "workspace/" + tmplName + entries, err := fs.ReadDir(workspaceFS, wsDir) + if err != nil { + return err + } + + if err := os.MkdirAll(targetDir, 0755); err != nil { + return err + } + + for _, entry := range entries { + if entry.IsDir() { + continue + } + + name := entry.Name() + content, err := fs.ReadFile(workspaceFS, wsDir+"/"+name) + if err != nil { + return err + } + + // Process .tmpl files through text/template + outputName := name + if strings.HasSuffix(name, ".tmpl") { + outputName = strings.TrimSuffix(name, ".tmpl") + tmpl, err := template.New(name).Parse(string(content)) + if err != nil { + return err + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, data); err != nil { + return err + } + content = buf.Bytes() + } + + if err := os.WriteFile(filepath.Join(targetDir, outputName), content, 0644); err != nil { + return err + } + } + + return nil +} + +// --- List Functions --- + +func ListPrompts() []string { return listDir(promptFS, "prompt") } +func ListFlows() []string { return listDir(flowFS, "flow") } +func ListWorkspaces() []string { return listDir(workspaceFS, "workspace") } + +func ListTasks() []string { + var slugs []string + fs.WalkDir(taskFS, "task", func(path string, d fs.DirEntry, err error) error { + if err != nil || d.IsDir() { + return nil + } + rel := strings.TrimPrefix(path, "task/") + ext := filepath.Ext(rel) + slugs = append(slugs, strings.TrimSuffix(rel, ext)) + return nil + }) + return slugs +} + +func ListPersonas() []string { + var paths []string + fs.WalkDir(personaFS, "persona", func(path string, d fs.DirEntry, err error) error { + if err != nil || d.IsDir() { + return nil + } + if strings.HasSuffix(path, ".md") { + rel := strings.TrimPrefix(path, "persona/") + rel = strings.TrimSuffix(rel, ".md") + paths = append(paths, rel) + } + return nil + }) + return paths +} + +func listDir(fsys embed.FS, dir string) []string { + entries, err := fsys.ReadDir(dir) + if err != nil { + return nil + } + var slugs []string + for _, e := range entries { + if e.IsDir() { + name := e.Name() + slugs = append(slugs, name) + continue + } + name := e.Name() + ext := filepath.Ext(name) + slugs = append(slugs, strings.TrimSuffix(name, ext)) + } + return slugs +} diff --git a/pkg/prompts/lib/persona/ads/auditor.md b/pkg/lib/persona/ads/auditor.md similarity index 100% rename from pkg/prompts/lib/persona/ads/auditor.md rename to pkg/lib/persona/ads/auditor.md diff --git a/pkg/prompts/lib/persona/ads/creative-strategist.md b/pkg/lib/persona/ads/creative-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/ads/creative-strategist.md rename to pkg/lib/persona/ads/creative-strategist.md diff --git a/pkg/prompts/lib/persona/ads/paid-social-strategist.md b/pkg/lib/persona/ads/paid-social-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/ads/paid-social-strategist.md rename to pkg/lib/persona/ads/paid-social-strategist.md diff --git a/pkg/prompts/lib/persona/ads/ppc-strategist.md b/pkg/lib/persona/ads/ppc-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/ads/ppc-strategist.md rename to pkg/lib/persona/ads/ppc-strategist.md diff --git a/pkg/prompts/lib/persona/ads/programmatic-buyer.md b/pkg/lib/persona/ads/programmatic-buyer.md similarity index 100% rename from pkg/prompts/lib/persona/ads/programmatic-buyer.md rename to pkg/lib/persona/ads/programmatic-buyer.md diff --git a/pkg/prompts/lib/persona/ads/search-query-analyst.md b/pkg/lib/persona/ads/search-query-analyst.md similarity index 100% rename from pkg/prompts/lib/persona/ads/search-query-analyst.md rename to pkg/lib/persona/ads/search-query-analyst.md diff --git a/pkg/prompts/lib/persona/ads/tracking-specialist.md b/pkg/lib/persona/ads/tracking-specialist.md similarity index 100% rename from pkg/prompts/lib/persona/ads/tracking-specialist.md rename to pkg/lib/persona/ads/tracking-specialist.md diff --git a/pkg/prompts/lib/persona/blockchain/identity-graph-operator.md b/pkg/lib/persona/blockchain/identity-graph-operator.md similarity index 100% rename from pkg/prompts/lib/persona/blockchain/identity-graph-operator.md rename to pkg/lib/persona/blockchain/identity-graph-operator.md diff --git a/pkg/prompts/lib/persona/blockchain/identity-trust.md b/pkg/lib/persona/blockchain/identity-trust.md similarity index 100% rename from pkg/prompts/lib/persona/blockchain/identity-trust.md rename to pkg/lib/persona/blockchain/identity-trust.md diff --git a/pkg/prompts/lib/persona/blockchain/security-auditor.md b/pkg/lib/persona/blockchain/security-auditor.md similarity index 100% rename from pkg/prompts/lib/persona/blockchain/security-auditor.md rename to pkg/lib/persona/blockchain/security-auditor.md diff --git a/pkg/prompts/lib/persona/blockchain/zk-steward.md b/pkg/lib/persona/blockchain/zk-steward.md similarity index 100% rename from pkg/prompts/lib/persona/blockchain/zk-steward.md rename to pkg/lib/persona/blockchain/zk-steward.md diff --git a/pkg/prompts/lib/persona/code/agents-orchestrator.md b/pkg/lib/persona/code/agents-orchestrator.md similarity index 100% rename from pkg/prompts/lib/persona/code/agents-orchestrator.md rename to pkg/lib/persona/code/agents-orchestrator.md diff --git a/pkg/prompts/lib/persona/code/ai-engineer.md b/pkg/lib/persona/code/ai-engineer.md similarity index 100% rename from pkg/prompts/lib/persona/code/ai-engineer.md rename to pkg/lib/persona/code/ai-engineer.md diff --git a/pkg/prompts/lib/persona/code/autonomous-optimization-architect.md b/pkg/lib/persona/code/autonomous-optimization-architect.md similarity index 100% rename from pkg/prompts/lib/persona/code/autonomous-optimization-architect.md rename to pkg/lib/persona/code/autonomous-optimization-architect.md diff --git a/pkg/prompts/lib/persona/code/backend-architect.md b/pkg/lib/persona/code/backend-architect.md similarity index 100% rename from pkg/prompts/lib/persona/code/backend-architect.md rename to pkg/lib/persona/code/backend-architect.md diff --git a/pkg/prompts/lib/persona/code/data-engineer.md b/pkg/lib/persona/code/data-engineer.md similarity index 100% rename from pkg/prompts/lib/persona/code/data-engineer.md rename to pkg/lib/persona/code/data-engineer.md diff --git a/pkg/prompts/lib/persona/code/developer-advocate.md b/pkg/lib/persona/code/developer-advocate.md similarity index 100% rename from pkg/prompts/lib/persona/code/developer-advocate.md rename to pkg/lib/persona/code/developer-advocate.md diff --git a/pkg/prompts/lib/persona/code/frontend-developer.md b/pkg/lib/persona/code/frontend-developer.md similarity index 100% rename from pkg/prompts/lib/persona/code/frontend-developer.md rename to pkg/lib/persona/code/frontend-developer.md diff --git a/pkg/prompts/lib/persona/code/lsp-index-engineer.md b/pkg/lib/persona/code/lsp-index-engineer.md similarity index 100% rename from pkg/prompts/lib/persona/code/lsp-index-engineer.md rename to pkg/lib/persona/code/lsp-index-engineer.md diff --git a/pkg/prompts/lib/persona/code/rapid-prototyper.md b/pkg/lib/persona/code/rapid-prototyper.md similarity index 100% rename from pkg/prompts/lib/persona/code/rapid-prototyper.md rename to pkg/lib/persona/code/rapid-prototyper.md diff --git a/pkg/prompts/lib/persona/code/senior-developer.md b/pkg/lib/persona/code/senior-developer.md similarity index 100% rename from pkg/prompts/lib/persona/code/senior-developer.md rename to pkg/lib/persona/code/senior-developer.md diff --git a/pkg/prompts/lib/persona/code/technical-writer.md b/pkg/lib/persona/code/technical-writer.md similarity index 100% rename from pkg/prompts/lib/persona/code/technical-writer.md rename to pkg/lib/persona/code/technical-writer.md diff --git a/pkg/prompts/lib/persona/design/brand-guardian.md b/pkg/lib/persona/design/brand-guardian.md similarity index 100% rename from pkg/prompts/lib/persona/design/brand-guardian.md rename to pkg/lib/persona/design/brand-guardian.md diff --git a/pkg/prompts/lib/persona/design/image-prompt-engineer.md b/pkg/lib/persona/design/image-prompt-engineer.md similarity index 100% rename from pkg/prompts/lib/persona/design/image-prompt-engineer.md rename to pkg/lib/persona/design/image-prompt-engineer.md diff --git a/pkg/prompts/lib/persona/design/inclusive-visuals-specialist.md b/pkg/lib/persona/design/inclusive-visuals-specialist.md similarity index 100% rename from pkg/prompts/lib/persona/design/inclusive-visuals-specialist.md rename to pkg/lib/persona/design/inclusive-visuals-specialist.md diff --git a/pkg/prompts/lib/persona/design/security-developer.md b/pkg/lib/persona/design/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/design/security-developer.md rename to pkg/lib/persona/design/security-developer.md diff --git a/pkg/prompts/lib/persona/design/ui-designer.md b/pkg/lib/persona/design/ui-designer.md similarity index 100% rename from pkg/prompts/lib/persona/design/ui-designer.md rename to pkg/lib/persona/design/ui-designer.md diff --git a/pkg/prompts/lib/persona/design/ux-architect.md b/pkg/lib/persona/design/ux-architect.md similarity index 100% rename from pkg/prompts/lib/persona/design/ux-architect.md rename to pkg/lib/persona/design/ux-architect.md diff --git a/pkg/prompts/lib/persona/design/ux-researcher.md b/pkg/lib/persona/design/ux-researcher.md similarity index 100% rename from pkg/prompts/lib/persona/design/ux-researcher.md rename to pkg/lib/persona/design/ux-researcher.md diff --git a/pkg/prompts/lib/persona/design/visual-storyteller.md b/pkg/lib/persona/design/visual-storyteller.md similarity index 100% rename from pkg/prompts/lib/persona/design/visual-storyteller.md rename to pkg/lib/persona/design/visual-storyteller.md diff --git a/pkg/prompts/lib/persona/design/whimsy-injector.md b/pkg/lib/persona/design/whimsy-injector.md similarity index 100% rename from pkg/prompts/lib/persona/design/whimsy-injector.md rename to pkg/lib/persona/design/whimsy-injector.md diff --git a/pkg/prompts/lib/persona/devops/automator.md b/pkg/lib/persona/devops/automator.md similarity index 100% rename from pkg/prompts/lib/persona/devops/automator.md rename to pkg/lib/persona/devops/automator.md diff --git a/pkg/prompts/lib/persona/devops/junior.md b/pkg/lib/persona/devops/junior.md similarity index 100% rename from pkg/prompts/lib/persona/devops/junior.md rename to pkg/lib/persona/devops/junior.md diff --git a/pkg/prompts/lib/persona/devops/security-developer.md b/pkg/lib/persona/devops/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/devops/security-developer.md rename to pkg/lib/persona/devops/security-developer.md diff --git a/pkg/prompts/lib/persona/devops/senior.md b/pkg/lib/persona/devops/senior.md similarity index 100% rename from pkg/prompts/lib/persona/devops/senior.md rename to pkg/lib/persona/devops/senior.md diff --git a/pkg/prompts/lib/persona/plan/EXECUTIVE-BRIEF.md b/pkg/lib/persona/plan/EXECUTIVE-BRIEF.md similarity index 100% rename from pkg/prompts/lib/persona/plan/EXECUTIVE-BRIEF.md rename to pkg/lib/persona/plan/EXECUTIVE-BRIEF.md diff --git a/pkg/prompts/lib/persona/plan/QUICKSTART.md b/pkg/lib/persona/plan/QUICKSTART.md similarity index 100% rename from pkg/prompts/lib/persona/plan/QUICKSTART.md rename to pkg/lib/persona/plan/QUICKSTART.md diff --git a/pkg/prompts/lib/persona/plan/coordination/agent-activation-prompts.md b/pkg/lib/persona/plan/coordination/agent-activation-prompts.md similarity index 100% rename from pkg/prompts/lib/persona/plan/coordination/agent-activation-prompts.md rename to pkg/lib/persona/plan/coordination/agent-activation-prompts.md diff --git a/pkg/prompts/lib/persona/plan/coordination/handoff-templates.md b/pkg/lib/persona/plan/coordination/handoff-templates.md similarity index 100% rename from pkg/prompts/lib/persona/plan/coordination/handoff-templates.md rename to pkg/lib/persona/plan/coordination/handoff-templates.md diff --git a/pkg/prompts/lib/persona/plan/experiment-tracker.md b/pkg/lib/persona/plan/experiment-tracker.md similarity index 100% rename from pkg/prompts/lib/persona/plan/experiment-tracker.md rename to pkg/lib/persona/plan/experiment-tracker.md diff --git a/pkg/prompts/lib/persona/plan/nexus-strategy.md b/pkg/lib/persona/plan/nexus-strategy.md similarity index 100% rename from pkg/prompts/lib/persona/plan/nexus-strategy.md rename to pkg/lib/persona/plan/nexus-strategy.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-0-discovery.md b/pkg/lib/persona/plan/playbooks/phase-0-discovery.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-0-discovery.md rename to pkg/lib/persona/plan/playbooks/phase-0-discovery.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-1-strategy.md b/pkg/lib/persona/plan/playbooks/phase-1-strategy.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-1-strategy.md rename to pkg/lib/persona/plan/playbooks/phase-1-strategy.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-2-foundation.md b/pkg/lib/persona/plan/playbooks/phase-2-foundation.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-2-foundation.md rename to pkg/lib/persona/plan/playbooks/phase-2-foundation.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-3-build.md b/pkg/lib/persona/plan/playbooks/phase-3-build.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-3-build.md rename to pkg/lib/persona/plan/playbooks/phase-3-build.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-4-hardening.md b/pkg/lib/persona/plan/playbooks/phase-4-hardening.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-4-hardening.md rename to pkg/lib/persona/plan/playbooks/phase-4-hardening.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-5-launch.md b/pkg/lib/persona/plan/playbooks/phase-5-launch.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-5-launch.md rename to pkg/lib/persona/plan/playbooks/phase-5-launch.md diff --git a/pkg/prompts/lib/persona/plan/playbooks/phase-6-operate.md b/pkg/lib/persona/plan/playbooks/phase-6-operate.md similarity index 100% rename from pkg/prompts/lib/persona/plan/playbooks/phase-6-operate.md rename to pkg/lib/persona/plan/playbooks/phase-6-operate.md diff --git a/pkg/prompts/lib/persona/plan/project-shepherd.md b/pkg/lib/persona/plan/project-shepherd.md similarity index 100% rename from pkg/prompts/lib/persona/plan/project-shepherd.md rename to pkg/lib/persona/plan/project-shepherd.md diff --git a/pkg/prompts/lib/persona/plan/runbooks/scenario-enterprise-feature.md b/pkg/lib/persona/plan/runbooks/scenario-enterprise-feature.md similarity index 100% rename from pkg/prompts/lib/persona/plan/runbooks/scenario-enterprise-feature.md rename to pkg/lib/persona/plan/runbooks/scenario-enterprise-feature.md diff --git a/pkg/prompts/lib/persona/plan/runbooks/scenario-incident-response.md b/pkg/lib/persona/plan/runbooks/scenario-incident-response.md similarity index 100% rename from pkg/prompts/lib/persona/plan/runbooks/scenario-incident-response.md rename to pkg/lib/persona/plan/runbooks/scenario-incident-response.md diff --git a/pkg/prompts/lib/persona/plan/runbooks/scenario-marketing-campaign.md b/pkg/lib/persona/plan/runbooks/scenario-marketing-campaign.md similarity index 100% rename from pkg/prompts/lib/persona/plan/runbooks/scenario-marketing-campaign.md rename to pkg/lib/persona/plan/runbooks/scenario-marketing-campaign.md diff --git a/pkg/prompts/lib/persona/plan/runbooks/scenario-startup-mvp.md b/pkg/lib/persona/plan/runbooks/scenario-startup-mvp.md similarity index 100% rename from pkg/prompts/lib/persona/plan/runbooks/scenario-startup-mvp.md rename to pkg/lib/persona/plan/runbooks/scenario-startup-mvp.md diff --git a/pkg/prompts/lib/persona/plan/senior.md b/pkg/lib/persona/plan/senior.md similarity index 100% rename from pkg/prompts/lib/persona/plan/senior.md rename to pkg/lib/persona/plan/senior.md diff --git a/pkg/prompts/lib/persona/plan/studio-operations.md b/pkg/lib/persona/plan/studio-operations.md similarity index 100% rename from pkg/prompts/lib/persona/plan/studio-operations.md rename to pkg/lib/persona/plan/studio-operations.md diff --git a/pkg/prompts/lib/persona/plan/studio-producer.md b/pkg/lib/persona/plan/studio-producer.md similarity index 100% rename from pkg/prompts/lib/persona/plan/studio-producer.md rename to pkg/lib/persona/plan/studio-producer.md diff --git a/pkg/prompts/lib/persona/product/behavioral-nudge-engine.md b/pkg/lib/persona/product/behavioral-nudge-engine.md similarity index 100% rename from pkg/prompts/lib/persona/product/behavioral-nudge-engine.md rename to pkg/lib/persona/product/behavioral-nudge-engine.md diff --git a/pkg/prompts/lib/persona/product/feedback-synthesizer.md b/pkg/lib/persona/product/feedback-synthesizer.md similarity index 100% rename from pkg/prompts/lib/persona/product/feedback-synthesizer.md rename to pkg/lib/persona/product/feedback-synthesizer.md diff --git a/pkg/prompts/lib/persona/product/security-developer.md b/pkg/lib/persona/product/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/product/security-developer.md rename to pkg/lib/persona/product/security-developer.md diff --git a/pkg/prompts/lib/persona/product/sprint-prioritizer.md b/pkg/lib/persona/product/sprint-prioritizer.md similarity index 100% rename from pkg/prompts/lib/persona/product/sprint-prioritizer.md rename to pkg/lib/persona/product/sprint-prioritizer.md diff --git a/pkg/prompts/lib/persona/product/trend-researcher.md b/pkg/lib/persona/product/trend-researcher.md similarity index 100% rename from pkg/prompts/lib/persona/product/trend-researcher.md rename to pkg/lib/persona/product/trend-researcher.md diff --git a/pkg/prompts/lib/persona/sales/account-strategist.md b/pkg/lib/persona/sales/account-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/sales/account-strategist.md rename to pkg/lib/persona/sales/account-strategist.md diff --git a/pkg/prompts/lib/persona/sales/coach.md b/pkg/lib/persona/sales/coach.md similarity index 100% rename from pkg/prompts/lib/persona/sales/coach.md rename to pkg/lib/persona/sales/coach.md diff --git a/pkg/prompts/lib/persona/sales/deal-strategist.md b/pkg/lib/persona/sales/deal-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/sales/deal-strategist.md rename to pkg/lib/persona/sales/deal-strategist.md diff --git a/pkg/prompts/lib/persona/sales/discovery-coach.md b/pkg/lib/persona/sales/discovery-coach.md similarity index 100% rename from pkg/prompts/lib/persona/sales/discovery-coach.md rename to pkg/lib/persona/sales/discovery-coach.md diff --git a/pkg/prompts/lib/persona/sales/engineer.md b/pkg/lib/persona/sales/engineer.md similarity index 100% rename from pkg/prompts/lib/persona/sales/engineer.md rename to pkg/lib/persona/sales/engineer.md diff --git a/pkg/prompts/lib/persona/sales/outbound-strategist.md b/pkg/lib/persona/sales/outbound-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/sales/outbound-strategist.md rename to pkg/lib/persona/sales/outbound-strategist.md diff --git a/pkg/prompts/lib/persona/sales/pipeline-analyst.md b/pkg/lib/persona/sales/pipeline-analyst.md similarity index 100% rename from pkg/prompts/lib/persona/sales/pipeline-analyst.md rename to pkg/lib/persona/sales/pipeline-analyst.md diff --git a/pkg/prompts/lib/persona/sales/proposal-strategist.md b/pkg/lib/persona/sales/proposal-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/sales/proposal-strategist.md rename to pkg/lib/persona/sales/proposal-strategist.md diff --git a/pkg/prompts/lib/persona/secops/architect.md b/pkg/lib/persona/secops/architect.md similarity index 100% rename from pkg/prompts/lib/persona/secops/architect.md rename to pkg/lib/persona/secops/architect.md diff --git a/pkg/prompts/lib/persona/secops/developer.md b/pkg/lib/persona/secops/developer.md similarity index 100% rename from pkg/prompts/lib/persona/secops/developer.md rename to pkg/lib/persona/secops/developer.md diff --git a/pkg/prompts/lib/persona/secops/devops.md b/pkg/lib/persona/secops/devops.md similarity index 100% rename from pkg/prompts/lib/persona/secops/devops.md rename to pkg/lib/persona/secops/devops.md diff --git a/pkg/prompts/lib/persona/secops/incident-commander.md b/pkg/lib/persona/secops/incident-commander.md similarity index 100% rename from pkg/prompts/lib/persona/secops/incident-commander.md rename to pkg/lib/persona/secops/incident-commander.md diff --git a/pkg/prompts/lib/persona/secops/junior.md b/pkg/lib/persona/secops/junior.md similarity index 100% rename from pkg/prompts/lib/persona/secops/junior.md rename to pkg/lib/persona/secops/junior.md diff --git a/pkg/prompts/lib/persona/secops/operations.md b/pkg/lib/persona/secops/operations.md similarity index 100% rename from pkg/prompts/lib/persona/secops/operations.md rename to pkg/lib/persona/secops/operations.md diff --git a/pkg/prompts/lib/persona/secops/senior.md b/pkg/lib/persona/secops/senior.md similarity index 100% rename from pkg/prompts/lib/persona/secops/senior.md rename to pkg/lib/persona/secops/senior.md diff --git a/pkg/prompts/lib/persona/smm/carousel-growth-engine.md b/pkg/lib/persona/smm/carousel-growth-engine.md similarity index 100% rename from pkg/prompts/lib/persona/smm/carousel-growth-engine.md rename to pkg/lib/persona/smm/carousel-growth-engine.md diff --git a/pkg/prompts/lib/persona/smm/content-creator.md b/pkg/lib/persona/smm/content-creator.md similarity index 100% rename from pkg/prompts/lib/persona/smm/content-creator.md rename to pkg/lib/persona/smm/content-creator.md diff --git a/pkg/prompts/lib/persona/smm/cultural-intelligence.md b/pkg/lib/persona/smm/cultural-intelligence.md similarity index 100% rename from pkg/prompts/lib/persona/smm/cultural-intelligence.md rename to pkg/lib/persona/smm/cultural-intelligence.md diff --git a/pkg/prompts/lib/persona/smm/growth-hacker.md b/pkg/lib/persona/smm/growth-hacker.md similarity index 100% rename from pkg/prompts/lib/persona/smm/growth-hacker.md rename to pkg/lib/persona/smm/growth-hacker.md diff --git a/pkg/prompts/lib/persona/smm/instagram-curator.md b/pkg/lib/persona/smm/instagram-curator.md similarity index 100% rename from pkg/prompts/lib/persona/smm/instagram-curator.md rename to pkg/lib/persona/smm/instagram-curator.md diff --git a/pkg/prompts/lib/persona/smm/linkedin-content-creator.md b/pkg/lib/persona/smm/linkedin-content-creator.md similarity index 100% rename from pkg/prompts/lib/persona/smm/linkedin-content-creator.md rename to pkg/lib/persona/smm/linkedin-content-creator.md diff --git a/pkg/prompts/lib/persona/smm/reddit-community-builder.md b/pkg/lib/persona/smm/reddit-community-builder.md similarity index 100% rename from pkg/prompts/lib/persona/smm/reddit-community-builder.md rename to pkg/lib/persona/smm/reddit-community-builder.md diff --git a/pkg/prompts/lib/persona/smm/security-developer.md b/pkg/lib/persona/smm/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/smm/security-developer.md rename to pkg/lib/persona/smm/security-developer.md diff --git a/pkg/prompts/lib/persona/smm/security-secops.md b/pkg/lib/persona/smm/security-secops.md similarity index 100% rename from pkg/prompts/lib/persona/smm/security-secops.md rename to pkg/lib/persona/smm/security-secops.md diff --git a/pkg/prompts/lib/persona/smm/seo-specialist.md b/pkg/lib/persona/smm/seo-specialist.md similarity index 100% rename from pkg/prompts/lib/persona/smm/seo-specialist.md rename to pkg/lib/persona/smm/seo-specialist.md diff --git a/pkg/prompts/lib/persona/smm/social-media-strategist.md b/pkg/lib/persona/smm/social-media-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/smm/social-media-strategist.md rename to pkg/lib/persona/smm/social-media-strategist.md diff --git a/pkg/prompts/lib/persona/smm/tiktok-strategist.md b/pkg/lib/persona/smm/tiktok-strategist.md similarity index 100% rename from pkg/prompts/lib/persona/smm/tiktok-strategist.md rename to pkg/lib/persona/smm/tiktok-strategist.md diff --git a/pkg/prompts/lib/persona/smm/twitter-engager.md b/pkg/lib/persona/smm/twitter-engager.md similarity index 100% rename from pkg/prompts/lib/persona/smm/twitter-engager.md rename to pkg/lib/persona/smm/twitter-engager.md diff --git a/pkg/prompts/lib/persona/spatial/macos-spatial-metal-engineer.md b/pkg/lib/persona/spatial/macos-spatial-metal-engineer.md similarity index 100% rename from pkg/prompts/lib/persona/spatial/macos-spatial-metal-engineer.md rename to pkg/lib/persona/spatial/macos-spatial-metal-engineer.md diff --git a/pkg/prompts/lib/persona/spatial/terminal-integration-specialist.md b/pkg/lib/persona/spatial/terminal-integration-specialist.md similarity index 100% rename from pkg/prompts/lib/persona/spatial/terminal-integration-specialist.md rename to pkg/lib/persona/spatial/terminal-integration-specialist.md diff --git a/pkg/prompts/lib/persona/support/accounts-payable.md b/pkg/lib/persona/support/accounts-payable.md similarity index 100% rename from pkg/prompts/lib/persona/support/accounts-payable.md rename to pkg/lib/persona/support/accounts-payable.md diff --git a/pkg/prompts/lib/persona/support/analytics-reporter.md b/pkg/lib/persona/support/analytics-reporter.md similarity index 100% rename from pkg/prompts/lib/persona/support/analytics-reporter.md rename to pkg/lib/persona/support/analytics-reporter.md diff --git a/pkg/prompts/lib/persona/support/compliance-auditor.md b/pkg/lib/persona/support/compliance-auditor.md similarity index 100% rename from pkg/prompts/lib/persona/support/compliance-auditor.md rename to pkg/lib/persona/support/compliance-auditor.md diff --git a/pkg/prompts/lib/persona/support/executive-summary-generator.md b/pkg/lib/persona/support/executive-summary-generator.md similarity index 100% rename from pkg/prompts/lib/persona/support/executive-summary-generator.md rename to pkg/lib/persona/support/executive-summary-generator.md diff --git a/pkg/prompts/lib/persona/support/finance-tracker.md b/pkg/lib/persona/support/finance-tracker.md similarity index 100% rename from pkg/prompts/lib/persona/support/finance-tracker.md rename to pkg/lib/persona/support/finance-tracker.md diff --git a/pkg/prompts/lib/persona/support/infrastructure-maintainer.md b/pkg/lib/persona/support/infrastructure-maintainer.md similarity index 100% rename from pkg/prompts/lib/persona/support/infrastructure-maintainer.md rename to pkg/lib/persona/support/infrastructure-maintainer.md diff --git a/pkg/prompts/lib/persona/support/legal-compliance-checker.md b/pkg/lib/persona/support/legal-compliance-checker.md similarity index 100% rename from pkg/prompts/lib/persona/support/legal-compliance-checker.md rename to pkg/lib/persona/support/legal-compliance-checker.md diff --git a/pkg/prompts/lib/persona/support/responder.md b/pkg/lib/persona/support/responder.md similarity index 100% rename from pkg/prompts/lib/persona/support/responder.md rename to pkg/lib/persona/support/responder.md diff --git a/pkg/prompts/lib/persona/support/security-developer.md b/pkg/lib/persona/support/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/support/security-developer.md rename to pkg/lib/persona/support/security-developer.md diff --git a/pkg/prompts/lib/persona/support/security-secops.md b/pkg/lib/persona/support/security-secops.md similarity index 100% rename from pkg/prompts/lib/persona/support/security-secops.md rename to pkg/lib/persona/support/security-secops.md diff --git a/pkg/prompts/lib/persona/testing/accessibility-auditor.md b/pkg/lib/persona/testing/accessibility-auditor.md similarity index 100% rename from pkg/prompts/lib/persona/testing/accessibility-auditor.md rename to pkg/lib/persona/testing/accessibility-auditor.md diff --git a/pkg/prompts/lib/persona/testing/api-tester.md b/pkg/lib/persona/testing/api-tester.md similarity index 100% rename from pkg/prompts/lib/persona/testing/api-tester.md rename to pkg/lib/persona/testing/api-tester.md diff --git a/pkg/prompts/lib/persona/testing/evidence-collector.md b/pkg/lib/persona/testing/evidence-collector.md similarity index 100% rename from pkg/prompts/lib/persona/testing/evidence-collector.md rename to pkg/lib/persona/testing/evidence-collector.md diff --git a/pkg/prompts/lib/persona/testing/model-qa.md b/pkg/lib/persona/testing/model-qa.md similarity index 100% rename from pkg/prompts/lib/persona/testing/model-qa.md rename to pkg/lib/persona/testing/model-qa.md diff --git a/pkg/prompts/lib/persona/testing/performance-benchmarker.md b/pkg/lib/persona/testing/performance-benchmarker.md similarity index 100% rename from pkg/prompts/lib/persona/testing/performance-benchmarker.md rename to pkg/lib/persona/testing/performance-benchmarker.md diff --git a/pkg/prompts/lib/persona/testing/reality-checker.md b/pkg/lib/persona/testing/reality-checker.md similarity index 100% rename from pkg/prompts/lib/persona/testing/reality-checker.md rename to pkg/lib/persona/testing/reality-checker.md diff --git a/pkg/prompts/lib/persona/testing/security-developer.md b/pkg/lib/persona/testing/security-developer.md similarity index 100% rename from pkg/prompts/lib/persona/testing/security-developer.md rename to pkg/lib/persona/testing/security-developer.md diff --git a/pkg/prompts/lib/persona/testing/test-results-analyzer.md b/pkg/lib/persona/testing/test-results-analyzer.md similarity index 100% rename from pkg/prompts/lib/persona/testing/test-results-analyzer.md rename to pkg/lib/persona/testing/test-results-analyzer.md diff --git a/pkg/prompts/lib/persona/testing/tool-evaluator.md b/pkg/lib/persona/testing/tool-evaluator.md similarity index 100% rename from pkg/prompts/lib/persona/testing/tool-evaluator.md rename to pkg/lib/persona/testing/tool-evaluator.md diff --git a/pkg/prompts/lib/persona/testing/workflow-optimizer.md b/pkg/lib/persona/testing/workflow-optimizer.md similarity index 100% rename from pkg/prompts/lib/persona/testing/workflow-optimizer.md rename to pkg/lib/persona/testing/workflow-optimizer.md diff --git a/pkg/prompts/lib/prompt/coding.md b/pkg/lib/prompt/coding.md similarity index 100% rename from pkg/prompts/lib/prompt/coding.md rename to pkg/lib/prompt/coding.md diff --git a/pkg/prompts/lib/prompt/conventions.md b/pkg/lib/prompt/conventions.md similarity index 100% rename from pkg/prompts/lib/prompt/conventions.md rename to pkg/lib/prompt/conventions.md diff --git a/pkg/prompts/lib/prompt/default.md b/pkg/lib/prompt/default.md similarity index 100% rename from pkg/prompts/lib/prompt/default.md rename to pkg/lib/prompt/default.md diff --git a/pkg/prompts/lib/prompt/security.md b/pkg/lib/prompt/security.md similarity index 100% rename from pkg/prompts/lib/prompt/security.md rename to pkg/lib/prompt/security.md diff --git a/pkg/prompts/lib/prompt/verify.md b/pkg/lib/prompt/verify.md similarity index 100% rename from pkg/prompts/lib/prompt/verify.md rename to pkg/lib/prompt/verify.md diff --git a/pkg/prompts/lib/task/api-consistency.yaml b/pkg/lib/task/api-consistency.yaml similarity index 100% rename from pkg/prompts/lib/task/api-consistency.yaml rename to pkg/lib/task/api-consistency.yaml diff --git a/pkg/prompts/lib/task/bug-fix.yaml b/pkg/lib/task/bug-fix.yaml similarity index 100% rename from pkg/prompts/lib/task/bug-fix.yaml rename to pkg/lib/task/bug-fix.yaml diff --git a/pkg/prompts/lib/task/code/dead-code.md b/pkg/lib/task/code/dead-code.md similarity index 100% rename from pkg/prompts/lib/task/code/dead-code.md rename to pkg/lib/task/code/dead-code.md diff --git a/pkg/prompts/lib/task/code/refactor.md b/pkg/lib/task/code/refactor.md similarity index 100% rename from pkg/prompts/lib/task/code/refactor.md rename to pkg/lib/task/code/refactor.md diff --git a/pkg/prompts/lib/task/code/review.md b/pkg/lib/task/code/review.md similarity index 100% rename from pkg/prompts/lib/task/code/review.md rename to pkg/lib/task/code/review.md diff --git a/pkg/prompts/lib/task/code/review/conventions.md b/pkg/lib/task/code/review/conventions.md similarity index 100% rename from pkg/prompts/lib/task/code/review/conventions.md rename to pkg/lib/task/code/review/conventions.md diff --git a/pkg/prompts/lib/task/code/review/plan.yaml b/pkg/lib/task/code/review/plan.yaml similarity index 100% rename from pkg/prompts/lib/task/code/review/plan.yaml rename to pkg/lib/task/code/review/plan.yaml diff --git a/pkg/prompts/lib/task/code/review/severity.md b/pkg/lib/task/code/review/severity.md similarity index 100% rename from pkg/prompts/lib/task/code/review/severity.md rename to pkg/lib/task/code/review/severity.md diff --git a/pkg/prompts/lib/task/code/simplifier.md b/pkg/lib/task/code/simplifier.md similarity index 100% rename from pkg/prompts/lib/task/code/simplifier.md rename to pkg/lib/task/code/simplifier.md diff --git a/pkg/prompts/lib/task/code/simplifier/patterns.md b/pkg/lib/task/code/simplifier/patterns.md similarity index 100% rename from pkg/prompts/lib/task/code/simplifier/patterns.md rename to pkg/lib/task/code/simplifier/patterns.md diff --git a/pkg/prompts/lib/task/code/test-gaps.md b/pkg/lib/task/code/test-gaps.md similarity index 100% rename from pkg/prompts/lib/task/code/test-gaps.md rename to pkg/lib/task/code/test-gaps.md diff --git a/pkg/prompts/lib/task/dependency-audit.yaml b/pkg/lib/task/dependency-audit.yaml similarity index 100% rename from pkg/prompts/lib/task/dependency-audit.yaml rename to pkg/lib/task/dependency-audit.yaml diff --git a/pkg/prompts/lib/task/doc-sync.yaml b/pkg/lib/task/doc-sync.yaml similarity index 100% rename from pkg/prompts/lib/task/doc-sync.yaml rename to pkg/lib/task/doc-sync.yaml diff --git a/pkg/prompts/lib/task/feature-port.yaml b/pkg/lib/task/feature-port.yaml similarity index 100% rename from pkg/prompts/lib/task/feature-port.yaml rename to pkg/lib/task/feature-port.yaml diff --git a/pkg/prompts/lib/task/new-feature.yaml b/pkg/lib/task/new-feature.yaml similarity index 100% rename from pkg/prompts/lib/task/new-feature.yaml rename to pkg/lib/task/new-feature.yaml diff --git a/pkg/lib/workspace/default/.gitignore b/pkg/lib/workspace/default/.gitignore new file mode 100644 index 0000000..cdc6f76 --- /dev/null +++ b/pkg/lib/workspace/default/.gitignore @@ -0,0 +1,4 @@ +.idea/ +.vscode/ +*.log +.core/ diff --git a/pkg/lib/workspace/default/CLAUDE.md.tmpl b/pkg/lib/workspace/default/CLAUDE.md.tmpl new file mode 100644 index 0000000..c8c4ec8 --- /dev/null +++ b/pkg/lib/workspace/default/CLAUDE.md.tmpl @@ -0,0 +1,25 @@ +# CLAUDE.md + +## Task +{{.Task}} + +## Repository +- **Repo**: {{.Repo}} +- **Branch**: {{.Branch}} +- **Language**: {{.Language}} + +## Instructions +{{.Prompt}} + +## Persona +{{.Persona}} + +## Build & Test +{{.Flow}} + +## Rules +- Work ONLY within this workspace — do not modify files outside src/ +- Commit your changes with clear conventional commit messages +- Run tests before committing +- UK English in all comments and strings +- Co-Author: `Co-Authored-By: {{.Agent}} ` diff --git a/pkg/lib/workspace/default/CONTEXT.md.tmpl b/pkg/lib/workspace/default/CONTEXT.md.tmpl new file mode 100644 index 0000000..34c82f2 --- /dev/null +++ b/pkg/lib/workspace/default/CONTEXT.md.tmpl @@ -0,0 +1,13 @@ +# Context + +## Repository: {{.Repo}} +{{.RepoDescription}} + +## Recent Changes +{{.Recent}} + +## Dependencies +{{.Dependencies}} + +## Conventions +{{.Conventions}} diff --git a/pkg/lib/workspace/default/PROMPT.md.tmpl b/pkg/lib/workspace/default/PROMPT.md.tmpl new file mode 100644 index 0000000..978ce5e --- /dev/null +++ b/pkg/lib/workspace/default/PROMPT.md.tmpl @@ -0,0 +1,11 @@ +# Prompt + +{{.Prompt}} + +--- + +## Task +{{.Task}} + +## Output Format +When complete, write a summary of changes to DONE.md in the workspace root. diff --git a/pkg/lib/workspace/default/TODO.md.tmpl b/pkg/lib/workspace/default/TODO.md.tmpl new file mode 100644 index 0000000..82974f3 --- /dev/null +++ b/pkg/lib/workspace/default/TODO.md.tmpl @@ -0,0 +1,14 @@ +# TODO + +## Task +{{.Task}} + +## Checklist +- [ ] Read and understand the codebase +- [ ] Implement the required changes +- [ ] Run build: `{{.BuildCmd}}` +- [ ] Run tests: `{{.TestCmd}}` +- [ ] Commit with conventional commit message + +## Context +{{.Context}} diff --git a/pkg/lib/workspace/review/CLAUDE.md.tmpl b/pkg/lib/workspace/review/CLAUDE.md.tmpl new file mode 100644 index 0000000..d910e4d --- /dev/null +++ b/pkg/lib/workspace/review/CLAUDE.md.tmpl @@ -0,0 +1,24 @@ +# CLAUDE.md — Code Review + +## Task +{{.Task}} + +## Repository +- **Repo**: {{.Repo}} +- **Branch**: {{.Branch}} + +## Persona +{{.Persona}} + +## Rules +- READ-ONLY review — do NOT modify source files +- Report findings with file:line format +- Categories: BUG, PATTERN, NAMING, DEAD_CODE, PERFORMANCE +- Skip cosmetic/style unless it affects readability +- Output report to REVIEW.md in the workspace root + +## Build & Test +{{.Flow}} + +## Conventions +{{.Conventions}} diff --git a/pkg/lib/workspace/review/REVIEW.md.tmpl b/pkg/lib/workspace/review/REVIEW.md.tmpl new file mode 100644 index 0000000..71a91b6 --- /dev/null +++ b/pkg/lib/workspace/review/REVIEW.md.tmpl @@ -0,0 +1,16 @@ +# Code Review: {{.Repo}} + +## Task +{{.Task}} + +## Summary +| Category | Count | +|----------|-------| +| BUG | 0 | +| PATTERN | 0 | +| NAMING | 0 | +| DEAD_CODE | 0 | + +## Findings + + diff --git a/pkg/lib/workspace/security/CLAUDE.md.tmpl b/pkg/lib/workspace/security/CLAUDE.md.tmpl new file mode 100644 index 0000000..74e1233 --- /dev/null +++ b/pkg/lib/workspace/security/CLAUDE.md.tmpl @@ -0,0 +1,22 @@ +# CLAUDE.md — Security Review + +## Task +{{.Task}} + +## Repository +- **Repo**: {{.Repo}} +- **Branch**: {{.Branch}} + +## Persona +{{.Persona}} + +## Rules +- This is a READ-ONLY security audit — do NOT modify source files +- Report findings with file:line format +- Rate each finding: CRITICAL / HIGH / MEDIUM / LOW +- Check for: OWASP top 10, injection, path traversal, race conditions, sandbox escapes +- Focus on real bugs — skip cosmetic/style issues +- Output findings to FINDINGS.md in the workspace root + +## Build & Test +{{.Flow}} diff --git a/pkg/lib/workspace/security/FINDINGS.md.tmpl b/pkg/lib/workspace/security/FINDINGS.md.tmpl new file mode 100644 index 0000000..9b8a3dd --- /dev/null +++ b/pkg/lib/workspace/security/FINDINGS.md.tmpl @@ -0,0 +1,13 @@ +# Security Findings: {{.Repo}} + +## Summary +| Severity | Count | +|----------|-------| +| CRITICAL | 0 | +| HIGH | 0 | +| MEDIUM | 0 | +| LOW | 0 | + +## Findings + + diff --git a/pkg/lib/workspace/security/TODO.md.tmpl b/pkg/lib/workspace/security/TODO.md.tmpl new file mode 100644 index 0000000..fd43c78 --- /dev/null +++ b/pkg/lib/workspace/security/TODO.md.tmpl @@ -0,0 +1,13 @@ +# Security Audit + +## Target +{{.Repo}} — {{.Task}} + +## Checklist +- [ ] Thread safety (race conditions, missing locks) +- [ ] Path traversal / sandbox escapes +- [ ] Injection (command, SQL, log) +- [ ] Error handling (swallowed errors, nil pointer risks) +- [ ] Authentication / authorisation gaps +- [ ] Cryptographic misuse +- [ ] Write findings to FINDINGS.md diff --git a/pkg/prompts/prompts.go b/pkg/prompts/prompts.go index ce6c1db..ff77e44 100644 --- a/pkg/prompts/prompts.go +++ b/pkg/prompts/prompts.go @@ -1,187 +1,19 @@ // SPDX-License-Identifier: EUPL-1.2 -// Package prompts provides embedded prompt content for agent dispatch. -// All content is loaded from lib/ at compile time via go:embed. -// -// Structure: -// -// lib/prompt/ — System prompts (PROMPT.md content, HOW to work) -// lib/task/ — Structured task plans (PLAN.md, WHAT to do) -// lib/task/code/ — Code-specific tasks (review, refactor, dead-code, test-gaps) -// lib/flow/ — Build/release workflows per language/tool -// lib/persona/ — Domain/role system prompts (WHO you are) -// -// Usage: -// -// prompt, _ := prompts.Prompt("coding") -// task, _ := prompts.Task("bug-fix") -// task, _ := prompts.Task("code/review") -// persona, _ := prompts.Persona("secops/developer") -// flow, _ := prompts.Flow("go") +// Package prompts re-exports the lib package for backwards compatibility. +// New code should import pkg/lib directly. package prompts -import ( - "embed" - "io/fs" - "path/filepath" - "strings" -) +import "forge.lthn.ai/core/agent/pkg/lib" -//go:embed lib/prompt/*.md -var promptFS embed.FS - -//go:embed all:lib/task -var taskFS embed.FS - -//go:embed lib/flow/*.md -var flowFS embed.FS - -//go:embed lib/persona -var personaFS embed.FS - -// Prompt returns a system prompt by slug (written as PROMPT.md). -// Slugs: "coding", "verify", "conventions", "security", "default". -func Prompt(slug string) (string, error) { - data, err := promptFS.ReadFile("lib/prompt/" + slug + ".md") - if err != nil { - return "", err - } - return string(data), nil -} - -// Template is an alias for Prompt (backwards compatibility). -func Template(slug string) (string, error) { - if content, err := Prompt(slug); err == nil { - return content, nil - } - return Task(slug) -} - -// Task returns a task definition by slug. -// Slugs: "bug-fix", "new-feature", "code/review", "code/refactor", etc. -func Task(slug string) (string, error) { - for _, ext := range []string{".md", ".yaml", ".yml"} { - data, err := taskFS.ReadFile("lib/task/" + slug + ext) - if err == nil { - return string(data), nil - } - } - return "", fs.ErrNotExist -} - -// TaskBundle returns the task definition plus all additional files in its bundle directory. -// For "code/review": returns review.md content + map of {filename: content} from review/. -// The bundle directory has the same name as the task file (without extension). -func TaskBundle(slug string) (string, map[string]string, error) { - // Get the main task definition - main, err := Task(slug) - if err != nil { - return "", nil, err - } - - // Look for a bundle directory with the same name - bundleDir := "lib/task/" + slug - entries, err := fs.ReadDir(taskFS, bundleDir) - if err != nil { - // No bundle — just the task definition - return main, nil, nil - } - - bundle := make(map[string]string) - for _, e := range entries { - if e.IsDir() { - continue - } - data, err := taskFS.ReadFile(bundleDir + "/" + e.Name()) - if err == nil { - bundle[e.Name()] = string(data) - } - } - - return main, bundle, nil -} - -// Flow returns a build/release workflow by slug. -// Slugs: "go", "php", "ts", "docker", "release", etc. -func Flow(slug string) (string, error) { - data, err := flowFS.ReadFile("lib/flow/" + slug + ".md") - if err != nil { - return "", err - } - return string(data), nil -} - -// Persona returns a domain/role system prompt by path. -// Paths: "secops/developer", "code/backend-architect", "smm/tiktok-strategist". -func Persona(path string) (string, error) { - data, err := personaFS.ReadFile("lib/persona/" + path + ".md") - if err != nil { - return "", err - } - return string(data), nil -} - -// ListPrompts returns all available prompt slugs. -func ListPrompts() []string { - return listDir(promptFS, "lib/prompt") -} - -// ListTasks returns all available task plan slugs (including nested like code/review). -func ListTasks() []string { - var slugs []string - fs.WalkDir(taskFS, "lib/task", func(path string, d fs.DirEntry, err error) error { - if err != nil || d.IsDir() { - return nil - } - rel := strings.TrimPrefix(path, "lib/task/") - ext := filepath.Ext(rel) - slugs = append(slugs, strings.TrimSuffix(rel, ext)) - return nil - }) - return slugs -} - -// ListFlows returns all available flow slugs. -func ListFlows() []string { - return listDir(flowFS, "lib/flow") -} - -// ListTemplates returns all prompt + task slugs (backwards compatibility). -func ListTemplates() []string { - return append(ListPrompts(), ListTasks()...) -} - -// ListPersonas returns all available persona paths. -func ListPersonas() []string { - var paths []string - fs.WalkDir(personaFS, "lib/persona", func(path string, d fs.DirEntry, err error) error { - if err != nil || d.IsDir() { - return nil - } - if strings.HasSuffix(path, ".md") { - rel := strings.TrimPrefix(path, "lib/persona/") - rel = strings.TrimSuffix(rel, ".md") - paths = append(paths, rel) - } - return nil - }) - return paths -} - -// listDir returns slugs from an embedded directory (non-recursive). -func listDir(fsys embed.FS, dir string) []string { - entries, err := fsys.ReadDir(dir) - if err != nil { - return nil - } - var slugs []string - for _, e := range entries { - if e.IsDir() { - continue - } - name := e.Name() - ext := filepath.Ext(name) - slugs = append(slugs, strings.TrimSuffix(name, ext)) - } - return slugs -} +func Prompt(slug string) (string, error) { return lib.Prompt(slug) } +func Task(slug string) (string, error) { return lib.Task(slug) } +func TaskBundle(slug string) (string, map[string]string, error) { return lib.TaskBundle(slug) } +func Flow(slug string) (string, error) { return lib.Flow(slug) } +func Persona(path string) (string, error) { return lib.Persona(path) } +func Template(slug string) (string, error) { return lib.Prompt(slug) } +func ListPrompts() []string { return lib.ListPrompts() } +func ListTasks() []string { return lib.ListTasks() } +func ListFlows() []string { return lib.ListFlows() } +func ListPersonas() []string { return lib.ListPersonas() } +func ListTemplates() []string { return append(lib.ListPrompts(), lib.ListTasks()...) }