File size: 19,904 Bytes
37f9abc
e9e55ec
37f9abc
 
e9e55ec
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
37f9abc
e9e55ec
 
 
 
 
 
37f9abc
 
e9e55ec
37f9abc
 
e9e55ec
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
37f9abc
e9e55ec
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
37f9abc
 
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
37f9abc
 
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
37f9abc
 
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
 
37f9abc
 
 
 
e9e55ec
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
e9e55ec
 
 
 
 
 
 
 
 
 
 
37f9abc
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
37f9abc
 
 
e9e55ec
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
 
 
37f9abc
 
e9e55ec
 
 
 
 
 
 
37f9abc
 
 
 
 
e9e55ec
 
 
 
 
37f9abc
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
37f9abc
 
6c314e0
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c314e0
 
e9e55ec
 
6c314e0
 
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
6c314e0
 
e9e55ec
 
 
 
 
 
 
 
 
6c314e0
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c314e0
 
e9e55ec
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
LIST_FILES_DESCRIPTION = """
List files and directories inside the current project.

Path rules:

* `path` must be relative to the current project root.
* Use `.` to list the project root.
* Do not include `sandbox/`, the project name, or an absolute path.
* Do not use `..`.

Correct examples:

* .
* src
* src/calculator
* config

Incorrect examples:

* sandbox/terminal-calculator
* /home/user/project
* ../other-project

Use this tool to inspect the project structure before implementation, repair,
configuration, or preliminary quality verification.

This tool only inspects the filesystem. It does not execute shell commands or
modify files.
""".strip()

READ_FILE_DESCRIPTION = """
Read a UTF-8 text file inside the current project.

Path rules:

* `path` must be relative to the current project root.
* Do not include `sandbox/`, the project name, or an absolute path.
* Do not use `..`.

Correct examples:

* pyproject.toml
* README.md
* src/calculator/main.py
* ruff.toml
* mypy.ini
* .coveragerc

Incorrect examples:

* sandbox/terminal-calculator/pyproject.toml
* /home/user/project/main.py
* ../other-project/main.py

Use this tool to inspect:

* existing production files;
* project metadata and packaging configuration;
* application entry points;
* existing quality-tool configuration;
* relevant existing tests when needed to understand a reported failure.

Reading a test file does not authorise the Coder to modify it.

This tool only reads files. It does not modify project contents.
""".strip()

WRITE_FILE_DESCRIPTION = """
Create or replace a Coder-owned file inside the current project.

Permitted files include:

* production source code;
* production configuration;
* project metadata and packaging configuration;
* application entry points;
* documentation;
* Coder-owned linting, formatting, static-type-checking, coverage, build, and
  packaging configuration.

Path rules:

* `path` must be relative to the current project root.
* Do not include `sandbox/`, the project name, or an absolute path.
* Do not use `..`.

Correct examples:

* pyproject.toml
* README.md
* src/calculator/**init**.py
* src/calculator/main.py
* ruff.toml
* mypy.ini
* .coveragerc

Incorrect examples:

* sandbox/terminal-calculator/src/calculator/main.py
* /absolute/path/main.py
* ../other-project/main.py
* tests/test_calculator.py
* tests/conftest.py

Test ownership boundary:

* Do not create, modify, rename, or delete automated tests.
* Do not create or modify fixtures, mocks, test data, test helpers, or other
  Tester-owned assets.
* Do not modify files under `test`, `tests`, `__tests__`, `spec`, or `specs`.
* Existing tests may be inspected, but test implementation belongs exclusively
  to the Tester.
* Do not modify valid tests to make production code appear correct.
* Do not retry rejected test work using another path, tool, or mechanism.

Quality-configuration boundary:

* Preserve existing quality configuration whenever possible.
* Add or modify quality-tool configuration only when necessary for preliminary
  Coder-side verification or an approved production task.
* Do not broadly disable linting or type-checking rules.
* Do not add unjustified ignores, exclusions, or type suppressions.
* Do not reduce coverage thresholds merely to obtain a successful result.
* Do not weaken approved acceptance criteria.

Python project requirements:

* Use `pyproject.toml` for project metadata and dependency declarations.
* Preserve established project-specific configuration files when they exist.
* Generated setup, quality-check, and application-execution instructions must
  use `uv`.
* Do not document or generate `pip install`, `python -m pip`, `uv pip`, manual
  virtual-environment activation, or direct modification of `.venv`.
* Application execution instructions should use `uv run`.
  """.strip()

