odoo-task-env
Stand up the working environment for one Odoo task: find work that already exists, create or reuse an isolated git worktree on the task branch, bring a runnable stack up. Use at the START of implementing any task, and whenever one is picked back up.
- License 许可
- MIT
- 最近更新
- 2026-11-02
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- odoo-task-env
- description
- Stand up the working environment for one Odoo task: find work that already exists, create or reuse an isolated git worktree on the task branch, bring a runnable stack up. Use at the START of implementing any task, and whenever one is picked back up.
- user-invocable
- false
02 资源文件 7
- 脚本scripts/_common.sh1.7 KB
- 脚本scripts/existing-work.sh7.3 KB
- 脚本scripts/preflight.sh9.8 KB
- 脚本scripts/stack-ensure.sh13.7 KB
- 脚本scripts/tests/existing-work.test.sh6.5 KB
- 脚本scripts/tests/task-env.test.sh21.3 KB
- 脚本scripts/worktree-ensure.sh5.7 KB
03 SKILL.md 正文
Odoo Task Environment
Three questions, in this order, each answered by one script:
- Does work for this task already exist? (branches and PRs, both naming conventions)
- Do the worktree and the branch exist? (create or reuse, never a second one)
- Is an Odoo stack running? (reuse, restart or create, never a second one)
Inputs: repo, repo_root, base_branch and odoo_version from the resolved project;
the task_id; a slug from the task name. base_branch is the base for every step. It
is the <base_branch> argument of the scripts below. When project-resolve.sh prints a
null base_branch (no branch of the flow exists on origin), pass an empty string:
existing-work.sh and worktree-ensure.sh print a warning and use origin/HEAD. A
repo with no repo-map entry is a warning, not a stop: use repo_root and origin
from the resolver.
Where this runs
| Context | Repos tree | Worktrees | Stacks |
|---|---|---|---|
| Host | $REPOS_DIR/<repo> |
yes | stack-ensure.sh manages docker |
| Devcontainer | not visible; the checkout is bind-mounted at /mnt/extra-addons |
yes, pass --repo-root /mnt/extra-addons |
already inside one; docker may be on PATH, odoo + postgres decide |
The context is detected container first: odoo on PATH and pg_isready answering
means devcontainer, whether or not docker is on PATH (the devcontainer mounts the
host socket). Only then is docker checked for host.
Every script takes --repo-root DIR to bypass repos-tree resolution. Inside the
devcontainer it is required.
Scripts
Every script prints one JSON object as its last stdout line. Write every path in full.
0. Preflight (once per machine or after a rebuild)
<base directory>/scripts/preflight.sh [--soft] [--target-series V] [--custom-tree DIR]
The series check fails (exit 1, failures[] carries both values) when ODOO_VERSION does not start with V.
In a devcontainer, --custom-tree DIR also imports every enterprise module in the dependency closure of the modules under DIR (failure import <name>: <error>, or closure: unknown module <name>).
→ {"ok","context","failures":[],"warnings":[],"ram_available_gb","repos_dir"}
Runs every check and reports all failures. On the host: docker, a populated repos tree,
the devcontainer CLI, gh. Inside a container: odoo, postgres, gh. Exit 1 on any
failure, 0 with --soft.
1. Existing work
<base directory>/scripts/existing-work.sh <repo> <task_id> <base_branch> [--repo-root DIR]
→ {"state","branch","candidates":[...],"prs":[...],"gh_error"}
| state | Meaning | Do |
|---|---|---|
complete |
a candidate branch merged into base, or a PR MERGED | Stop. Report it. Do not redo. |
resume |
exactly one unmerged candidate | Continue on branch; pass it as <resume_branch> |
ambiguous |
two or more unmerged candidates | Stop. List the candidates. Do not choose. |
none |
nothing found | Start fresh |
- Both branch forms are probed:
<id>#<slug>and<id>-<slug>. "prs": []with a non-nullgh_errormeans unknown, not "no PRs". Say so.
2. Worktree and branch
<base directory>/scripts/worktree-ensure.sh <repo> <task_id> <slug> <base_branch> [<resume_branch>] [--repo-root DIR]
→ {"worktree","branch","status":"created"|"reused"}
- Idempotent and flocked per repo. On reuse the branch is read from the worktree.
- A new task branch has no upstream. The first
pr-open.shpush sets it, so a baregit pushcannot reach the base branch. - It is the single git writer for the task branch. No command creates a branch.
- This skill records no time. Time comes from the dispatched job row and the hook events.
<resume_branch>is adopted as it stands: never reset, rebased or re-cut.
3. Stack
<base directory>/scripts/stack-ensure.sh <repo> [--target-series NN.0] [--repo-root DIR]
→ {"stack","status":"reused"|"restarted"|"created"|"in-container","stopped_lru":[]}
- One stack per project, host-globally locked, LRU eviction below
MIN_FREE_GB. Readiness is proved before it returns. in-containermeans you are already inside the stack. It reports the core asodoo_version, the fullodoo --versionline (Odoo Server 19.0-20260810), andside_cores:[{"series":"18.0","bin","conf","version"}, ...]for each$ODOO_SRC_ROOT/odooNN-bin(default/var/lib/odoo/src) withodooNN.confbeside it,[]when none. With--target-series, a disagreement with the core's major adds"series_mismatch": trueand awarning; the exit is still 0. A side core for the target series meansrun-tests.shcan still run it.--repo-root DIRis the repo checkout on the host (replaces$REPOS_DIR/<repo>); in a container it is accepted and ignored.- Every exit path prints one JSON line and exits 0, or prints an error on stderr and
exits non-zero. Exit 0 always comes with JSON: if you see none, your pipe (for
example
| tail -1) lost it, so check the exit code. exit 5— neither a working Odoo container (odooon PATH andpg_isreadyanswering) nor docker → stop; you are in the wrong place.exit 2— usage, or on the host the repos tree cannot be resolved (the message names--repo-rootandREPOS_DIR), or the repo directory is missing → stop; fix the call.- Never point it at a worktree path. That mints a second compose project for the repo.
Re-run
- Reuse the worktree and the branch. Never create a second one.
- Report an open PR before you create anything.
- Report
statusas printed (createdorreused).
Environment knobs
| Variable | Default | Why you would change it |
|---|---|---|
ODOO_DEV_HOME |
$HOME/.config/odoo-dev |
The state root: the repo map and tasks/<id>/. <plugin root>/scripts/state-dir.sh is the one script that resolves it. odoo-dev doctor --migrate sets it up once |
REPOS_DIR |
resolved by repos-dir.sh |
Non-standard repos tree. A tree with one clone declares itself with touch <tree>/.odoo-repos-dir |
WORKTREE_SUBDIR |
.worktrees |
Worktrees live elsewhere in this repo |
ODOO_ACTIVE_REPOS |
empty | Protect in-use stacks from LRU eviction |
MIN_FREE_GB |
6 |
A different RAM budget |
ODOO_SHARED_COMPOSE |
$REPOS_DIR/.devcontainer/shared/compose.yml |
The shared postgres and proxy stack lives elsewhere |
ODOO_REPO_MAP_SCRIPTS |
the sibling map skill's scripts/ |
The map skill moved |
Stop conditions
existing-work.sh→completeorambiguous: stop and report.- An open PR for this task: stop and report it. Never cut a second branch.
stack-ensure.shexit 5 or exit 2: stop.
04 同仓库更多 Skills
report-incident
Draft a terse GitHub issue for an incident in the Odoo dev suite (odoo-dev, odoo-orchestrator, dispatcher), with a current environment block and no private data. Files it only after you approve. Use when a tool or workflow failed.
principles
Engineering principles indexed as one-liners: safety and correctness, design and architecture, composition and interfaces, code structure, performance, visibility. Use when writing new code, reviewing a diff, or justifying a design choice.
odoo-upgrade
Plan and run code upgrades of custom Odoo modules between major versions (16.0→17.0→18.0→19.0). Use to migrate or port a module or addon, for breaking changes, a module inventory, or an upgrade estimate or plan.
odoo-upgrade-project
Human SOP for a whole Odoo upgrade project past the code port: staging database upgrade through upgrade.odoo.com, on-prem restore, cutover, go-live, support tickets and functional requirements. A planning reference.
odoo-test-run
Run an Odoo module's unit tests and HttpCase browser tours on a throwaway database and return machine-checkable evidence: tests executed, tours executed, failure lines. Use before a PR, after a fix, or when a green run never said how many tests ran.
odoo-session-db
Give one session its own throwaway test database name, so two sessions on one task in one project cannot land on the same database. Use before odoo-dev:odoo-test-run whenever more than one session can work in the same project, and when a test database vanished mid-run.