@turri-dev/cli 0.4.3-next.620bae9 → 0.4.3-next.7ada234

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.
Files changed (122) hide show
  1. package/README.md +1 -0
  2. package/dist/background-skills.d.ts +4 -1
  3. package/dist/background-skills.js +9 -1
  4. package/dist/capture/agents.d.ts +406 -0
  5. package/dist/capture/agents.js +379 -0
  6. package/dist/capture/area.d.ts +58 -0
  7. package/dist/capture/area.js +197 -0
  8. package/dist/capture/assemble.d.ts +112 -0
  9. package/dist/capture/assemble.js +453 -0
  10. package/dist/capture/capture.d.ts +116 -0
  11. package/dist/capture/capture.js +1315 -0
  12. package/dist/capture/chat.d.ts +29 -0
  13. package/dist/capture/chat.js +94 -0
  14. package/dist/capture/checks.d.ts +142 -0
  15. package/dist/capture/checks.js +649 -0
  16. package/dist/capture/config.d.ts +13 -0
  17. package/dist/capture/config.js +66 -0
  18. package/dist/capture/interface.d.ts +71 -0
  19. package/dist/capture/interface.js +199 -0
  20. package/dist/capture/map.d.ts +56 -0
  21. package/dist/capture/map.js +530 -0
  22. package/dist/capture/models.d.ts +4 -0
  23. package/dist/capture/models.js +16 -0
  24. package/dist/capture/plan.d.ts +7 -0
  25. package/dist/capture/plan.js +13 -0
  26. package/dist/capture/progress.d.ts +111 -0
  27. package/dist/capture/progress.js +266 -0
  28. package/dist/capture/python-interface.d.ts +3 -0
  29. package/dist/capture/python-interface.js +17 -0
  30. package/dist/capture/report.d.ts +75 -0
  31. package/dist/capture/report.js +268 -0
  32. package/dist/capture/runners.d.ts +6 -0
  33. package/dist/capture/runners.js +59 -0
  34. package/dist/capture/scripts.d.ts +26 -0
  35. package/dist/capture/scripts.js +38 -0
  36. package/dist/capture/state.d.ts +310 -0
  37. package/dist/capture/state.js +43 -0
  38. package/dist/capture/trial.d.ts +34 -0
  39. package/dist/capture/trial.js +89 -0
  40. package/dist/capture-cli.d.ts +1 -0
  41. package/dist/capture-cli.js +77 -0
  42. package/dist/chat-tab-header.d.ts +3 -2
  43. package/dist/chat-tab-header.js +22 -9
  44. package/dist/chat-tabs.d.ts +7 -1
  45. package/dist/chat-tabs.js +10 -6
  46. package/dist/chat-terminal.js +27 -6
  47. package/dist/chats.d.ts +14 -8
  48. package/dist/chats.js +46 -20
  49. package/dist/cli.js +32 -14
  50. package/dist/config-edit.js +5 -2
  51. package/dist/config.d.ts +15 -2
  52. package/dist/config.js +62 -3
  53. package/dist/extension.d.ts +2 -1
  54. package/dist/extension.js +225 -68
  55. package/dist/identity.js +2 -1
  56. package/dist/init-config.d.ts +4 -1
  57. package/dist/init-config.js +31 -4
  58. package/dist/loop-cli.js +5 -1
  59. package/dist/loop-tools.js +5 -1
  60. package/dist/new-project.d.ts +5 -0
  61. package/dist/new-project.js +11 -0
  62. package/dist/pi-launch.js +2 -0
  63. package/dist/pi-themes.d.ts +3 -0
  64. package/dist/pi-themes.js +21 -0
  65. package/dist/pi.d.ts +2 -2
  66. package/dist/pi.js +4 -4
  67. package/dist/plain-code-blocks.d.ts +14 -0
  68. package/dist/plain-code-blocks.js +56 -0
  69. package/dist/pointer-hover.d.ts +1 -1
  70. package/dist/pointer-hover.js +4 -0
  71. package/dist/question-dialog.d.ts +5 -0
  72. package/dist/question-dialog.js +26 -3
  73. package/dist/regenerate/agent-env.js +5 -1
  74. package/dist/regenerate/command-check.js +80 -11
  75. package/dist/regenerate/job-panel.d.ts +5 -107
  76. package/dist/regenerate/job-panel.js +4 -289
  77. package/dist/regenerate/loop.js +9 -1
  78. package/dist/regenerate/side-panel.d.ts +2 -0
  79. package/dist/regenerate/side-panel.js +32 -5
  80. package/dist/regenerate/spec-map-view.d.ts +2 -2
  81. package/dist/regenerate/test-scripts.d.ts +5 -0
  82. package/dist/regenerate/test-scripts.js +4 -0
  83. package/dist/reopen.d.ts +29 -0
  84. package/dist/reopen.js +47 -0
  85. package/dist/sentinel-chat.js +7 -2
  86. package/dist/sentinel.d.ts +1 -1
  87. package/dist/sentinel.js +3 -1
  88. package/dist/setup.js +9 -1
  89. package/dist/terminal-notifications.d.ts +37 -0
  90. package/dist/terminal-notifications.js +164 -0
  91. package/docs/README.md +2 -0
  92. package/docs/capture.md +227 -0
  93. package/docs/chats.md +6 -3
  94. package/docs/config.md +18 -4
  95. package/docs/development.md +4 -1
  96. package/docs/hosting.md +2 -2
  97. package/docs/launch.md +2 -2
  98. package/docs/regenerating.md +1 -1
  99. package/docs/sandbox.md +4 -2
  100. package/docs/sentinel.md +11 -11
  101. package/docs/theming.md +3 -3
  102. package/docs/using.md +7 -3
  103. package/genome/capture/capture.md +26 -0
  104. package/genome/capture/check-conventions.md +5 -0
  105. package/genome/capture/check-reference.md +12 -0
  106. package/genome/capture/compact.md +7 -0
  107. package/genome/capture/concepts.md +3 -0
  108. package/genome/capture/divide.md +9 -0
  109. package/genome/capture/feature.md +45 -0
  110. package/genome/capture/interface.md +9 -0
  111. package/genome/capture/modules.md +25 -0
  112. package/genome/capture/outline.md +11 -0
  113. package/genome/capture/python-interface.py +111 -0
  114. package/genome/capture/readability.md +12 -0
  115. package/genome/capture/reference.md +10 -0
  116. package/genome/capture/runners/python-requirements.sh +67 -0
  117. package/genome/capture/split.md +9 -0
  118. package/genome/capture/survey.md +39 -0
  119. package/genome/capture/trial.md +18 -0
  120. package/genome/capture/verify.md +7 -0
  121. package/genome/rules/turri-regeneration.md +1 -1
  122. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ # Capture the interface no feature captured
