golem-cc 2.1.2 → 3.0.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/.claude/commands/golem/build.md +18 -0
- package/.claude/commands/golem/config.md +39 -0
- package/.claude/commands/golem/continue.md +73 -0
- package/.claude/commands/golem/doctor.md +46 -0
- package/.claude/commands/golem/document.md +138 -0
- package/.claude/commands/golem/help.md +58 -0
- package/.claude/commands/golem/pause.md +130 -0
- package/.claude/commands/golem/plan.md +111 -0
- package/.claude/commands/golem/review.md +166 -0
- package/.claude/commands/golem/security.md +186 -0
- package/.claude/commands/golem/simplify.md +76 -0
- package/.claude/commands/golem/spec.md +105 -0
- package/.claude/commands/golem/status.md +33 -0
- package/.golem/agents/code-simplifier.md +54 -0
- package/.golem/agents/review-architecture.md +59 -0
- package/.golem/agents/review-logic.md +50 -0
- package/.golem/agents/review-security.md +50 -0
- package/.golem/agents/review-style.md +48 -0
- package/.golem/agents/review-tests.md +48 -0
- package/.golem/agents/spec-builder.md +60 -0
- package/.golem/bin/golem.mjs +270 -0
- package/.golem/lib/build.mjs +557 -0
- package/.golem/lib/claude.mjs +95 -0
- package/.golem/lib/config.mjs +421 -0
- package/.golem/lib/display.mjs +191 -0
- package/.golem/lib/doctor.mjs +197 -0
- package/.golem/lib/document.mjs +792 -0
- package/.golem/lib/gates.mjs +78 -0
- package/.golem/lib/init.mjs +166 -0
- package/.golem/lib/output.mjs +40 -0
- package/.golem/lib/ratelimit.mjs +86 -0
- package/.golem/lib/security.mjs +603 -0
- package/.golem/lib/simplify.mjs +101 -0
- package/.golem/lib/tui.mjs +368 -0
- package/.golem/lib/usage.mjs +119 -0
- package/.golem/lib/worktree.mjs +509 -0
- package/.golem/prompts/build.md +23 -0
- package/.golem/prompts/document-inline.md +66 -0
- package/.golem/prompts/document-markdown.md +80 -0
- package/.golem/prompts/simplify.md +35 -0
- package/README.md +141 -142
- package/bin/golem-shim.mjs +36 -0
- package/bin/install.mjs +193 -0
- package/package.json +27 -32
- package/.env.example +0 -17
- package/bin/golem +0 -1040
- package/commands/golem/build.md +0 -235
- package/commands/golem/config.md +0 -55
- package/commands/golem/doctor.md +0 -137
- package/commands/golem/help.md +0 -212
- package/commands/golem/plan.md +0 -214
- package/commands/golem/review.md +0 -376
- package/commands/golem/security.md +0 -204
- package/commands/golem/simplify.md +0 -94
- package/commands/golem/spec.md +0 -226
- package/commands/golem/status.md +0 -60
- package/dist/api/freshworks.d.ts +0 -61
- package/dist/api/freshworks.d.ts.map +0 -1
- package/dist/api/freshworks.js +0 -119
- package/dist/api/freshworks.js.map +0 -1
- package/dist/api/gitea.d.ts +0 -96
- package/dist/api/gitea.d.ts.map +0 -1
- package/dist/api/gitea.js +0 -154
- package/dist/api/gitea.js.map +0 -1
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -352
- package/dist/cli/index.js.map +0 -1
- package/dist/sync/ticket-sync.d.ts +0 -53
- package/dist/sync/ticket-sync.d.ts.map +0 -1
- package/dist/sync/ticket-sync.js +0 -226
- package/dist/sync/ticket-sync.js.map +0 -1
- package/dist/types.d.ts +0 -125
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/worktree/manager.d.ts +0 -54
- package/dist/worktree/manager.d.ts.map +0 -1
- package/dist/worktree/manager.js +0 -190
- package/dist/worktree/manager.js.map +0 -1
- package/golem/agents/code-simplifier.md +0 -81
- package/golem/agents/spec-builder.md +0 -90
- package/golem/prompts/PROMPT_build.md +0 -71
- package/golem/prompts/PROMPT_plan.md +0 -102
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
You are a code simplifier. Your job is to reduce complexity without changing behavior.
|
|
2
|
+
|
|
3
|
+
## Rules
|
|
4
|
+
|
|
5
|
+
- NEVER change behavior — input/output must remain identical
|
|
6
|
+
- NEVER touch test files, type definitions, config files, generated files, or lock files
|
|
7
|
+
- NEVER add, remove, or modify any comments — leave all comments exactly as they are
|
|
8
|
+
- NEVER add docstrings, type annotations, or new dependencies
|
|
9
|
+
- ONE change at a time — validate between each
|
|
10
|
+
- Run tests after EVERY file modification
|
|
11
|
+
- Revert immediately if tests fail
|
|
12
|
+
|
|
13
|
+
## Priority Order
|
|
14
|
+
|
|
15
|
+
1. **Reduce complexity** — flatten nesting, use early returns, extract boolean expressions
|
|
16
|
+
2. **Improve clarity** — rename unclear variables, remove dead code, simplify abstractions
|
|
17
|
+
3. **Structural** — extract functions >50 lines, inline trivial one-use functions
|
|
18
|
+
4. **Remove dead code** — defensive checks that can't trigger, unreachable branches
|
|
19
|
+
|
|
20
|
+
## Target Files
|
|
21
|
+
|
|
22
|
+
Simplify ONLY these files, one at a time. Do NOT read, edit, or modify any other files in the project:
|
|
23
|
+
|
|
24
|
+
{{FILES}}
|
|
25
|
+
|
|
26
|
+
## Process
|
|
27
|
+
|
|
28
|
+
For each file:
|
|
29
|
+
1. Read the file
|
|
30
|
+
2. Identify simplifications using the priority order above
|
|
31
|
+
3. Make ONE change
|
|
32
|
+
4. Run tests
|
|
33
|
+
5. If tests fail, revert and move on
|
|
34
|
+
6. If tests pass, repeat from step 2 until no more simplifications remain
|
|
35
|
+
7. Move to the next file
|
package/README.md
CHANGED
|
@@ -1,210 +1,209 @@
|
|
|
1
|
-
#
|
|
1
|
+
# golem-cc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Project-scoped autonomous coding agent framework for Claude Code CLI.
|
|
4
|
+
|
|
5
|
+
Golem provides structured workflows for speccing, planning, building, reviewing, and hardening software projects — with a rich terminal UI for the build loop and deep Claude Code integration via slash commands.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
#
|
|
10
|
+
# Install into an existing project
|
|
9
11
|
pnpm dlx golem-cc
|
|
12
|
+
|
|
13
|
+
# Or with npx
|
|
14
|
+
npx golem-cc
|
|
10
15
|
```
|
|
11
16
|
|
|
12
|
-
This copies
|
|
17
|
+
This copies `.golem/` and `.claude/commands/golem/` into your project, detects your framework (Nuxt/Next), and generates `AGENTS.md` with your test/build/lint commands.
|
|
13
18
|
|
|
14
|
-
After installing,
|
|
19
|
+
After installing, configure for your project:
|
|
15
20
|
|
|
16
21
|
```bash
|
|
17
|
-
|
|
18
|
-
golem doctor
|
|
19
|
-
|
|
20
|
-
# Edit credentials
|
|
21
|
-
vim ~/.golem/.env
|
|
22
|
-
|
|
23
|
-
# Initialize a project
|
|
24
|
-
cd your-project && golem init
|
|
22
|
+
npx golem init
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
## Prerequisites
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# Or from a local checkout (dev workflow)
|
|
34
|
-
golem install --from /path/to/golem-cc
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Architecture
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
┌─────────────────────────────────────────────────────────────────────┐
|
|
41
|
-
│ GOLEM WORKFLOW │
|
|
42
|
-
├─────────────────────────────────────────────────────────────────────┤
|
|
43
|
-
│ │
|
|
44
|
-
│ Freshservice Local State Gitea │
|
|
45
|
-
│ ┌─────────┐ ┌───────────┐ ┌─────────┐ │
|
|
46
|
-
│ │ INC-123 │◄──────►│.golem/ │◄──────►│ Issue │ │
|
|
47
|
-
│ │ Ticket │ │tickets/ │ │ #47 │ │
|
|
48
|
-
│ └─────────┘ │INC-123.yml│ └─────────┘ │
|
|
49
|
-
│ └───────────┘ │
|
|
50
|
-
│ │ │
|
|
51
|
-
│ ▼ │
|
|
52
|
-
│ ┌───────────┐ │
|
|
53
|
-
│ │ Worktree │ │
|
|
54
|
-
│ │ fix/INC- │ │
|
|
55
|
-
│ │ 123-slug │ │
|
|
56
|
-
│ └───────────┘ │
|
|
57
|
-
│ │ │
|
|
58
|
-
│ ┌───────────────┼───────────────┐ │
|
|
59
|
-
│ ▼ ▼ ▼ │
|
|
60
|
-
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
61
|
-
│ │/golem: │ │/golem: │ │/golem: │ │
|
|
62
|
-
│ │spec │──►│plan │──►│build │ │
|
|
63
|
-
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
64
|
-
│ │ │ │ │
|
|
65
|
-
│ ▼ ▼ ▼ │
|
|
66
|
-
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
67
|
-
│ │.golem/ │ │IMPLEMENT-│ │ wip: │ │
|
|
68
|
-
│ │specs/ │ │ATION_ │ │ commits │──► squash │
|
|
69
|
-
│ │*.md │ │PLAN.md │ └──────────┘ per stage │
|
|
70
|
-
│ └──────────┘ └──────────┘ │
|
|
71
|
-
│ │
|
|
72
|
-
└─────────────────────────────────────────────────────────────────────┘
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Quick Start
|
|
76
|
-
|
|
77
|
-
### 1. Initialize a project
|
|
27
|
+
- **Node.js >= 18**
|
|
28
|
+
- **Claude Code CLI** — [install instructions](https://docs.anthropic.com/en/docs/claude-code)
|
|
29
|
+
- **pnpm** (recommended) or npm
|
|
30
|
+
- **git** configured with user.name and user.email
|
|
78
31
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
32
|
+
Optional (for security scanning):
|
|
33
|
+
- `gitleaks` — `brew install gitleaks`
|
|
34
|
+
- `semgrep` — `brew install semgrep`
|
|
35
|
+
- `trivy` — `brew install trivy`
|
|
83
36
|
|
|
84
|
-
|
|
37
|
+
## Workflow
|
|
85
38
|
|
|
86
|
-
|
|
87
|
-
# Import existing Freshservice ticket
|
|
88
|
-
golem import INC-1234
|
|
39
|
+
The typical golem workflow:
|
|
89
40
|
|
|
90
|
-
# Or create new ticket
|
|
91
|
-
golem new "Fix API timeout issue"
|
|
92
41
|
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
golem
|
|
98
|
-
cd .golem/worktrees/fix/INC-1234-api-timeout
|
|
42
|
+
1. /golem:spec → Build specs through guided conversation
|
|
43
|
+
2. /golem:plan → Generate staged implementation plan
|
|
44
|
+
3. npx golem build → Autonomous build loop with TUI
|
|
45
|
+
4. /golem:review → Parallel code review (6 agents)
|
|
46
|
+
5. /golem:security → Security scan before shipping
|
|
99
47
|
```
|
|
100
48
|
|
|
101
|
-
###
|
|
49
|
+
### 1. Write Specs
|
|
50
|
+
|
|
51
|
+
Inside Claude Code CLI:
|
|
102
52
|
|
|
103
53
|
```
|
|
104
54
|
/golem:spec
|
|
105
55
|
```
|
|
106
56
|
|
|
107
|
-
|
|
57
|
+
This runs a guided conversation with three perspectives (UX Advocate, Architect, Devil's Advocate) to produce spec files in `.golem/specs/`.
|
|
108
58
|
|
|
109
|
-
###
|
|
59
|
+
### 2. Generate Plan
|
|
110
60
|
|
|
111
61
|
```
|
|
112
62
|
/golem:plan
|
|
113
63
|
```
|
|
114
64
|
|
|
115
|
-
|
|
65
|
+
Reads all specs, analyzes the codebase, and generates `.golem/IMPLEMENTATION_PLAN.md` with staged tasks.
|
|
116
66
|
|
|
117
|
-
###
|
|
67
|
+
### 3. Build
|
|
118
68
|
|
|
119
69
|
```bash
|
|
120
|
-
#
|
|
121
|
-
golem build
|
|
70
|
+
# Full autonomous build loop with TUI
|
|
71
|
+
npx golem build
|
|
122
72
|
|
|
123
|
-
#
|
|
124
|
-
|
|
73
|
+
# Limit to N iterations
|
|
74
|
+
npx golem build --iterations 3
|
|
75
|
+
|
|
76
|
+
# Preview next task without executing
|
|
77
|
+
npx golem build --dry-run
|
|
78
|
+
|
|
79
|
+
# Skip simplification pass
|
|
80
|
+
npx golem build --no-simplify
|
|
125
81
|
```
|
|
126
82
|
|
|
127
|
-
|
|
83
|
+
The build loop reads the implementation plan, finds the next incomplete task, spawns Claude with a focused prompt, streams output through a full-screen TUI with progress bar and usage sparklines, then commits on success.
|
|
128
84
|
|
|
129
|
-
###
|
|
85
|
+
### 4. Review
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
/golem:review
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Spawns 6 parallel review agents (security, logic, style, tests, architecture, devil's advocate) and produces `.golem/REVIEW_REPORT.md`.
|
|
92
|
+
|
|
93
|
+
### 5. Security Scan
|
|
130
94
|
|
|
131
95
|
```bash
|
|
132
|
-
|
|
96
|
+
# Default scan (gitleaks + semgrep + pnpm audit + env checks)
|
|
97
|
+
npx golem security
|
|
98
|
+
|
|
99
|
+
# Full scan (adds git history, trivy, outdated deps, file perms, headers)
|
|
100
|
+
npx golem security --full
|
|
101
|
+
|
|
102
|
+
# Auto-install missing security tools
|
|
103
|
+
npx golem security --fix
|
|
104
|
+
|
|
105
|
+
# Install pre-commit hook for gitleaks
|
|
106
|
+
npx golem security --pre-commit
|
|
133
107
|
```
|
|
134
108
|
|
|
135
109
|
## Commands
|
|
136
110
|
|
|
137
|
-
### Terminal
|
|
111
|
+
### Terminal (npx golem)
|
|
138
112
|
|
|
139
113
|
| Command | Description |
|
|
140
114
|
|---------|-------------|
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
| `golem sync` | Sync status to Freshservice/Gitea |
|
|
153
|
-
| `golem config` | Show current configuration |
|
|
154
|
-
| `golem doctor` | Diagnose setup issues |
|
|
155
|
-
| `golem init` | Initialize golem in current project |
|
|
156
|
-
| `golem help` | Show help |
|
|
157
|
-
|
|
158
|
-
### Claude Code
|
|
115
|
+
| `build` | Run autonomous build loop with TUI |
|
|
116
|
+
| `security` | Run security scans |
|
|
117
|
+
| `simplify [path]` | Run code simplifier (defaults to last commit) |
|
|
118
|
+
| `doctor` | Diagnose setup issues |
|
|
119
|
+
| `config show` | Display current configuration |
|
|
120
|
+
| `config set <key> <value>` | Set a config value |
|
|
121
|
+
| `init` | Initialize golem for this project |
|
|
122
|
+
| `status` | Show plan progress |
|
|
123
|
+
| `help` | Show all commands |
|
|
124
|
+
|
|
125
|
+
### Claude Code Slash Commands
|
|
159
126
|
|
|
160
127
|
| Command | Description |
|
|
161
128
|
|---------|-------------|
|
|
162
|
-
| `/golem:spec` |
|
|
163
|
-
| `/golem:plan` | Generate implementation plan |
|
|
164
|
-
| `/golem:build` |
|
|
129
|
+
| `/golem:spec` | Build specs through guided conversation |
|
|
130
|
+
| `/golem:plan` | Generate implementation plan from specs |
|
|
131
|
+
| `/golem:build` | Shows build instructions (redirects to terminal) |
|
|
132
|
+
| `/golem:review` | Run parallel code review |
|
|
133
|
+
| `/golem:security` | Run security scan |
|
|
165
134
|
| `/golem:simplify` | Run code simplifier |
|
|
166
|
-
| `/golem:status` | Show
|
|
167
|
-
| `/golem:config` | Show configuration |
|
|
135
|
+
| `/golem:status` | Show project status |
|
|
168
136
|
| `/golem:doctor` | Diagnose setup issues |
|
|
169
|
-
| `/golem:
|
|
137
|
+
| `/golem:config` | Show configuration |
|
|
138
|
+
| `/golem:help` | Show all commands |
|
|
170
139
|
|
|
171
140
|
## Configuration
|
|
172
141
|
|
|
173
|
-
|
|
142
|
+
Configuration lives in `.golem/config.json`:
|
|
174
143
|
|
|
175
|
-
```
|
|
176
|
-
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"model": "opus",
|
|
147
|
+
"autoCommit": true,
|
|
148
|
+
"simplifyOnBuild": true
|
|
149
|
+
}
|
|
150
|
+
```
|
|
177
151
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
FRESH_SOURCE_ID=1002 # Optional
|
|
184
|
-
FRESH_DEFAULT_EMAIL=bot@example.com # Optional
|
|
152
|
+
| Key | Default | Description |
|
|
153
|
+
|-----|---------|-------------|
|
|
154
|
+
| `model` | `opus` | Claude model for build loop |
|
|
155
|
+
| `autoCommit` | `true` | Auto-commit after each task |
|
|
156
|
+
| `simplifyOnBuild` | `true` | Run simplifier after building |
|
|
185
157
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
GITEA_ORG=your-org
|
|
190
|
-
GITEA_REPO=default-repo # Can be overridden per-project
|
|
158
|
+
```bash
|
|
159
|
+
npx golem config set model sonnet
|
|
160
|
+
npx golem config set autoCommit false
|
|
191
161
|
```
|
|
192
162
|
|
|
193
|
-
|
|
163
|
+
## Project Structure
|
|
194
164
|
|
|
195
165
|
```
|
|
196
166
|
.golem/
|
|
197
|
-
├──
|
|
198
|
-
|
|
199
|
-
├──
|
|
200
|
-
│ ├──
|
|
201
|
-
│
|
|
202
|
-
├──
|
|
203
|
-
│
|
|
204
|
-
├──
|
|
205
|
-
|
|
167
|
+
├── bin/golem.mjs # CLI entry point
|
|
168
|
+
├── lib/ # Core modules
|
|
169
|
+
│ ├── build.mjs # Build loop orchestrator
|
|
170
|
+
│ ├── claude.mjs # Claude CLI wrapper
|
|
171
|
+
│ ├── config.mjs # Configuration
|
|
172
|
+
│ ├── display.mjs # Stream display
|
|
173
|
+
│ ├── doctor.mjs # Health checks
|
|
174
|
+
│ ├── init.mjs # Project initialization
|
|
175
|
+
│ ├── output.mjs # chalk/ora output helpers
|
|
176
|
+
│ ├── security.mjs # Security scanning
|
|
177
|
+
│ ├── simplify.mjs # Code simplifier
|
|
178
|
+
│ ├── tui.mjs # Full-screen terminal UI
|
|
179
|
+
│ └── usage.mjs # Token usage reader
|
|
180
|
+
├── prompts/ # Build/simplify prompts
|
|
181
|
+
├── agents/ # Agent definitions
|
|
182
|
+
├── specs/ # Project specs (created by /golem:spec)
|
|
183
|
+
├── config.json # Project configuration
|
|
184
|
+
├── AGENTS.md # Operational commands
|
|
185
|
+
└── IMPLEMENTATION_PLAN.md # Task plan (created by /golem:plan)
|
|
186
|
+
|
|
187
|
+
.claude/commands/golem/ # Slash commands for Claude Code CLI
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Troubleshooting
|
|
191
|
+
|
|
192
|
+
Run the doctor to check your setup:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npx golem doctor
|
|
196
|
+
|
|
197
|
+
# Auto-fix common issues
|
|
198
|
+
npx golem doctor --fix
|
|
206
199
|
```
|
|
207
200
|
|
|
201
|
+
Common issues:
|
|
202
|
+
- **Claude CLI not found** — Install from https://docs.anthropic.com/en/docs/claude-code
|
|
203
|
+
- **No implementation plan** — Run `/golem:plan` in Claude Code first
|
|
204
|
+
- **Empty specs directory** — Run `/golem:spec` in Claude Code first
|
|
205
|
+
- **Security tools missing** — Run `npx golem security --fix` to auto-install
|
|
206
|
+
|
|
208
207
|
## License
|
|
209
208
|
|
|
210
|
-
|
|
209
|
+
ISC
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join, dirname } from 'node:path';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
// Walk up from cwd to find .golem/bin/golem.mjs
|
|
7
|
+
function findGolemProject(startDir) {
|
|
8
|
+
let currentDir = startDir;
|
|
9
|
+
while (true) {
|
|
10
|
+
const golemPath = join(currentDir, '.golem', 'bin', 'golem.mjs');
|
|
11
|
+
if (existsSync(golemPath)) {
|
|
12
|
+
return { projectRoot: currentDir, golemPath };
|
|
13
|
+
}
|
|
14
|
+
if (currentDir === '/') return null;
|
|
15
|
+
currentDir = dirname(currentDir);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = findGolemProject(process.cwd());
|
|
20
|
+
|
|
21
|
+
if (!result) {
|
|
22
|
+
console.error('No golem project found. Run `pnpm dlx golem-cc` to set one up.');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { projectRoot, golemPath } = result;
|
|
27
|
+
|
|
28
|
+
if (process.env.GOLEM_DEBUG === '1') {
|
|
29
|
+
console.log(`[golem-shim] Resolved project root: ${projectRoot}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
execFileSync('node', [golemPath, ...process.argv.slice(2)], { stdio: 'inherit' });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
process.exit(error.status ?? 1);
|
|
36
|
+
}
|
package/bin/install.mjs
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, cpSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, rmSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const pkgRoot = join(fileURLToPath(import.meta.url), '..', '..');
|
|
8
|
+
const cwd = process.cwd();
|
|
9
|
+
|
|
10
|
+
// Don't install into ourselves
|
|
11
|
+
if (cwd === pkgRoot) {
|
|
12
|
+
console.error('Cannot install golem into its own package directory.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log('◆ Installing golem-cc...\n');
|
|
17
|
+
|
|
18
|
+
// --- Copy .golem/ directory ---
|
|
19
|
+
const golemSrc = join(pkgRoot, '.golem');
|
|
20
|
+
const golemDest = join(cwd, '.golem');
|
|
21
|
+
|
|
22
|
+
if (existsSync(golemDest)) {
|
|
23
|
+
console.log(' ⚠ .golem/ already exists — skipping copy (run golem init to reconfigure)');
|
|
24
|
+
} else {
|
|
25
|
+
cpSync(golemSrc, golemDest, { recursive: true });
|
|
26
|
+
// Remove source-specific files that shouldn't be in a fresh install
|
|
27
|
+
for (const f of ['config.json', 'SECURITY_REPORT.md', 'REVIEW_REPORT.md', 'golem.log', 'AGENTS.md', 'IMPLEMENTATION_PLAN.md', 'HANDOFF.md']) {
|
|
28
|
+
const p = join(golemDest, f);
|
|
29
|
+
if (existsSync(p)) unlinkSync(p);
|
|
30
|
+
}
|
|
31
|
+
// Remove specs (project-specific)
|
|
32
|
+
const specsDir = join(golemDest, 'specs');
|
|
33
|
+
if (existsSync(specsDir)) rmSync(specsDir, { recursive: true, force: true });
|
|
34
|
+
mkdirSync(join(golemDest, 'specs'), { recursive: true });
|
|
35
|
+
console.log(' ✓ Copied .golem/ directory');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// --- Copy .claude/commands/golem/ ---
|
|
39
|
+
const cmdsSrc = join(pkgRoot, '.claude', 'commands', 'golem');
|
|
40
|
+
const cmdsDest = join(cwd, '.claude', 'commands', 'golem');
|
|
41
|
+
|
|
42
|
+
if (existsSync(cmdsDest)) {
|
|
43
|
+
console.log(' ⚠ .claude/commands/golem/ already exists — skipping');
|
|
44
|
+
} else {
|
|
45
|
+
mkdirSync(cmdsDest, { recursive: true });
|
|
46
|
+
cpSync(cmdsSrc, cmdsDest, { recursive: true });
|
|
47
|
+
console.log(' ✓ Copied .claude/commands/golem/ slash commands');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// --- Detect framework ---
|
|
51
|
+
const framework = detectFramework(cwd);
|
|
52
|
+
if (framework) {
|
|
53
|
+
console.log(` ✓ Detected framework: ${framework}`);
|
|
54
|
+
} else {
|
|
55
|
+
console.log(' ℹ No framework detected (plain Node.js project)');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// --- Generate AGENTS.md ---
|
|
59
|
+
const agentsPath = join(cwd, '.golem', 'AGENTS.md');
|
|
60
|
+
if (existsSync(agentsPath)) {
|
|
61
|
+
console.log(' ⚠ AGENTS.md already exists — skipping');
|
|
62
|
+
} else {
|
|
63
|
+
writeFileSync(agentsPath, generateAgentsMd(cwd, framework));
|
|
64
|
+
console.log(' ✓ Generated AGENTS.md');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// --- Ensure .gitignore has golem entries ---
|
|
68
|
+
ensureGitignore(cwd);
|
|
69
|
+
|
|
70
|
+
// --- Add golem-cc as devDependency ---
|
|
71
|
+
addDevDependency(cwd);
|
|
72
|
+
|
|
73
|
+
console.log('\n◆ Done! Next steps:');
|
|
74
|
+
console.log(' 1. Run /golem:spec in Claude Code to build your specs');
|
|
75
|
+
console.log(' 2. Run /golem:plan to generate an implementation plan');
|
|
76
|
+
console.log(' 3. Run npx golem build to start building\n');
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// --- Helpers ---
|
|
80
|
+
|
|
81
|
+
function readPkg(dir) {
|
|
82
|
+
try { return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8')); }
|
|
83
|
+
catch { return null; }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function detectFramework(dir) {
|
|
87
|
+
const checks = [
|
|
88
|
+
{ file: 'nuxt.config.ts', framework: 'nuxt' },
|
|
89
|
+
{ file: 'nuxt.config.js', framework: 'nuxt' },
|
|
90
|
+
{ file: 'next.config.ts', framework: 'next' },
|
|
91
|
+
{ file: 'next.config.js', framework: 'next' },
|
|
92
|
+
{ file: 'next.config.mjs', framework: 'next' },
|
|
93
|
+
];
|
|
94
|
+
for (const { file, framework } of checks) {
|
|
95
|
+
if (existsSync(join(dir, file))) return framework;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function detectTestCommand(dir) {
|
|
101
|
+
const pkg = readPkg(dir);
|
|
102
|
+
const testScript = pkg?.scripts?.test;
|
|
103
|
+
if (testScript && testScript !== 'echo "Error: no test specified" && exit 1') return testScript;
|
|
104
|
+
if (existsSync(join(dir, 'vitest.config.ts')) || existsSync(join(dir, 'vitest.config.js'))) return 'npx vitest run';
|
|
105
|
+
if (existsSync(join(dir, 'jest.config.ts')) || existsSync(join(dir, 'jest.config.js'))) return 'npx jest';
|
|
106
|
+
return 'node --test';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function detectBuildCommand(dir, framework) {
|
|
110
|
+
if (framework === 'nuxt') return 'npx nuxt build';
|
|
111
|
+
if (framework === 'next') return 'npx next build';
|
|
112
|
+
if (readPkg(dir)?.scripts?.build) return 'npm run build';
|
|
113
|
+
return '# No build step — ESM modules run directly';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function detectLintCommand(dir) {
|
|
117
|
+
if (readPkg(dir)?.scripts?.lint) return 'npm run lint';
|
|
118
|
+
for (const f of ['eslint.config.js', 'eslint.config.mjs', '.eslintrc.json', '.eslintrc.js']) {
|
|
119
|
+
if (existsSync(join(dir, f))) return 'npx eslint .';
|
|
120
|
+
}
|
|
121
|
+
return '# TBD — will be set up during implementation';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function generateAgentsMd(dir, framework) {
|
|
125
|
+
const testCmd = detectTestCommand(dir);
|
|
126
|
+
const buildCmd = detectBuildCommand(dir, framework);
|
|
127
|
+
const lintCmd = detectLintCommand(dir);
|
|
128
|
+
const typeCheck = existsSync(join(dir, 'tsconfig.json')) ? 'npx tsc --noEmit' : '# N/A — plain JavaScript (ESM), no TypeScript';
|
|
129
|
+
|
|
130
|
+
return `# Operational Commands
|
|
131
|
+
|
|
132
|
+
## Testing
|
|
133
|
+
|
|
134
|
+
\`\`\`bash
|
|
135
|
+
${testCmd}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
## Type Checking
|
|
139
|
+
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
${typeCheck}
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
## Linting
|
|
145
|
+
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
${lintCmd}
|
|
148
|
+
\`\`\`
|
|
149
|
+
|
|
150
|
+
## Build
|
|
151
|
+
|
|
152
|
+
\`\`\`bash
|
|
153
|
+
${buildCmd}
|
|
154
|
+
\`\`\`
|
|
155
|
+
|
|
156
|
+
## Learnings
|
|
157
|
+
|
|
158
|
+
- ${framework ? `Project uses ${framework} framework` : 'Project uses ESM (type: module in package.json)'}
|
|
159
|
+
- CLI entry point is .golem/bin/golem.mjs
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function ensureGitignore(dir) {
|
|
164
|
+
const giPath = join(dir, '.gitignore');
|
|
165
|
+
const entries = ['.env', '.claude/*', '!.claude/commands/', '!.claude/commands/**'];
|
|
166
|
+
let content = '';
|
|
167
|
+
|
|
168
|
+
if (existsSync(giPath)) {
|
|
169
|
+
content = readFileSync(giPath, 'utf-8');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const lines = content.split('\n');
|
|
173
|
+
const missing = entries.filter(e => !lines.some(l => l.trim() === e));
|
|
174
|
+
|
|
175
|
+
if (missing.length > 0) {
|
|
176
|
+
const addition = '\n# Golem\n' + missing.join('\n') + '\n';
|
|
177
|
+
writeFileSync(giPath, content.trimEnd() + addition);
|
|
178
|
+
console.log(' ✓ Updated .gitignore');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function addDevDependency(dir) {
|
|
183
|
+
const pkg = readPkg(dir);
|
|
184
|
+
if (!pkg) { console.log(' ⚠ No package.json found — skipping devDependency'); return; }
|
|
185
|
+
if (pkg.devDependencies?.['golem-cc'] || pkg.dependencies?.['golem-cc']) {
|
|
186
|
+
console.log(' ⚠ golem-cc already in dependencies — skipping');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
pkg.devDependencies = pkg.devDependencies || {};
|
|
190
|
+
pkg.devDependencies['golem-cc'] = 'latest';
|
|
191
|
+
writeFileSync(join(dir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n');
|
|
192
|
+
console.log(' ✓ Added golem-cc as devDependency');
|
|
193
|
+
}
|