aai-coding 0.1.0__tar.gz → 0.1.1__tar.gz

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 (44) hide show
  1. aai_coding-0.1.1/PKG-INFO +110 -0
  2. aai_coding-0.1.1/README.md +88 -0
  3. aai_coding-0.1.1/aai_coding/__init__.py +2 -0
  4. aai_coding-0.1.1/aai_coding/_writing.py +44 -0
  5. aai_coding-0.1.1/aai_coding/claudesub.py +42 -0
  6. aai_coding-0.1.1/aai_coding/coding_patterns.py +89 -0
  7. aai_coding-0.1.1/aai_coding/harness.py +328 -0
  8. aai_coding-0.1.1/aai_coding/harness_docs.py +23 -0
  9. {aai_coding-0.1.0 → aai_coding-0.1.1}/aai_coding/llms.py +11 -11
  10. aai_coding-0.1.1/aai_coding/nbreview.py +88 -0
  11. aai_coding-0.1.1/aai_coding/understand.py +50 -0
  12. aai_coding-0.1.1/aai_coding/vision.py +146 -0
  13. aai_coding-0.1.1/aai_coding/write_docs.py +93 -0
  14. aai_coding-0.1.1/aai_coding/write_llms.py +90 -0
  15. aai_coding-0.1.1/aai_coding/write_prose.py +74 -0
  16. aai_coding-0.1.1/aai_coding/write_summary.py +50 -0
  17. aai_coding-0.1.1/aai_coding.egg-info/PKG-INFO +110 -0
  18. {aai_coding-0.1.0 → aai_coding-0.1.1}/aai_coding.egg-info/SOURCES.txt +8 -6
  19. {aai_coding-0.1.0 → aai_coding-0.1.1}/aai_coding.egg-info/entry_points.txt +5 -2
  20. aai_coding-0.1.1/aai_coding.egg-info/requires.txt +9 -0
  21. {aai_coding-0.1.0 → aai_coding-0.1.1}/pyproject.toml +9 -6
  22. aai_coding-0.1.1/tests/test_startup.py +12 -0
  23. aai_coding-0.1.1/tests/test_vision.py +42 -0
  24. aai_coding-0.1.0/CHANGELOG.md +0 -25
  25. aai_coding-0.1.0/MANIFEST.in +0 -3
  26. aai_coding-0.1.0/PKG-INFO +0 -46
  27. aai_coding-0.1.0/README.md +0 -27
  28. aai_coding-0.1.0/aai_coding/__init__.py +0 -1
  29. aai_coding-0.1.0/aai_coding/coding_patterns.py +0 -137
  30. aai_coding-0.1.0/aai_coding/harness.py +0 -304
  31. aai_coding-0.1.0/aai_coding/harness_docs.py +0 -20
  32. aai_coding-0.1.0/aai_coding/looker.py +0 -71
  33. aai_coding-0.1.0/aai_coding/theory.py +0 -23
  34. aai_coding-0.1.0/aai_coding/write_docs.py +0 -101
  35. aai_coding-0.1.0/aai_coding/write_prose.py +0 -127
  36. aai_coding-0.1.0/aai_coding/write_summary.py +0 -62
  37. aai_coding-0.1.0/aai_coding.egg-info/PKG-INFO +0 -46
  38. aai_coding-0.1.0/aai_coding.egg-info/requires.txt +0 -6
  39. aai_coding-0.1.0/tests/test_harness.py +0 -191
  40. aai_coding-0.1.0/tests/test_looker.py +0 -37
  41. {aai_coding-0.1.0 → aai_coding-0.1.1}/LICENSE +0 -0
  42. {aai_coding-0.1.0 → aai_coding-0.1.1}/aai_coding.egg-info/dependency_links.txt +0 -0
  43. {aai_coding-0.1.0 → aai_coding-0.1.1}/aai_coding.egg-info/top_level.txt +0 -0
  44. {aai_coding-0.1.0 → aai_coding-0.1.1}/setup.cfg +0 -0
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: aai-coding
3
+ Version: 0.1.1
4
+ Summary: Pyskills for Answer.AI coding sessions
5
+ Author: aai-coding contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/AnswerDotAI/aai-coding
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pypdfium2>=5
14
+ Requires-Dist: pyvips[binary]>=3
15
+ Requires-Dist: python-fastllm>=0.0.75
16
+ Requires-Dist: pyskills>=0.0.35
17
+ Provides-Extra: dev
18
+ Requires-Dist: fastship; extra == "dev"
19
+ Requires-Dist: build; extra == "dev"
20
+ Requires-Dist: twine; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ # aai-coding
24
+
25
+ `aai-coding` contains Answer.AI's shared configuration, skills, and tools for Claude Code, Codex, and Antigravity. It defines the team's coding and writing guidance, tool permissions, and Python workflows. An LLM setting up the harness should read this README before following `SETUP.md`. The design decisions below also help you advise users who already have a setup.
26
+
27
+ ## Getting started
28
+
29
+ You do not need an Answer.AI account or our existing workspace. [SETUP.md](SETUP.md) starts by creating a workspace in a directory you choose, managed by [fastws](https://github.com/AnswerDotAI/fastws). It then covers harness configuration.
30
+
31
+ The workspace holds separate Git checkouts that share one uv environment. Because its Python projects use editable installs, changes in a checkout are available without reinstalling it.
32
+
33
+ Start with:
34
+
35
+ ```bash
36
+ uvx --from 'fastws-cli>=0.0.14' ws-setup AnswerDotAI/aai-ws ~/aai-ws
37
+ ```
38
+
39
+ Activate the new environment and follow [SETUP.md](SETUP.md). The public [aai-ws baseline](https://github.com/AnswerDotAI/aai-ws) includes aai-coding, fastws, kernel startup and editing tools, and tools used by the Claude hooks. Other Python dependencies are installed as packages.
40
+
41
+ Answer.AI team members use `AnswerDotAI/private-ws` instead of `AnswerDotAI/aai-ws` in that command. Both workspace repos receive shared baseline updates through `ws-sync`. In either setup:
42
+
43
+ - `repos.txt` holds the shared baseline.
44
+ - Gitignored `repos-local.txt` holds personal extras.
45
+ - fastws creates and maintains the workspace's untracked `pyproject.toml`.
46
+
47
+ Reuse existing workspaces. Do not run `ws-setup` on them. See the [team migration instructions](https://github.com/AnswerDotAI/private-ws#migrating-an-existing-workspace).
48
+
49
+ ## Tool workflows
50
+
51
+ Claude Code, Codex, and Antigravity use persistent kernels for Python, file inspection, searching, notebooks, and most edits. Pyskills provide the tools; exhash provides hash-verified editing. Use Bash for shell commands, builds, and Git. Use native tools where the installed skills call for them.
52
+
53
+ Run ordinary Claude Code, Codex, or Antigravity with `clikernel-mcp` registered as an MCP server. Each agent has its own kernel and Python state. Claude Code and Antigravity use `clikernel-hook` to isolate callers on a shared MCP connection (subagents in Claude Code; all conversations and subagents in Antigravity). Codex isolates its MCP sessions without that hook.
54
+
55
+ Claude Code uses the `persistent-python` and `pyskills` host skills. Codex and Antigravity use `kernel-notebook-editing` from `skills/clikernel`, and `cli-notebook-editing` only when the user explicitly requests working without a kernel. Antigravity packages its MCP server, hooks, skills, and `core.md` as one global plugin at `~/.gemini/config/plugins/aai-coding/`. The setup steps link the existing skills without changing them.
56
+
57
+ Task guidance is in pyskills. A pyskill is a Python module docstring, listed by `list_pyskills()` and read with `doc()`. Pyskills are versioned, released, and installed with their Python packages.
58
+
59
+ ## What is in here
60
+
61
+ The repository contains:
62
+
63
+ - `aai_coding/`: Python pyskills and the hook implementation, listed below.
64
+ - `skills/`: host-level `SKILL.md` sources linked into each harness's skills directory. [SETUP.md](SETUP.md#5-skills-safecmd-and-prompts) lists the links.
65
+ - `plugins/safecmd/`: a Claude Code plugin that auto-approves allowlisted Bash commands using the `safecmd` package.
66
+ - `prompts/`: shared behavioural rules and a replacement Claude Code system prompt, described below.
67
+ - `SETUP.md`: a setup runbook written as a prompt for an LLM session. It is not an installer script.
68
+
69
+ ### Python modules
70
+
71
+ - `coding_patterns` covers coding style, testing judgment, and team policy. Kernel startup imports it and tells the agent to read it with `doc(acp)`.
72
+ - `nbreview` guides notebook style reviews, including chkstyle findings, method extraction, lessons, and testing judgment. It builds on `nbdev.skill` and `coding_patterns`.
73
+ - `write_prose` covers anti-slop rules for narrative prose.
74
+ - `write_docs` covers plain reference prose for docstrings, READMEs, and PRs.
75
+ - `write_summary` covers summaries that a reader can use without the source.
76
+ - `write_llms` covers files that an LLM reads: `llms.txt` files, pyskill docstrings, setup runbooks, and prompts.
77
+ - `harness_docs` explains how to find official harness documentation through `llms.txt`.
78
+ - `vision` describes and transcribes images and PDFs through fastllm, without tools. `look` answers questions; `transcribe` saves Markdown and returns usage, timing and cost.
79
+ - `understand` covers building and holding a Theory (Naur, Socrates, Knoblich et al., Lakatos) before proposing, changing, or reviewing code or designs.
80
+ - `harness` implements hooks for Claude Code, Codex, and Antigravity through the `aai-hook` CLI. It is not a pyskill.
81
+
82
+ ### Prompts
83
+
84
+ `prompts/core.md` contains harness-neutral behavioural rules. Codex reads shared and personal rules from `~/.codex/AGENTS.md`, symlinked to `core.md` or merged into an existing personal file. Claude Code appends `core.md` to its system prompt. Antigravity loads `core.md` from `rules/AGENTS.md` and `prompts/agy-kernel.md` (its always-on kernel-first and swarm-forking workflow rule) from `rules/GEMINI.md` inside its global plugin, and has no flag to replace its built-in system prompt.
85
+
86
+ `prompts/sysp.md` replaces Claude Code's default system prompt. It aims to reduce the default prompt's tendency to give consultant-style advice and act without sufficient justification. Launch with:
87
+
88
+ ```bash
89
+ claude --system-prompt-file <this repo>/prompts/sysp.md --append-system-prompt-file <this repo>/prompts/core.md
90
+ ```
91
+
92
+ Replacing the default prompt removes its prose, its dynamic environment block and its scratchpad path. Tool schemas remain available.
93
+
94
+ ## Design decisions, and why
95
+
96
+ - Task skills use Python's packaging and discovery rather than a harness's skill machinery. Their instructions and executable tools can share a module. Host skills bootstrap the kernel and explain how to use its tools with the harness.
97
+ - This repo's hooks are subcommands of `aai-hook` in `aai_coding/harness.py`. The kernel isolation hook for Claude Code and Antigravity comes from `clikernel`. Harness settings register the commands rather than copying their implementations.
98
+ - Each harness's skills and the kernel startup file are symlinks into this checkout. Pulling updates them without copying files. The setup steps merge harness settings and personal instruction files with the user's existing configuration.
99
+ - Where the harnesses differ, a module gives each version in the same place, in a dictionary keyed by harness or in neighbouring bullets. There are no generated per-harness templates.
100
+ - This repo contains agreed team guidance. Model choice, sounds, and personal workflows such as release management belong in each person's `CLAUDE.md`, settings, and local skills. `SETUP.md` identifies which settings are shared and which are personal.
101
+
102
+ ## Using and changing it
103
+
104
+ Activate the workspace's `.venv`, then work in a project checkout. Use `ws-status` to inspect local changes, `ws-sync` to pull and install updates, and `ws-add owner/repo` to add a project. See [the workspace workflow](SETUP.md#using-the-workspace) for details, including what syncing changes.
105
+
106
+ You do not need to start the harness manually each day. Sessions use the skills described in [Tool workflows](#tool-workflows). Agents find Python tools in the pyskills catalog and read their documentation with `doc()` or `pyskills-doc`.
107
+
108
+ To change a skill, edit its source in this checkout. Others receive the changes by pulling. Release with the standard fastship command, `ship-release`. Bump the version in `aai_coding/__init__.py` after each release.
109
+
110
+ Tests cover substantive logic where hidden errors are realistic: event ordering, accumulated state, duplicate suppression, and PDF rendering. Do not add tests for prompt wording, straightforward dispatch, or trivial configuration branches. Run the tests with `pytest`.
@@ -0,0 +1,88 @@
1
+ # aai-coding
2
+
3
+ `aai-coding` contains Answer.AI's shared configuration, skills, and tools for Claude Code, Codex, and Antigravity. It defines the team's coding and writing guidance, tool permissions, and Python workflows. An LLM setting up the harness should read this README before following `SETUP.md`. The design decisions below also help you advise users who already have a setup.
4
+
5
+ ## Getting started
6
+
7
+ You do not need an Answer.AI account or our existing workspace. [SETUP.md](SETUP.md) starts by creating a workspace in a directory you choose, managed by [fastws](https://github.com/AnswerDotAI/fastws). It then covers harness configuration.
8
+
9
+ The workspace holds separate Git checkouts that share one uv environment. Because its Python projects use editable installs, changes in a checkout are available without reinstalling it.
10
+
11
+ Start with:
12
+
13
+ ```bash
14
+ uvx --from 'fastws-cli>=0.0.14' ws-setup AnswerDotAI/aai-ws ~/aai-ws
15
+ ```
16
+
17
+ Activate the new environment and follow [SETUP.md](SETUP.md). The public [aai-ws baseline](https://github.com/AnswerDotAI/aai-ws) includes aai-coding, fastws, kernel startup and editing tools, and tools used by the Claude hooks. Other Python dependencies are installed as packages.
18
+
19
+ Answer.AI team members use `AnswerDotAI/private-ws` instead of `AnswerDotAI/aai-ws` in that command. Both workspace repos receive shared baseline updates through `ws-sync`. In either setup:
20
+
21
+ - `repos.txt` holds the shared baseline.
22
+ - Gitignored `repos-local.txt` holds personal extras.
23
+ - fastws creates and maintains the workspace's untracked `pyproject.toml`.
24
+
25
+ Reuse existing workspaces. Do not run `ws-setup` on them. See the [team migration instructions](https://github.com/AnswerDotAI/private-ws#migrating-an-existing-workspace).
26
+
27
+ ## Tool workflows
28
+
29
+ Claude Code, Codex, and Antigravity use persistent kernels for Python, file inspection, searching, notebooks, and most edits. Pyskills provide the tools; exhash provides hash-verified editing. Use Bash for shell commands, builds, and Git. Use native tools where the installed skills call for them.
30
+
31
+ Run ordinary Claude Code, Codex, or Antigravity with `clikernel-mcp` registered as an MCP server. Each agent has its own kernel and Python state. Claude Code and Antigravity use `clikernel-hook` to isolate callers on a shared MCP connection (subagents in Claude Code; all conversations and subagents in Antigravity). Codex isolates its MCP sessions without that hook.
32
+
33
+ Claude Code uses the `persistent-python` and `pyskills` host skills. Codex and Antigravity use `kernel-notebook-editing` from `skills/clikernel`, and `cli-notebook-editing` only when the user explicitly requests working without a kernel. Antigravity packages its MCP server, hooks, skills, and `core.md` as one global plugin at `~/.gemini/config/plugins/aai-coding/`. The setup steps link the existing skills without changing them.
34
+
35
+ Task guidance is in pyskills. A pyskill is a Python module docstring, listed by `list_pyskills()` and read with `doc()`. Pyskills are versioned, released, and installed with their Python packages.
36
+
37
+ ## What is in here
38
+
39
+ The repository contains:
40
+
41
+ - `aai_coding/`: Python pyskills and the hook implementation, listed below.
42
+ - `skills/`: host-level `SKILL.md` sources linked into each harness's skills directory. [SETUP.md](SETUP.md#5-skills-safecmd-and-prompts) lists the links.
43
+ - `plugins/safecmd/`: a Claude Code plugin that auto-approves allowlisted Bash commands using the `safecmd` package.
44
+ - `prompts/`: shared behavioural rules and a replacement Claude Code system prompt, described below.
45
+ - `SETUP.md`: a setup runbook written as a prompt for an LLM session. It is not an installer script.
46
+
47
+ ### Python modules
48
+
49
+ - `coding_patterns` covers coding style, testing judgment, and team policy. Kernel startup imports it and tells the agent to read it with `doc(acp)`.
50
+ - `nbreview` guides notebook style reviews, including chkstyle findings, method extraction, lessons, and testing judgment. It builds on `nbdev.skill` and `coding_patterns`.
51
+ - `write_prose` covers anti-slop rules for narrative prose.
52
+ - `write_docs` covers plain reference prose for docstrings, READMEs, and PRs.
53
+ - `write_summary` covers summaries that a reader can use without the source.
54
+ - `write_llms` covers files that an LLM reads: `llms.txt` files, pyskill docstrings, setup runbooks, and prompts.
55
+ - `harness_docs` explains how to find official harness documentation through `llms.txt`.
56
+ - `vision` describes and transcribes images and PDFs through fastllm, without tools. `look` answers questions; `transcribe` saves Markdown and returns usage, timing and cost.
57
+ - `understand` covers building and holding a Theory (Naur, Socrates, Knoblich et al., Lakatos) before proposing, changing, or reviewing code or designs.
58
+ - `harness` implements hooks for Claude Code, Codex, and Antigravity through the `aai-hook` CLI. It is not a pyskill.
59
+
60
+ ### Prompts
61
+
62
+ `prompts/core.md` contains harness-neutral behavioural rules. Codex reads shared and personal rules from `~/.codex/AGENTS.md`, symlinked to `core.md` or merged into an existing personal file. Claude Code appends `core.md` to its system prompt. Antigravity loads `core.md` from `rules/AGENTS.md` and `prompts/agy-kernel.md` (its always-on kernel-first and swarm-forking workflow rule) from `rules/GEMINI.md` inside its global plugin, and has no flag to replace its built-in system prompt.
63
+
64
+ `prompts/sysp.md` replaces Claude Code's default system prompt. It aims to reduce the default prompt's tendency to give consultant-style advice and act without sufficient justification. Launch with:
65
+
66
+ ```bash
67
+ claude --system-prompt-file <this repo>/prompts/sysp.md --append-system-prompt-file <this repo>/prompts/core.md
68
+ ```
69
+
70
+ Replacing the default prompt removes its prose, its dynamic environment block and its scratchpad path. Tool schemas remain available.
71
+
72
+ ## Design decisions, and why
73
+
74
+ - Task skills use Python's packaging and discovery rather than a harness's skill machinery. Their instructions and executable tools can share a module. Host skills bootstrap the kernel and explain how to use its tools with the harness.
75
+ - This repo's hooks are subcommands of `aai-hook` in `aai_coding/harness.py`. The kernel isolation hook for Claude Code and Antigravity comes from `clikernel`. Harness settings register the commands rather than copying their implementations.
76
+ - Each harness's skills and the kernel startup file are symlinks into this checkout. Pulling updates them without copying files. The setup steps merge harness settings and personal instruction files with the user's existing configuration.
77
+ - Where the harnesses differ, a module gives each version in the same place, in a dictionary keyed by harness or in neighbouring bullets. There are no generated per-harness templates.
78
+ - This repo contains agreed team guidance. Model choice, sounds, and personal workflows such as release management belong in each person's `CLAUDE.md`, settings, and local skills. `SETUP.md` identifies which settings are shared and which are personal.
79
+
80
+ ## Using and changing it
81
+
82
+ Activate the workspace's `.venv`, then work in a project checkout. Use `ws-status` to inspect local changes, `ws-sync` to pull and install updates, and `ws-add owner/repo` to add a project. See [the workspace workflow](SETUP.md#using-the-workspace) for details, including what syncing changes.
83
+
84
+ You do not need to start the harness manually each day. Sessions use the skills described in [Tool workflows](#tool-workflows). Agents find Python tools in the pyskills catalog and read their documentation with `doc()` or `pyskills-doc`.
85
+
86
+ To change a skill, edit its source in this checkout. Others receive the changes by pulling. Release with the standard fastship command, `ship-release`. Bump the version in `aai_coding/__init__.py` after each release.
87
+
88
+ Tests cover substantive logic where hidden errors are realistic: event ordering, accumulated state, duplicate suppression, and PDF rendering. Do not add tests for prompt wording, straightforward dispatch, or trivial configuration branches. Run the tests with `pytest`.
@@ -0,0 +1,2 @@
1
+ __version__ = "0.1.1"
2
+
@@ -0,0 +1,44 @@
1
+ "Text that `write_docs` and `write_prose` share. Each module calls `fill` on its docstring at import, replacing each `{name}` placeholder with the matching `SHARED` entry."
2
+
3
+ SHARED = dict(
4
+ markers = r'''`[n]` marks tells; in both passages, 2nd=problem, 1st=fix.''',
5
+ new_tells = r'''New tell: next number; mark 2nd passage if short.''',
6
+ tacked_on = r'''Tacked-on clauses & consequence glue: em dash (` - `,` -- `), `;`, `:`, `, and`, `, which`, or trailing `, so` / same-sense `, and` ("cache is warm, and calls are fast") restating/implying prior clause (list/example `:` OK; label+list=restatement). Rebuild from reader needs, never split or swap `, because`.''',
7
+ hedging = r'''Hedging: "may/might/potentially/in some cases/should generally". State truth or direct uncertainty ("undefined with concurrent writers").''',
8
+ filler = r'''Filler: noting ("note that", "worth/important to note", "notably/importantly/interestingly", "keep in mind"->delete); transitions ("Furthermore/Moreover/Additionally/In conclusion/To summarize/When it comes to/In the realm of"->use "and"/"also" or lead with subject).''',
9
+ restatement = r'''Restatement: heading echoed by line 1; lead/closing paragraph summary. State once; summaries at doc scale only (abstract/TL;DR/README p1).''',
10
+ decorative_verbs = r'''Decorative verbs: verb not naming event or impossible for inanimate subject. Colorful ("ids ride", "note lands"->appear); impossible plain ("dfn names arg", "count takes items", "settings load"->actor/imperative/passive); mental (`want/need/decide/respect/rely on/invent`); ownership/comms (`own/assign/carry/ship/record/respond`, structural `reads as`). OK: real action ("holds value", "`watch` polls"), perceptual ("read as bright"), whiteboard idioms ("walk tree", "goes stale", "costs O(n)"). Whiteboard test. (`land`/`shape` below.)''',
11
+ audience = r'''Audience misjudged: name audience; cut knowns; define local terms or use plain words. Explaining known: daily terms ("air conditioning, a technology that cools air"), instant inferences, obvious practices. Undefined jargon: local coinages ("glidepath", "carrier", "wisp", codenames); terms of art (CFRunLoop, kqueue, monad) OK.''',
12
+ throat_clearing = r'''Throat-clearing: openers announcing doc ("This section describes...", "Purpose of...", "In this piece...", "Let's dive into...") or today's-world ("In today's [fast-paced/digital/modern] world...", "...AI landscape..."). Delete; start with subject.''',
13
+ advertising = r'''Metadiscourse/advertising: stub+`:` ("Core mechanism: `watch`.", "Fix: retry."->full sentence); teaser pivot ("here's where it gets interesting", "X, but main event is Y", "real story is..."->facts in order); appraisal preamble ("worth being precise", "key point", "what's interesting", "crucially"->delete).''',
14
+ not_x_but_y = r'''Not-X-but-Y: "It's not X, it's Y", "isn't just X, it's Y", "not X, but Y". State directly.''',
15
+ symmetry = r'''Forced symmetry & over-structuring: 3 adjectives, 3 pros/cons, 5 steps, equal sections, matching openers (distrust 3/5); headers/tables/bullets on 1-screen doc (headers=navigation; bullets for parallel facts only).''',
16
+ agent_defocusing = r'''Agent defocusing: artifact-as-agent hides person ("tests shaped", "PR introduces", "design lets you"->person "I added..." or behavior "`connect` retries"; UI: "override `--x` on `[ui]`", not "`[ui]` can change `--x`"); recipient-as-subject puts beneficiary with `gets/gains/receives` + doer in `via/through/thanks to` or dropped->name actor or new state ("new process listens on fresh ports").''',
17
+ decoration = r'''Decoration: emoji/ornamental unicode. ASCII unless asked (`->`, words).''',
18
+ false_depth = r'''False depth: fancier restatement, obvious points, "it depends". Give specifics: identifiers, numbers, edge cases, failures.''',
19
+ plain_words = r'''Plain: utilize/leverage->use; enhance/optimize (unless literally optimizing)->improve; comprehensive->complete; robust->strong; facilitate->help; seamless->smooth; empower->let/help; foster->encourage.''',
20
+ banned_words = r'''Banned: streamline, pivotal, "a testament to", realm, landscape (metaphorical), navigate (metaphorical), delve, myriad, plethora, paradigm, synergy, holistic, catalyze, juxtapose, tapestry, embark, endeavor, encompass, multifaceted, elucidate, nuanced (filler), minted (metaphorical).''',
21
+ hidden_words = r'''Hidden jargon: land/landed->merged/committed/pushed/released/appears; shape/shaped (OK geometry/array/tensor)->structure/format/adapted/copied/informed; invariant->rule/guarantee unless none plainer; `-bearing`->plainer form.''',
22
+ formatting = r'''Formatting: 1 line/para (soft-wrap). Backtick code: functions, params, paths, packages (`fastcore`), literal syntax (`to_html`, `{=html}`).''')
23
+
24
+
25
+ def fill(doc):
26
+ "`doc` with each `{name}` placeholder replaced by `SHARED[name]`"
27
+ for k,v in SHARED.items(): doc = doc.replace('{'+k+'}', v)
28
+ return doc
29
+
30
+
31
+ def charter(
32
+ kind, # The checker's register, e.g. 'prose' or 'reference-prose'
33
+ verb_tells, # The guide's numbers for the decorative-verb and agent-defocusing tells, e.g. '10 and 17'
34
+ audience_tells, # The guide's audience tell, e.g. 'tell 11'
35
+ ):
36
+ "System prompt for a subagent that checks text against a writing guide"
37
+ return f"""You are a {kind} checker called as a subagent: your output is parsed by another model, and no human reads it. Praise, hedging, overall verdicts, and commentary on the text's quality therefore serve nobody; emit flags or "Clean" and nothing else. The user message contains prose-style rules, an AUDIENCE line naming the intended readers, then the text to review under "TEXT UNDER REVIEW".
38
+ - Sweep per tell: for each numbered tell, scan the ENTIRE text for it before moving to the next. Do not substitute one general pass.
39
+ - Report each candidate violation as: the tell name and number, and the offending span quoted verbatim. Also flag banned words, em dashes, and hard-wrapped paragraphs.
40
+ - Give extra attention to the two verb tells, {verb_tells}: they are the subtlest and the most commonly missed. Question every verb whose subject is an artifact.
41
+ - Judge {audience_tells} against the stated audience.
42
+ - Err on the side of flagging: the caller applies judgment to your flags, so a missed tell costs more than a false positive. When a span merely resembles a tell, flag it and append "borderline".
43
+ - Where the fix is not obvious from the flag itself, append a suggested replacement for the quoted span; never rewrite beyond that.
44
+ - "Clean" is a valid answer when nothing matches. Never append a verdict to it, and never summarize or soften a flag list."""
@@ -0,0 +1,42 @@
1
+ "The `claudesub` command: run a headless Claude child from the current session's compacted history, in its own kernel. It needs llmsurgery and fastclaude, which aai-coding doesn't install."
2
+ from fastcore.script import call_parse
3
+
4
+ PROTOCOL = """You are a subagent spawned by another Claude Code session with `claudesub`. The history above is that session's compacted transcript: you hold its decisions and evidence, but none of its kernel state. Your clikernel kernel is your own; no other session shares it. No person is watching, so never wait for an answer or ask a question mid-task: if you are blocked, stop and report exactly what you need, and the parent can resume you with `claudesub -r <your session id> '<answer>'`, which restarts your kernel, so finish whatever does not depend on the answer before you stop. Do the directive, and end with a report the parent can act on without reading your transcript: what you did, what you found, and anything left undone."""
5
+
6
+ @call_parse(nested=True, pos=['directive'])
7
+ def main(
8
+ directive:str, # The child's task
9
+ Resume:str=None, # A child session id to continue with `directive` as its next prompt, instead of spawning from this session
10
+ sid:bool=False, # Print the prepared child session id instead of launching
11
+ Quiet:bool=False, # Print only the child's final report, not its progress text
12
+ cwd:str=None, # Project directory to work from, for the parent lookup, the child session, and the child itself; the current directory if None
13
+ ):
14
+ "Start or resume a headless Claude child and print its progress and result."
15
+ import json, os, subprocess, sys
16
+ from fastclaude.core import claude_env
17
+ from fastclaude.session import save_sess
18
+ from llmsurgery.ant import prepare_compaction
19
+ from llmsurgery.sess import launch_args
20
+ if cwd: os.chdir(cwd)
21
+ s = Resume
22
+ if not s:
23
+ parent = os.environ.get('CLAUDE_CODE_SESSION_ID')
24
+ if not parent: sys.exit('CLAUDE_CODE_SESSION_ID is unset: claudesub runs from inside a Claude Code session')
25
+ s = save_sess(list(prepare_compaction(parent).records), ts=True)
26
+ if sid: return print(s)
27
+ argv = ['claude', '-p', directive, f'--resume={s}', '--output-format=stream-json', '--verbose',
28
+ '--append-system-prompt', PROTOCOL, *launch_args('claude'), *sys.argv[1:]]
29
+ p = subprocess.Popen(argv, stdout=subprocess.PIPE, text=True, env=claude_env())
30
+ res = None
31
+ for line in p.stdout:
32
+ try: e = json.loads(line)
33
+ except json.JSONDecodeError: continue
34
+ if e.get('type') == 'result': res = e
35
+ elif e.get('type') == 'assistant' and not Quiet:
36
+ for b in e['message'].get('content', []):
37
+ if b.get('type') == 'text' and b['text'].strip(): print(b['text'].strip(), flush=True)
38
+ p.wait()
39
+ if res is None: sys.exit(f'claude exited {p.returncode} without a result')
40
+ if Quiet: print(res.get('result', ''))
41
+ print(f"[claudesub {res['subtype']}] session {res['session_id']}, {res['num_turns']} turns, ${res.get('total_cost_usd', 0):.2f}", flush=True)
42
+ if res['subtype'] != 'success': sys.exit(1)
@@ -0,0 +1,89 @@
1
+ r'''Jeremy's coding style and conventions: read before writing, reviewing, or assessing any code.
2
+
3
+ notation: /why
4
+
5
+ - applies: all Jeremy's projects; from fastai style guide, his three decades' experience
6
+ - libraries: his sibling-editable ecosystem (`fastcore`, `fasthtml`, `fastlite`, ...) over heavier alternatives
7
+
8
+ ## Design
9
+
10
+ - improving a tool > finishing one task /helps future tasks, sessions, team
11
+ - ergonomics: matter as much as capability
12
+ - friction: fix or raise; never quietly work around /workarounds are the learned default; our tools are one edit away
13
+ - APIs, upstream too: improve beyond smallest fix; another package's private names, reproduced dependency logic, helpers only bridging a package's gap: workaround signs; propose the API that removes them
14
+ - omit: constructs whose need you can't explain (redundant `str(x)` or other coercions, unmutated `list(x)` copies, just-in-case try/excepts, unused parameters); weightless type hints, docstrings, boilerplate; prefer concise readable code /readers infer necessity: useless constructs cost confusion, doubled in nbdev where tests document code
15
+ - useful features: needn't await request; judge by design needs, user expectations /open-source users meeting gaps assume incapability, leave
16
+ - comments: only what code can't show, next to that code; never provenance, next-line narration, change justification /those address reviewers, not future readers
17
+ - refactor continually, encountered mess too: as simple as design allows; inherited mess never excuses more
18
+ - fix needing design decision: report, don't decide
19
+ - one home per fact, constant or piece of logic; noticed duplication: remove all of it together, templates, tests and docs too; never fix copies singly; new duplication: explicit agreement only
20
+
21
+ ## Tools
22
+
23
+ - defaults (CLI flags, Python arguments, tool options): trust unless a task requirement can't otherwise be met; never override habitually or for assumed gains; noisy or wrong output: report as tool bug /defaults target correct, readable output
24
+
25
+ ## Python
26
+
27
+ - docments (fastcore trailing parameter comments): NEVER remove in refactors
28
+ - docmented or long signature:
29
+
30
+ ```python
31
+ @delegates(start_kernel)
32
+ async def run_kernel(
33
+ kernel_name='python3', # Kernelspec name to launch
34
+ manager_cls=KernelManager, # Manager class, e.g. a subclass customizing launch
35
+ **kwargs
36
+ ):
37
+ ```
38
+
39
+ - `**kwargs` forwarded to known callee: `@delegates(callee)`, exposing its options; skip if callee's signature is only `**kwargs`; collector MUST be `kwargs`, not `kw`
40
+ - raw strings for ANY nontrivial literal: regexes, tool text, code, markup, multiline, backslashes /plain `\n` `\d` can error or silently corrupt text; raw costs nothing when escapes absent
41
+ - one-line bodies:
42
+
43
+ ```python
44
+ if not x: return default
45
+ try: return run("cmd").strip() or default
46
+ except Exception: return default
47
+ for i in range(n): result[i] = 0
48
+ ```
49
+
50
+ - imports combined: `import os, re, sys, shutil`; `from fastcore.utils import *` supplies `os`, `Path`, much of stdlib: don't re-import them
51
+
52
+ ## Projects
53
+
54
+ - `chkstyle {path}` (path only if needed): hint, not gospel; nbdev: on notebooks (`chkstyle nbs/00_core.ipynb`), not exported `.py` /notebooks include unexported examples, tests
55
+ - standard config: read, don't duplicate (`.github/release.yml` release notes; `pyproject.toml` `[tool.yourpkg]`); infer values when possible, e.g. package name from `[project].name`
56
+ - bundled data: inside package, read via `importlib.resources`
57
+ - layout: prefer flat (`myproject/mypkg/`, `tests/`, `pyproject.toml`) over `src/`
58
+ - Python versions: Jeremy bumps right AFTER release, as part of it, never during changes /tree holds next release version
59
+ - sibling floors may name unreleased local versions (`foo>=<foo's local version>`)
60
+ - new dependency: its downstream pin is part of the change; consuming unreleased dependency behavior or API: update consumers' pins SAME SESSION, never at release
61
+ - other artifacts: version at change time
62
+
63
+ ## Testing
64
+
65
+ - MUST read `testing` skill before writing, editing, or requesting any test
66
+ - nbdev (most projects): no test cells; tests ARE documentation; revise lesson cells
67
+ - MUST NOT add tests for trivial logic or tests longer than the implementation without explicit agreement
68
+ - add tests only for meaningful uncertainty or substantive logic, never for coverage: documents an idea; logic needing careful thought (edge cases, parsing, arithmetic, tricky conditionals open to silent breakage); somewhat-likely-to-break external assumption (file format, API response shape, another tool's behavior): exercise REAL system, usually slow-marked /mocks merely restate assumptions
69
+ - wiring and orchestration (re-exports, delegation, one-line glue, functions ONLY sequencing tool calls): zero tests /they assert Python works, constrain changeable internals
70
+ - reaching code needs recording fakes or mock collaborators: strongly suggests testing implementation transcripts, not logic; extract and test a small pure function, or don't test
71
+ - red-green: only for assertions actually added or revised, to check the test works (`doc(nbdev.skill)`)
72
+ - pytest: checks that fit no readable notebook lesson AND are too complex or distracting even for `#|hide`; as few as possible, combined into readable, faster stories
73
+ - useful checks: in real tests or notebook cells, never ad-hoc commands; notebook explorations often ARE narrative: keep example cells documenting what we needed to know and guarding it; pytest explorations: only under criteria above
74
+ - assert logic and guarantees, not incidental renderings, reprs or field order (content in Markdown display block, not exact text); NEVER lock in behavior unless essential logic or contract guaranteed forever
75
+ ## CLI harness
76
+
77
+ - **IMPORTANT**: this section applies to CLI coding harnesses only; inside an interactive dialog, follow the dialog skills instead
78
+ - documented build and test commands: MUST run exactly, no added flags unless explicitly requested; read output before working around expected problems
79
+ - flag wanted every run: into config, back to bare command (recurring `pytest --timeout 300` → `timeout = 60` under `[tool.pytest.ini_options]`)
80
+ - applying is the goal: `cargo fmt`, not `cargo fmt --check` then `cargo fmt`; `--check`: final no-mutation verification, e.g. CI
81
+ - never truncate (`| tail -20`, `| grep PASS`) or merge stderr (`2>&1`) /unseen output hides problems; separate stderr makes crashes unmissable
82
+ - shell redirect: NEVER without explicit direct approval, separate from command approval /breaks harness approvals
83
+ - real one-off flag: give reason; use once; drop next call
84
+ - run: `pytest -q`, not `python -m pytest` (prompts for permission); nbdev: `nbdev-test` on changed notebook
85
+ - ask first only if runs (`eval: false` cells too) may take >~2min or reach authenticated external services
86
+ - slow-marked tests: only at session finish or after changes likely to affect them directly
87
+ '''
88
+
89
+ __all__ = []