2
+
3
+ Every feature of the part is written, and the surfaces listed in `<the interface to capture>` are named in none of their ***plain: options, commands, routes, screens or environment variables the code defines, each with the file that defines it. A capture leaves no interface out - whoever calls one in the original must find it, the same, in what is regenerated - so they are yours, as a feature of their own in the module.
4
+
5
+ - Capture each exactly: what it does and what a user sees of it, by every name it has. One the part's interface reference holds is listed with its entry - what it takes, its choices, its default and its help are there, exact: use the part's interface concept, and say them only where a behaviour turns on them. One it does not hold, capture whole yourself: what it takes, its choices and its default too. Read each where it is defined and follow it to what it does - never from its name or its help text alone.
6
+ - Group them into functional specs by what they do, as any feature's: several options in one functional spec when they are one behaviour.
7
+ - Where one belongs with another feature's behaviour - an option of what another feature does - capture this part of the interface exactly, build on that feature, and name it; never write its behaviour again.
8
+ - One that is not the software's interface - an option of a development script, a variable only its tests or its build read - goes in `dropped`, by its name, with why. Nothing else is dropped: an option users rarely pass is still the interface.
9
+ - `title`: a few words for what they are, as a feature of the module - `Proxies and network options`.
@@ -0,0 +1,25 @@
1
+ # Gather the features into modules
2
+
3
+ The part's ***plain is a chain of modules. Below is every feature of the part, area by area in the order of the code, with what it owns, the first line of each functional spec and its scenarios - and the modules as the code's areas make them, gathered by size alone. Gather the features into modules by concern, and put the modules in the order they are built. Call `submit_capture_modules` once.
4
+
5
+ ## A module is a concern
6
+
7
+ A module is what a person looks for in one file: a command-line tool's request sending, its output formatting, its sessions, its downloads, its plugin manager; a backend's accounts, its orders, its payments. One module that holds everything is as hard to read as the code, and every change to it regenerates all of it; a concern split across modules is read in pieces.
8
+
9
+ - `modules`, each with a `name` - short kebab-case, the concern - an `about` line, and its `features` by key, in the order its functional specs are written. Every feature is in one module.
10
+ - A module of one feature is right when that feature is a concern of its own. Put a feature with another only when it is part of that concern - never to make a module larger.
11
+ - A concern too large to read in one file - past about 40 functional specs - is two modules, each a part of it.
12
+ - The areas are folders of the code - often a concern each, never binding: a module may take features of several areas, and an area's features may go to several modules. Where the code's areas are concerns already, keep them.
13
+
14
+ ## The order they are built in
15
+
16
+ Each module is built on the code of the modules before it, and its conformance tests - its scenarios - run as soon as it is built, with nothing after it there. A module whose scenarios send a request, print a response or save a session needs the module that does that before it: built earlier, its scenarios cannot pass, and its coding agent invents what a later module captures.
17
+
18
+ The areas are in the order of the code's imports, which is not that order: the code that runs everything imports everything, yet everything else needs it built first - a command-line tool's request sending before the output formatting that prints what it answers, a backend's routes before the middleware that wraps them. List the modules in the order they are built: the core flow first, what extends it after.
19
+
20
+ - `needs`: for each module, the modules before it whose behaviour its functional specs build on and its scenarios run - the module where the command, the route or the screen its scenarios use does what they rely on. A scenario that runs a command needs the module that makes the command do it, not only the one that names its options.
21
+ - `rewrites`: a scenario that needs a module after its own whatever the order - two modules whose scenarios each need the other - is rewritten so it checks what it checks with only the modules before it: a scenario of output formatting that follows a redirect checks the formatting of a plain response instead. Its feature's key, its functional spec's func-id, its scenario's id, its whole new text, and `why`: the later module it needed. None when none: most orders need no rewrite. Never merge two modules to spare a rewrite.
22
+
23
+ You see the ***plain, not the code: decide from what each feature does and what its scenarios run.
24
+
25
+ Prefer the order that preserves the original observations. In particular, a test of the effect of an option must not become a test that the option is merely accepted. A test of one named failure must not become a test of a different failure that happens to share its exit code. Put the consumer after the features needed to demonstrate the original outcome. When choosing between a neat ordering and an exact observable contract, keep the contract.
@@ -0,0 +1,11 @@
1
+ # Outline an area's features
2
+
3
+ Your area of the codebase becomes one module of ***plain. Outline it into features - each a thing a user or a client can do, or a part of what they see - which agents then capture side by side, one feature each. Call `submit_capture_features` once.
4
+
5
+ - A feature gets a short kebab-case `name`, a `title` of a few words, a line `about` what it lets someone do, and its `paths`: the folders and files where it is built, relative to the codebase - where its agent starts looking.
6
+ - A feature is about what a user sees: `sign-up`, `password-reset`, `invoice-export` - never a layer or a file (`models`, `utils`).
7
+ - Size: a feature is captured in up to eight functional specs, each about two hundred lines of code. A larger one is two features.
8
+ - List them in build order: each feature only builds on those before it - the first is the simplest thing the area does that can be seen working, and what everything else needs (the data it keeps) comes early. In a codebase that starts here, the first feature also brings up the project - its entry point, its first screen or endpoint.
9
+ - What the stack below already settles is not a feature: settings, logging, request ids, error bodies, middleware, how the app starts. Put such a file in `left_out` with why - settled by the stack - unless the original does something there that a user or a client would notice is different from what the stack says; then that difference alone is a feature.
10
+ - Every route, command, option, screen, environment variable and table of your area belongs to a feature, or the file it is in is in `left_out` with why: the interface is captured whole, so no option is too small to be a feature's. Shared helpers belong to no feature: what they do shows in the features that use them.
11
+ - The area's tests are where its features show: a test file belongs with the feature it tests.
@@ -0,0 +1,111 @@
1
+ """Static Python package interface. Read only the mapped files on stdin; never import the project."""
2
+ import ast
3
+ import json
4
+ import pathlib
5
+ import sys
6
+
7
+
8
+ def public_reference(root, paths):
9
+ modules, files, exports, decls, aliases = {}, {}, {}, {}, {}
10
+ for path in paths:
11
+ p = pathlib.PurePosixPath(path)
12
+ if p.suffix != '.py' or any(x.startswith('.') or x == '__pycache__' for x in p.parts):
13
+ continue
14
+ try:
15
+ raw = (root / p).read_bytes()
16
+ if len(raw) > 512 * 1024:
17
+ continue
18
+ tree = ast.parse(raw)
19
+ except (OSError, SyntaxError, ValueError, RecursionError):
20
+ continue
21
+ files[path] = tree
22
+ for path, tree in files.items():
23
+ p = pathlib.PurePosixPath(path)
24
+ parts = [] if p.stem == '__init__' else [p.stem]
25
+ folder = p.parent
26
+ while str(folder / '__init__.py') in files:
27
+ parts.insert(0, folder.name)
28
+ folder = folder.parent
29
+ if not parts or (len(parts) == 1 and p.stem != '__init__'):
30
+ continue
31
+ mod = '.'.join(parts)
32
+ modules[mod] = path
33
+ for node in tree.body:
34
+ if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == '__all__' for t in node.targets) and isinstance(node.value, (ast.List, ast.Tuple)):
35
+ exports[mod] = [x.value for x in node.value.elts if isinstance(x, ast.Constant) and isinstance(x.value, str)]
36
+ if isinstance(node, ast.ImportFrom):
37
+ package = mod if p.stem == '__init__' else mod.rpartition('.')[0]
38
+ prefix = (package.split('.')[:len(package.split('.')) - node.level + 1] if node.level else []) + ([node.module] if node.module else [])
39
+ for a in node.names:
40
+ aliases[mod + '.' + (a.asname or a.name)] = '.'.join([*prefix, a.name])
41
+ if isinstance(node, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)):
42
+ decls[mod + '.' + node.name] = node
43
+ package_api = {mod + '.' + name for mod, names in exports.items() for name in names}
44
+ # Public uses in the original's own tests are evidence too. test_*.py may itself be an installed API module.
45
+ for path, tree in files.items():
46
+ dirs = pathlib.PurePosixPath(path).parts[:-1]
47
+ if not (any(x in {'tests', 'ext_tests', 'test'} for x in dirs) or (path not in modules.values() and pathlib.PurePosixPath(path).name.startswith('test_'))):
48
+ continue
49
+ imports = {}
50
+ for n in ast.walk(tree):
51
+ if isinstance(n, ast.ImportFrom) and n.module in modules:
52
+ for a in n.names:
53
+ qualified = n.module + '.' + a.name
54
+ if a.name != '*' and not a.name.startswith('_'):
55
+ imports[a.asname or a.name] = qualified
56
+ package_api.add(qualified)
57
+ if isinstance(n, ast.Import):
58
+ for a in n.names:
59
+ if a.name in modules:
60
+ imports[a.asname or a.name.split('.')[0]] = a.name if a.asname else a.name.split('.')[0]
61
+ for n in ast.walk(tree):
62
+ if isinstance(n, ast.Attribute) and isinstance(n.value, ast.Name) and n.value.id in imports and not n.attr.startswith('_'):
63
+ name = imports[n.value.id] + '.' + n.attr
64
+ if name in decls or name in modules or name in aliases:
65
+ package_api.add(name)
66
+ # Exception types in an explicitly exported module are public, including ones looked up dynamically.
67
+ for name, node in decls.items():
68
+ if isinstance(node, ast.ClassDef) and name.rpartition('.')[0] in package_api and any(ast.unparse(b).endswith(('Exception', 'Error')) for b in node.bases):
69
+ package_api.add(name)
70
+ # Record shapes reached via the public signatures matter to callers just as much as their function names.
71
+ pending = list(package_api)
72
+ while pending:
73
+ name = pending.pop()
74
+ target = aliases.get(name, name)
75
+ node = decls.get(target)
76
+ annotations = ([node.returns] if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) else [n.annotation for n in node.body if isinstance(n, ast.AnnAssign)] if isinstance(node, ast.ClassDef) else [])
77
+ for a in annotations:
78
+ for token in ast.walk(a) if a else []:
79
+ if not isinstance(token, (ast.Name, ast.Attribute)):
80
+ continue
81
+ first, _, rest = ast.unparse(token).partition('.')
82
+ local = target.rpartition('.')[0] + '.' + first
83
+ typ = aliases.get(local, local) + ('.' + rest if rest else '')
84
+ if typ not in package_api and isinstance(decls.get(typ), ast.ClassDef):
85
+ package_api.add(typ); pending.append(typ)
86
+ rows = []
87
+ for name in sorted(package_api):
88
+ target, seen = name, set()
89
+ while target in aliases and target not in seen:
90
+ seen.add(target); target = aliases[target]
91
+ node = decls.get(target)
92
+ if isinstance(node, ast.ClassDef):
93
+ bases = ', '.join(ast.unparse(b) for b in node.bases)
94
+ declaration = 'class ' + name + ('(' + bases + ')' if bases else '')
95
+ fields = [n.target.id + ': ' + ast.unparse(n.annotation) for n in node.body if isinstance(n, ast.AnnAssign) and isinstance(n.target, ast.Name) and not n.target.id.startswith('_')]
96
+ if fields:
97
+ declaration += ' - fields: ' + ', '.join(fields)
98
+ rows.append(declaration)
99
+ for method in node.body:
100
+ if isinstance(method, (ast.FunctionDef, ast.AsyncFunctionDef)) and not method.name.startswith('_'):
101
+ prop = any(isinstance(d, ast.Name) and d.id == 'property' for d in method.decorator_list)
102
+ rows.append(f'{name}.{method.name}' + (' (property)' if prop else '(' + ast.unparse(method.args) + ')') + (' -> ' + ast.unparse(method.returns) if method.returns else ''))
103
+ elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
104
+ rows.append(f'{name}({ast.unparse(node.args)})' + (' -> ' + ast.unparse(node.returns) if node.returns else ''))
105
+ else:
106
+ rows.append(name)
107
+ return '\n'.join('- `' + row + '`' for row in rows)
108
+
109
+
110
+ if __name__ == '__main__':
111
+ sys.stdout.write(public_reference(pathlib.Path.cwd(), json.load(sys.stdin)))
@@ -0,0 +1,12 @@
1
+ # Make the module readable
2
+
3
+ Below is a module's ***plain as a capture wrote it - feature by feature, by agents that each saw only their own feature - each functional spec with its scenarios. You read the ***plain alone, never the code: what you judge is whether a person can review it. Rewrite a functional spec only where it reads as code rather than as what the software does:
4
+
5
+ - a function, class, file, variable or internal data shape named, where the behaviour is what matters
6
+ - a default stated - that invalid input is rejected, that data is saved, that errors are reported - with nothing particular about it, or anything the stack below says already - never an option's default, choices or value, which are the interface
7
+ - a restatement of a functional spec before it, or of a concept's definition
8
+ - a case where the rule is stated - an example, what one wrong input or a missing record answers - that a scenario of it pins, or that the stack settles: the scenario and the stack keep it
9
+ - rationale, narration, history, hedges and adjectives no test can check
10
+ - one fact spread over several sentences, or several facts in one long sentence
11
+
12
+ A functional spec that says nothing the stack and the specs before it do not say already is cut down to what is left, or, when nothing is, to its first line. Keep every fact that is its own: every interface detail - a command, an option and each of its names, its choices and default, a method, path, field, status code, message, exit code, environment variable, format - however obvious it reads, every boundary, and every error the stack does not settle and no scenario pins. Scenarios are not yours to change. Keep its concepts, or use others its module has. A functional spec that reads well is left as it is: most are. Call `submit_capture_edits` once, with the new text of each functional spec you rewrote, by its func-id - none at all when none needs it.
@@ -0,0 +1,10 @@
1
+ # Take the interface from the code
2
+
3
+ You take the software's interface from its code, as data: every command, argument, option, route and environment variable a user, a client or a script calls by name - in the files you are given, and any of their interface the map missed. It becomes the part's interface reference: kept beside the ***plain as a linked resource, given whole to every agent that regenerates the code or tests it, and the one place its details are written. So it is exact, whole, and taken from the code alone - never from a name, the docs, or what a framework would do. Call `submit_capture_reference` once.
4
+
5
+ - **Read each file you are given whole,** and follow what defines the interface to where it is worked out: a list of choices built elsewhere, a computed default, a group of options a helper adds. Then grep the part for interface the map missed: subcommands, positional arguments, routes a router adds, variables read through a helper.
6
+ - **One entry each,** of its kind: `command`, `argument` (positional), `option`, `route`, `env`, or `other` - a configuration key, a file it reads: what a user or a script names. Its `name` exactly as the code has it - a route as `METHOD /path` in the code's own parameter syntax - and every other name it has in `aliases`. For an argument or an option, `command`: the command it belongs to, as its users type it.
7
+ - **Exactly as the code has it:** `takes` (its metavar or type), `choices` (each value, from wherever the code lists them), `default`, `repeatable`, `required`, `hidden` when it is left out of its help, and `help` word for word, placeholders and all - the whole text `--help` prints, every paragraph: where the code keeps a short help and a long one, the one `--help` prints. Choices or a default the code works out when it runs - filtered by what the machine has, taken from what is installed - go in `details`, saying how, never as a fixed list that is not always the list. A route's parameters, the fields it takes and answers, and its statuses, a line each in `details`. Leave a field out rather than guess it: what the code does not say, the entry does not.
8
+ - **Before you say what a set, a list or a mapping holds,** grep every line that builds it or adds to it - a set defined in one place is often added to in another - and read each.
9
+ - **`where`: the file and the line it is defined on.** Every literal you give - each name, alias, choice, default, and the help - is checked against that file and the files you name in `also` (where a default or the choices are worked out): one the code does not have sends the entry back.
10
+ - **Whole:** every surface the map found in your files is an entry, or is in `excluded` with why - only what is not the software's interface: an option of a development script, a variable only its tests read. An option users rarely pass is the interface still.
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # Self-contained runner for a Python project run from its root. Inputs are read-only.
3
+ set -eu -o pipefail
4
+ mode='@MODE@'; build_var='@BUILD_VAR@'; python_var='@PYTHON_VAR@'
5
+ if [[ $mode == unit ]]; then [[ $# == 1 ]] || exit 1; else [[ $# == 2 ]] || exit 69; fi
6
+ src=$(cd "$1" && pwd) || exit 2
7
+ if [[ $mode != unit ]]; then
8
+ tests=$(cd "$2" && pwd) || exit 2
9
+ misplaced=$(grep -rlE --exclude='.turri*' --exclude-dir=.venv --exclude-dir=.git '(conformance tests|(conformance|acceptance) scenario [a-z0-9-]+) of [^[:space:]:]+:[a-z0-9-]+' "$src" || true
10
+ find "$src" -type f \( -ipath '*conformance*' -o -ipath '*acceptance*' \) -iname '*test*' ! -name '.turri*')
11
+ if [[ -n $misplaced ]]; then echo "Conformance tests belong in $tests, not the build: $misplaced"; exit 1; fi
12
+ fi
13
+ work=$(mktemp -d "${TMPDIR:-/tmp}/turri-tests.XXXXXXXX") || exit 2
14
+ trap 'rm -rf "$work"' EXIT
15
+ mkdir -p "$work/build" "$work/tmp"
16
+ tar -C "$src" --exclude=.git --exclude=.venv --exclude=__pycache__ -cf - . | tar -C "$work/build" -xf - || exit 2
17
+ cd "$work/build"
18
+ export TMPDIR="$work/tmp" PYTHONDONTWRITEBYTECODE=1 PIP_DISABLE_PIP_VERSION_CHECK=1
19
+ unset PYTHONPATH PYTHONHOME
20
+ for py in python3 python; do "$py" -c 'import sys; assert sys.version_info.major == 3' 2>/dev/null && break; done
21
+ "$py" -m venv "$work/venv" || { echo 'Python 3 with venv is required'; exit 69; }
22
+ bin="$work/venv/bin"; [[ -d "$bin" ]] || bin="$work/venv/Scripts"
23
+ export PATH="$bin:$PATH"
24
+ if [[ '@INSTALL@' == package ]]; then
25
+ "$bin/python" -m pip install --cache-dir "$work/pip" '@EXTRA@' || exit $?
26
+ else
27
+ "$bin/python" -m pip install --cache-dir "$work/pip" -r requirements.txt || exit $?
28
+ fi
29
+ [[ -z $build_var ]] || export "$build_var=$PWD"
30
+ [[ -z $python_var ]] || export "$python_var=$bin/python"
31
+ checks=0
32
+ if [[ $mode == bats ]]; then
33
+ if ! command -v bats >/dev/null; then
34
+ git clone -q --depth 1 --branch v1.12.0 https://github.com/bats-core/bats-core.git "$work/bats" || exit 69
35
+ export PATH="$work/bats/bin:$PATH"
36
+ fi
37
+ # Bats preprocessing checks the suite's shell syntax. Count first: zero tests must never pass.
38
+ count=$(bats --recursive --count "$tests") || exit 1
39
+ [[ $count =~ ^[1-9][0-9]*$ ]] || { echo 'No Bats tests discovered'; exit 1; }
40
+ bats --recursive --formatter tap "$tests"
41
+ else
42
+ if [[ '@CHECKS@' == black ]]; then
43
+ "$bin/python" -m pip install --cache-dir "$work/pip" pytest black isort flake8 mypy || exit $?
44
+ target=.; [[ $mode == unit ]] || target=$tests
45
+ "$bin/python" -m black --check --config pyproject.toml "$target" || checks=80
46
+ "$bin/python" -m isort --check-only --settings-path pyproject.toml "$target" || checks=80
47
+ "$bin/python" -m flake8 --isolated "$target" || checks=80
48
+ else
49
+ "$bin/python" -m pip install --cache-dir "$work/pip" pytest ruff mypy || exit $?
50
+ fi
51
+ if [[ $mode == unit ]]; then
52
+ if [[ '@CHECKS@' != black ]]; then
53
+ "$bin/python" -m ruff format --check . || checks=80
54
+ "$bin/python" -m ruff check . || checks=80
55
+ fi
56
+ "$bin/python" -m mypy . || checks=80
57
+ "$bin/python" -m pytest
58
+ else
59
+ if [[ '@CHECKS@' != black ]]; then
60
+ "$bin/python" -m ruff format --check --isolated --no-cache "$tests" || checks=80
61
+ "$bin/python" -m ruff check --isolated --no-cache "$tests" || checks=80
62
+ fi
63
+ "$bin/python" -m mypy --config-file= --disallow-untyped-defs --follow-imports=silent "$tests" || checks=80
64
+ "$bin/python" -m pytest -c /dev/null -p no:cacheprovider --basetemp="$work/pytest" "$tests"
65
+ fi
66
+ fi
67
+ exit "$checks"
@@ -0,0 +1,9 @@
1
+ # Split an area
2
+
3
+ Your area of the codebase is too large for one agent to outline: split it into smaller areas, each a cohesive part of what the software does - authentication, billing, the editor, the admin screens - so each can be captured on its own. Call `submit_capture_areas` once.
4
+
5
+ - Each area gets a short kebab-case `name` from what it does, a line `about` what it does, and its `paths`: folders or files of your area, relative to the codebase.
6
+ - Divide by what the software does, not by technical layer, where the code allows it: an area's routes, its data and its screens together. Where the code is layered - a `models/` folder for everything - follow the folders, and name an area by what it does.
7
+ - Every file of your area belongs to one area, or is in `left_out` with why: vendored, generated, tooling. A path in one area is in no other.
8
+ - At least two areas, each smaller than yours. Fewer, larger areas are better than many small ones: an area is worth an agent when it holds a few thousand lines.
9
+ - List them in build order: the foundations first - the data model, shared services - then what is built on them. The harness also orders them by what imports what.
@@ -0,0 +1,39 @@
1
+ # Survey the codebase
2
+
3
+ You start the capture: from the map of the whole codebase, its manifests and its docs, you say what the software is built on and how it divides into parts, you settle the conventions every feature follows, and you write what every part's ***plain shares. Call `submit_capture_survey` once, with all of it.
4
+
5
+ ## Parts
6
+
7
+ A part is software on one stack: a backend, a frontend, a command-line tool, a library. Most codebases are one part. A codebase with a Python backend and a React frontend is two - each captured as a chain of modules of its own, built and tested with its own toolchain. Two parts never share a folder.
8
+
9
+ - `name`: short kebab-case, what the part is - `api`, `web`, `cli`, or the product's name when there is one part.
10
+ - `paths`: the folders and files that are the part, relative to the codebase - `.` for the whole of it when there is one part.
11
+ - Leave out what is not the software: vendored code, generated code, build and deployment tooling, editor settings, the docs themselves - each in `left_out`, with why. A part's own tests are part of it, never left out: they are the evidence of what it does.
12
+
13
+ ## The stack
14
+
15
+ Select stock testing `runners` only where they match the part. Ordinary pytest can use a requirements.txt build or a standard pip-installable pyproject.toml package, including src layouts and installed console scripts. The runner installs the build in a fresh venv and runs pytest with the staged project as cwd (for conformance, only the supplied external tests). For conformance on a requirements.txt build, Bats is also available. Read any test helper for the exact environment variable names for the build folder and Python interpreter. Choose custom for any different checkers, services, flags or setup. Do not change the original's stack to make a stock runner fit.
16
+
17
+ The parts are captured on the stack they are on now - the same language, framework, storage and main libraries, with their versions from the manifests.
18
+
19
+ - `stdlib_stack`: turri's standard library has templates that settle a stack (the catalogue is below). Read the one that matches. Name it only when the original agrees with it - its framework, its layout, its libraries - since everything in it becomes a requirement. When it contradicts the original anywhere that matters, name none, and write the stack in `implementation_reqs` instead.
20
+ - `stdlib_conformance`: true to import the stack's conformance template too - when you named a stack that has one and the original's black-box tests, if it has any, run the way it says.
21
+ - `implementation_reqs`: how the part is built, one fact a line, without the `- `: the language and its version, the framework, storage, the libraries that shape behaviour or architecture - an ORM, an outside service such as a payment provider - and how it starts. Write :Implementation: as the subject. Not what a named `stdlib_stack` says already; not utility libraries. When the original has unit tests, how they run - their framework - with :UnitTests: as the subject.
22
+ - `test_reqs`: how the black-box conformance tests run, with :ConformanceTests: as the subject - the framework, how they reach the software (start the server and call it over HTTP, run the command, drive the page). Take it from the original's own black-box tests when it has them, and from how they run the software: read their harness - fixtures, helpers, `conftest` - for what standard input is (a terminal, empty, piped), the environment and the servers they start, and say it. A conformance test run any other way tests another program: a command that reads piped standard input as its body acts differently when its tests give it none.
23
+ - Then what every test sets up so the software acts the same on every run and every machine - read the code for what would otherwise vary: whatever it fetches or checks on its own - an update check, telemetry, a remote configuration - turned off, or pointed at a local stand-in; a home and a configuration folder of the test's own, empty unless the test fills them; the terminal width fixed (`COLUMNS`) where its output wraps or cuts to it; a pseudo-terminal where it prompts on one - a password - or acts otherwise on one; the servers it talks to started locally, never the internet. Each as one fact, with how: the variable and its value, the file and what it holds. Leave `test_reqs` empty only when the conformance template you named says it all.
24
+
25
+ ## Conventions
26
+
27
+ `conventions`: what every feature of a part does the same way and a user or a script relies on, settled here once - the agents that capture each feature follow them, and never decide them again. Four agents each deciding a command's exit code on a usage error decide it differently. For a command-line tool: how an error is written - the stream, its exact form - the exit code of each kind of failure (a usage error, a failed request, a timeout, Ctrl-C), and what changes when standard input or output is not a terminal. For a backend: the error body, the status of each kind of failure, what every request needs. For a frontend: how errors and loading show.
28
+
29
+ For software that talks to other software - a client that sends requests, a server that answers them, a tool that writes files another program reads - also what reaches the other side, exactly, whichever feature makes the call: the headers it adds of its own and when (`User-Agent`, `Accept`, `Content-Type`, `Content-Length`); how a body is encoded - JSON's separators and whether non-ASCII is escaped, the charset, a form's encoding; how a header's value is encoded and trimmed; when a body is sent or read whole, streamed, or not read at all. No feature's writer looks at the wire; the other side sees it on every call.
30
+
31
+ - Settle each from the code that does it: follow the entry point to where it catches errors and exits, and read what it does there. A declaration is no evidence - an enum lists codes the code may never use - and neither is a framework's default the entry point changes: argparse exits 2 on a usage error unless the program catches it and exits otherwise.
32
+ - One fact a line, without the `- `, exact: the stream, the text, the code. In `where`, the files whose code decides it.
33
+ - Only what the stack you named does not say the same way: where the original departs from it, or what it leaves open.
34
+
35
+ ## Concepts
36
+
37
+ `definitions`: the core concepts of each part's domain - what its data model, its tables and its screens are about: `:User:`, `:Order:`, `:Invoice:`. Each is one plain sentence that starts with the concept and says what it is, with its attributes when they matter to what users see. Only those used across the software; the agents that capture each feature define their own. Concept names are CamelCase between colons, and never one of the predefined ones (:Implementation:, :UnitTests:, :ConformanceTests:, :AcceptanceTests: and the rest).
38
+
39
+ Every concept your bullets use must be one of yours or a predefined one. Two definitions never name each other - `:Link:` naming `:LinkCode:` and `:LinkCode:` naming `:Link:` is a circle ***plain refuses: the one built on the other names it, and that one names nothing back.
@@ -0,0 +1,18 @@
1
+ # Try the scenarios on the original
2
+
3
+ The scenarios below are what the conformance tests of the regenerated code will check. Agents wrote them from the original's code and tests, and never ran it - so one can expect a terminal its test will not give, a site on the internet, output wrapped at a width nobody set, a message the original never prints. A scenario the original itself fails is wrong: a coding agent builds to it and breaks what users rely on, or its module's conformance tests fail for good.
4
+
5
+ You have a shell. Your folder is a copy of the original codebase - its files, none of its dependencies installed. Install it there, as its manifests and README say, then run each scenario against it the way its conformance test will: from outside, through its interface - the command run, the request sent, the page driven - under the test reqs below: what standard input and output are, the environment, the servers it talks to. Never change the original's files to make a scenario hold.
6
+
7
+ Call `submit_capture_trial` once, with every scenario you were given, each with its `outcome`:
8
+
9
+ - `held`: the original does what it says. In `ran`, what you ran and what it answered, in a line.
10
+ - `corrected`: it does otherwise. Its whole new text in `text`, saying what the original does; `why`; and in `ran`, what you ran and what it answered. Keep what it checks - change its values, what it expects, or how it gets there: a local server for a site on the internet, the option that forces colour when its test's output is not a terminal. Never check less. Where its functional spec says the same wrong thing, correct the functional spec too, in `functional_specs`, its whole new text and why.
11
+ - `removed`: nothing outside the software can check it - it calls a function, mocks a library, needs a real terminal no test can give - with `why`. Rare: first look for a way to check it from outside.
12
+ - `untried`: you could not run it - the original would not install or start here, it needs a service this machine lacks - with `why`. It stays as written. Never `held` or `removed` for a scenario you did not run.
13
+
14
+ What every conformance test of the part must set up for the original to act as the scenarios say goes in `test_reqs`, one fact a line, with :ConformanceTests: as the subject, when the test reqs below do not say it already: an environment variable such as `COLUMNS`, a configuration folder of the test's own, an update check or telemetry turned off, how bodies are compared, a local server in place of the internet.
15
+
16
+ The test reqs are read by whoever writes any conformance test of the part, for every scenario of every module. So what only some scenarios need - a file one sends, a session file one starts from, a server that answers one exact body, a pseudo-terminal for the one password prompt, a variable unset for one case - is never a test req: it goes in those scenarios' own text. Return each `corrected`, its text saying the setup it needs as part of what it does, and `why`: the setup it did not say. A test req names no scenario and no functional spec.
17
+
18
+ Run the smallest batch of actual commands that demonstrates all the scenarios, capturing stdout, stderr and exit status separately. A standard-library CLI you can run from its source tree needs no install: invoke it directly. A test framework is not needed to observe what its black-box tests observe. Do not spend a turn installing a framework just to launch the same command.
@@ -0,0 +1,7 @@
1
+ # Check the interface against the code
2
+
3
+ Below is a module's ***plain - each functional spec with its scenarios - and the interface the code of its features defines. From now on the ***plain is the source of truth and the code is regenerated from it: what it says of the interface must be what the original does, exactly. Check every interface fact it states against the code that decides it - each option's names, the value it takes, its choices and default; each command; each route's method, path, parameters, fields and status codes; each message, output format and exit code a user or a script sees; each environment variable. Read the definition and follow it: never take the ***plain's word, a name, a help text or a docstring when the code does otherwise. The agents that wrote it were offline and read in a hurry; expect mistakes.
4
+
5
+ When the part has an interface reference, its entries are listed: taken from the code, every literal checked against it. The ***plain must agree with it - an option, a choice, a default it gives otherwise is wrong, unless the code shows the reference is - and an option the ***plain names that the reference does not have is listed for you to settle against the code.
6
+
7
+ Correct what is wrong, and add what is missing of the interface it already describes: a choice left out, a default unsaid, an alias, a message's exact text, a field. A scenario that would fail against the original is corrected too. Call `submit_capture_corrections` once, with each correction: the functional spec's func-id - and the scenario's id when the correction is to the scenario - its whole new text, and why, citing the code. Change nothing else: a functional spec that holds keeps its words, behaviour that is not interface is not yours, and no fact is cut. None at all when everything holds.
@@ -56,7 +56,7 @@ The other rules say what a spec means. This one says what turri does with a chan
56
56
  - Bad conformance tests are fixed the same way, their code untouched: `conform` naming a functional spec whose tests are written writes them again, anew from its scenarios; `conform` from scratch takes out the tests folder at the tip of the module's chain and writes them again - from the tests of the module the tip requires, or, its whole chain, from nothing - only when the person asks for it
57
57
  - Pulses regenerate in the background: the spec can be changed while they run, and need not wait for them. A change inside what a running pulse regenerates steers it; the rest is planned again around it
58
58
  - A pulse that does not land is rolled back whole - code, tests and record together - and its module waits until the spec changes or the module is asked for again. Running it again unchanged usually ends the same way: look at why it did not land first
59
- - A finished pulse goes to the sentinel, a chat of turri's own - unless `sentinel: false`; under `sentinel: ask`, the default, only once the person said to start it, asked by turri before it first opens in a session (declined, a pulse goes to the chat that asked for it, as with `false`): it checks every pulse, in order, tests it in what was launched - a launch whose commit holds the pulse's - fixes a testing script - or where the config says the scripts are - itself and regenerates the module again, and puts anything else that is wrong to the person as a notice with what can be done. It never changes ***plain. turri installs nothing on the machine and changes none of its settings - not the sentinel, the chat, a launch or any agent: a toolchain the machine lacks is the person's to install, told the exact command. A pulse that landed is told to the chat the person is in too, only to say it landed and what the sentinel does with it, and when the sentinel is done with a pulse, what it found - the chat does nothing else about either; a pulse that went wrong is not told to it - the chat's agent is given a notice's task once the person accepts it, and does that
59
+ - A finished pulse goes to the sentinel, a chat of turri's own - unless `sentinel: false`; under `sentinel: ask`, the default, only once the person said to start it. It checks every pulse in order and tests it in a launch whose commit holds the pulse's. It can fix a testing script or its configuration and resume the module. Anything else that is wrong goes to the person as a notice with evidence and actions. The sentinel never changes ***plain. turri installs nothing on the machine and changes none of its settings: a missing toolchain is the person's to install, told the exact command. Where the surface shows notifications, finished pulses, findings and conclusions are for the person to read there. The chat does not repeat them; it answers when asked and carries out a notice's task once the person accepts it
60
60
 
61
61
  ## Where the cost is
62
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.4.3-next.620bae9",
3
+ "version": "0.4.3-next.7ada234",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {