Skip to content

Use ask.sh, devai.sh, and plan_exec.sh

The scripts in /opt/devsecops-ai/scripts are the command-line entry points for an existing local AI installation. They turn the API and model router into everyday question-answering, development, and planning workflows.

From Windows PowerShell, enter the Ubuntu distribution hosting the service:

Terminal window
wsl -d Ubuntu

Then use WSL Bash:

Terminal window
cd /opt/devsecops-ai
ls scripts/ask.sh scripts/devai.sh scripts/plan_exec.sh
systemctl status devsecops-ai ollama
ollama list

This assumes an existing deployment at /opt/devsecops-ai. For a development checkout, use its own root instead and follow installation. Do not create an empty /opt directory as a substitute for installing the project.

The scripts need Bash, curl, Python 3, and standard Linux shell utilities. Memory operations also need the project’s compatible Python environment. The examples use bash scripts/... so they do not depend on aliases, executable bits, or your shell’s PATH.

ScriptBest starting pointRouter behavior
ask.shAsk one question and continue a saved thread on the next invocationAutomatic unless MODEL_SELECTION requests a model
devai.shGenerate/review code, chat, and manage local knowledge memoryAutomatic unless DEVAI_MODEL requests a model; supports a task hint
plan_exec.shProduce a plan, then request implementation from the code specialistExplicit planner and executor models, with different task hints

All three call the FastAPI backend. They do not run a separate model server. With routing enabled, the backend analyzes the request and checks model availability. With routing disabled, it uses OLLAMA_MODEL and ignores these per-request model choices.

Argument order matters: put devai.sh and plan_exec.sh flags before the quoted task. The current parsers treat everything after the first task argument as prompt text, even when it looks like a flag.

Terminal window
cd /opt/devsecops-ai
bash scripts/ask.sh

Type the question at What would you like to know?. For example: Explain the purpose of a GitLab merge request. This script reads an interactive question; passing task text as a command-line argument is not its interface.

After the answer, look for Model: and Routing:. These report the backend’s selected model and reason. With conversation memory enabled, a saved conversation ID allows another invocation of ask.sh to continue that thread.

Terminal window
MODEL_SELECTION=qwen3.5:2b bash scripts/ask.sh
MODEL_SELECTION=qwen2.5-coder:3b TASK_TYPE=coding bash scripts/ask.sh
TASK_TYPE=planning bash scripts/ask.sh

The last example leaves model selection automatic and supplies only a planning hint. To return to automatic behavior, omit the model setting; if you previously exported it, unset it in that terminal.

ask.sh builds JSON through shell interpolation. Quoted or multiline input can break the request. Use a JSON file with the API for complex input instead of repeatedly escaping it.

Terminal window
bash scripts/devai.sh --help
bash scripts/devai.sh --health

Health output is a starting check, not proof of successful inference. Use a small request to verify generation.

Generate a response without running generated code

Section titled “Generate a response without running generated code”
Terminal window
bash scripts/devai.sh "Write a Python function that validates a nonempty project name."

The default one-shot mode displays the response and can save extracted code under /tmp/devai. It also logs activity and ingests the result into local knowledge memory. “Do not execute generated code” does not mean “no files or memory are written.”

Use automatic routing or a requested specialist

Section titled “Use automatic routing or a requested specialist”
Terminal window
DEVAI_TASK_TYPE=coding bash scripts/devai.sh "Write a Python function that adds two integers."
DEVAI_MODEL=qwen2.5-coder:3b DEVAI_TASK_TYPE=coding bash scripts/devai.sh "Write the same function with type hints."
DEVAI_MODEL=qwen3.5:2b bash scripts/devai.sh "Explain the tradeoffs in the proposed design."

Read the [Model: ... | Routing: ...] diagnostic, printed to standard error. It can disappear from a capture that saves only standard output. Model availability can cause a fallback; inspect the actual selection rather than assuming the requested model ran.

Terminal window
bash scripts/devai.sh --interactive

Type a question, or use health, history, search <text>, and exit/quit. If a response contains code blocks, this mode saves them and asks whether to execute them. Answer N when you only want to inspect the code.

Terminal window
bash scripts/devai.sh --ingest "The fictional Aurora service uses port 8123 in the training lab."
bash scripts/devai.sh --search "Aurora service port"
bash scripts/devai.sh --history
bash scripts/devai.sh --clear

Ingest/search/history operate through the local Python memory helper and vector store. --clear (also --new) resets devai’s saved thread ID; it does not erase stored conversations, knowledge, backups, or the thread saved by ask.sh.

In an isolated lab where execution is intended:

Terminal window
bash scripts/devai.sh --execute "Write a Python script that prints a greeting."

