ystack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-04-09
4
+
5
+ First public release. Claude Code only.
6
+
7
+ ### Features
8
+
9
+ - **CLI** — `ystack create`, `init`, `update`, `remove` commands with interactive prompts (@clack/prompts)
10
+ - **Skills** — `/build`, `/go`, `/review`, `/docs`, `/pr`, `/import`, `/scaffold`, `/address-review`
11
+ - **Hooks** — context-monitor (tracks context usage), workflow-nudge (suggests `/build` when editing without a plan), session-start (shows ready front)
12
+ - **Module registry** — `ystack.config.json` maps code scopes to doc pages and Beads epics
13
+ - **Beads integration** — persistent task memory with epics, features, ready front, structured notes
14
+ - **Docs support** — Nextra 4 and Fumadocs, framework-agnostic doc layer
15
+ - **`ystack create`** — scaffolds a full monorepo (Turborepo, pnpm, Ultracite, TypeScript strict, docs site)
16
+ - **`ystack init`** — adds ystack to an existing project with auto-detection of docs framework, monorepo tool, and Beads
17
+
18
+ ### Design
19
+
20
+ - Three-layer architecture: Docs (what it is), Beads (what's done), Code (the implementation)
21
+ - Doc-driven workflow: read spec, plan, execute, verify, update docs
22
+ - Fresh subagent per task for context isolation
23
+ - Wave-based parallel execution with dependency tracking
24
+ - Goal-backward verification against success criteria
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Yulong He
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/LINTING.md ADDED
@@ -0,0 +1,198 @@
1
+ # Agent Linting
2
+
3
+ > **Status: Design Spec — Not Yet Implemented**
4
+ > None of the agent lint rules, hook infrastructure (`hooks/agent-lint.js`), or per-skill `rules/*.json` files described below are built. This document is a design specification for a future version of ystack. v0.1 includes basic Claude Code hooks (context monitoring, file-count nudge) but not the structured rule system described here.
5
+
6
+ ## Two Types of Linting
7
+
8
+ **Code linting** checks what the code looks like — formatting, syntax, style. Tools like Ultracite/Biome handle this. You configure it once and it covers all code. Adding a new feature doesn't mean adding new rules.
9
+
10
+ **Agent linting** checks what the agent does — did it follow the process? Did it read the spec? Did it verify its work? This is the harness enforcing discipline on agent behavior, not code quality.
11
+
12
+ Code linting is static. Agent linting grows with the harness. Each new skill or convention can ship with its own agent lint rule.
13
+
14
+ ## How Agent Linting Works
15
+
16
+ Agent lint rules are implemented as Claude Code hooks — `PreToolUse` and `PostToolUse` checks in `.claude/settings.json`. They run automatically during agent execution, providing warnings or blocks at the right moment.
17
+
18
+ ```
19
+ Agent tries to edit code
20
+ → PreToolUse hook fires
21
+ → Check: is there an active plan?
22
+ → No plan → soft warning: "Consider /build for tracked changes"
23
+ → Has plan → proceed
24
+ ```
25
+
26
+ Rules come in two severities:
27
+
28
+ - **Warn** — surface a message, let the agent continue. For nudges and best practices.
29
+ - **Block** — prevent the action. For hard constraints that protect quality.
30
+
31
+ ## Core Rules
32
+
33
+ These ship with ystack out of the box.
34
+
35
+ ### Workflow Rules
36
+
37
+ | Rule | Severity | When | What it checks |
38
+ |------|----------|------|---------------|
39
+ | `plan-before-edit` | Warn | PreToolUse on Edit | Is there an active `.context/<bead-id>/PLAN.md`? Nudges toward `/build` or `/quick`. |
40
+ | `spec-before-plan` | Block | During `/build` | Did the agent read the module's doc page before creating a plan? Prevents hallucinated architecture. |
41
+ | `decisions-before-execute` | Block | During `/go` | Does `.context/<bead-id>/DECISIONS.md` exist? No executing without confirmed decisions. |
42
+ | `plan-checker-passed` | Block | During `/go` | Has the plan-checker agent validated the plan? No executing unchecked plans. |
43
+ | `no-scope-reduction` | Block | During `/plan` | Does the plan cover ALL locked decisions from DECISIONS.md? Catches silent simplification. |
44
+
45
+ ### Verification Rules
46
+
47
+ | Rule | Severity | When | What it checks |
48
+ |------|----------|------|---------------|
49
+ | `verify-before-ship` | Block | During `/pr` | Has `/review` passed all success criteria? No shipping unverified work. |
50
+ | `docs-before-ship` | Warn | During `/pr` | Are there closed beads without corresponding doc updates? Nudges toward `/docs`. |
51
+ | `typecheck-before-ship` | Block | During `/pr` | Does `pnpm typecheck` pass? No shipping broken types. |
52
+
53
+ ### Documentation Rules
54
+
55
+ | Rule | Severity | When | What it checks |
56
+ |------|----------|------|---------------|
57
+ | `cross-references` | Warn | During `/docs` | Does the updated doc page link to related modules? Flags isolated pages. |
58
+ | `final-state-only` | Block | During `/docs` | Does the doc contain "planned", "coming soon", "TODO", "WIP"? Docs describe what IS. |
59
+ | `module-registered` | Warn | During `/build` | Is the target module in `ystack.config.json`? Catches work outside any module's scope. |
60
+
61
+ ### Context Rules
62
+
63
+ | Rule | Severity | When | What it checks |
64
+ |------|----------|------|---------------|
65
+ | `context-budget` | Warn | PostToolUse | Is context usage above 60%? Suggests spawning subagents. |
66
+ | `context-critical` | Warn | PostToolUse | Is context usage above 80%? Suggests finishing current task or `/pause`. |
67
+ | `reference-not-dump` | Warn | During `/build` | Did the agent inline a full doc page into the plan instead of referencing it? |
68
+
69
+ ## Adding Rules When You Add Skills
70
+
71
+ Each skill can ship with its own lint rules. When you install a skill, its rules get added to the hook configuration automatically.
72
+
73
+ **Example: adding a `/test` skill**
74
+
75
+ The skill comes with:
76
+ ```
77
+ skills/test/
78
+ ├── SKILL.md
79
+ └── rules/
80
+ └── tests-before-ship.json
81
+ ```
82
+
83
+ The rule definition:
84
+ ```json
85
+ {
86
+ "name": "tests-before-ship",
87
+ "severity": "warn",
88
+ "hook": "PreToolUse",
89
+ "trigger": "during /pr",
90
+ "check": "Do test files exist for changed modules?",
91
+ "message": "Changed modules have no tests. Consider /test before shipping."
92
+ }
93
+ ```
94
+
95
+ On install, this gets wired into `.claude/settings.json` alongside the skill.
96
+
97
+ ## Rule Lifecycle
98
+
99
+ Rules evolve with the project:
100
+
101
+ 1. **Start soft.** New rules ship as `warn`. Teams adopt the practice before it becomes enforced.
102
+ 2. **Promote to block.** Once the team is comfortable, flip severity to `block` for critical rules.
103
+ 3. **Project-specific rules.** Teams can add their own rules in `ystack.config.json`:
104
+
105
+ ```json
106
+ {
107
+ "linting": {
108
+ "rules": {
109
+ "plan-before-edit": "warn",
110
+ "spec-before-plan": "block",
111
+ "verify-before-ship": "block",
112
+ "docs-before-ship": "warn",
113
+ "cross-references": "warn",
114
+ "custom-rules": [
115
+ {
116
+ "name": "security-review-for-auth",
117
+ "severity": "block",
118
+ "trigger": "during /pr",
119
+ "check": "If changed packages include 'auth', has a security-focused review been done?",
120
+ "message": "Auth changes require security review. Run /review --security first."
121
+ }
122
+ ]
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ 4. **Disable rules.** Any rule can be turned off per-project:
129
+
130
+ ```json
131
+ {
132
+ "linting": {
133
+ "rules": {
134
+ "context-budget": "off"
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Implementation
141
+
142
+ Agent lint rules are thin hooks. Each rule is a single check that runs at a specific point in the workflow.
143
+
144
+ ### Hook Structure
145
+
146
+ ```javascript
147
+ // hooks/agent-lint.js
148
+ // PostToolUse hook — runs after every tool call
149
+
150
+ export default function agentLint({ tool, input, output, config }) {
151
+ const rules = loadRules(config);
152
+ const violations = [];
153
+
154
+ for (const rule of rules) {
155
+ if (rule.shouldRun(tool, input)) {
156
+ const result = rule.check(tool, input, output);
157
+ if (result.violated) {
158
+ violations.push({
159
+ rule: rule.name,
160
+ severity: rule.severity,
161
+ message: result.message
162
+ });
163
+ }
164
+ }
165
+ }
166
+
167
+ // Warnings get surfaced as messages
168
+ // Blocks prevent the action
169
+ return formatViolations(violations);
170
+ }
171
+ ```
172
+
173
+ ### What Rules Can Check
174
+
175
+ Rules have access to:
176
+ - **Tool name and input** — which tool was called and with what arguments
177
+ - **File system** — read `.context/`, `ystack.config.json`, doc pages
178
+ - **Beads state** — `bd show`, `bd ready` (via shell)
179
+ - **Git state** — current diff, branch, recent commits
180
+
181
+ Rules do NOT:
182
+ - Modify files
183
+ - Call external APIs
184
+ - Block indefinitely
185
+ - Access conversation history
186
+
187
+ ## Code Linting vs. Agent Linting
188
+
189
+ | | Code Linting | Agent Linting |
190
+ |---|---|---|
191
+ | **Tool** | Ultracite / Biome | ystack hooks |
192
+ | **Checks** | Formatting, syntax, style | Process, workflow, constraints |
193
+ | **When** | Pre-commit hook | During agent execution |
194
+ | **Grows with** | Language features | New skills and conventions |
195
+ | **Examples** | "Use `const` not `let`" | "Read the spec before planning" |
196
+ | **Configured in** | `biome.json` | `ystack.config.json` |
197
+
198
+ Both run automatically. Code linting on commit, agent linting during workflow. Together they ensure both the code and the process that produced it meet the team's standards.
package/PHILOSOPHY.md ADDED
@@ -0,0 +1,132 @@
1
+ # Design Philosophy
2
+
3
+ ## The Five Constraints
4
+
5
+ The harness enforces five things on every agent interaction:
6
+
7
+ 1. **Read the spec first.** Before writing code, the agent reads the relevant doc page. No guessing.
8
+ 2. **Plan before executing.** The agent shows you what it will do. You confirm or correct.
9
+ 3. **Verify against criteria.** After execution, goal-backward verification checks the codebase — "does this column exist? Is this endpoint wired?" — not "did the task complete?"
10
+ 4. **Never simplify silently.** If the plan can't deliver what was decided, it splits into phases instead of cutting corners.
11
+ 5. **Update docs when done.** Documentation reflects the new reality before the PR is created.
12
+
13
+ The harness also includes [agent linting](./LINTING.md) — rules that check agent behavior, not code style. Did the agent read the spec? Does the plan cover all decisions? Are docs updated? These rules grow with the harness: each new skill can ship its own lint rules.
14
+
15
+ ## Documentation as the Operating System
16
+
17
+ Most teams treat documentation as a chore — something you write after the code is done, if you write it at all. ystack treats documentation as the operating system for your entire development process.
18
+
19
+ When you write a doc page for a module, that page becomes:
20
+ - The **spec** your AI agent reads before writing code
21
+ - The **reference** your team reads to understand the system
22
+ - The **context** a new developer uses to get up to speed
23
+ - The **contract** between modules that defines boundaries
24
+
25
+ You write it once. It serves all four purposes. There is no separate "planning doc" and "user doc" and "AI context file" — they are the same document.
26
+
27
+ ## Three Layers, Three Roles
28
+
29
+ ```
30
+ Docs → What the system IS (final state)
31
+ Beads → What's been done, what's left (development state)
32
+ Code → The actual implementation
33
+ ```
34
+
35
+ These three layers never overlap in responsibility:
36
+
37
+ **Docs** describe the finished design. They answer: what does this module do? How does it connect to other modules? What data does it manage? What are the contracts at its boundaries? Docs never contain "planned", "coming soon", "TODO", or "v2". If it's in the docs, it's built and working.
38
+
39
+ **Beads** tracks the journey. It knows which features are implemented, which are in progress, which are blocked. It holds the structured notes that let an agent resume work after a context reset. It manages dependencies between tasks. Beads is the development state machine — it knows where you are in the process.
40
+
41
+ **Code** is the implementation. It doesn't need to explain itself beyond what's necessary for maintenance. The architecture lives in docs. The progress lives in Beads. The code just works.
42
+
43
+ ## Why Human-Readable Markdown
44
+
45
+ AI agents work better with clean, structured prose than with machine-generated metadata blobs. A well-written doc page gives an agent:
46
+
47
+ - **Selective context** — read only the page you need, not a 500-line dump
48
+ - **Navigable structure** — headings, sections, and cross-references let the agent find exactly what's relevant
49
+ - **Accurate mental model** — prose written for humans forces clarity that JSON schemas don't
50
+
51
+ This is why ystack works with documentation frameworks like Nextra and Fumadocs. The docs are rendered as a real documentation site that humans browse. The same markdown files are what AI agents read as context. The format that's good for humans turns out to be good for agents too.
52
+
53
+ The alternative — generating machine-readable context files, planning artifacts, or structured metadata — creates information that's useful to nobody except the tool that generated it. It rots quickly, nobody maintains it, and it bloats agent context with noise.
54
+
55
+ ## References, Not Dumps
56
+
57
+ When an agent needs to understand the payments module, ystack tells it: "Read `docs/src/content/shared/payments.mdx`." It does not paste the entire page into the prompt.
58
+
59
+ This matters because:
60
+
61
+ 1. **Context windows are finite.** Every token of inlined content is a token you can't use for reasoning.
62
+ 2. **Docs change.** A reference always points to the current version. Inlined content is stale the moment it's pasted.
63
+ 3. **Agents can navigate.** A doc page with cross-references lets the agent follow links to related modules, just like a human developer would.
64
+
65
+ The module registry (`ystack.config.json`) exists to give agents a map: "payments lives here in the code, here in the docs, and here in Beads." From that map, the agent reads what it needs, when it needs it.
66
+
67
+ ## Connected Documentation
68
+
69
+ Every doc page should be highly connected to related pages. Cross-references are not optional — they are how agents (and humans) navigate the system.
70
+
71
+ A module overview page should link to:
72
+ - Its sub-module pages (detailed specs for each component)
73
+ - Modules it depends on (upstream contracts it relies on)
74
+ - Modules that depend on it (downstream consumers)
75
+ - Data model pages (shared schema definitions)
76
+ - The system architecture page (where it fits in the big picture)
77
+
78
+ When an agent reads a module page and finds a reference to another module, it can follow that link to understand the boundary. This is how agents build understanding incrementally — by navigating a graph of connected documents, not by receiving a monolithic context dump.
79
+
80
+ The navigation structure (framework-specific: `_meta.ts` in Nextra, `meta.json` in Fumadocs) defines the hierarchy. Cross-references within page content define the graph. Together they create a documentation site that works as both a human-readable reference and an agent-navigable knowledge base.
81
+
82
+ ## The Module Registry
83
+
84
+ The module registry bridges three worlds:
85
+
86
+ ```json
87
+ {
88
+ "payments": {
89
+ "doc": "shared/payments",
90
+ "scope": [
91
+ "packages/payments/**",
92
+ "packages/db/src/schema/transactions.*",
93
+ "apps/api/src/routes/payments.*"
94
+ ],
95
+ "epic": "bd-a1b2"
96
+ }
97
+ }
98
+ ```
99
+
100
+ - **doc** → where to read the spec (and where to write updates when features complete)
101
+ - **scope** → where the code lives, as glob patterns. A module doesn't have to be a package — it can span files across multiple packages, or live within a subdirectory of one. This is what to scan when planning and what to verify when done.
102
+ - **epic** → where progress lives (which features are built, which are pending)
103
+
104
+ The registry tracks **modules only**. Sub-modules are tracked by the docs site (sub-pages within a module). Features are tracked by Beads (child beads under the module's epic). Each layer has its own hierarchy — the registry connects the top level.
105
+
106
+ When a Beads epic's child closes, ystack knows which doc page might need updating. When `/build` starts planning, it knows which files across the repo are relevant. When `/import` scans an existing repo, it builds this map automatically.
107
+
108
+ The registry is small, stable, and rarely changes. It's the index — the docs, code, and beads are the content.
109
+
110
+ ## Documentation Reflects Only Completed Work
111
+
112
+ This is a hard rule. Docs describe what IS, never what's planned.
113
+
114
+ When you run `/scaffold` to start a new project, it creates doc stubs — module overviews with interaction diagrams and section headers. These stubs show structure (what modules exist and how they connect) but not implementation detail. The detail gets filled in by `/docs` as features are completed and verified.
115
+
116
+ This means:
117
+ - A new team member reading the docs sees exactly what's built and working
118
+ - An agent reading the docs gets accurate context, not aspirational specs
119
+ - There's no "planned" section that's been "planned" for six months
120
+ - The gap between docs and reality is always zero for documented features
121
+
122
+ Beads tracks what's planned and in progress. That's its job. Docs track what's done. The boundary is clean.
123
+
124
+ ## Why This Works for Teams
125
+
126
+ A developer joins the project. They read the docs site. They understand the architecture, the module boundaries, the data models, the contracts. Everything they read is accurate because it describes completed, verified work.
127
+
128
+ They pick up a feature. `/build` reads the same docs to understand context. The agent and the developer are reading the same source of truth. The agent creates a plan grounded in real architecture, not hallucinated structure.
129
+
130
+ They finish the feature. `/docs` updates the relevant pages. The docs site now reflects the new reality. The next developer — or the next agent session — gets accurate context automatically.
131
+
132
+ No one wrote documentation as a separate task. The docs updated as a natural step in the workflow. The documentation site is always current because it's part of the development process, not an afterthought.