taskchef 7.27.2 → 7.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskchef",
3
- "version": "7.27.2",
3
+ "version": "7.28.0",
4
4
  "description": "Dispatch work from a data-only workspace to visible Codex project tasks.",
5
5
  "author": {
6
6
  "name": "Favo Yang",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskchef",
3
- "version": "7.27.2",
3
+ "version": "7.28.0",
4
4
  "description": "A non-blocking interactive dispatcher for visible Codex tasks.",
5
5
  "license": "MIT",
6
6
  "author": "Favo Yang",
@@ -37,6 +37,7 @@
37
37
  "docs/images/reported-work-duration-mobile.jpg",
38
38
  "index.js",
39
39
  "mcp",
40
+ "scripts/roles",
40
41
  "scripts/benchmark-dispatch-prepare.js",
41
42
  "scripts/e2e-benchmark.js",
42
43
  "src",
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env python3
2
+ """Read native Codex agent preferences without applying their instruction layers.
3
+
4
+ Requires Python 3.11+. Standalone, standard library only. TaskChef packages an
5
+ identical copy; neither installation imports the other at runtime.
6
+ """
7
+ import argparse
8
+ import json
9
+ import os
10
+ from pathlib import Path
11
+ import sys
12
+ import tomllib
13
+
14
+ ROLES = ('planner', 'implementer', 'reviewer')
15
+ EFFORTS = ('none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra')
16
+
17
+
18
+ def read_layer(directory):
19
+ found = {}
20
+ problems = []
21
+ try:
22
+ with os.scandir(directory) as entries:
23
+ files = sorted(Path(entry.path) for entry in entries if entry.name.endswith('.toml'))
24
+ for file in files:
25
+ try:
26
+ if file.stat().st_size > 65536:
27
+ raise ValueError('profile exceeds 64 KiB')
28
+ with file.open('rb') as stream:
29
+ data = tomllib.load(stream)
30
+ name = data.get('name')
31
+ if name not in ROLES:
32
+ if file.stem in ROLES:
33
+ raise ValueError('name must match the role filename')
34
+ continue
35
+ errors = []
36
+ for field in ('description', 'developer_instructions'):
37
+ if not isinstance(data.get(field), str) or not data[field].strip():
38
+ errors.append(f'{field} must be a nonempty string')
39
+ model = data.get('model')
40
+ effort = data.get('model_reasoning_effort')
41
+ entry = {'source': str(file), 'model': model, 'effort': effort, 'problems': errors}
42
+ if name in found:
43
+ entry['problems'].append('duplicate role name in the same directory')
44
+ found[name] = entry
45
+ except (OSError, ValueError) as error:
46
+ # Do not expose TOML lines, which can contain unrelated private data.
47
+ message = f'{file}: unreadable or malformed agent TOML ({type(error).__name__})'
48
+ problems.append(message)
49
+ if file.stem in ROLES:
50
+ found[file.stem] = {'source': str(file), 'model': None, 'effort': None, 'problems': [message]}
51
+ except FileNotFoundError:
52
+ return found, problems
53
+ except OSError:
54
+ message = f'{directory}: cannot read agent directory'
55
+ problems.append(message)
56
+ found = {role: {'source': str(directory), 'model': None, 'effort': None, 'problems': [message]} for role in ROLES}
57
+ return found, problems
58
+
59
+
60
+ def resolve(project=None, codex_home=None, explicit_model=None, explicit_effort=None):
61
+ home = Path(codex_home or os.environ.get('CODEX_HOME') or Path.home() / '.codex').expanduser().resolve()
62
+ personal, problems = read_layer(home / 'agents')
63
+ local, local_problems = read_layer(Path(project).resolve() / '.codex' / 'agents') if project else ({}, [])
64
+ problems += local_problems
65
+ catalog = None
66
+ catalog_source = str(home / 'models_cache.json')
67
+ try:
68
+ cache = json.loads(Path(catalog_source).read_text())
69
+ if not isinstance(cache, dict) or not isinstance(cache.get('models'), list):
70
+ raise ValueError('invalid catalog')
71
+ for model in cache['models']:
72
+ if not isinstance(model, dict) or not isinstance(model.get('slug'), str):
73
+ raise ValueError('invalid model entry')
74
+ levels = model.get('supported_reasoning_levels')
75
+ if not isinstance(levels, list) or any(not isinstance(level, dict) or not isinstance(level.get('effort'), str) for level in levels):
76
+ raise ValueError('invalid effort catalog')
77
+ catalog = {model['slug']: model for model in cache['models']}
78
+ except FileNotFoundError:
79
+ pass
80
+ except (OSError, ValueError, KeyError, TypeError):
81
+ problems.append('Local Codex model catalog is unreadable or malformed; validate availability with the current native tool.')
82
+ results = []
83
+ for role in ROLES:
84
+ entry = local.get(role, personal.get(role))
85
+ source = entry['source'] if entry else None
86
+ model = entry['model'] if entry else None
87
+ effort = entry['effort'] if entry else None
88
+ errors = list(entry['problems']) if entry else []
89
+ if explicit_model is not None:
90
+ model, effort = explicit_model, explicit_effort
91
+ effective_source = 'explicit user model choice'
92
+ errors = []
93
+ else:
94
+ effective_source = source
95
+ if explicit_effort is not None:
96
+ effort = explicit_effort
97
+ if model is not None and (not isinstance(model, str) or not model.strip() or len(model) > 256):
98
+ errors.append('model must be a nonempty string of at most 256 characters')
99
+ if effort is not None and effort not in EFFORTS:
100
+ errors.append('reasoning effort is unsupported')
101
+ status = 'invalid' if errors else 'configured' if (model is not None or effort is not None) else 'missing'
102
+ availability = 'not checked; native tool must validate before dispatch'
103
+ if model and not errors and catalog is not None:
104
+ if model not in catalog:
105
+ errors.append('model absent from local Codex catalog; confirm against the current native tool before dispatch')
106
+ status = 'unavailable'
107
+ else:
108
+ supported = [v.get('effort') for v in catalog[model].get('supported_reasoning_levels', []) if isinstance(v, dict)]
109
+ if effort and effort not in supported:
110
+ errors.append('effort absent from local model catalog; confirm against the current native tool')
111
+ status = 'unavailable'
112
+ availability = 'present in cached catalog; current native tool is authoritative'
113
+ overrides = {}
114
+ if status == 'configured':
115
+ if model is not None:
116
+ overrides['model'] = model
117
+ if effort is not None:
118
+ overrides['thinking'] = effort
119
+ results.append({'role': role, 'source': source, 'effectiveSource': effective_source,
120
+ 'model': model, 'effort': effort, 'status': status,
121
+ 'availability': availability, 'problems': errors,
122
+ 'taskOverrides': overrides,
123
+ 'subagentOverrides': {('reasoning_effort' if k == 'thinking' else k): v for k, v in overrides.items()},
124
+ 'fallback': 'inherit parent settings' if role == 'reviewer' else 'native new-task default (not guaranteed dispatcher inheritance)'})
125
+ return {'roles': results, 'problems': problems, 'catalogSource': catalog_source if catalog is not None else None,
126
+ 'precedence': 'explicit user model (and its explicit effort) > project role > personal role > native defaults; explicit effort alone overrides role effort',
127
+ 'scope': 'Model and effort only; agent instructions, tools, permissions, and other TOML keys are not applied by this adapter.'}
128
+
129
+
130
+ def setup(role, model, effort, codex_home=None):
131
+ home = Path(codex_home or os.environ.get('CODEX_HOME') or Path.home() / '.codex').expanduser().resolve()
132
+ existing, problems = read_layer(home / 'agents')
133
+ if role in existing or problems:
134
+ return {'created': False, 'role': role, 'problems': problems or ['existing role preserved'], 'source': existing.get(role, {}).get('source')}
135
+ if not model.strip() or len(model) > 256 or effort not in EFFORTS:
136
+ raise ValueError('invalid model or effort')
137
+ directory = home / 'agents'
138
+ directory.mkdir(parents=True, exist_ok=True)
139
+ target = directory / f'{role}.toml'
140
+ data = {'name': role, 'description': f'{role.capitalize()} model preferences',
141
+ 'developer_instructions': f'Perform the assigned {role} work within the user\'s requested scope.',
142
+ 'model': model, 'model_reasoning_effort': effort}
143
+ try:
144
+ with target.open('x') as stream:
145
+ stream.write(''.join(f'{key} = {json.dumps(value)}\n' for key, value in data.items()))
146
+ except FileExistsError:
147
+ return {'created': False, 'role': role, 'source': str(target), 'problems': ['existing file preserved']}
148
+ return {'created': True, 'role': role, 'source': str(target), 'model': model, 'effort': effort}
149
+
150
+
151
+ def main():
152
+ parser = argparse.ArgumentParser(description=__doc__)
153
+ parser.add_argument('--project')
154
+ parser.add_argument('--codex-home')
155
+ parser.add_argument('--role', choices=ROLES)
156
+ parser.add_argument('--model')
157
+ parser.add_argument('--effort')
158
+ parser.add_argument('--setup', action='store_true')
159
+ args = parser.parse_args()
160
+ if args.setup:
161
+ if not (args.role and args.model and args.effort):
162
+ parser.error('--setup requires --role, --model, and --effort')
163
+ result = setup(args.role, args.model, args.effort, args.codex_home)
164
+ else:
165
+ result = resolve(args.project, args.codex_home, args.model, args.effort)
166
+ if args.role:
167
+ result['roles'] = [r for r in result['roles'] if r['role'] == args.role]
168
+ print(json.dumps(result, indent=2))
169
+
170
+
171
+ if __name__ == '__main__':
172
+ main()
@@ -56,3 +56,29 @@ For adding, importing, removing, listing, or reindexing projects, read
56
56
  [project index](references/project-index.md). Preserve exact canonical local
57
57
  Codex project identity and existing curated entries; opening a folder is not
58
58
  proof of registration. Completion requires verifying the intended index entry.
59
+
60
+ ## Optional model roles
61
+
62
+ Offer planner, implementer, and reviewer profiles during setup. Model and effort
63
+ preferences belong in user configuration, never defaults hard-coded in skills.
64
+ If the user provides values, configure them without asking again. Otherwise
65
+ explain the optional profiles and retain native defaults until values are chosen.
66
+
67
+ Run `python3 <plugin-root>/scripts/roles/resolve_roles.py` to preview personal
68
+ roles. Python 3.11+ is required for this optional helper. Create each requested
69
+ missing profile with:
70
+
71
+ ```sh
72
+ python3 <plugin-root>/scripts/roles/resolve_roles.py --setup --role <role> --model <requested-model> --effort <requested-effort>
73
+ ```
74
+
75
+ This authorized role setup may create `$CODEX_HOME/agents/<role>.toml` (default
76
+ `~/.codex/agents/`) outside the dispatcher workspace. Existing definitions,
77
+ including custom filenames, are preserved. Report conflicts and diagnostics;
78
+ never overwrite a custom role. Re-run the preview and check model/effort against
79
+ the available native interface. Missing roles are optional: TaskChef omits
80
+ new-task overrides; reviewers inherit parent settings. Native new-task defaults
81
+ are not guaranteed dispatcher inheritance. Read the delegate's
82
+ [role resolution](../taskchef-delegate/references/model-roles.md) for precedence
83
+ and adapter limits. Open the dashboard's `/#settings` preview to show the
84
+ configured sources, requested effective settings, fallback, and problems.
@@ -49,6 +49,13 @@ stop and report that the TaskChef plugin must be reloaded or installed.
49
49
  3. Route against configured project `name`, `description`, and canonical
50
50
  `githubRepos`; use `path` only as checkout identity. Require exactly one
51
51
  match and an exact native-project path. Ask instead of guessing.
52
+ Select `planner` for a requested planning assignment and `implementer` for
53
+ coding work. Use the matched project's `projectModelRoles` from preparation;
54
+ resolve explicit user choices and follow [model roles](references/model-roles.md).
55
+ Small coding changes need no separate planning task. For a planning/coding
56
+ split, the saved plan is the handoff to a separately requested implementation
57
+ assignment; do not switch models during a turn or coordinate phases automatically.
58
+ Resolve configuration problems before recording the task.
52
59
  4. Build each executor instruction in this exact shape:
53
60
 
54
61
  - Begin with the actual assignment on the first line and keep its complete
@@ -0,0 +1,49 @@
1
+ # Dispatch model roles
2
+
3
+ Preparation includes personal and per-project model previews. Use the exact
4
+ matched project's preview. Role preferences use native Codex agent TOML under
5
+ `$CODEX_HOME/agents/` (default `~/.codex/agents/`) and that project's
6
+ `.codex/agents/`; they are optional. The resolver requires Python 3.11+.
7
+
8
+ Select `planner` for a planning assignment or `implementer` for coding. Pass
9
+ its `taskOverrides` as native `model` and `thinking` arguments only after checking
10
+ those values against the current create-task tool's supported model/effort
11
+ choices. A missing role means omit both arguments and use the native new-task
12
+ default. This is not guaranteed to inherit the dispatcher's model.
13
+
14
+ Explicit user model choices take precedence over the project role, personal
15
+ role, and native defaults. An explicit model without explicit effort omits effort and uses the native
16
+ interface's omission behavior; do not mix in a different role's effort or claim
17
+ a specific effective effort without evidence. Explicit effort
18
+ alone replaces the resolved role effort. Project roles replace personal roles
19
+ as a unit. To resolve explicit choices, or recheck a preview after configuration
20
+ changes, run:
21
+
22
+ ```sh
23
+ python3 <plugin-root>/scripts/roles/resolve_roles.py --project <project-path> --role implementer --model <user-model> --effort <user-effort>
24
+ ```
25
+
26
+ Omit flags the user did not specify. Resolve the plugin root from this skill's
27
+ real path, two parents above the skill directory. Do not substitute dispatcher
28
+ paths for the target project or infer model names from skill prose.
29
+
30
+ Report malformed profiles, duplicate names, unavailable models/efforts, and
31
+ resolver failures. Do not quietly fall back and claim preferences were honored.
32
+ The local model catalog is advisory: explain if a current native tool disproves
33
+ its stale warning. Otherwise resolve the problem or obtain a valid explicit
34
+ choice before task creation. Native creation failures retain normal TaskChef
35
+ failure reporting. A preparation without role fields supports historical
36
+ installations: check role files before deciding that no preferences exist.
37
+
38
+ Only model and effort are adapted. The native agent file's instructions, tools,
39
+ permissions, and other settings are not applied by create-task arguments. A
40
+ role name in a title is not a native role selector. If the native interface adds
41
+ a role selector, use it only with verified effective settings.
42
+
43
+ For a plan-to-implementation handoff, a planner assignment can save
44
+ `plans/addition.md` describing a pure addition function and the acceptance
45
+ example `2 + 3 = 5`. A later implementer assignment reads that exact plan,
46
+ implements the function, runs the example, and uses fresh reviewer subagents.
47
+ The dispatcher returns after each creation; it does not wait for or launch
48
+ subsequent phases automatically. A small addition change can instead go
49
+ straight to the implementer.