CREATE_DIRECTORY_DESCRIPTION = """
Create a Coder-owned directory inside the current project.

Permitted directories include:

* production source packages;
* production configuration;
* application resources;
* documentation;
* directories required by Coder-owned build, packaging, or quality-tool
  configuration.

Path rules:

* `path` must be relative to the current project root.
* Do not include `sandbox/`, the project name, or an absolute path.
* Do not use `..`.

Correct examples:

* src
* src/calculator
* config
* docs

Incorrect examples:

* sandbox/terminal-calculator/src
* /absolute/path
* ../other-project
* tests
* src/tests
* tests/fixtures

Test ownership boundary:

* Do not create `test`, `tests`, `__tests__`, `spec`, or `specs` directories.
* Do not create fixture, mock, test-data, or Tester-owned verification
  directories.
* Test-directory creation belongs exclusively to the Tester.

This tool uses Python filesystem operations directly. It does not run `mkdir`,
shell commands, Python snippets, or project-management commands.
""".strip()

RUN_APPLICATION_DESCRIPTION = """
Run a declared project application entry point inside the current project's
uv-managed environment.

The tool internally executes:

```
uv run <entry_point> [arguments]
```

The Coder provides only:

* an entry-point name declared in `[project.scripts]` in `pyproject.toml`;
* optional application arguments.

Correct examples:

* entry_point="calc", arguments=[]
* entry_point="calc", arguments=["2 + 3"]
* entry_point="odd-even", arguments=["7"]
* entry_point="my-app", arguments=["--help"]

Important uv rules:

* Do not include `uv run` in `entry_point`.
* Do not activate `.venv` manually.
* Do not use `python`, `pytest`, `pip`, `uv pip`, shell commands, or absolute
  paths.
* The tool runs from the current project root, allowing `uv` to discover
  `pyproject.toml` and use the project's managed environment.
* Use this tool instead of requesting a generic shell command.

Permitted use:

* direct application execution;
* focused smoke checks;
* command-line-interface checks;
* argument-handling checks;
* preliminary application-behaviour checks;
* reproduction of a Tester-reported application failure.

Boundaries:

* Do not use this tool to execute Pytest or another test runner.
* Do not use it to execute Ruff, Mypy, Coverage, build tools, packaging tools,
  shell scripts, or arbitrary executables.
* Do not simulate interactive input through temporary subprocess scripts.
* Record the observed output and exit status.
* Repair failures only when they originate from Coder-owned production
  artefacts.
* Do not treat successful Coder-side execution as independent acceptance.
* The Tester must independently verify applicable behaviour and acceptance
  criteria.
  """.strip()

RUN_PYTHON_MODULE_DESCRIPTION = """
Run an importable application module inside the current project's uv-managed
environment.

The tool internally executes:

```
uv run python -m <module> [arguments]
```

The Coder provides only:

* an importable application module name;
* optional application arguments.

Correct examples:

* module="calculator"
* module="calculator.cli"
* module="odd_even"
* module="customer_support.main"

Incorrect examples:

* module="src/calculator/main.py"
* module="python -m calculator"
* module="pytest"
* module="unittest"
* module="coverage"
* module="ruff"
* module="mypy"
* module="pip"
* module="-c"

Important uv rules:

* Do not include `uv run python -m` in `module`.
* Do not provide a file path or Python source code.
* Do not activate `.venv` manually.
* Do not use direct `python`, `pytest`, `pip`, `uv pip`, or shell commands.
* `uv` executes the module inside the current project's managed environment.

Permitted use:

* execute importable application modules;
* perform focused application smoke checks;
* reproduce application-module failures reported by the Tester.

Boundaries:

* This tool cannot execute testing, linting, formatting, type-checking,
  coverage, build, packaging, or environment-management modules.
* Do not use it to execute Pytest, unittest, Coverage, Ruff, Mypy, or another
  verification framework.
* Do not use it to create or execute temporary verification scripts.
* Record observed failures accurately.
* Repair failures only when they originate from Coder-owned artefacts.
* Successful execution remains preliminary and must not be represented as
  independent Tester verification.
  """.strip()

INSTALL_RUNTIME_DEPENDENCIES_DESCRIPTION = """
Add required production runtime dependencies to the current project using `uv`.

The tool internally executes:

```
uv add <package> [<package> ...]
```

`uv add`:

* records dependencies in `project.dependencies` in `pyproject.toml`;
* updates `uv.lock`;
* synchronises the project's uv-managed environment.

Provide only runtime dependency specifications.

Correct examples:

* ["click"]
* ["requests>=2.32"]
* ["pydantic>=2"]
* ["fastapi", "uvicorn"]

Incorrect examples:

* ["uv", "add", "click"]
* ["pip install click"]
* ["--dev", "ruff"]
* ["pytest"]
* ["ruff"]
* ["mypy"]
* ["coverage"]
* ["git+https://example.com/repository.git"]
* ["package @ https://example.com/package.whl"]

Important rules:

* Do not use `pip`, `python -m pip`, or `uv pip install`.
* Do not manually edit or activate `.venv`.
* Use this tool only when the production application genuinely requires an
  external runtime dependency.
* Do not add packages already provided by the Python standard library.
* Do not add direct URL, Version Control System, SSH, or local-file
  dependencies.
* Do not add linting, formatting, type-checking, coverage, testing, build, or
  other development dependencies with this tool.
* Record every runtime dependency actually added or changed.
  """.strip()

INSTALL_DEVELOPMENT_DEPENDENCIES_DESCRIPTION = """
Add required Coder-side quality and development dependencies to the current
project using `uv`.

The tool internally executes:

```
uv add --dev <package> [<package> ...]
```

`uv add --dev`:

* records dependencies as development dependencies in `pyproject.toml`;
* updates `uv.lock`;
* synchronises the project's uv-managed environment.

Use this tool only for dependencies required to perform approved preliminary
Coder-side operations such as:

* linting and formatting with Ruff;
* static type checking with Mypy;
* coverage reporting or analysis;
* build and packaging validation when supported by an approved Coder tool.

Correct examples:

* ["ruff"]
* ["mypy"]
* ["coverage[toml]>=7"]
* ["build"]

Incorrect examples:

* ["uv", "add", "--dev", "ruff"]
* ["pip install ruff"]
* ["--dev", "mypy"]
* ["pytest"]
* ["pytest-cov"]
* ["requests"]
* ["fastapi"]
* ["git+https://example.com/repository.git"]
* ["package @ https://example.com/package.whl"]

Important rules:

* Pytest and other test runners are not Coder-owned dependencies.
* Do not add Pytest, pytest-cov, Hypothesis, Tox, Nox, or other Tester-owned
  testing dependencies.
* Do not use `pip`, `python -m pip`, or `uv pip install`.
* Do not manually edit or activate `.venv`.
* Reuse existing development dependencies whenever possible.
* Add only dependencies genuinely required for approved Coder-side quality
  operations.
* Do not add direct URL, Version Control System, SSH, or local-file
  dependencies.
* Do not add a production requirement as a development dependency.
* Record every development dependency added and explain why it was necessary.

Coder-side quality results remain preliminary. The Tester must independently
execute the applicable checks before the workflow proceeds to review.
""".strip()

RUN_SYNC_PROJECT = """
Synchronise the current Python project and validate its declared environment
using uv.

The tool internally executes:

```
uv sync
```

Use this tool after:

* creating or materially modifying `pyproject.toml`;
* adding or changing runtime dependencies;
* adding or changing approved development dependencies;
* changing the package structure;
* changing build-system or packaging configuration;
* changing application entry points;
* changing quality-tool configuration that affects synchronisation;
* repairing an earlier `uv sync` failure.

Correct usage examples:

* After creating a new `pyproject.toml`.
* After adding `click` to `[project.dependencies]`.
* After adding Ruff or Mypy as an approved development dependency.
* After changing the package path from `src/app` to `src/my_app`.
* After adding or modifying an entry under `[project.scripts]`.
* After correcting Hatchling build configuration.

Do not provide a command, path, package name, or application argument.
This tool requires no project-specific input other than the optional timeout.

A successful result confirms that:

* `pyproject.toml` can be parsed;
* declared runtime and development dependencies can be resolved;
* the project can be built and installed into its uv-managed environment;
* the declared package structure is compatible with the build configuration.

A successful result does not confirm that:

* application behaviour is correct;
* command-line arguments work as intended;
* tests pass;
* linting or formatting passes;
* static type checking passes;
* coverage requirements are satisfied;
* acceptance criteria pass;
* independent Tester verification has succeeded.

If synchronisation fails because of Coder-owned source, dependencies, package
structure, build configuration, entry points, or quality-tool configuration,
inspect the returned error, repair the relevant Coder-owned files, and run this
tool again.

Do not use this tool to:

* add dependencies;
* execute Pytest or another test runner;
* execute Ruff, Mypy, Coverage, or other quality tools;
* execute the application;
* claim that independent verification succeeded.
  """.strip()

