lazyopencode-core 0.0.1

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 (89) hide show
  1. package/ATTRIBUTION.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +357 -0
  4. package/dist/agents/councillor.d.ts +1 -0
  5. package/dist/agents/councillor.js +14 -0
  6. package/dist/agents/designer.d.ts +1 -0
  7. package/dist/agents/designer.js +31 -0
  8. package/dist/agents/explorer.d.ts +1 -0
  9. package/dist/agents/explorer.js +15 -0
  10. package/dist/agents/fixer.d.ts +1 -0
  11. package/dist/agents/fixer.js +23 -0
  12. package/dist/agents/index.d.ts +2 -0
  13. package/dist/agents/index.js +55 -0
  14. package/dist/agents/lazy.d.ts +1 -0
  15. package/dist/agents/lazy.js +3 -0
  16. package/dist/agents/librarian.d.ts +1 -0
  17. package/dist/agents/librarian.js +26 -0
  18. package/dist/agents/observer.d.ts +1 -0
  19. package/dist/agents/observer.js +20 -0
  20. package/dist/agents/oracle.d.ts +1 -0
  21. package/dist/agents/oracle.js +30 -0
  22. package/dist/council/council-manager.d.ts +42 -0
  23. package/dist/council/council-manager.js +223 -0
  24. package/dist/council/index.d.ts +2 -0
  25. package/dist/council/index.js +1 -0
  26. package/dist/hooks/apply-patch-rescue.d.ts +7 -0
  27. package/dist/hooks/apply-patch-rescue.js +150 -0
  28. package/dist/hooks/background-job-board.d.ts +92 -0
  29. package/dist/hooks/background-job-board.js +452 -0
  30. package/dist/hooks/chat-params.d.ts +16 -0
  31. package/dist/hooks/chat-params.js +30 -0
  32. package/dist/hooks/deepwork.d.ts +9 -0
  33. package/dist/hooks/deepwork.js +55 -0
  34. package/dist/hooks/error-recovery.d.ts +21 -0
  35. package/dist/hooks/error-recovery.js +216 -0
  36. package/dist/hooks/index.d.ts +3 -0
  37. package/dist/hooks/index.js +61 -0
  38. package/dist/hooks/lazy-command.d.ts +16 -0
  39. package/dist/hooks/lazy-command.js +178 -0
  40. package/dist/hooks/messages-transform.d.ts +40 -0
  41. package/dist/hooks/messages-transform.js +358 -0
  42. package/dist/hooks/permission-guard.d.ts +5 -0
  43. package/dist/hooks/permission-guard.js +38 -0
  44. package/dist/hooks/runtime.d.ts +169 -0
  45. package/dist/hooks/runtime.js +653 -0
  46. package/dist/hooks/session-events.d.ts +16 -0
  47. package/dist/hooks/session-events.js +65 -0
  48. package/dist/hooks/system-transform.d.ts +8 -0
  49. package/dist/hooks/system-transform.js +113 -0
  50. package/dist/hooks/task-session.d.ts +32 -0
  51. package/dist/hooks/task-session.js +177 -0
  52. package/dist/hooks/workflow-classifier.d.ts +17 -0
  53. package/dist/hooks/workflow-classifier.js +170 -0
  54. package/dist/index.d.ts +13 -0
  55. package/dist/index.js +85 -0
  56. package/dist/opencode-control-plane.d.ts +20 -0
  57. package/dist/opencode-control-plane.js +95 -0
  58. package/dist/ponytail.d.ts +1 -0
  59. package/dist/ponytail.js +33 -0
  60. package/dist/skills/index.d.ts +5 -0
  61. package/dist/skills/index.js +10 -0
  62. package/dist/skills/lazy/build/SKILL.md +62 -0
  63. package/dist/skills/lazy/debug/SKILL.md +17 -0
  64. package/dist/skills/lazy/grill/SKILL.md +54 -0
  65. package/dist/skills/lazy/plan/SKILL.md +52 -0
  66. package/dist/skills/lazy/review/SKILL.md +29 -0
  67. package/dist/skills/lazy/security/SKILL.md +29 -0
  68. package/dist/skills/lazy/simplify/SKILL.md +52 -0
  69. package/dist/skills/lazy/specify/SKILL.md +62 -0
  70. package/dist/skills/lazy/worktree/SKILL.md +66 -0
  71. package/dist/tools/cancel-task.d.ts +3 -0
  72. package/dist/tools/cancel-task.js +37 -0
  73. package/dist/tools/council.d.ts +6 -0
  74. package/dist/tools/council.js +41 -0
  75. package/dist/tools/index.d.ts +2 -0
  76. package/dist/tools/index.js +2 -0
  77. package/dist/v2.d.ts +1 -0
  78. package/dist/v2.js +42 -0
  79. package/docs/architecture.md +47 -0
  80. package/docs/council.md +200 -0
  81. package/docs/desktop-distribution.md +36 -0
  82. package/docs/opencode-integration.md +54 -0
  83. package/docs/positioning.md +44 -0
  84. package/docs/product-audit.md +187 -0
  85. package/docs/product-plan.md +56 -0
  86. package/docs/state-machine.md +35 -0
  87. package/docs/user-manual.md +439 -0
  88. package/docs/work-plan.md +190 -0
  89. package/package.json +44 -0
