aidevops 2.52.1
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/.agent/AGENTS.md +614 -0
- package/.agent/accounts.md +65 -0
- package/.agent/aidevops/add-new-mcp-to-aidevops.md +456 -0
- package/.agent/aidevops/api-integrations.md +335 -0
- package/.agent/aidevops/architecture.md +510 -0
- package/.agent/aidevops/configs.md +274 -0
- package/.agent/aidevops/docs.md +244 -0
- package/.agent/aidevops/extension.md +311 -0
- package/.agent/aidevops/mcp-integrations.md +340 -0
- package/.agent/aidevops/mcp-troubleshooting.md +162 -0
- package/.agent/aidevops/memory-patterns.md +172 -0
- package/.agent/aidevops/providers.md +217 -0
- package/.agent/aidevops/recommendations.md +321 -0
- package/.agent/aidevops/requirements.md +301 -0
- package/.agent/aidevops/resources.md +214 -0
- package/.agent/aidevops/security-requirements.md +174 -0
- package/.agent/aidevops/security.md +350 -0
- package/.agent/aidevops/service-links.md +400 -0
- package/.agent/aidevops/services.md +357 -0
- package/.agent/aidevops/setup.md +153 -0
- package/.agent/aidevops/troubleshooting.md +389 -0
- package/.agent/aidevops.md +124 -0
- package/.agent/build-plus.md +244 -0
- package/.agent/content/guidelines.md +109 -0
- package/.agent/content.md +87 -0
- package/.agent/health.md +59 -0
- package/.agent/legal.md +59 -0
- package/.agent/loop-state/full-loop.local.md +16 -0
- package/.agent/loop-state/ralph-loop.local.md +10 -0
- package/.agent/marketing.md +440 -0
- package/.agent/memory/README.md +260 -0
- package/.agent/onboarding.md +796 -0
- package/.agent/plan-plus.md +245 -0
- package/.agent/research.md +100 -0
- package/.agent/sales.md +333 -0
- package/.agent/scripts/101domains-helper.sh +701 -0
- package/.agent/scripts/add-missing-returns.sh +140 -0
- package/.agent/scripts/agent-browser-helper.sh +311 -0
- package/.agent/scripts/agno-setup.sh +712 -0
- package/.agent/scripts/ahrefs-mcp-wrapper.js +168 -0
- package/.agent/scripts/aidevops-update-check.sh +71 -0
- package/.agent/scripts/ampcode-cli.sh +522 -0
- package/.agent/scripts/auto-version-bump.sh +156 -0
- package/.agent/scripts/autogen-helper.sh +512 -0
- package/.agent/scripts/beads-sync-helper.sh +596 -0
- package/.agent/scripts/closte-helper.sh +5 -0
- package/.agent/scripts/cloudron-helper.sh +321 -0
- package/.agent/scripts/codacy-cli-chunked.sh +581 -0
- package/.agent/scripts/codacy-cli.sh +442 -0
- package/.agent/scripts/code-audit-helper.sh +5 -0
- package/.agent/scripts/coderabbit-cli.sh +417 -0
- package/.agent/scripts/coderabbit-pro-analysis.sh +238 -0
- package/.agent/scripts/commands/code-simplifier.md +86 -0
- package/.agent/scripts/commands/full-loop.md +246 -0
- package/.agent/scripts/commands/postflight-loop.md +103 -0
- package/.agent/scripts/commands/recall.md +182 -0
- package/.agent/scripts/commands/remember.md +132 -0
- package/.agent/scripts/commands/save-todo.md +175 -0
- package/.agent/scripts/commands/session-review.md +154 -0
- package/.agent/scripts/comprehensive-quality-fix.sh +106 -0
- package/.agent/scripts/context-builder-helper.sh +522 -0
- package/.agent/scripts/coolify-cli-helper.sh +674 -0
- package/.agent/scripts/coolify-helper.sh +380 -0
- package/.agent/scripts/crawl4ai-examples.sh +401 -0
- package/.agent/scripts/crawl4ai-helper.sh +1078 -0
- package/.agent/scripts/crewai-helper.sh +681 -0
- package/.agent/scripts/dev-browser-helper.sh +513 -0
- package/.agent/scripts/dns-helper.sh +396 -0
- package/.agent/scripts/domain-research-helper.sh +917 -0
- package/.agent/scripts/dspy-helper.sh +285 -0
- package/.agent/scripts/dspyground-helper.sh +291 -0
- package/.agent/scripts/eeat-score-helper.sh +1242 -0
- package/.agent/scripts/efficient-return-fix.sh +92 -0
- package/.agent/scripts/extract-opencode-prompts.sh +128 -0
- package/.agent/scripts/find-missing-returns.sh +113 -0
- package/.agent/scripts/fix-auth-headers.sh +104 -0
- package/.agent/scripts/fix-common-strings.sh +254 -0
- package/.agent/scripts/fix-content-type.sh +100 -0
- package/.agent/scripts/fix-error-messages.sh +130 -0
- package/.agent/scripts/fix-misplaced-returns.sh +74 -0
- package/.agent/scripts/fix-remaining-literals.sh +152 -0
- package/.agent/scripts/fix-return-statements.sh +41 -0
- package/.agent/scripts/fix-s131-default-cases.sh +249 -0
- package/.agent/scripts/fix-sc2155-simple.sh +102 -0
- package/.agent/scripts/fix-shellcheck-critical.sh +187 -0
- package/.agent/scripts/fix-string-literals.sh +273 -0
- package/.agent/scripts/full-loop-helper.sh +773 -0
- package/.agent/scripts/generate-opencode-agents.sh +497 -0
- package/.agent/scripts/generate-opencode-commands.sh +1629 -0
- package/.agent/scripts/generate-skills.sh +366 -0
- package/.agent/scripts/git-platforms-helper.sh +640 -0
- package/.agent/scripts/gitea-cli-helper.sh +743 -0
- package/.agent/scripts/github-cli-helper.sh +702 -0
- package/.agent/scripts/gitlab-cli-helper.sh +682 -0
- package/.agent/scripts/gsc-add-user-helper.sh +325 -0
- package/.agent/scripts/gsc-sitemap-helper.sh +678 -0
- package/.agent/scripts/hetzner-helper.sh +485 -0
- package/.agent/scripts/hostinger-helper.sh +229 -0
- package/.agent/scripts/keyword-research-helper.sh +1815 -0
- package/.agent/scripts/langflow-helper.sh +544 -0
- package/.agent/scripts/linkedin-automation.py +241 -0
- package/.agent/scripts/linter-manager.sh +599 -0
- package/.agent/scripts/linters-local.sh +434 -0
- package/.agent/scripts/list-keys-helper.sh +488 -0
- package/.agent/scripts/local-browser-automation.py +339 -0
- package/.agent/scripts/localhost-helper.sh +744 -0
- package/.agent/scripts/loop-common.sh +806 -0
- package/.agent/scripts/mainwp-helper.sh +728 -0
- package/.agent/scripts/markdown-formatter.sh +338 -0
- package/.agent/scripts/markdown-lint-fix.sh +311 -0
- package/.agent/scripts/mass-fix-returns.sh +58 -0
- package/.agent/scripts/mcp-diagnose.sh +167 -0
- package/.agent/scripts/mcp-inspector-helper.sh +449 -0
- package/.agent/scripts/memory-helper.sh +650 -0
- package/.agent/scripts/monitor-code-review.sh +255 -0
- package/.agent/scripts/onboarding-helper.sh +706 -0
- package/.agent/scripts/opencode-github-setup-helper.sh +797 -0
- package/.agent/scripts/opencode-test-helper.sh +213 -0
- package/.agent/scripts/pagespeed-helper.sh +464 -0
- package/.agent/scripts/pandoc-helper.sh +362 -0
- package/.agent/scripts/postflight-check.sh +555 -0
- package/.agent/scripts/pre-commit-hook.sh +259 -0
- package/.agent/scripts/pre-edit-check.sh +169 -0
- package/.agent/scripts/qlty-cli.sh +356 -0
- package/.agent/scripts/quality-cli-manager.sh +525 -0
- package/.agent/scripts/quality-feedback-helper.sh +462 -0
- package/.agent/scripts/quality-fix.sh +263 -0
- package/.agent/scripts/quality-loop-helper.sh +1108 -0
- package/.agent/scripts/ralph-loop-helper.sh +836 -0
- package/.agent/scripts/ralph-upstream-check.sh +341 -0
- package/.agent/scripts/secretlint-helper.sh +847 -0
- package/.agent/scripts/servers-helper.sh +241 -0
- package/.agent/scripts/ses-helper.sh +619 -0
- package/.agent/scripts/session-review-helper.sh +404 -0
- package/.agent/scripts/setup-linters-wizard.sh +379 -0
- package/.agent/scripts/setup-local-api-keys.sh +330 -0
- package/.agent/scripts/setup-mcp-integrations.sh +472 -0
- package/.agent/scripts/shared-constants.sh +246 -0
- package/.agent/scripts/site-crawler-helper.sh +1487 -0
- package/.agent/scripts/snyk-helper.sh +940 -0
- package/.agent/scripts/sonarcloud-autofix.sh +193 -0
- package/.agent/scripts/sonarcloud-cli.sh +191 -0
- package/.agent/scripts/sonarscanner-cli.sh +455 -0
- package/.agent/scripts/spaceship-helper.sh +747 -0
- package/.agent/scripts/stagehand-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-setup.sh +441 -0
- package/.agent/scripts/stagehand-setup.sh +439 -0
- package/.agent/scripts/system-cleanup.sh +340 -0
- package/.agent/scripts/terminal-title-helper.sh +388 -0
- package/.agent/scripts/terminal-title-setup.sh +549 -0
- package/.agent/scripts/test-stagehand-both-integration.sh +317 -0
- package/.agent/scripts/test-stagehand-integration.sh +309 -0
- package/.agent/scripts/test-stagehand-python-integration.sh +341 -0
- package/.agent/scripts/todo-ready.sh +263 -0
- package/.agent/scripts/tool-version-check.sh +362 -0
- package/.agent/scripts/toon-helper.sh +469 -0
- package/.agent/scripts/twilio-helper.sh +917 -0
- package/.agent/scripts/updown-helper.sh +279 -0
- package/.agent/scripts/validate-mcp-integrations.sh +250 -0
- package/.agent/scripts/validate-version-consistency.sh +131 -0
- package/.agent/scripts/vaultwarden-helper.sh +597 -0
- package/.agent/scripts/vercel-cli-helper.sh +816 -0
- package/.agent/scripts/verify-mirrors.sh +169 -0
- package/.agent/scripts/version-manager.sh +831 -0
- package/.agent/scripts/webhosting-helper.sh +471 -0
- package/.agent/scripts/webhosting-verify.sh +238 -0
- package/.agent/scripts/wordpress-mcp-helper.sh +508 -0
- package/.agent/scripts/worktree-helper.sh +595 -0
- package/.agent/scripts/worktree-sessions.sh +577 -0
- package/.agent/seo/dataforseo.md +215 -0
- package/.agent/seo/domain-research.md +532 -0
- package/.agent/seo/eeat-score.md +659 -0
- package/.agent/seo/google-search-console.md +366 -0
- package/.agent/seo/gsc-sitemaps.md +282 -0
- package/.agent/seo/keyword-research.md +521 -0
- package/.agent/seo/serper.md +278 -0
- package/.agent/seo/site-crawler.md +387 -0
- package/.agent/seo.md +236 -0
- package/.agent/services/accounting/quickfile.md +159 -0
- package/.agent/services/communications/telfon.md +470 -0
- package/.agent/services/communications/twilio.md +569 -0
- package/.agent/services/crm/fluentcrm.md +449 -0
- package/.agent/services/email/ses.md +399 -0
- package/.agent/services/hosting/101domains.md +378 -0
- package/.agent/services/hosting/closte.md +177 -0
- package/.agent/services/hosting/cloudflare.md +251 -0
- package/.agent/services/hosting/cloudron.md +478 -0
- package/.agent/services/hosting/dns-providers.md +335 -0
- package/.agent/services/hosting/domain-purchasing.md +344 -0
- package/.agent/services/hosting/hetzner.md +327 -0
- package/.agent/services/hosting/hostinger.md +287 -0
- package/.agent/services/hosting/localhost.md +419 -0
- package/.agent/services/hosting/spaceship.md +353 -0
- package/.agent/services/hosting/webhosting.md +330 -0
- package/.agent/social-media.md +69 -0
- package/.agent/templates/plans-template.md +114 -0
- package/.agent/templates/prd-template.md +129 -0
- package/.agent/templates/tasks-template.md +108 -0
- package/.agent/templates/todo-template.md +89 -0
- package/.agent/tools/ai-assistants/agno.md +471 -0
- package/.agent/tools/ai-assistants/capsolver.md +326 -0
- package/.agent/tools/ai-assistants/configuration.md +221 -0
- package/.agent/tools/ai-assistants/overview.md +209 -0
- package/.agent/tools/ai-assistants/status.md +171 -0
- package/.agent/tools/ai-assistants/windsurf.md +193 -0
- package/.agent/tools/ai-orchestration/autogen.md +406 -0
- package/.agent/tools/ai-orchestration/crewai.md +445 -0
- package/.agent/tools/ai-orchestration/langflow.md +405 -0
- package/.agent/tools/ai-orchestration/openprose.md +487 -0
- package/.agent/tools/ai-orchestration/overview.md +362 -0
- package/.agent/tools/ai-orchestration/packaging.md +647 -0
- package/.agent/tools/browser/agent-browser.md +464 -0
- package/.agent/tools/browser/browser-automation.md +400 -0
- package/.agent/tools/browser/chrome-devtools.md +282 -0
- package/.agent/tools/browser/crawl4ai-integration.md +422 -0
- package/.agent/tools/browser/crawl4ai-resources.md +277 -0
- package/.agent/tools/browser/crawl4ai-usage.md +416 -0
- package/.agent/tools/browser/crawl4ai.md +585 -0
- package/.agent/tools/browser/dev-browser.md +341 -0
- package/.agent/tools/browser/pagespeed.md +260 -0
- package/.agent/tools/browser/playwright.md +266 -0
- package/.agent/tools/browser/playwriter.md +310 -0
- package/.agent/tools/browser/stagehand-examples.md +456 -0
- package/.agent/tools/browser/stagehand-python.md +483 -0
- package/.agent/tools/browser/stagehand.md +421 -0
- package/.agent/tools/build-agent/agent-review.md +224 -0
- package/.agent/tools/build-agent/build-agent.md +784 -0
- package/.agent/tools/build-mcp/aidevops-plugin.md +476 -0
- package/.agent/tools/build-mcp/api-wrapper.md +445 -0
- package/.agent/tools/build-mcp/build-mcp.md +240 -0
- package/.agent/tools/build-mcp/deployment.md +401 -0
- package/.agent/tools/build-mcp/server-patterns.md +632 -0
- package/.agent/tools/build-mcp/transports.md +366 -0
- package/.agent/tools/code-review/auditing.md +383 -0
- package/.agent/tools/code-review/automation.md +219 -0
- package/.agent/tools/code-review/best-practices.md +203 -0
- package/.agent/tools/code-review/codacy.md +151 -0
- package/.agent/tools/code-review/code-simplifier.md +174 -0
- package/.agent/tools/code-review/code-standards.md +309 -0
- package/.agent/tools/code-review/coderabbit.md +101 -0
- package/.agent/tools/code-review/management.md +155 -0
- package/.agent/tools/code-review/qlty.md +248 -0
- package/.agent/tools/code-review/secretlint.md +565 -0
- package/.agent/tools/code-review/setup.md +250 -0
- package/.agent/tools/code-review/snyk.md +563 -0
- package/.agent/tools/code-review/tools.md +230 -0
- package/.agent/tools/content/summarize.md +353 -0
- package/.agent/tools/context/augment-context-engine.md +468 -0
- package/.agent/tools/context/context-builder-agent.md +76 -0
- package/.agent/tools/context/context-builder.md +375 -0
- package/.agent/tools/context/context7.md +371 -0
- package/.agent/tools/context/dspy.md +302 -0
- package/.agent/tools/context/dspyground.md +374 -0
- package/.agent/tools/context/llm-tldr.md +219 -0
- package/.agent/tools/context/osgrep.md +488 -0
- package/.agent/tools/context/prompt-optimization.md +338 -0
- package/.agent/tools/context/toon.md +292 -0
- package/.agent/tools/conversion/pandoc.md +304 -0
- package/.agent/tools/credentials/api-key-management.md +154 -0
- package/.agent/tools/credentials/api-key-setup.md +224 -0
- package/.agent/tools/credentials/environment-variables.md +180 -0
- package/.agent/tools/credentials/vaultwarden.md +382 -0
- package/.agent/tools/data-extraction/outscraper.md +974 -0
- package/.agent/tools/deployment/coolify-cli.md +388 -0
- package/.agent/tools/deployment/coolify-setup.md +353 -0
- package/.agent/tools/deployment/coolify.md +345 -0
- package/.agent/tools/deployment/vercel.md +390 -0
- package/.agent/tools/git/authentication.md +132 -0
- package/.agent/tools/git/gitea-cli.md +193 -0
- package/.agent/tools/git/github-actions.md +207 -0
- package/.agent/tools/git/github-cli.md +223 -0
- package/.agent/tools/git/gitlab-cli.md +190 -0
- package/.agent/tools/git/opencode-github-security.md +350 -0
- package/.agent/tools/git/opencode-github.md +328 -0
- package/.agent/tools/git/opencode-gitlab.md +252 -0
- package/.agent/tools/git/security.md +196 -0
- package/.agent/tools/git.md +207 -0
- package/.agent/tools/opencode/oh-my-opencode.md +375 -0
- package/.agent/tools/opencode/opencode-anthropic-auth.md +446 -0
- package/.agent/tools/opencode/opencode.md +651 -0
- package/.agent/tools/social-media/bird.md +437 -0
- package/.agent/tools/task-management/beads.md +336 -0
- package/.agent/tools/terminal/terminal-title.md +251 -0
- package/.agent/tools/ui/shadcn.md +196 -0
- package/.agent/tools/ui/ui-skills.md +115 -0
- package/.agent/tools/wordpress/localwp.md +311 -0
- package/.agent/tools/wordpress/mainwp.md +391 -0
- package/.agent/tools/wordpress/scf.md +527 -0
- package/.agent/tools/wordpress/wp-admin.md +729 -0
- package/.agent/tools/wordpress/wp-dev.md +940 -0
- package/.agent/tools/wordpress/wp-preferred.md +398 -0
- package/.agent/tools/wordpress.md +95 -0
- package/.agent/workflows/branch/bugfix.md +63 -0
- package/.agent/workflows/branch/chore.md +95 -0
- package/.agent/workflows/branch/experiment.md +115 -0
- package/.agent/workflows/branch/feature.md +59 -0
- package/.agent/workflows/branch/hotfix.md +98 -0
- package/.agent/workflows/branch/refactor.md +92 -0
- package/.agent/workflows/branch/release.md +96 -0
- package/.agent/workflows/branch.md +347 -0
- package/.agent/workflows/bug-fixing.md +267 -0
- package/.agent/workflows/changelog.md +129 -0
- package/.agent/workflows/code-audit-remote.md +279 -0
- package/.agent/workflows/conversation-starter.md +69 -0
- package/.agent/workflows/error-feedback.md +578 -0
- package/.agent/workflows/feature-development.md +355 -0
- package/.agent/workflows/git-workflow.md +702 -0
- package/.agent/workflows/multi-repo-workspace.md +268 -0
- package/.agent/workflows/plans.md +709 -0
- package/.agent/workflows/postflight.md +604 -0
- package/.agent/workflows/pr.md +571 -0
- package/.agent/workflows/preflight.md +278 -0
- package/.agent/workflows/ralph-loop.md +773 -0
- package/.agent/workflows/release.md +498 -0
- package/.agent/workflows/session-manager.md +254 -0
- package/.agent/workflows/session-review.md +311 -0
- package/.agent/workflows/sql-migrations.md +631 -0
- package/.agent/workflows/version-bump.md +283 -0
- package/.agent/workflows/wiki-update.md +333 -0
- package/.agent/workflows/worktree.md +477 -0
- package/LICENSE +21 -0
- package/README.md +1446 -0
- package/VERSION +1 -0
- package/aidevops.sh +1746 -0
- package/bin/aidevops +21 -0
- package/package.json +75 -0
- package/scripts/npm-postinstall.js +60 -0
- package/setup.sh +2366 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# Efficient script to add return statements to functions that need them
|
|
5
|
+
# Based on SonarCloud S7682 analysis
|
|
6
|
+
|
|
7
|
+
cd providers || exit
|
|
8
|
+
|
|
9
|
+
# Function to add return statement to a specific line
|
|
10
|
+
add_return_to_line() {
|
|
11
|
+
local file="$1"
|
|
12
|
+
local line_num="$2"
|
|
13
|
+
|
|
14
|
+
if [[ -f "$file" ]]; then
|
|
15
|
+
# Check if line before closing brace already has return
|
|
16
|
+
local prev_line
|
|
17
|
+
prev_line=$((line_num - 1))
|
|
18
|
+
local line_content
|
|
19
|
+
line_content=$(sed -n "${prev_line}p" "$file")
|
|
20
|
+
|
|
21
|
+
if [[ ! "$line_content" =~ return ]]; then
|
|
22
|
+
echo "Adding return statement to $file at line $line_num"
|
|
23
|
+
# Use perl for more reliable in-place editing
|
|
24
|
+
perl -i -pe "if (\$. == $prev_line) { \$_ .= \" return 0\n\" }" "$file"
|
|
25
|
+
else
|
|
26
|
+
echo "Return statement already exists in $file at line $line_num"
|
|
27
|
+
fi
|
|
28
|
+
else
|
|
29
|
+
echo "File $file not found"
|
|
30
|
+
fi
|
|
31
|
+
return 0
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Process mainwp-helper.sh (most issues)
|
|
35
|
+
echo "Processing mainwp-helper.sh..."
|
|
36
|
+
for line in 64 84 115 126 140 160 180 200 220 241 262 286 310 330 350 371 391 412 432 483 512; do
|
|
37
|
+
add_return_to_line "mainwp-helper.sh" "$line"
|
|
38
|
+
done
|
|
39
|
+
|
|
40
|
+
# Process code-audit-helper.sh (13+ issues)
|
|
41
|
+
echo "Processing code-audit-helper.sh..."
|
|
42
|
+
for line in 188 202 223 237 258 272 293 332 384 411; do
|
|
43
|
+
add_return_to_line "code-audit-helper.sh" "$line"
|
|
44
|
+
done
|
|
45
|
+
|
|
46
|
+
# Process localhost-helper.sh (remaining issues)
|
|
47
|
+
echo "Processing localhost-helper.sh..."
|
|
48
|
+
for line in 166 189 266 328 460; do
|
|
49
|
+
add_return_to_line "localhost-helper.sh" "$line"
|
|
50
|
+
done
|
|
51
|
+
|
|
52
|
+
# Process cloudron-helper.sh (remaining issues)
|
|
53
|
+
echo "Processing cloudron-helper.sh..."
|
|
54
|
+
for line in 103 129 161 177 191; do
|
|
55
|
+
add_return_to_line "cloudron-helper.sh" "$line"
|
|
56
|
+
done
|
|
57
|
+
|
|
58
|
+
# Process remaining files
|
|
59
|
+
echo "Processing git-platforms-helper.sh..."
|
|
60
|
+
for line in 156 202 217 247 261 344 388 425; do
|
|
61
|
+
add_return_to_line "git-platforms-helper.sh" "$line"
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
echo "Processing ses-helper.sh..."
|
|
65
|
+
for line in 338 359 383 408 442; do
|
|
66
|
+
add_return_to_line "ses-helper.sh" "$line"
|
|
67
|
+
done
|
|
68
|
+
|
|
69
|
+
echo "Processing hetzner-helper.sh..."
|
|
70
|
+
for line in 112 157; do
|
|
71
|
+
add_return_to_line "hetzner-helper.sh" "$line"
|
|
72
|
+
done
|
|
73
|
+
|
|
74
|
+
echo "Processing hostinger-helper.sh..."
|
|
75
|
+
for line in 72 110 139; do
|
|
76
|
+
add_return_to_line "hostinger-helper.sh" "$line"
|
|
77
|
+
done
|
|
78
|
+
|
|
79
|
+
echo "Processing closte-helper.sh..."
|
|
80
|
+
for line in 105 133 247; do
|
|
81
|
+
add_return_to_line "closte-helper.sh" "$line"
|
|
82
|
+
done
|
|
83
|
+
|
|
84
|
+
echo "Processing coolify-helper.sh..."
|
|
85
|
+
add_return_to_line "coolify-helper.sh" "235"
|
|
86
|
+
|
|
87
|
+
echo "Processing dns-helper.sh..."
|
|
88
|
+
for line in 90 254; do
|
|
89
|
+
add_return_to_line "dns-helper.sh" "$line"
|
|
90
|
+
done
|
|
91
|
+
|
|
92
|
+
echo "Efficient return statement fix completed!"
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Extract OpenCode Prompts from Binary
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# Extracts embedded prompts from the OpenCode binary for use by aidevops agents.
|
|
6
|
+
# This ensures our agents stay in sync with OpenCode updates.
|
|
7
|
+
#
|
|
8
|
+
# Usage: ./extract-opencode-prompts.sh
|
|
9
|
+
# Output: ~/.aidevops/cache/opencode-prompts/
|
|
10
|
+
# =============================================================================
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
# Colors
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
BLUE='\033[0;34m'
|
|
17
|
+
YELLOW='\033[1;33m'
|
|
18
|
+
# shellcheck disable=SC2034 # RED reserved for future error messages
|
|
19
|
+
RED='\033[0;31m'
|
|
20
|
+
NC='\033[0m'
|
|
21
|
+
|
|
22
|
+
CACHE_DIR="$HOME/.aidevops/cache/opencode-prompts"
|
|
23
|
+
OPENCODE_BIN=""
|
|
24
|
+
|
|
25
|
+
# Find OpenCode binary
|
|
26
|
+
find_opencode_binary() {
|
|
27
|
+
local locations=(
|
|
28
|
+
"$HOME/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode"
|
|
29
|
+
"$HOME/.bun/install/global/node_modules/opencode-darwin-x64/bin/opencode"
|
|
30
|
+
"$HOME/.bun/install/global/node_modules/opencode-linux-x64/bin/opencode"
|
|
31
|
+
"$HOME/.bun/install/global/node_modules/opencode-linux-arm64/bin/opencode"
|
|
32
|
+
"/usr/local/bin/opencode"
|
|
33
|
+
"$HOME/.local/bin/opencode"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
for loc in "${locations[@]}"; do
|
|
37
|
+
if [[ -f "$loc" ]]; then
|
|
38
|
+
OPENCODE_BIN="$loc"
|
|
39
|
+
return 0
|
|
40
|
+
fi
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
# Try which as fallback
|
|
44
|
+
if command -v opencode &>/dev/null; then
|
|
45
|
+
local bin_path
|
|
46
|
+
bin_path=$(which opencode)
|
|
47
|
+
# Follow symlinks to find actual binary
|
|
48
|
+
if [[ -L "$bin_path" ]]; then
|
|
49
|
+
bin_path=$(readlink -f "$bin_path" 2>/dev/null || readlink "$bin_path")
|
|
50
|
+
fi
|
|
51
|
+
if [[ -f "$bin_path" ]]; then
|
|
52
|
+
OPENCODE_BIN="$bin_path"
|
|
53
|
+
return 0
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
return 1
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Extract a specific prompt by variable name
|
|
61
|
+
# Usage: extract_prompt "plan_default" "plan.txt"
|
|
62
|
+
extract_prompt() {
|
|
63
|
+
local var_name="$1"
|
|
64
|
+
local output_file="$2"
|
|
65
|
+
local start_marker="var ${var_name} = \`"
|
|
66
|
+
|
|
67
|
+
# Extract content between backticks
|
|
68
|
+
strings "$OPENCODE_BIN" | \
|
|
69
|
+
grep -A 500 "^${start_marker}" | \
|
|
70
|
+
head -n 100 | \
|
|
71
|
+
sed "s/^${start_marker}//" | \
|
|
72
|
+
sed '/^var init_/q' | \
|
|
73
|
+
sed '/^var init_/d' | \
|
|
74
|
+
sed 's/`$//' \
|
|
75
|
+
> "$CACHE_DIR/$output_file"
|
|
76
|
+
|
|
77
|
+
# Verify extraction worked
|
|
78
|
+
if [[ -s "$CACHE_DIR/$output_file" ]]; then
|
|
79
|
+
echo -e " ${GREEN}✓${NC} Extracted $output_file"
|
|
80
|
+
return 0
|
|
81
|
+
else
|
|
82
|
+
echo -e " ${YELLOW}⚠${NC} Failed to extract $output_file"
|
|
83
|
+
return 1
|
|
84
|
+
fi
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Get OpenCode version
|
|
88
|
+
get_opencode_version() {
|
|
89
|
+
if command -v opencode &>/dev/null; then
|
|
90
|
+
opencode --version 2>/dev/null || echo "unknown"
|
|
91
|
+
else
|
|
92
|
+
echo "unknown"
|
|
93
|
+
fi
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main() {
|
|
97
|
+
echo -e "${BLUE}Extracting OpenCode prompts...${NC}"
|
|
98
|
+
|
|
99
|
+
# Find binary
|
|
100
|
+
if ! find_opencode_binary; then
|
|
101
|
+
echo -e "${YELLOW}Warning: OpenCode binary not found. Skipping prompt extraction.${NC}"
|
|
102
|
+
echo -e "${YELLOW}Install OpenCode with: bun install -g opencode-ai${NC}"
|
|
103
|
+
return 0
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
echo -e " Found binary: $OPENCODE_BIN"
|
|
107
|
+
|
|
108
|
+
# Create cache directory
|
|
109
|
+
mkdir -p "$CACHE_DIR"
|
|
110
|
+
|
|
111
|
+
# Get version for tracking
|
|
112
|
+
local version
|
|
113
|
+
version=$(get_opencode_version)
|
|
114
|
+
echo "$version" > "$CACHE_DIR/version.txt"
|
|
115
|
+
echo -e " OpenCode version: $version"
|
|
116
|
+
|
|
117
|
+
# Extract prompts
|
|
118
|
+
extract_prompt "plan_default" "plan-reminder.txt" || true
|
|
119
|
+
extract_prompt "build_switch_default" "build-switch.txt" || true
|
|
120
|
+
extract_prompt "max_steps_default" "max-steps.txt" || true
|
|
121
|
+
|
|
122
|
+
# Record extraction timestamp
|
|
123
|
+
date -u +"%Y-%m-%dT%H:%M:%SZ" > "$CACHE_DIR/extracted-at.txt"
|
|
124
|
+
|
|
125
|
+
echo -e "${GREEN}Done!${NC} Prompts cached in $CACHE_DIR"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
main "$@"
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# Find Functions Missing Return Statements
|
|
5
|
+
# Identify functions that need return statements for S7682 compliance
|
|
6
|
+
#
|
|
7
|
+
# Author: AI DevOps Framework
|
|
8
|
+
# Version: 1.1.1
|
|
9
|
+
|
|
10
|
+
# Colors for output
|
|
11
|
+
readonly BLUE='\033[0;34m'
|
|
12
|
+
readonly RED='\033[0;31m'
|
|
13
|
+
readonly NC='\033[0m'
|
|
14
|
+
|
|
15
|
+
print_info() {
|
|
16
|
+
local _arg1="$1"
|
|
17
|
+
echo -e "${BLUE}ℹ️ $_arg1${NC}"
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
print_error() {
|
|
22
|
+
local _arg1="$1"
|
|
23
|
+
echo -e "${RED}❌ $_arg1${NC}"
|
|
24
|
+
return 0
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Find functions missing return statements in a file
|
|
28
|
+
find_missing_returns_in_file() {
|
|
29
|
+
local file="$1"
|
|
30
|
+
|
|
31
|
+
print_info "Analyzing: $file"
|
|
32
|
+
|
|
33
|
+
# Extract function definitions and check for return statements
|
|
34
|
+
awk '
|
|
35
|
+
BEGIN {
|
|
36
|
+
in_function = 0
|
|
37
|
+
function_name = ""
|
|
38
|
+
function_content = ""
|
|
39
|
+
brace_count = 0
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Function start
|
|
43
|
+
/^[a-zA-Z_][a-zA-Z0-9_]*\(\)[[:space:]]*\{/ {
|
|
44
|
+
if (in_function) {
|
|
45
|
+
# Previous function ended without proper closing
|
|
46
|
+
if (function_content !~ /return[[:space:]]+[0-9]+/ &&
|
|
47
|
+
function_content !~ /return[[:space:]]+\$/ &&
|
|
48
|
+
function_content !~ /return[[:space:]]*$/ &&
|
|
49
|
+
function_content !~ /exit[[:space:]]+[0-9]+/) {
|
|
50
|
+
print "Missing return: " function_name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
in_function = 1
|
|
55
|
+
function_name = $1
|
|
56
|
+
gsub(/\(\).*/, "", function_name)
|
|
57
|
+
function_content = ""
|
|
58
|
+
brace_count = 1
|
|
59
|
+
next
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Inside function
|
|
63
|
+
in_function == 1 {
|
|
64
|
+
function_content = function_content "\n" $0
|
|
65
|
+
|
|
66
|
+
# Count braces
|
|
67
|
+
brace_count += gsub(/\{/, "&")
|
|
68
|
+
brace_count -= gsub(/\}/, "&")
|
|
69
|
+
|
|
70
|
+
# Function ends
|
|
71
|
+
if (brace_count == 0) {
|
|
72
|
+
if (function_content !~ /return[[:space:]]+[0-9]+/ &&
|
|
73
|
+
function_content !~ /return[[:space:]]+\$/ &&
|
|
74
|
+
function_content !~ /return[[:space:]]*$/ &&
|
|
75
|
+
function_content !~ /exit[[:space:]]+[0-9]+/) {
|
|
76
|
+
print "Missing return: " function_name
|
|
77
|
+
}
|
|
78
|
+
in_function = 0
|
|
79
|
+
function_name = ""
|
|
80
|
+
function_content = ""
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
END {
|
|
85
|
+
# Handle case where file ends while in function
|
|
86
|
+
if (in_function && function_content !~ /return[[:space:]]+[0-9]+/ &&
|
|
87
|
+
function_content !~ /return[[:space:]]*$/ &&
|
|
88
|
+
function_content !~ /exit[[:space:]]+[0-9]+/) {
|
|
89
|
+
print "Missing return: " function_name
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
' "$file"
|
|
93
|
+
return 0
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Main execution
|
|
97
|
+
main() {
|
|
98
|
+
local target="${1:-.}"
|
|
99
|
+
|
|
100
|
+
if [[ -f "$target" && "$target" == *.sh ]]; then
|
|
101
|
+
find_missing_returns_in_file "$target"
|
|
102
|
+
elif [[ -d "$target" ]]; then
|
|
103
|
+
find "$target" -name "*.sh" -type f | while read -r file; do
|
|
104
|
+
find_missing_returns_in_file "$file"
|
|
105
|
+
done
|
|
106
|
+
else
|
|
107
|
+
print_error "Invalid target: $target"
|
|
108
|
+
return 1
|
|
109
|
+
fi
|
|
110
|
+
return 0
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main "$@"
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# Fix Authorization Header String Literals
|
|
5
|
+
# Replace repeated "Authorization: Bearer" patterns with constants
|
|
6
|
+
#
|
|
7
|
+
# Author: AI DevOps Framework
|
|
8
|
+
# Version: 1.1.1
|
|
9
|
+
|
|
10
|
+
# Colors for output
|
|
11
|
+
readonly GREEN='\033[0;32m'
|
|
12
|
+
readonly BLUE='\033[0;34m'
|
|
13
|
+
readonly NC='\033[0m'
|
|
14
|
+
|
|
15
|
+
print_success() {
|
|
16
|
+
local _arg1="$1"
|
|
17
|
+
echo -e "${GREEN}✅ $_arg1${NC}"
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
print_info() {
|
|
22
|
+
local _arg1="$1"
|
|
23
|
+
echo -e "${BLUE}ℹ️ $_arg1${NC}"
|
|
24
|
+
return 0
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Fix Authorization header in a file
|
|
28
|
+
fix_auth_header_in_file() {
|
|
29
|
+
local file="$1"
|
|
30
|
+
local count
|
|
31
|
+
count=$(grep -c "Authorization: Bearer" "$file" 2>/dev/null || echo "0")
|
|
32
|
+
|
|
33
|
+
if [[ $count -ge 3 ]]; then
|
|
34
|
+
print_info "Fixing $count Authorization header occurrences in: $file"
|
|
35
|
+
|
|
36
|
+
# Add constant if not present
|
|
37
|
+
if ! grep -q "AUTH_BEARER_PREFIX" "$file"; then
|
|
38
|
+
# Find where to insert the constant (after CONTENT_TYPE_JSON or after colors)
|
|
39
|
+
if grep -q "readonly CONTENT_TYPE_JSON" "$file"; then
|
|
40
|
+
sed -i '' '/readonly CONTENT_TYPE_JSON/a\
|
|
41
|
+
readonly AUTH_BEARER_PREFIX="Authorization: Bearer"
|
|
42
|
+
' "$file"
|
|
43
|
+
elif grep -q "NC=.*No Color" "$file"; then
|
|
44
|
+
sed -i '' '/NC=.*No Color/a\
|
|
45
|
+
\
|
|
46
|
+
# Common constants\
|
|
47
|
+
readonly AUTH_BEARER_PREFIX="Authorization: Bearer"
|
|
48
|
+
' "$file"
|
|
49
|
+
elif grep -q "readonly.*NC=" "$file"; then
|
|
50
|
+
sed -i '' '/readonly.*NC=/a\
|
|
51
|
+
\
|
|
52
|
+
# Common constants\
|
|
53
|
+
readonly AUTH_BEARER_PREFIX="Authorization: Bearer"
|
|
54
|
+
' "$file"
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Replace occurrences - handle different patterns
|
|
59
|
+
sed -i '' "s/\"Authorization: Bearer \\\$api_token\"/\"\$AUTH_BEARER_PREFIX \$api_token\"/g" "$file"
|
|
60
|
+
sed -i '' "s/\"Authorization: Bearer \\\${api_token}\"/\"\$AUTH_BEARER_PREFIX \${api_token}\"/g" "$file"
|
|
61
|
+
sed -i '' "s/\"Authorization: Bearer \\\$token\"/\"\$AUTH_BEARER_PREFIX \$token\"/g" "$file"
|
|
62
|
+
sed -i '' "s/\"Authorization: Bearer \\\${token}\"/\"\$AUTH_BEARER_PREFIX \${token}\"/g" "$file"
|
|
63
|
+
|
|
64
|
+
# Verify
|
|
65
|
+
local new_count
|
|
66
|
+
new_count=$(grep -c "Authorization: Bearer" "$file" 2>/dev/null || echo "0")
|
|
67
|
+
local const_count
|
|
68
|
+
const_count=$(grep -c "AUTH_BEARER_PREFIX" "$file" 2>/dev/null || echo "0")
|
|
69
|
+
|
|
70
|
+
if [[ $new_count -eq 1 && $const_count -gt 1 ]]; then
|
|
71
|
+
print_success "Fixed $file: $count → 1 definition + $((const_count-1)) usages"
|
|
72
|
+
return 0
|
|
73
|
+
else
|
|
74
|
+
print_info "Partial fix in $file: $new_count literals remaining, $const_count constant usages"
|
|
75
|
+
return 1
|
|
76
|
+
fi
|
|
77
|
+
else
|
|
78
|
+
print_info "Skipping $file: only $count occurrences (need 3+)"
|
|
79
|
+
return 1
|
|
80
|
+
fi
|
|
81
|
+
return 0
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Main execution
|
|
85
|
+
main() {
|
|
86
|
+
print_info "Fixing Authorization header string literals in provider files..."
|
|
87
|
+
|
|
88
|
+
local files_fixed=0
|
|
89
|
+
local files_processed=0
|
|
90
|
+
|
|
91
|
+
for file in .agent/scripts/*.sh; do
|
|
92
|
+
if [[ -f "$file" ]]; then
|
|
93
|
+
((files_processed++))
|
|
94
|
+
if fix_auth_header_in_file "$file"; then
|
|
95
|
+
((files_fixed++))
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
done
|
|
99
|
+
|
|
100
|
+
print_success "Summary: $files_fixed/$files_processed files fixed"
|
|
101
|
+
return 0
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
main "$@"
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# Common String Literals Fix Script
|
|
5
|
+
# Fix the most common repeated string literals for SonarCloud S1192 compliance
|
|
6
|
+
#
|
|
7
|
+
# Usage: ./fix-common-strings.sh [file|directory]
|
|
8
|
+
#
|
|
9
|
+
# Author: AI DevOps Framework
|
|
10
|
+
# Version: 1.1.1
|
|
11
|
+
# License: MIT
|
|
12
|
+
|
|
13
|
+
# Colors for output
|
|
14
|
+
readonly GREEN='\033[0;32m'
|
|
15
|
+
readonly BLUE='\033[0;34m'
|
|
16
|
+
readonly YELLOW='\033[1;33m'
|
|
17
|
+
readonly RED='\033[0;31m'
|
|
18
|
+
readonly PURPLE='\033[0;35m'
|
|
19
|
+
readonly NC='\033[0m' # No Color
|
|
20
|
+
|
|
21
|
+
# Print functions
|
|
22
|
+
print_success() {
|
|
23
|
+
local message="$1"
|
|
24
|
+
echo -e "${GREEN}✅ $message${NC}"
|
|
25
|
+
return 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
print_info() {
|
|
29
|
+
local message="$1"
|
|
30
|
+
echo -e "${BLUE}ℹ️ $message${NC}"
|
|
31
|
+
return 0
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
print_warning() {
|
|
35
|
+
local message="$1"
|
|
36
|
+
echo -e "${YELLOW}⚠️ $message${NC}"
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
print_error() {
|
|
41
|
+
local message="$1"
|
|
42
|
+
echo -e "${RED}❌ $message${NC}" >&2
|
|
43
|
+
return 0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
print_header() {
|
|
47
|
+
local message="$1"
|
|
48
|
+
echo -e "${PURPLE}🔧 $message${NC}"
|
|
49
|
+
return 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# Fix common repeated strings in a file
|
|
53
|
+
fix_common_strings_in_file() {
|
|
54
|
+
local file="$1"
|
|
55
|
+
local backup_file="${file}.backup"
|
|
56
|
+
local temp_file
|
|
57
|
+
temp_file=$(mktemp)
|
|
58
|
+
local changes_made=0
|
|
59
|
+
|
|
60
|
+
print_info "Processing: $file"
|
|
61
|
+
|
|
62
|
+
# Create backup
|
|
63
|
+
cp "$file" "$backup_file"
|
|
64
|
+
|
|
65
|
+
# Check if file needs constants section
|
|
66
|
+
local needs_constants=false
|
|
67
|
+
|
|
68
|
+
# Check for common repeated strings
|
|
69
|
+
if grep -q "Content-Type: application/json" "$file" && \
|
|
70
|
+
[[ $(grep -c "Content-Type: application/json" "$file") -ge 3 ]]; then
|
|
71
|
+
needs_constants=true
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if grep -q "Authorization: Bearer" "$file" && \
|
|
75
|
+
[[ $(grep -c "Authorization: Bearer" "$file") -ge 3 ]]; then
|
|
76
|
+
needs_constants=true
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
if grep -q "Unknown command:" "$file" && \
|
|
80
|
+
[[ $(grep -c "Unknown command:" "$file") -ge 3 ]]; then
|
|
81
|
+
needs_constants=true
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
if [[ "$needs_constants" == "true" ]]; then
|
|
85
|
+
# Add constants section if not present
|
|
86
|
+
if ! grep -q "# HTTP constants" "$file" && ! grep -q "# Common constants" "$file"; then
|
|
87
|
+
# Find a good place to insert constants (after colors, before functions)
|
|
88
|
+
awk '
|
|
89
|
+
BEGIN { constants_added = 0 }
|
|
90
|
+
/^readonly.*NC=/ && !constants_added {
|
|
91
|
+
print $0
|
|
92
|
+
print ""
|
|
93
|
+
print "# Common constants"
|
|
94
|
+
constants_added = 1
|
|
95
|
+
next
|
|
96
|
+
}
|
|
97
|
+
/^# Print functions/ && !constants_added {
|
|
98
|
+
print "# Common constants"
|
|
99
|
+
print ""
|
|
100
|
+
print $0
|
|
101
|
+
constants_added = 1
|
|
102
|
+
next
|
|
103
|
+
}
|
|
104
|
+
{ print }
|
|
105
|
+
' "$file" > "$temp_file"
|
|
106
|
+
mv "$temp_file" "$file"
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
# Add specific constants and replace strings
|
|
110
|
+
|
|
111
|
+
# Content-Type header
|
|
112
|
+
local content_type_count
|
|
113
|
+
content_type_count=$(grep -c "Content-Type: application/json" "$file" 2>/dev/null || echo "0")
|
|
114
|
+
if [[ $content_type_count -ge 3 ]]; then
|
|
115
|
+
if ! grep -q "readonly.*CONTENT_TYPE_JSON" "$file"; then
|
|
116
|
+
sed -i '/# Common constants/a readonly CONTENT_TYPE_JSON="Content-Type: application/json"' "$file"
|
|
117
|
+
changes_made=1
|
|
118
|
+
fi
|
|
119
|
+
sed -i 's/"Content-Type: application\/json"/$CONTENT_TYPE_JSON/g' "$file"
|
|
120
|
+
print_success "Replaced $content_type_count occurrences of Content-Type header"
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
# Authorization header pattern
|
|
124
|
+
local auth_count
|
|
125
|
+
auth_count=$(grep -c "Authorization: Bearer" "$file" 2>/dev/null || echo "0")
|
|
126
|
+
if [[ "$auth_count" -ge 3 ]]; then
|
|
127
|
+
if ! grep -q "readonly.*AUTH_BEARER_PREFIX" "$file"; then
|
|
128
|
+
sed -i '/# Common constants/a readonly AUTH_BEARER_PREFIX="Authorization: Bearer"' "$file"
|
|
129
|
+
changes_made=1
|
|
130
|
+
fi
|
|
131
|
+
sed -i 's|"Authorization: Bearer \([^"]*\)"|"$AUTH_BEARER_PREFIX \1"|g' "$file"
|
|
132
|
+
print_success "Replaced $auth_count occurrences of Authorization header"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Unknown command message
|
|
136
|
+
local unknown_cmd_count
|
|
137
|
+
unknown_cmd_count=$(grep -c "Unknown command:" "$file" 2>/dev/null || echo "0")
|
|
138
|
+
if [[ "$unknown_cmd_count" -ge 3 ]]; then
|
|
139
|
+
if ! grep -q "readonly.*ERROR_UNKNOWN_COMMAND" "$file"; then
|
|
140
|
+
sed -i '/# Common constants/a readonly ERROR_UNKNOWN_COMMAND="Unknown command:"' "$file"
|
|
141
|
+
changes_made=1
|
|
142
|
+
fi
|
|
143
|
+
sed -i 's|"Unknown command: \$command"|"$ERROR_UNKNOWN_COMMAND $command"|g' "$file"
|
|
144
|
+
print_success "Replaced $unknown_cmd_count occurrences of unknown command message"
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# Help message
|
|
148
|
+
local help_count
|
|
149
|
+
help_count=$(grep -c "help.*- Show this help message" "$file" 2>/dev/null || echo "0")
|
|
150
|
+
if [[ "$help_count" -ge 3 ]]; then
|
|
151
|
+
if ! grep -q "readonly.*HELP_MESSAGE" "$file"; then
|
|
152
|
+
sed -i '/# Common constants/a readonly HELP_MESSAGE_SUFFIX="- Show this help message"' "$file"
|
|
153
|
+
changes_made=1
|
|
154
|
+
fi
|
|
155
|
+
sed -i 's|" help[[:space:]]*- Show this help message"|" help - $HELP_MESSAGE_SUFFIX"|g' "$file"
|
|
156
|
+
print_success "Replaced $help_count occurrences of help message"
|
|
157
|
+
fi
|
|
158
|
+
|
|
159
|
+
# Usage message
|
|
160
|
+
local usage_count
|
|
161
|
+
usage_count=$(grep -c "Usage: \\$0" "$file" 2>/dev/null || echo "0")
|
|
162
|
+
if [[ "$usage_count" -ge 3 ]]; then
|
|
163
|
+
if ! grep -q "readonly.*USAGE_PREFIX" "$file"; then
|
|
164
|
+
sed -i '/# Common constants/a readonly USAGE_PREFIX="Usage:"' "$file"
|
|
165
|
+
changes_made=1
|
|
166
|
+
fi
|
|
167
|
+
sed -i 's|"Usage: \\$0"|"$USAGE_PREFIX $0"|g' "$file"
|
|
168
|
+
print_success "Replaced $usage_count occurrences of usage message"
|
|
169
|
+
fi
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
if [[ $changes_made -gt 0 ]]; then
|
|
173
|
+
print_success "Fixed repeated strings in: $file"
|
|
174
|
+
return 0
|
|
175
|
+
else
|
|
176
|
+
rm "$backup_file"
|
|
177
|
+
print_info "No repeated strings requiring fixes in: $file"
|
|
178
|
+
return 1
|
|
179
|
+
fi
|
|
180
|
+
return 0
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# Process directory for common string fixes
|
|
184
|
+
process_directory_common_strings() {
|
|
185
|
+
local target_dir="${1:-.}"
|
|
186
|
+
|
|
187
|
+
print_header "Fixing Common Repeated Strings in: $target_dir"
|
|
188
|
+
|
|
189
|
+
local files_processed=0
|
|
190
|
+
local files_modified=0
|
|
191
|
+
|
|
192
|
+
find "$target_dir" -name "*.sh" -type f | while read -r file; do
|
|
193
|
+
((files_processed++))
|
|
194
|
+
if fix_common_strings_in_file "$file"; then
|
|
195
|
+
((files_modified++))
|
|
196
|
+
fi
|
|
197
|
+
done
|
|
198
|
+
|
|
199
|
+
print_info "Summary: $files_modified/$files_processed files modified"
|
|
200
|
+
return 0
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
# Show help message
|
|
204
|
+
show_help() {
|
|
205
|
+
print_header "Common String Literals Fix Help"
|
|
206
|
+
echo ""
|
|
207
|
+
echo "Usage: $0 [target]"
|
|
208
|
+
echo ""
|
|
209
|
+
echo "Examples:"
|
|
210
|
+
echo " $0 .agent/scripts/"
|
|
211
|
+
echo " $0 setup.sh"
|
|
212
|
+
echo " $0 ."
|
|
213
|
+
echo ""
|
|
214
|
+
echo "This script addresses SonarCloud S1192 violations by fixing the most common repeated strings:"
|
|
215
|
+
echo ""
|
|
216
|
+
echo "Fixed patterns:"
|
|
217
|
+
echo " • \"Content-Type: application/json\" → \$CONTENT_TYPE_JSON"
|
|
218
|
+
echo " • \"Authorization: Bearer\" → \$AUTH_BEARER_PREFIX"
|
|
219
|
+
echo " • \"Unknown command:\" → \$ERROR_UNKNOWN_COMMAND"
|
|
220
|
+
echo " • \"Usage: \\$0\" → \\$USAGE_PREFIX"
|
|
221
|
+
echo " • Help messages → \$HELP_MESSAGE_SUFFIX"
|
|
222
|
+
echo ""
|
|
223
|
+
echo "Requirements:"
|
|
224
|
+
echo " • String must appear 3+ times in the same file"
|
|
225
|
+
echo " • Constants are added to existing or new constants section"
|
|
226
|
+
echo " • Backup files (.backup) are created for all modified files"
|
|
227
|
+
echo ""
|
|
228
|
+
echo "This targets the highest-impact repeated strings for maximum S1192 compliance improvement."
|
|
229
|
+
return 0
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
# Main function
|
|
233
|
+
main() {
|
|
234
|
+
local target="${1:-.}"
|
|
235
|
+
|
|
236
|
+
if [[ "$target" == "help" || "$target" == "--help" || "$target" == "-h" ]]; then
|
|
237
|
+
show_help
|
|
238
|
+
return 0
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
if [[ -f "$target" && "$target" == *.sh ]]; then
|
|
242
|
+
fix_common_strings_in_file "$target"
|
|
243
|
+
elif [[ -d "$target" ]]; then
|
|
244
|
+
process_directory_common_strings "$target"
|
|
245
|
+
else
|
|
246
|
+
print_error "Invalid target: $target"
|
|
247
|
+
print_info "Use: $0 help for usage information"
|
|
248
|
+
return 1
|
|
249
|
+
fi
|
|
250
|
+
return 0
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
# Execute main function with all arguments
|
|
254
|
+
main "$@"
|