--execute/--exec asks before running extracted code. Adding --yes removes that prompt for code that passes the script’s pattern checks. Those checks are not a sandbox or a safety guarantee. The runner uses Python for Python blocks and Bash otherwise; a saved YAML or Dockerfile is not automatically deployed with the appropriate tool.

The default planner is qwen3.5:2b; the default executor is qwen2.5-coder:3b. The script supplies explicit models and planning/coding task hints to the same backend router. This is a two-phase workflow, not a separate training process.

Terminal window
cd /opt/devsecops-ai
mkdir -p /tmp/devai
bash scripts/plan_exec.sh --plan-only "Plan a small Python command-line greeting program."
less /tmp/devai/current_plan.txt

Create the temporary directory before the first planning call: the current script redirects the plan there before its code-saving helper creates the directory. TMP_DIR can select another location.

Review the plan’s objective, constraints, tasks, acceptance criteria, and handoff. A later planning call overwrites current_plan.txt, so preserve a reviewed plan separately if you need it. See the handoff guide for field types and two-pass planning.

Only when you intend to request implementation and review any offered execution:

Terminal window
bash scripts/plan_exec.sh --exec-only "Implement the reviewed Python greeting program."

This reads the existing plan, asks the code specialist for implementation, saves extracted blocks, and prompts before running them. --exec-only is not a preview flag. It still needs task text. Starting without either phase flag runs planning followed by implementation; --auto can execute generated code without individual prompts and is not a recommended first-use mode.

Terminal window
PLAN_MODEL=qwen3.5:2b EXEC_MODEL=qwen2.5-coder:3b \
bash scripts/plan_exec.sh --plan-only "Plan a small Python greeting program."

The plan-only command uses the planner; EXEC_MODEL applies when the execution phase is requested. The interactive mode (--interactive) supports plan <task>, exec <task>, help, and exit. Avoid auto <task> until its execution behavior is understood.

The planner schema includes prerequisites. The executor prompt asks for dependency installation commands in a separate Bash block beginning with # install, before the application code. Review both blocks: the current detector matches a line beginning with # install anywhere in a block, rather than strictly validating its first line.

Normal mode asks before running installation commands; --auto may run them without that prompt, subject to the script’s pattern filter. Install commands can change your environment. Blocks run in response order, and an installation failure does not reliably stop subsequent blocks because the caller suppresses execution failures.

Generated Python files undergo python3 -m py_compile before execution. A syntax failure prevents that file from running; syntax success does not establish correctness or safety. Shebang detection helps select Python versus Bash, and multiple blocks receive distinct filenames. The pattern filter is not a sandbox.

Long plans are shortened before the execution request; see command behavior. Confirm that the portion sent to the coder still contains the acceptance criteria and prerequisites.

For generated webcam or recording tools, verify that the device actually exists in the execution environment (for example, /dev/video* in WSL). Otherwise use an environment with device access; model-generated code cannot attach hardware to WSL.

The advancement is from a fixed answering model to a shared request path with task analysis, metadata signals, explicit overrides, and availability-aware selection:

ask.sh / devai.sh / plan_exec.sh
→ query + optional model + task_type
→ FastAPI model router
→ selected Ollama model
→ answer + model + routing reason

The backend also accepts prompt/playbook metadata paths, but these three helpers do not currently send prompt_id or playbook_id. Use the API when you need those signals. Neither a routing score nor a specialist label proves answer quality. Compare results using the routing lab.

Configuration, memory, and troubleshooting

Section titled “Configuration, memory, and troubleshooting”

See CLI settings and paths for exact variable names. They differ between scripts; MODEL_SELECTION does not configure devai.sh.

  • Authentication fails: check which environment file the helper reads and whether it matches the backend.
  • No model or wrong model: check ollama list, routing enablement, and the returned model/reason. Refresh the backend registry after downloading a model.
  • Plan fails with 422: the full schema plus task, or a two-pass prompt, can exceed the committed API limit. Start with a short request and inspect the deployed API schema.
  • Plan fails on a missing path: create the configured TMP_DIR and confirm it is writable.
  • Memory fails: use the project’s ChromaDB-compatible virtual environment; do not let a different system package rewrite the store.
  • Helper parsing fails after a response: compare with a direct API request and inspect that helper’s error; a working backend does not prove the shell wrapper parsed its response.

The helpers currently omit user_id, and the backend can use the credential as that identifier when conversation memory is enabled. Semantic thread isolation is also incomplete. Disabling backend memory does not disable devai.sh’s separate local knowledge ingestion. Read memory behavior before using private data.

Next: CLI settings and paths, model selection, or build an API client.