grain-kit 0.1.0__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.
- grain_kit-0.1.0/PKG-INFO +580 -0
- grain_kit-0.1.0/README.md +548 -0
- grain_kit-0.1.0/pyproject.toml +59 -0
- grain_kit-0.1.0/setup.cfg +4 -0
- grain_kit-0.1.0/src/grain/__init__.py +0 -0
- grain_kit-0.1.0/src/grain/adapters/__init__.py +0 -0
- grain_kit-0.1.0/src/grain/adapters/adapter_config.py +207 -0
- grain_kit-0.1.0/src/grain/adapters/capabilities.py +199 -0
- grain_kit-0.1.0/src/grain/adapters/export.py +104 -0
- grain_kit-0.1.0/src/grain/adapters/filesystem.py +32 -0
- grain_kit-0.1.0/src/grain/adapters/manifest.py +36 -0
- grain_kit-0.1.0/src/grain/adapters/model_config.py +205 -0
- grain_kit-0.1.0/src/grain/cli/__init__.py +81 -0
- grain_kit-0.1.0/src/grain/cli/adapter.py +115 -0
- grain_kit-0.1.0/src/grain/cli/context.py +282 -0
- grain_kit-0.1.0/src/grain/cli/docs.py +89 -0
- grain_kit-0.1.0/src/grain/cli/error_handler.py +39 -0
- grain_kit-0.1.0/src/grain/cli/init.py +45 -0
- grain_kit-0.1.0/src/grain/cli/model.py +202 -0
- grain_kit-0.1.0/src/grain/cli/onboard.py +61 -0
- grain_kit-0.1.0/src/grain/cli/orchestrate.py +204 -0
- grain_kit-0.1.0/src/grain/cli/output.py +54 -0
- grain_kit-0.1.0/src/grain/cli/phase.py +67 -0
- grain_kit-0.1.0/src/grain/cli/prompt.py +63 -0
- grain_kit-0.1.0/src/grain/cli/review.py +183 -0
- grain_kit-0.1.0/src/grain/cli/task.py +303 -0
- grain_kit-0.1.0/src/grain/cli/workflow.py +188 -0
- grain_kit-0.1.0/src/grain/domain/__init__.py +33 -0
- grain_kit-0.1.0/src/grain/domain/adapters.py +178 -0
- grain_kit-0.1.0/src/grain/domain/context.py +147 -0
- grain_kit-0.1.0/src/grain/domain/documents.py +81 -0
- grain_kit-0.1.0/src/grain/domain/errors.py +42 -0
- grain_kit-0.1.0/src/grain/domain/onboard.py +12 -0
- grain_kit-0.1.0/src/grain/domain/orchestrator.py +69 -0
- grain_kit-0.1.0/src/grain/domain/packets.py +111 -0
- grain_kit-0.1.0/src/grain/domain/routing.py +221 -0
- grain_kit-0.1.0/src/grain/domain/scan_result.py +19 -0
- grain_kit-0.1.0/src/grain/domain/workflow.py +27 -0
- grain_kit-0.1.0/src/grain/domain/workflow_loop.py +73 -0
- grain_kit-0.1.0/src/grain/services/__init__.py +0 -0
- grain_kit-0.1.0/src/grain/services/codebase_scanner.py +191 -0
- grain_kit-0.1.0/src/grain/services/context_service.py +557 -0
- grain_kit-0.1.0/src/grain/services/docs_extractor.py +82 -0
- grain_kit-0.1.0/src/grain/services/docs_service.py +167 -0
- grain_kit-0.1.0/src/grain/services/graph_service.py +524 -0
- grain_kit-0.1.0/src/grain/services/handoff_service.py +414 -0
- grain_kit-0.1.0/src/grain/services/init_service.py +223 -0
- grain_kit-0.1.0/src/grain/services/model_service.py +82 -0
- grain_kit-0.1.0/src/grain/services/onboard_doc_generator.py +134 -0
- grain_kit-0.1.0/src/grain/services/onboard_service.py +59 -0
- grain_kit-0.1.0/src/grain/services/orchestration_service.py +460 -0
- grain_kit-0.1.0/src/grain/services/pdf_extractor.py +41 -0
- grain_kit-0.1.0/src/grain/services/prompt_service.py +73 -0
- grain_kit-0.1.0/src/grain/services/review_service.py +238 -0
- grain_kit-0.1.0/src/grain/services/spreadsheet_extractor.py +90 -0
- grain_kit-0.1.0/src/grain/services/structural_intelligence_service.py +494 -0
- grain_kit-0.1.0/src/grain/services/task_prepare_service.py +59 -0
- grain_kit-0.1.0/src/grain/services/task_service.py +302 -0
- grain_kit-0.1.0/src/grain/services/workflow_loop_config_service.py +168 -0
- grain_kit-0.1.0/src/grain/services/workflow_loop_service.py +525 -0
- grain_kit-0.1.0/src/grain/services/workflow_run_service.py +258 -0
- grain_kit-0.1.0/src/grain/services/workflow_service.py +367 -0
- grain_kit-0.1.0/src/grain/templates/__init__.py +0 -0
- grain_kit-0.1.0/src/grain/templates/loader.py +18 -0
- grain_kit-0.1.0/src/grain/validators/__init__.py +3 -0
- grain_kit-0.1.0/src/grain/validators/authority_validator.py +58 -0
- grain_kit-0.1.0/src/grain/validators/doc_existence_validator.py +30 -0
- grain_kit-0.1.0/src/grain/validators/manifest_validator.py +102 -0
- grain_kit-0.1.0/src/grain/validators/orchestrator_validator.py +58 -0
- grain_kit-0.1.0/src/grain/validators/packet_validator.py +108 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/PKG-INFO +580 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/SOURCES.txt +161 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/dependency_links.txt +1 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/entry_points.txt +2 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/requires.txt +12 -0
- grain_kit-0.1.0/src/grain_kit.egg-info/top_level.txt +1 -0
- grain_kit-0.1.0/tests/test_adapter_capability.py +163 -0
- grain_kit-0.1.0/tests/test_adapter_cmd.py +107 -0
- grain_kit-0.1.0/tests/test_adapter_config_loader.py +92 -0
- grain_kit-0.1.0/tests/test_adapter_context.py +110 -0
- grain_kit-0.1.0/tests/test_adapter_domain.py +50 -0
- grain_kit-0.1.0/tests/test_adapter_loading.py +115 -0
- grain_kit-0.1.0/tests/test_authority_validator.py +104 -0
- grain_kit-0.1.0/tests/test_bump_version_script.py +29 -0
- grain_kit-0.1.0/tests/test_canonical_doc_selection.py +172 -0
- grain_kit-0.1.0/tests/test_cli_entrypoint.py +15 -0
- grain_kit-0.1.0/tests/test_closure_validation.py +98 -0
- grain_kit-0.1.0/tests/test_codebase_scanner.py +106 -0
- grain_kit-0.1.0/tests/test_command_groups.py +57 -0
- grain_kit-0.1.0/tests/test_context_build.py +206 -0
- grain_kit-0.1.0/tests/test_context_build_cmd.py +304 -0
- grain_kit-0.1.0/tests/test_context_bundle.py +69 -0
- grain_kit-0.1.0/tests/test_context_export.py +100 -0
- grain_kit-0.1.0/tests/test_context_export_cmd.py +276 -0
- grain_kit-0.1.0/tests/test_context_show_cmd.py +151 -0
- grain_kit-0.1.0/tests/test_context_sources.py +136 -0
- grain_kit-0.1.0/tests/test_doc_existence_validator.py +92 -0
- grain_kit-0.1.0/tests/test_docs_extractor.py +185 -0
- grain_kit-0.1.0/tests/test_docs_index_cmd.py +71 -0
- grain_kit-0.1.0/tests/test_docs_show_cmd.py +49 -0
- grain_kit-0.1.0/tests/test_docs_validate_cmd.py +67 -0
- grain_kit-0.1.0/tests/test_document_adapters_integration.py +406 -0
- grain_kit-0.1.0/tests/test_document_registry.py +125 -0
- grain_kit-0.1.0/tests/test_error_handler.py +60 -0
- grain_kit-0.1.0/tests/test_filesystem_adapter.py +47 -0
- grain_kit-0.1.0/tests/test_graph_adapter_capability.py +63 -0
- grain_kit-0.1.0/tests/test_graph_service.py +121 -0
- grain_kit-0.1.0/tests/test_handoff_service.py +125 -0
- grain_kit-0.1.0/tests/test_help_ergonomics.py +36 -0
- grain_kit-0.1.0/tests/test_imports.py +20 -0
- grain_kit-0.1.0/tests/test_init_service.py +196 -0
- grain_kit-0.1.0/tests/test_manifest_loader.py +62 -0
- grain_kit-0.1.0/tests/test_manifest_validator.py +155 -0
- grain_kit-0.1.0/tests/test_model_config_loader.py +91 -0
- grain_kit-0.1.0/tests/test_model_escalate_cmd.py +203 -0
- grain_kit-0.1.0/tests/test_model_routing.py +89 -0
- grain_kit-0.1.0/tests/test_model_select_cmd.py +145 -0
- grain_kit-0.1.0/tests/test_model_service.py +113 -0
- grain_kit-0.1.0/tests/test_model_show_cmd.py +88 -0
- grain_kit-0.1.0/tests/test_onboard_cmd.py +101 -0
- grain_kit-0.1.0/tests/test_onboard_doc_generator.py +78 -0
- grain_kit-0.1.0/tests/test_orchestrate_cmd.py +191 -0
- grain_kit-0.1.0/tests/test_orchestration_integration.py +126 -0
- grain_kit-0.1.0/tests/test_orchestration_service.py +168 -0
- grain_kit-0.1.0/tests/test_orchestrator_domain.py +130 -0
- grain_kit-0.1.0/tests/test_orchestrator_validator.py +65 -0
- grain_kit-0.1.0/tests/test_output_formatter.py +55 -0
- grain_kit-0.1.0/tests/test_packet_file_validation.py +129 -0
- grain_kit-0.1.0/tests/test_packet_status.py +194 -0
- grain_kit-0.1.0/tests/test_pdf_extractor.py +225 -0
- grain_kit-0.1.0/tests/test_phase10_integration_pipeline.py +175 -0
- grain_kit-0.1.0/tests/test_phase13_integration.py +182 -0
- grain_kit-0.1.0/tests/test_phase5_integration.py +69 -0
- grain_kit-0.1.0/tests/test_phase7_integration.py +234 -0
- grain_kit-0.1.0/tests/test_phase_next_cmd.py +104 -0
- grain_kit-0.1.0/tests/test_prompt_show_cmd.py +183 -0
- grain_kit-0.1.0/tests/test_review_check_cmd.py +87 -0
- grain_kit-0.1.0/tests/test_review_handoff_cmd.py +122 -0
- grain_kit-0.1.0/tests/test_review_service.py +116 -0
- grain_kit-0.1.0/tests/test_review_summary_cmd.py +102 -0
- grain_kit-0.1.0/tests/test_runner_integration.py +366 -0
- grain_kit-0.1.0/tests/test_smoke.py +58 -0
- grain_kit-0.1.0/tests/test_spreadsheet_extractor.py +198 -0
- grain_kit-0.1.0/tests/test_structural_intelligence_service.py +125 -0
- grain_kit-0.1.0/tests/test_task_close_cmd.py +127 -0
- grain_kit-0.1.0/tests/test_task_create_cmd.py +129 -0
- grain_kit-0.1.0/tests/test_task_create_dir.py +73 -0
- grain_kit-0.1.0/tests/test_task_id.py +57 -0
- grain_kit-0.1.0/tests/test_task_lifecycle.py +277 -0
- grain_kit-0.1.0/tests/test_task_list_cmd.py +95 -0
- grain_kit-0.1.0/tests/test_task_next_cmd.py +87 -0
- grain_kit-0.1.0/tests/test_task_prepare_cmd.py +80 -0
- grain_kit-0.1.0/tests/test_task_show_cmd.py +95 -0
- grain_kit-0.1.0/tests/test_task_status_cmd.py +146 -0
- grain_kit-0.1.0/tests/test_task_validate_cmd.py +142 -0
- grain_kit-0.1.0/tests/test_template_loader.py +27 -0
- grain_kit-0.1.0/tests/test_workflow_loop_cmd.py +230 -0
- grain_kit-0.1.0/tests/test_workflow_loop_config_service.py +114 -0
- grain_kit-0.1.0/tests/test_workflow_next_cmd.py +93 -0
- grain_kit-0.1.0/tests/test_workflow_onboard_existing_prompt.py +26 -0
- grain_kit-0.1.0/tests/test_workflow_run_cmd.py +302 -0
- grain_kit-0.1.0/tests/test_workflow_state_service.py +201 -0
- grain_kit-0.1.0/tests/test_working_doc_selection.py +160 -0
grain_kit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: grain-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI-first workflow toolkit for structured AI-assisted software development.
|
|
5
|
+
License-Expression: LicenseRef-Proprietary
|
|
6
|
+
Project-URL: Homepage, https://github.com/barbaricum/ai-build-toolkit
|
|
7
|
+
Project-URL: Repository, https://github.com/barbaricum/ai-build-toolkit
|
|
8
|
+
Project-URL: Issues, https://github.com/barbaricum/ai-build-toolkit/issues
|
|
9
|
+
Keywords: ai,workflow,cli,orchestration,developer-tools
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: click>=8.1
|
|
22
|
+
Requires-Dist: PyYAML>=6.0
|
|
23
|
+
Requires-Dist: networkx>=3.3
|
|
24
|
+
Requires-Dist: tree-sitter>=0.25.2
|
|
25
|
+
Requires-Dist: tree-sitter-language-pack>=0.13.0
|
|
26
|
+
Requires-Dist: openpyxl>=3.1
|
|
27
|
+
Requires-Dist: python-docx>=1.1
|
|
28
|
+
Requires-Dist: pdfplumber>=0.11
|
|
29
|
+
Provides-Extra: release
|
|
30
|
+
Requires-Dist: build>=1.4.3; extra == "release"
|
|
31
|
+
Requires-Dist: twine>=5.1; extra == "release"
|
|
32
|
+
|
|
33
|
+
# Grain
|
|
34
|
+
|
|
35
|
+
Grain is a CLI-first workflow system for structured AI-assisted software development.
|
|
36
|
+
|
|
37
|
+
It gives you:
|
|
38
|
+
- canonical docs as source of truth
|
|
39
|
+
- working docs for sequencing and planning
|
|
40
|
+
- task packets as the execution unit
|
|
41
|
+
- explicit review and close loops
|
|
42
|
+
- minimal-context execution instead of broad repo dumping
|
|
43
|
+
- more useful work per agent context window by reducing drift, retries, and unnecessary rereads
|
|
44
|
+
|
|
45
|
+
Grain is not a coding model by itself.
|
|
46
|
+
It is the workflow and file system that external agent CLIs operate against.
|
|
47
|
+
It exists in part to help agent-CLI users avoid burning through token windows on broad, repetitive, underspecified conversations.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Who It Is For
|
|
52
|
+
|
|
53
|
+
Grain is for developers and technical operators who:
|
|
54
|
+
- use agent CLIs such as Codex or Claude Code
|
|
55
|
+
- want inspectable markdown files instead of opaque orchestration
|
|
56
|
+
- want scoped task execution, review, and closure
|
|
57
|
+
- want less context drift and lower token waste than ad hoc prompting
|
|
58
|
+
- regularly hit context or usage limits before useful work is complete
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quickstart
|
|
63
|
+
|
|
64
|
+
### New project
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 1. Install
|
|
68
|
+
uv tool install grain-kit
|
|
69
|
+
|
|
70
|
+
# 2. Create a repo and initialize
|
|
71
|
+
mkdir my-project && cd my-project
|
|
72
|
+
git init
|
|
73
|
+
grain init
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
After `grain init` your repo has:
|
|
77
|
+
```
|
|
78
|
+
docs/canonical/ ← source-of-truth decisions (you fill these in)
|
|
79
|
+
docs/working/ ← backlog, current task, open questions
|
|
80
|
+
docs/runtime/ ← workflow rules, manifest, adapter profiles
|
|
81
|
+
tasks/ ← one folder per task packet
|
|
82
|
+
prompts/ ← workflow entrypoints for your agent CLI
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# 3. Open prompts/workflow.onboard.new.md in your agent CLI
|
|
87
|
+
# Fill in the Project Context section at the top
|
|
88
|
+
# The agent generates your canonical docs, backlog, and first task
|
|
89
|
+
|
|
90
|
+
# 4. Check what to do next
|
|
91
|
+
grain workflow next
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Output looks like:
|
|
95
|
+
```
|
|
96
|
+
workflow next: ok
|
|
97
|
+
phase 1
|
|
98
|
+
active_task_id P1-T01-TASK-0001
|
|
99
|
+
next_action task_execute
|
|
100
|
+
recommended_prompt prompts/task.execute.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# 5. Run prompts/task.execute.md in your agent CLI — it executes the task
|
|
105
|
+
# 6. Run prompts/task.review.md — review the work
|
|
106
|
+
# 7. Run prompts/task.close.md — close the task and move to the next one
|
|
107
|
+
# 8. Repeat from step 4
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
That is the full loop. `grain workflow next` always tells you exactly where you are and what to do next.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Existing project
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# 1. Install (if not already done)
|
|
118
|
+
uv tool install grain-kit
|
|
119
|
+
|
|
120
|
+
# 2. Scaffold Grain into your existing repo
|
|
121
|
+
cd your-existing-project
|
|
122
|
+
grain onboard
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Output looks like:
|
|
126
|
+
```
|
|
127
|
+
onboard: ok
|
|
128
|
+
root /your-existing-project
|
|
129
|
+
Created:
|
|
130
|
+
- docs/canonical
|
|
131
|
+
- docs/working
|
|
132
|
+
- docs/runtime
|
|
133
|
+
- tasks
|
|
134
|
+
- prompts
|
|
135
|
+
- docs/canonical/product_scope.md
|
|
136
|
+
- docs/canonical/architecture.md
|
|
137
|
+
- docs/working/backlog.md
|
|
138
|
+
- docs/working/current_focus.md
|
|
139
|
+
- docs/working/open_questions.md
|
|
140
|
+
Skipped:
|
|
141
|
+
- (any files that already existed are listed here)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# 3. Open prompts/workflow.onboard.existing.md in your agent CLI
|
|
146
|
+
# The agent scans your codebase, fills in the DRAFT docs, and records
|
|
147
|
+
# gaps as open questions — review everything before treating it as canonical
|
|
148
|
+
|
|
149
|
+
# 4. grain workflow next — start the workflow loop from there
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Core Idea
|
|
155
|
+
|
|
156
|
+
Grain separates work into layers:
|
|
157
|
+
|
|
158
|
+
- `docs/canonical/`
|
|
159
|
+
- source-of-truth decisions
|
|
160
|
+
- `docs/working/`
|
|
161
|
+
- current plan, backlog, questions, proposals, metrics
|
|
162
|
+
- `docs/runtime/`
|
|
163
|
+
- execution rules, manifest, context-loading rules, model profiles
|
|
164
|
+
- `tasks/`
|
|
165
|
+
- one packet per task
|
|
166
|
+
- `prompts/`
|
|
167
|
+
- stable workflow entrypoints for agent CLIs
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Adapter Inventory
|
|
172
|
+
|
|
173
|
+
Grain uses a contract-driven adapter model to tune workflow behavior for different domains.
|
|
174
|
+
|
|
175
|
+
The workflow loop is the same for every domain. Adapters change context selection, validation hints, and review focus — not workflow law.
|
|
176
|
+
|
|
177
|
+
### Official Adapters (Supported Today)
|
|
178
|
+
|
|
179
|
+
- `code_adapter`
|
|
180
|
+
- Python, Rust, backend services, CLI tooling
|
|
181
|
+
- `frontend_adapter`
|
|
182
|
+
- TypeScript, JavaScript, React, Storybook, Tauri UI
|
|
183
|
+
|
|
184
|
+
### Official Adapters (Supported)
|
|
185
|
+
|
|
186
|
+
- `docs_adapter`
|
|
187
|
+
- Markdown documentation systems, Word documents (.docx), PDF files
|
|
188
|
+
- `spreadsheet_adapter`
|
|
189
|
+
- Excel (.xlsx/.xls) and CSV spreadsheet workflows
|
|
190
|
+
|
|
191
|
+
### Custom Adapters
|
|
192
|
+
|
|
193
|
+
Users may define custom adapter profiles locally for any domain.
|
|
194
|
+
|
|
195
|
+
Examples of valid custom adapter domains:
|
|
196
|
+
- DevOps workflows — VPS provisioning, deployment setup, service configuration
|
|
197
|
+
- System administration — reverse-proxy setup, firewall and SSH hardening, backup planning, monitoring
|
|
198
|
+
- Local ops — machine-admin repos, dotfile management, workstation automation
|
|
199
|
+
- Containerization — Docker/Compose setup, rollback procedures
|
|
200
|
+
- Content pipelines — editorial systems, publishing workflows
|
|
201
|
+
- Any operational domain expressible through repo artifacts and task packets
|
|
202
|
+
|
|
203
|
+
Custom adapters follow the same contract as official adapters. Add them to `docs/runtime/adapter_profiles.md` and declare them in the manifest. No plugin system or marketplace is required.
|
|
204
|
+
|
|
205
|
+
### Future Possibilities
|
|
206
|
+
|
|
207
|
+
- shareable community adapter profiles
|
|
208
|
+
- adapter-aware template sets per domain
|
|
209
|
+
|
|
210
|
+
If you are managing content with Grain, `docs_adapter` is the natural direction because it fits markdown-first editorial, knowledge-base, and documentation workflows. If you are managing infrastructure or operations work, define a `devops_adapter` or `local_ops_adapter` with the file patterns and validation hints relevant to your domain.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Recursive Build Principle
|
|
215
|
+
|
|
216
|
+
Grain is intended to be used to build Grain itself, then to build Assay on top of it.
|
|
217
|
+
|
|
218
|
+
That recursive use is deliberate.
|
|
219
|
+
It is one of the main ways the product is validated in real work:
|
|
220
|
+
|
|
221
|
+
- if Grain cannot manage its own build cleanly, its workflow claims are weak
|
|
222
|
+
- if Grain reduces token waste, drift, and retries while building itself, that is stronger evidence than a synthetic demo
|
|
223
|
+
- if Assay can later verify work produced through Grain, the loop becomes: structure the work, execute the work, verify the result
|
|
224
|
+
|
|
225
|
+
Recursive building is validation, not proof of universal fit.
|
|
226
|
+
Grain still needs to work outside its own repo shape and outside its creator's habits.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Installation
|
|
231
|
+
|
|
232
|
+
Requirements:
|
|
233
|
+
- Python 3.11+
|
|
234
|
+
- `uv` (recommended) or `pip`
|
|
235
|
+
|
|
236
|
+
### Recommended: uv tool install
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
uv tool install grain-kit
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
This installs `grain` into uv's global tool path. No virtual environment needed.
|
|
243
|
+
|
|
244
|
+
### Alternative: pip install
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
pip install grain-kit
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Local source install (development or testing)
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
uv tool install --from . grain
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Fallback using a local venv:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
python3 -m venv .venv
|
|
260
|
+
source .venv/bin/activate
|
|
261
|
+
pip install -e .
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Verify
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
grain --version
|
|
268
|
+
grain init --help
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Expected output:
|
|
272
|
+
- `grain, version <x.y.z>`
|
|
273
|
+
- `Usage: grain init [OPTIONS]`
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Updating
|
|
278
|
+
|
|
279
|
+
### uv tool install
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
uv tool upgrade grain-kit
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### pip install
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
pip install --upgrade grain-kit
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Local source install
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
uv tool install --from . grain --force
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
or for a venv-based install:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
pip install -e . --upgrade
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Troubleshooting
|
|
306
|
+
|
|
307
|
+
If `grain` is not found after `uv tool install`:
|
|
308
|
+
- run `uv tool dir --bin` and add that directory to your `PATH`
|
|
309
|
+
- macOS/Linux: `export PATH="$(uv tool dir --bin):$PATH"`
|
|
310
|
+
- Windows PowerShell: `$env:Path = "$(uv tool dir --bin);$env:Path"`
|
|
311
|
+
|
|
312
|
+
If you have a Python version mismatch:
|
|
313
|
+
- check: `python --version` (Grain requires Python 3.11+)
|
|
314
|
+
- install with a specific interpreter: `uv tool install --python 3.11 grain`
|
|
315
|
+
|
|
316
|
+
If venv conflicts cause unexpected behavior:
|
|
317
|
+
- check: `which grain` (or `where grain` on Windows) to confirm the active path
|
|
318
|
+
- reinstall: `uv tool uninstall grain-kit && uv tool install grain-kit`
|
|
319
|
+
- for local source testing, use isolated env vars:
|
|
320
|
+
- point `UV_TOOL_DIR`, `UV_CACHE_DIR`, and `HOME` at temp directories
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Should You Use Grain For Your Machine?
|
|
325
|
+
|
|
326
|
+
Yes, sometimes.
|
|
327
|
+
|
|
328
|
+
Good use cases:
|
|
329
|
+
- managing dotfiles or local automation as a project
|
|
330
|
+
- maintaining workstation setup scripts
|
|
331
|
+
- organizing home-lab, local tooling, or machine-admin workflows
|
|
332
|
+
- managing content repositories, docs sites, and markdown-first knowledge bases
|
|
333
|
+
- treating your local environment as an inspectable system with tasks, review, and change history
|
|
334
|
+
|
|
335
|
+
Bad default:
|
|
336
|
+
- treating your entire home directory or whole machine as one Grain project
|
|
337
|
+
|
|
338
|
+
Better pattern:
|
|
339
|
+
- create a dedicated repo such as:
|
|
340
|
+
- `local-ops`
|
|
341
|
+
- `machine-admin`
|
|
342
|
+
- `personal-systems`
|
|
343
|
+
- use Grain inside that repo
|
|
344
|
+
|
|
345
|
+
Reason:
|
|
346
|
+
- keeps scope bounded
|
|
347
|
+
- keeps context smaller
|
|
348
|
+
- keeps tasks coherent
|
|
349
|
+
- avoids mixing unrelated files and projects into one authority tree
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## How New Users Should Start
|
|
354
|
+
|
|
355
|
+
Use the `README` as the entrypoint and the prompts as the workflow engine.
|
|
356
|
+
|
|
357
|
+
There are two starting modes:
|
|
358
|
+
|
|
359
|
+
1. new project
|
|
360
|
+
2. existing project
|
|
361
|
+
|
|
362
|
+
### New Project
|
|
363
|
+
|
|
364
|
+
1. create or enter the project repo
|
|
365
|
+
2. run `grain init`
|
|
366
|
+
3. open `prompts/workflow.onboard.new.md`
|
|
367
|
+
4. fill in the `Project Context`
|
|
368
|
+
5. paste that prompt into your agent CLI
|
|
369
|
+
6. let the agent generate the initial docs, manifest, backlog, and open questions
|
|
370
|
+
7. review those generated docs before treating canonical content as approved
|
|
371
|
+
|
|
372
|
+
Optional onboarding-aware init flags:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
grain init --primary-adapter code_adapter --secondary-adapter frontend_adapter --bootstrap
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
- `--primary-adapter` sets the default adapter context for onboarding
|
|
379
|
+
- `--secondary-adapter` can be repeated for additional adapters
|
|
380
|
+
- `--bootstrap` creates a starter task packet and initializes `docs/working/current_task.md`
|
|
381
|
+
|
|
382
|
+
Compatibility note:
|
|
383
|
+
- `prompts/workflow.init.md` is kept as an alias for users who still invoke the old onboarding name.
|
|
384
|
+
|
|
385
|
+
After onboarding, use the normal loop:
|
|
386
|
+
|
|
387
|
+
1. `prompts/task.plan.next.md` only when a task must be selected or split
|
|
388
|
+
2. `prompts/task.execute.md`
|
|
389
|
+
3. `prompts/task.review.md`
|
|
390
|
+
4. `prompts/task.close.md`
|
|
391
|
+
|
|
392
|
+
### Existing Project
|
|
393
|
+
|
|
394
|
+
1. run `grain onboard` inside the existing repo (or pass a path)
|
|
395
|
+
2. open `prompts/workflow.onboard.existing.md`
|
|
396
|
+
3. paste that prompt into your agent CLI
|
|
397
|
+
4. the agent reviews the scaffold manifest, scans the codebase, and generates draft canonical docs
|
|
398
|
+
5. review all generated docs before treating them as canonical — all output is marked `# DRAFT`
|
|
399
|
+
|
|
400
|
+
Optional flags:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
grain onboard # scaffold into current directory
|
|
404
|
+
grain onboard /path/to/repo # scaffold into a specific path
|
|
405
|
+
grain onboard --dry-run # preview what would be created without writing
|
|
406
|
+
grain onboard --format json # get a machine-readable manifest of created/skipped files
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
`grain onboard` is additive only — it never overwrites existing files. Any file already present is skipped and listed in the manifest.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Agent CLI Usage
|
|
414
|
+
|
|
415
|
+
Grain is designed to be used from an agent CLI.
|
|
416
|
+
|
|
417
|
+
The basic pattern is:
|
|
418
|
+
|
|
419
|
+
1. run the Grain CLI when filesystem scaffolding or validation is needed
|
|
420
|
+
2. run a prompt from `prompts/`
|
|
421
|
+
3. let the agent update the repo files
|
|
422
|
+
4. continue through the structured loop
|
|
423
|
+
|
|
424
|
+
### Recommended Stable Prompt Surface
|
|
425
|
+
|
|
426
|
+
Phase planning:
|
|
427
|
+
- `prompts/phase.plan.next.md`
|
|
428
|
+
- `prompts/phase.review.md`
|
|
429
|
+
- `prompts/phase.review_and_close.md`
|
|
430
|
+
|
|
431
|
+
Task planning and execution:
|
|
432
|
+
- `prompts/task.plan.next.md`
|
|
433
|
+
- `prompts/task.execute.md`
|
|
434
|
+
- `prompts/task.review.md`
|
|
435
|
+
- `prompts/task.close.md`
|
|
436
|
+
|
|
437
|
+
Project bootstrap:
|
|
438
|
+
- `prompts/workflow.onboard.new.md` — new project onboarding
|
|
439
|
+
- `prompts/workflow.onboard.existing.md` — existing project adoption
|
|
440
|
+
- `prompts/workflow.init.md` (compatibility alias for new-project onboarding)
|
|
441
|
+
|
|
442
|
+
### Recommended Daily Loop
|
|
443
|
+
|
|
444
|
+
Use this loop continuously inside the active phase:
|
|
445
|
+
|
|
446
|
+
1. `task.plan.next` — only when the next task must be selected, split, or added
|
|
447
|
+
2. `task.execute`
|
|
448
|
+
3. `task.review`
|
|
449
|
+
4. `task.close`
|
|
450
|
+
|
|
451
|
+
Do not run `task.plan.next` every time if a ready task already exists.
|
|
452
|
+
|
|
453
|
+
### Recommended Planning Loop
|
|
454
|
+
|
|
455
|
+
Use this less often:
|
|
456
|
+
|
|
457
|
+
1. `phase.plan.next`
|
|
458
|
+
2. `phase.review` or `phase.review_and_close` at phase boundaries
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Customization
|
|
463
|
+
|
|
464
|
+
Grain is meant to be customized to the project it is managing.
|
|
465
|
+
|
|
466
|
+
Users should customize:
|
|
467
|
+
- canonical docs for the project domain and scope
|
|
468
|
+
- working docs for sequencing, backlog, and open questions
|
|
469
|
+
- adapter selection and adapter profiles
|
|
470
|
+
- model strategy and agent preferences
|
|
471
|
+
- onboarding outputs for new or existing projects
|
|
472
|
+
|
|
473
|
+
Users should try to keep stable:
|
|
474
|
+
- the core workflow loop: plan → execute → review → close
|
|
475
|
+
- file-backed workflow state
|
|
476
|
+
- authority boundaries between canonical, working, runtime, and task layers
|
|
477
|
+
- explicit review and change-proposal gates
|
|
478
|
+
|
|
479
|
+
Good customization:
|
|
480
|
+
- adapt Grain to Python, Rust, React, docs, spreadsheets, local-ops, or mixed projects
|
|
481
|
+
- add project-specific constraints, risks, adapters, and backlog structure
|
|
482
|
+
|
|
483
|
+
Bad customization:
|
|
484
|
+
- silently bypass review
|
|
485
|
+
- hide state outside the repo
|
|
486
|
+
- collapse canonical and working docs into one layer
|
|
487
|
+
- make every project invent its own incompatible workflow loop
|
|
488
|
+
|
|
489
|
+
In short:
|
|
490
|
+
- customize the project model
|
|
491
|
+
- keep the workflow model disciplined
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Minimal CLI Reference
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
# Setup
|
|
499
|
+
grain init # initialize a new project
|
|
500
|
+
grain onboard [path] # scaffold into an existing repo (additive)
|
|
501
|
+
grain onboard --dry-run # preview scaffold without writing
|
|
502
|
+
|
|
503
|
+
# Docs and validation
|
|
504
|
+
grain docs validate # validate doc manifest and structure
|
|
505
|
+
grain task validate --id TASK-#### # validate one task packet
|
|
506
|
+
|
|
507
|
+
# Task management
|
|
508
|
+
grain task create --title "..."
|
|
509
|
+
grain task list
|
|
510
|
+
grain task show --id TASK-####
|
|
511
|
+
grain task status --id TASK-#### --status done
|
|
512
|
+
grain task next # which task to work on
|
|
513
|
+
grain task prepare --id TASK-#### # assemble context prerequisites
|
|
514
|
+
|
|
515
|
+
# Workflow automation
|
|
516
|
+
grain workflow next # next legal step + blockers
|
|
517
|
+
grain workflow next --format json # machine-readable for agent CLIs
|
|
518
|
+
grain workflow run # execute one step, stop at gates
|
|
519
|
+
grain workflow loop # run full execute→review→close cycle
|
|
520
|
+
grain workflow loop --supervision gated # stop at review/close gates (default)
|
|
521
|
+
grain workflow loop --supervision supervised # approve every action
|
|
522
|
+
grain workflow loop --dry-run # preview loop plan without execution
|
|
523
|
+
|
|
524
|
+
# Context assembly
|
|
525
|
+
grain context build --id TASK-####
|
|
526
|
+
grain context build --id TASK-#### --format json
|
|
527
|
+
|
|
528
|
+
# Orchestration
|
|
529
|
+
grain orchestrate scope --scope "..."
|
|
530
|
+
grain orchestrate plan --scope "..."
|
|
531
|
+
grain orchestrate accept --plan <id> # mark a plan accepted for loop ordering
|
|
532
|
+
|
|
533
|
+
# Adapter inspection
|
|
534
|
+
grain adapter list
|
|
535
|
+
grain adapter show --id <id>
|
|
536
|
+
|
|
537
|
+
# Prompts
|
|
538
|
+
grain prompt show # recommended prompt for current state
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
In normal Grain usage, the prompts drive most of the workflow and the CLI handles scaffolding, validation, and command surfaces.
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## Important Rules
|
|
546
|
+
|
|
547
|
+
- do not treat prompts as canonical truth
|
|
548
|
+
- do not edit canonical docs silently
|
|
549
|
+
- do not execute multiple unrelated tasks in one packet
|
|
550
|
+
- do not let review and close perform backlog planning implicitly
|
|
551
|
+
- if prompt or workflow-contract docs change mid-conversation, restart the relevant agent conversation
|
|
552
|
+
|
|
553
|
+
See:
|
|
554
|
+
- `docs/runtime/PROJECT_RULES.md`
|
|
555
|
+
- `docs/runtime/docs_manifest.yaml`
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## Current Product State
|
|
560
|
+
|
|
561
|
+
- v1 core workflow complete (Phases 1–5 closed) — init, docs, task, context, model, review commands
|
|
562
|
+
- Phase 6 closed — adapter system foundation (`code_adapter`, `frontend_adapter`)
|
|
563
|
+
- Phase 7 closed — new-project onboarding flow (`grain init` with adapter selection and starter-packet bootstrap)
|
|
564
|
+
- Phase 8 closed — workflow automation runner (`grain workflow next/run`, `grain task next/prepare`, `grain phase next`, `grain prompt show`, machine-readable JSON contract)
|
|
565
|
+
- Phase 9 closed — orchestration service (`grain orchestrate scope/plan`, `grain adapter list/show`, OrchestratorPlan domain model)
|
|
566
|
+
- Phase 10 closed — structural intelligence (tree-sitter extraction, knowledge graph, graph-assisted context selection)
|
|
567
|
+
- Phase 11 closed — distribution and global install (`pip install grain-kit`, `uv tool install grain-kit`, PyPI publish workflow)
|
|
568
|
+
- Phase 12 closed — automated workflow loop (`grain workflow loop`, supervision levels, per-step logging, `grain orchestrate accept`)
|
|
569
|
+
- Phase 13 closed — existing project adoption (`grain onboard`, `CodebaseScanner`, draft canonical doc generation, `workflow.onboard.existing.md` prompt)
|
|
570
|
+
- Phase 14 closed — document and spreadsheet adapters (`SpreadsheetExtractor` for xlsx/csv, `DocsExtractor` for docx/md, `PdfExtractor` for pdf with graceful degradation)
|
|
571
|
+
|
|
572
|
+
Workflow loop guardrails:
|
|
573
|
+
- `grain workflow loop --steps N` sets a hard loop-step limit
|
|
574
|
+
- `grain workflow loop --dry-run` previews planned actions without mutating state
|
|
575
|
+
- supervision levels:
|
|
576
|
+
- `supervised`: operator approval before each action
|
|
577
|
+
- `gated`: automatic run, stops at review/close gates (default)
|
|
578
|
+
- `autonomous`: minimal stops, unverified automation (Assay will provide future independent verification)
|
|
579
|
+
|
|
580
|
+
See `docs/working/current_focus.md` and `docs/working/implementation_plan.md` for active phase detail.
|