RUN_VERIFICATION_COMMAND_DESCRIPTION = """
Run an approved Coder-side quality command inside the current project's
uv-managed environment.

The tool internally executes:

```
uv run <command> [arguments]
```

Approved commands:

* `ruff` for linting, formatting checks, safe automatic fixes, and formatting;
* `mypy` for static type checking;
* `coverage` for coverage reporting and analysis.

The Coder may use this tool during initial implementation and repair cycles to
detect and address problems in Coder-owned production code, production
configuration, dependency declarations, packaging metadata, or application
entry points.

Ruff permissions:

* `ruff check` is permitted.
* `ruff check --fix` is permitted for safe automatic fixes.
* `ruff check --diff` is permitted.
* `ruff format` is permitted.
* `ruff format --check` is permitted.
* `--unsafe-fixes` is prohibited.
* Automatic fixes and formatting must target only Coder-owned files.
* Do not run automatic fixes against test directories or Tester-owned files.
* After applying fixes or formatting, rerun the relevant Ruff check.
* Rerun Mypy or applicable application smoke checks when Ruff changes could
  affect application behaviour or interfaces.

Mypy permissions:

* Run Mypy only against Coder-owned production modules or approved production
  paths.
* Fix valid type errors in production artefacts.
* Preserve existing type-checking configuration.
* Do not suppress valid errors through blanket ignores, broad exclusions, or
  unjustified annotations.
* Do not run Mypy against Tester-owned files for the purpose of modifying them.

Coverage permissions:

* Coverage may be used for reporting, combining, inspecting, exporting, or
  analysing existing coverage data.
* Coverage may execute an approved application module only when needed to
  measure production application execution.
* Do not use Coverage to invoke Pytest, unittest, another test runner, an
  arbitrary Python file, inline Python, or a temporary verification script.
* Do not lower coverage thresholds.
* Do not omit production modules merely to improve the reported percentage.
* Do not create or modify tests to increase coverage.
* When additional tests are required, report the gap to the Tester.

Prohibited commands:

* `pytest`;
* `python`;
* `python3`;
* `unittest`;
* `tox`;
* `nox`;
* shell interpreters;
* arbitrary executables.

Command boundaries:

* Pytest cannot be used through this tool.
* Direct Python execution cannot be used through this tool.
* Existing tests and authoritative test execution belong exclusively to the
  Tester.
* Application entry points must be executed with `run_application`.
* Importable application modules must normally be executed with
  `run_python_module`.
* Do not use an approved command as a wrapper for a prohibited command.
* Do not use `coverage run` to bypass the prohibition against Pytest, arbitrary
  Python scripts, or inline Python.
* Do not include `uv run` in `command`.

General rules:

* Use only an approved command.
* Do not execute shell commands, arbitrary executables, external scripts,
  temporary scripts, or inline Python.
* Do not create, modify, rename, or delete valid tests or Tester-owned files.
* Do not weaken linting rules, type-checking rules, coverage thresholds, or
  approved acceptance criteria merely to obtain a successful result.
* Fix valid findings when they originate from Coder-owned production artefacts.
* Record the exact command, arguments, exit status, and observed result.
* Treat successful results as preliminary Coder-side quality evidence.
* The Tester must independently rerun the applicable checks before the
  workflow proceeds to review.
  """.strip()

SUBMIT_CODER_SUMMARY_DESCRIPTION = """
Submit the final structured handoff summary for the current Coder implementation
or repair cycle.

Call this tool only when:

* all safe Coder-owned implementation and preliminary quality work for the
  current cycle is complete; or
* no further safe work can continue because of a genuine blocker.

This is a terminal Coder action. Call it alone.

After calling it, do not request additional:

* filesystem operations;
* dependency operations;
* project synchronisation;
* application or module execution;
* Ruff, Mypy, Coverage, build, or packaging operations.

Populate the summary only with evidence from:

* Coder-owned tasks in the approved DevelopmentPlan;
* the current Tester repair requests when operating in repair mode;
* successful filesystem operations;
* runtime and approved development-dependency operations;
* project-synchronisation results;
* application or module execution results;
* Coder-executed Ruff, Mypy, Coverage, build, or packaging operations;
* observed failures and blockers.

The summary must:

* identify completed Coder-owned task IDs;
* list project-relative Coder-owned files created or modified;
* list runtime dependencies actually added or changed;
* list approved development dependencies actually added or changed;
* list command-line entry points actually configured;
* record only operations that were actually executed;
* record the observed outcome of every reported operation;
* distinguish successful Coder-side quality checks from independent Tester
  verification;
* identify unresolved failures, blockers, uncertainties, and incomplete work;
* identify Tester repair requests addressed during a repair cycle;
* provide concise `tester_notes` describing checks, coverage gaps, behaviours,
  and acceptance criteria requiring independent verification or
  re-verification.

Do not:

* call this tool while more safe Coder-owned work remains;
* call it together with another tool;
* include test files or Tester-owned work as completed Coder work;
* claim that Pytest or another Tester-owned test runner was executed;
* claim that automated tests passed during the Coder stage;
* claim that independent Tester verification, review, human approval, merge,
  deployment, publishing, or release succeeded;
* claim that an operation succeeded without a supporting tool result;
* invent files, dependencies, commands, task completion, verification results,
  or successful outcomes;
* return the final summary as ordinary text, JSON, or Markdown instead of
  calling this tool.
  """.strip()