@@ -0,0 +1,187 @@
1
+ # Product Audit
2
+
3
+ ## Verdict
4
+
5
+ LazyOpenCode should be positioned as an OpenCode-native governed team runtime.
6
+
7
+ It should not be framed as only a scope gate, only an agent pack, or only a
8
+ prompt toolbox. The product combines three things:
9
+
10
+ - A zero-config OpenCode team runtime.
11
+ - A governance layer for scope, risk, budget, permissions, and closure.
12
+ - A future Desktop distribution that makes those defaults visible and easy.
13
+
14
+ The current `0.0.1` core is close to a usable kernel: commands, agents, skills,
15
+ runtime state, job board, council guard, token control, doctor output, and close
16
+ report all exist and pass verification. The next work is mostly deepening,
17
+ simplifying, and making the boundaries sharper.
18
+
19
+ ## Product Positioning
20
+
21
+ ### Category
22
+
23
+ OpenCode-native governed team runtime.
24
+
25
+ ### Promise
26
+
27
+ Turn OpenCode into a small, visible, budgeted, reviewable AI coding team.
28
+
29
+ ### Audience
30
+
31
+ - OpenCode users who want a complete default setup.
32
+ - Users who want subagents, but do not want unmanaged agent sprawl.
33
+ - Developers who care about risk control, review, and closure.
34
+ - Future Desktop users who expect the system to work without hand-assembling
35
+ config.
36
+
37
+ ### Enemy
38
+
39
+ - Vague requests entering implementation.
40
+ - Agent work that cannot be reconciled.
41
+ - Background jobs that disappear from working memory.
42
+ - Large changes without success criteria or must-not-break constraints.
43
+ - “Done” responses without tests, review, simplification, or risk notes.
44
+ - Tooling that requires users to assemble too many pieces manually.
45
+
46
+ ### North Star
47
+
48
+ Small scope, visible work, bounded context, reviewed output.
49
+
50
+ ## Product Capabilities
51
+
52
+ ### Current Strengths
53
+
54
+ - `lazy` primary agent plus focused subagents.
55
+ - `/lazy start` classification and workflow gate.
56
+ - `/lazy status` with mode, workflow, jobs, token control, OpenCode snapshot,
57
+ and recent decisions.
58
+ - `/lazy close` with a structured close report.
59
+ - `/lazy doctor` for install and runtime health.
60
+ - Background job state machine with running, terminal, reusable, and stale jobs.
61
+ - Guarded council escalation for high-risk, ambiguous, or debug work.
62
+ - Message-count context budget with pruning stats.
63
+ - Permission guard for destructive operations.
64
+ - Zero-config defaults with optional `lazyopencode` config.
65
+ - Deno maintainer toolchain with npm ESM runtime output.
66
+
67
+ ### Current Gaps
68
+
69
+ - `LazyRuntime` is too broad and owns too many responsibilities.
70
+ - Close evidence collection is useful but heuristic.
71
+ - OpenCode control-plane integration is best-effort and needs real-client
72
+ hardening as OpenCode v2 surfaces mature.
73
+ - Worktree isolation is advice/policy, not full automation.
74
+ - Doctor output checks the important basics, but should become a deeper module
75
+ with structured checks.
76
+ - Desktop is intentionally not implemented in `0.0.1`.
77
+
78
+ ## Project Design
79
+
80
+ ### Desired Layers
81
+
82
+ 1. OpenCode adapter layer:
83
+ - v2 registration
84
+ - legacy hook adapter
85
+ - control-plane snapshot
86
+ - tool/session/permission/event bridge
87
+
88
+ 2. Governance core:
89
+ - classifier
90
+ - gate
91
+ - delegation discipline
92
+ - job board
93
+ - token budget
94
+ - close report
95
+ - doctor
96
+
97
+ 3. Distribution layer:
98
+ - default config
99
+ - documentation
100
+ - Desktop packaging and health UI in `0.1.0`
101
+
102
+ ### Current Structure
103
+
104
+ The current package layout is understandable:
105
+
106
+ - `src/agents`
107
+ - `src/hooks`
108
+ - `src/council`
109
+ - `src/skills`
110
+ - `src/tools`
111
+ - `src/opencode-control-plane.ts`
112
+ - `src/v2.ts`
113
+
114
+ The main structural issue is that `src/hooks/runtime.ts` has become a central
115
+ god module. It works, but future changes will be easier if runtime becomes a
116
+ small facade over deeper modules.
117
+
118
+ ## Framework And Technical Choices
119
+
120
+ ### Keep
121
+
122
+ - npm ESM package as the user runtime.
123
+ - Deno as the maintainer all-in-one toolchain.
124
+ - TypeScript strict mode.
125
+ - Local rule-based classifier for `0.0.x`.
126
+ - Message-count budget instead of provider-specific token accounting.
127
+ - No new runtime dependencies unless a feature truly requires one.
128
+ - Legacy hook adapter while v2 lacks equivalent governance hook coverage.
129
+
130
+ ### Revisit
131
+
132
+ - The minimum supported `@opencode-ai/plugin` version should be explicit.
133
+ - Runtime internals should be split before adding more features.
134
+ - Close report evidence should eventually use stronger sources such as diff,
135
+ test command results, and OpenCode todos when available.
136
+ - Worktree isolation should remain advisory until OpenCode exposes a stable
137
+ project-copy/worktree control plane.
138
+
139
+ ## Code Quality Audit
140
+
141
+ ### Good
142
+
143
+ - `npm run verify` passes.
144
+ - Generated package includes `dist`, docs, README, license, attribution, and
145
+ lazy skills.
146
+ - Old JS test copies are removed; TS/Deno tests are the authority.
147
+ - Stale renamed agent files are absent from `dist`.
148
+ - Public agent names avoid known collision-prone generic names.
149
+ - Persistence stays outside the project repo by default.
150
+
151
+ ### Needs Work
152
+
153
+ - `runtime.ts` is approximately 900 lines and mixes config, persistence,
154
+ workflow state, doctor, OpenCode snapshot, close report, and formatting.
155
+ - `messages-transform.ts` mixes pruning, image handling, job-board injection,
156
+ workflow gate, and skill filtering.
157
+ - `background-job-board.ts` is large but more cohesive; it can stay until runtime
158
+ is split.
159
+ - Tests are integration-heavy; after module split, add narrower tests for
160
+ doctor, close report, status formatting, and persistence.
161
+
162
+ ## Product Boundary
163
+
164
+ LazyOpenCode should not require another OpenCode plugin to provide its core team
165
+ runtime. It can learn from adjacent products, but the public product should feel
166
+ complete on its own.
167
+
168
+ Compared with lightweight agent-routing plugins, LazyOpenCode includes routing
169
+ but adds governance and closure.
170
+
171
+ Compared with autonomous coding assistants, LazyOpenCode stays OpenCode-native
172
+ and prioritizes controlled engineering workflow over long independent runs.
173
+
174
+ Compared with future Desktop distributions, `@lazyopencode/core` is the source
175
+ of truth. Desktop should package and visualize core behavior, not duplicate it.
176
+
177
+ ## Release Readiness
178
+
179
+ `0.0.1` is releaseable once these stay true:
180
+
181
+ - `npm run verify` passes.
182
+ - README and docs use governed team runtime positioning.
183
+ - No stale renamed agents are packed.
184
+ - No JS test duplicates remain.
185
+ - `/lazy start`, `/lazy status`, `/lazy close`, and `/lazy doctor` remain covered
186
+ by tests.
187
+ - Desktop work is documented as a later stage, not implied as complete.
@@ -0,0 +1,56 @@
1
+ # LazyOpenCode 0.0.1 Governed Runtime Plan
2
+
3
+ LazyOpenCode 0.0.1 ships a minimum complete governed team runtime for OpenCode:
4
+
5
+ `/lazy start <task>` -> classify -> gate or allow -> track -> close with review or simplification.
6
+
7
+ The long-term product shape is OpenCode-native: core provides the governed team
8
+ runtime, and Desktop becomes the preinstalled distribution in `0.1.0`.
9
+
10
+ ## Product Contract
11
+
12
+ - Classify task risk and ambiguity.
13
+ - Gate high-risk or ambiguous work until scope is clear.
14
+ - Track background jobs, terminal jobs, reusable sessions, and stale sessions.
15
+ - Budget message context and council escalation.
16
+ - Ask before destructive commands.
17
+ - Close implementation work with review, simplify, and verification.
18
+
19
+ ## 0.0.1 Boundaries
20
+
21
+ Included:
22
+
23
+ - Governed team runtime positioning and docs.
24
+ - `/lazy` command namespace.
25
+ - Runtime config and persistence.
26
+ - Rule-based workflow classifier.
27
+ - Shared runtime for hooks.
28
+ - Token-control layer for bounded messages, image redirects, skill filtering, summarized job state, and mini job board status.
29
+ - Council eligibility guard for high-risk, ambiguous, or debug escalation.
30
+ - Permission guard for destructive OpenCode permission requests.
31
+ - Hardened job board semantics.
32
+ - Skill output contracts.
33
+ - Verification scripts and tests.
34
+ - deepwork mode for focused single-goal sessions.
35
+ - OpenCode v2 default registration with legacy hook adapter.
36
+ - `/lazy doctor`, close evidence capture, and Desktop health snapshot support.
37
+
38
+ Not included:
39
+
40
+ - UI.
41
+ - Desktop fork implementation.
42
+ - MCP marketplace.
43
+ - GitHub issue automation.
44
+ - Provider marketplace.
45
+ - Full worktree automation.
46
+ - Model-based classification.
47
+ - Deno as user runtime requirement.
48
+ - Desktop copying core governance rules.
49
+
50
+ ## Release Criteria
51
+
52
+ - README and docs describe governed team runtime positioning.
53
+ - `/lazy start`, `status`, `reset`, `mode`, `explain`, `review`, `simplify`, `debug`, `close`, `doctor`, and `deepwork` work in integration tests.
54
+ - Runtime state survives save/load and marks previously running jobs as stale.
55
+ - Permission guard and zero-config merge tests pass.
56
+ - `npm run verify` passes.
@@ -0,0 +1,35 @@
1
+ # Job State Machine
2
+
3
+ ## States
4
+
5
+ - `running`: task has launched and may still produce output
6
+ - `completed`: task ended successfully and is terminal unreconciled
7
+ - `error`: task ended with an error and is terminal unreconciled
8
+ - `cancelled`: task was cancelled and is terminal unreconciled
9
+ - `reconciled`: successful completed task acknowledged by the parent session
10
+ - `stale`: task was running before process restart and cannot be trusted as running
11
+
12
+ ## Transitions
13
+
14
+ - launch -> `running`
15
+ - task output completed -> `completed` + terminal unreconciled
16
+ - task output error -> `error` + terminal unreconciled
17
+ - task output cancelled -> `cancelled` + terminal unreconciled
18
+ - session idle reconcile completed -> `reconciled`
19
+ - persisted running load -> `stale`
20
+ - session deleted -> removed
21
+
22
+ ## Reusable Sessions
23
+
24
+ `reusable` is derived, not stored as a state.
25
+
26
+ A job is reusable only when:
27
+
28
+ - state is `reconciled`
29
+ - terminal unreconciled is false
30
+
31
+ `error`, `cancelled`, and `stale` jobs are never reusable.
32
+
33
+ ## Restart Recovery
34
+
35
+ Persisted `running` jobs become `stale` after load. They remain visible in `/lazy status` so the user can see the interrupted work, but they are not reused.