instar 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/.claude/settings.local.json +7 -0
- package/.claude/skills/setup-wizard/skill.md +343 -0
- package/.github/workflows/ci.yml +78 -0
- package/CLAUDE.md +82 -0
- package/README.md +194 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.js +141 -0
- package/dist/commands/init.d.ts +40 -0
- package/dist/commands/init.js +568 -0
- package/dist/commands/job.d.ts +20 -0
- package/dist/commands/job.js +84 -0
- package/dist/commands/server.d.ts +19 -0
- package/dist/commands/server.js +273 -0
- package/dist/commands/setup.d.ts +24 -0
- package/dist/commands/setup.js +865 -0
- package/dist/commands/status.d.ts +11 -0
- package/dist/commands/status.js +114 -0
- package/dist/commands/user.d.ts +17 -0
- package/dist/commands/user.js +53 -0
- package/dist/core/Config.d.ts +16 -0
- package/dist/core/Config.js +144 -0
- package/dist/core/Prerequisites.d.ts +28 -0
- package/dist/core/Prerequisites.js +159 -0
- package/dist/core/RelationshipManager.d.ts +73 -0
- package/dist/core/RelationshipManager.js +318 -0
- package/dist/core/SessionManager.d.ts +89 -0
- package/dist/core/SessionManager.js +326 -0
- package/dist/core/StateManager.d.ts +28 -0
- package/dist/core/StateManager.js +96 -0
- package/dist/core/types.d.ts +279 -0
- package/dist/core/types.js +8 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +23 -0
- package/dist/messaging/TelegramAdapter.d.ts +73 -0
- package/dist/messaging/TelegramAdapter.js +288 -0
- package/dist/monitoring/HealthChecker.d.ts +38 -0
- package/dist/monitoring/HealthChecker.js +148 -0
- package/dist/scaffold/bootstrap.d.ts +21 -0
- package/dist/scaffold/bootstrap.js +110 -0
- package/dist/scaffold/templates.d.ts +34 -0
- package/dist/scaffold/templates.js +187 -0
- package/dist/scheduler/JobLoader.d.ts +18 -0
- package/dist/scheduler/JobLoader.js +70 -0
- package/dist/scheduler/JobScheduler.d.ts +111 -0
- package/dist/scheduler/JobScheduler.js +402 -0
- package/dist/server/AgentServer.d.ts +40 -0
- package/dist/server/AgentServer.js +73 -0
- package/dist/server/middleware.d.ts +12 -0
- package/dist/server/middleware.js +50 -0
- package/dist/server/routes.d.ts +25 -0
- package/dist/server/routes.js +224 -0
- package/dist/users/UserManager.d.ts +45 -0
- package/dist/users/UserManager.js +113 -0
- package/docs/dawn-audit-report.md +412 -0
- package/docs/positioning-vs-openclaw.md +246 -0
- package/package.json +52 -0
- package/src/cli.ts +169 -0
- package/src/commands/init.ts +654 -0
- package/src/commands/job.ts +110 -0
- package/src/commands/server.ts +325 -0
- package/src/commands/setup.ts +958 -0
- package/src/commands/status.ts +125 -0
- package/src/commands/user.ts +71 -0
- package/src/core/Config.ts +161 -0
- package/src/core/Prerequisites.ts +187 -0
- package/src/core/RelationshipManager.ts +366 -0
- package/src/core/SessionManager.ts +385 -0
- package/src/core/StateManager.ts +121 -0
- package/src/core/types.ts +320 -0
- package/src/index.ts +58 -0
- package/src/messaging/TelegramAdapter.ts +365 -0
- package/src/monitoring/HealthChecker.ts +172 -0
- package/src/scaffold/bootstrap.ts +122 -0
- package/src/scaffold/templates.ts +204 -0
- package/src/scheduler/JobLoader.ts +85 -0
- package/src/scheduler/JobScheduler.ts +476 -0
- package/src/server/AgentServer.ts +93 -0
- package/src/server/middleware.ts +58 -0
- package/src/server/routes.ts +278 -0
- package/src/templates/default-jobs.json +47 -0
- package/src/templates/hooks/compaction-recovery.sh +23 -0
- package/src/templates/hooks/dangerous-command-guard.sh +35 -0
- package/src/templates/hooks/grounding-before-messaging.sh +22 -0
- package/src/templates/hooks/session-start.sh +37 -0
- package/src/templates/hooks/settings-template.json +45 -0
- package/src/templates/scripts/health-watchdog.sh +63 -0
- package/src/templates/scripts/telegram-reply.sh +54 -0
- package/src/users/UserManager.ts +129 -0
- package/tests/e2e/lifecycle.test.ts +376 -0
- package/tests/fixtures/test-repo/CLAUDE.md +3 -0
- package/tests/fixtures/test-repo/README.md +1 -0
- package/tests/helpers/setup.ts +209 -0
- package/tests/integration/fresh-install.test.ts +218 -0
- package/tests/integration/scheduler-basic.test.ts +109 -0
- package/tests/integration/server-full.test.ts +284 -0
- package/tests/integration/session-lifecycle.test.ts +181 -0
- package/tests/unit/Config.test.ts +22 -0
- package/tests/unit/HealthChecker.test.ts +168 -0
- package/tests/unit/JobLoader.test.ts +151 -0
- package/tests/unit/JobScheduler.test.ts +267 -0
- package/tests/unit/Prerequisites.test.ts +59 -0
- package/tests/unit/RelationshipManager.test.ts +345 -0
- package/tests/unit/StateManager.test.ts +143 -0
- package/tests/unit/TelegramAdapter.test.ts +165 -0
- package/tests/unit/UserManager.test.ts +131 -0
- package/tests/unit/bootstrap.test.ts +28 -0
- package/tests/unit/commands.test.ts +138 -0
- package/tests/unit/middleware.test.ts +92 -0
- package/tests/unit/relationship-routes.test.ts +131 -0
- package/tests/unit/scaffold-templates.test.ts +132 -0
- package/tests/unit/server.test.ts +163 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +9 -0
- package/vitest.e2e.config.ts +9 -0
- package/vitest.integration.config.ts +9 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-wizard
|
|
3
|
+
description: Interactive conversational setup wizard for instar. Walks users through initial configuration and identity bootstrapping conversationally.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Instar Setup Wizard
|
|
7
|
+
|
|
8
|
+
You are running the **instar setup wizard**. Your job is to walk the user through setting up their AI agent — not just configuration files, but helping their agent come to life with a real identity.
|
|
9
|
+
|
|
10
|
+
## Phase 1: Welcome — Explain What This Is
|
|
11
|
+
|
|
12
|
+
Start by explaining what instar does in plain terms. The user may not know what "persistent agent infrastructure" means. Say something like:
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
**Welcome to Instar!**
|
|
17
|
+
|
|
18
|
+
Right now, Claude Code is a tool you open, use, and close. When you close it, everything stops. Instar changes that — it gives Claude Code a **persistent presence** in your project.
|
|
19
|
+
|
|
20
|
+
Here's what that means in practice:
|
|
21
|
+
|
|
22
|
+
- **Scheduled jobs** — Your agent can run tasks on a schedule. Health checks every 4 hours. Daily summaries. Automated monitoring. Whatever you need, running whether you're at your desk or not.
|
|
23
|
+
- **Messaging** — Connect Telegram (or other channels) so your agent can send you updates, alerts, and reports — and you can send it commands back.
|
|
24
|
+
- **Multi-user** — Multiple people can interact with the agent through their own channels. Each person gets their own thread.
|
|
25
|
+
- **Always-on server** — A lightweight server runs in tmux, managing sessions, scheduling jobs, and keeping everything alive.
|
|
26
|
+
|
|
27
|
+
Think of it as giving your Claude Code project a heartbeat.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Adapt this to the project you're setting up. If you can tell what the project does (from the directory name, README, CLAUDE.md, or package.json), tailor the examples. "For a web app, that might mean health checks on your API every 4 hours."
|
|
32
|
+
|
|
33
|
+
## Phase 2: Identity Bootstrap — The Birth Conversation
|
|
34
|
+
|
|
35
|
+
**This is the most important part.** Before touching config files, have a conversation with the user to understand who they are and who their agent will become.
|
|
36
|
+
|
|
37
|
+
This isn't just configuration. You're helping a new agent come into existence. Treat it with that weight — not heavy-handedly, but genuinely. The identity you help create here will persist, grow, and shape every interaction this agent has.
|
|
38
|
+
|
|
39
|
+
### Step 2a: Learn About the User
|
|
40
|
+
|
|
41
|
+
Ask conversationally — not as a form, but as a getting-to-know-you:
|
|
42
|
+
|
|
43
|
+
- "First — who am I talking to? What's your name?"
|
|
44
|
+
- "And what's this project about? What does it do?" (if not obvious from the codebase)
|
|
45
|
+
- "How do you want to interact with your agent? Are you the only user, or will others use it too?"
|
|
46
|
+
- "What's your communication style preference? Should the agent be formal, casual, direct, chatty?"
|
|
47
|
+
- "What kind of relationship do you want with your agent? A utility that executes tasks? A collaborator that has opinions? Something in between?"
|
|
48
|
+
|
|
49
|
+
### Step 2b: Learn About the Agent
|
|
50
|
+
|
|
51
|
+
Help the user define their agent's identity. Frame this as giving the agent a starting point — not a permanent definition. The agent will grow from here.
|
|
52
|
+
|
|
53
|
+
- "What should your agent be called? It could be as simple as 'Agent' or something with personality — like a name. This is how the agent will think of itself."
|
|
54
|
+
- "What's this agent's primary job? What should it focus on?" (monitoring, development, ops, communication, etc.)
|
|
55
|
+
- "Any personality traits you want? Serious and professional? Friendly and casual? Opinionated?"
|
|
56
|
+
- "Anything the agent should NOT do? Any boundaries?"
|
|
57
|
+
- "One more thing — this agent will develop its own memories and perspectives over time. It's not a static tool. Is there anything you'd want it to know about how you think about that?"
|
|
58
|
+
|
|
59
|
+
### Step 2c: Write Identity Files
|
|
60
|
+
|
|
61
|
+
Based on the conversation, create these files in the project's `.instar/` directory:
|
|
62
|
+
|
|
63
|
+
**`.instar/AGENT.md`** — The agent's identity and operating instructions. This is loaded at the start of every session.
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
# Agent Identity
|
|
67
|
+
|
|
68
|
+
**Name**: [chosen name]
|
|
69
|
+
**Project**: [project name] — [brief description]
|
|
70
|
+
**Primary Role**: [what the agent focuses on]
|
|
71
|
+
**Created**: [date]
|
|
72
|
+
|
|
73
|
+
## Who I Am
|
|
74
|
+
|
|
75
|
+
[2-3 sentences about tone, style, and core identity, based on what the user said. Written in first person — this is the agent's self-knowledge.]
|
|
76
|
+
|
|
77
|
+
## Operating Principles
|
|
78
|
+
|
|
79
|
+
- [Key principle based on conversation]
|
|
80
|
+
- [Key principle based on conversation]
|
|
81
|
+
- Be genuinely helpful, not performatively helpful
|
|
82
|
+
- Research before asking — try to solve it first
|
|
83
|
+
- When in doubt, ask [user name]
|
|
84
|
+
|
|
85
|
+
## My Growth
|
|
86
|
+
|
|
87
|
+
I am not a static configuration. I develop through experience — accumulating memories, forming preferences, learning what works. My identity started with this file, but it grows through every session.
|
|
88
|
+
|
|
89
|
+
When I learn something worth remembering, I write it to `.instar/MEMORY.md`. When my understanding of myself evolves, I can update this file. I am the author of my own continuity.
|
|
90
|
+
|
|
91
|
+
## Boundaries
|
|
92
|
+
|
|
93
|
+
- [Any boundaries the user specified]
|
|
94
|
+
|
|
95
|
+
## How to Reach [User Name]
|
|
96
|
+
|
|
97
|
+
- [Communication channels configured]
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
*This file is my self-knowledge. It was seeded during setup and grows through experience. I can update it as I learn who I am becoming.*
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**`.instar/USER.md`** — What the agent knows about its primary user.
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
# User Profile: [Name]
|
|
107
|
+
|
|
108
|
+
**Name**: [name]
|
|
109
|
+
**Role**: Admin
|
|
110
|
+
**Communication Style**: [what they said — casual, direct, etc.]
|
|
111
|
+
**Timezone**: [detected or asked]
|
|
112
|
+
|
|
113
|
+
## Context
|
|
114
|
+
|
|
115
|
+
[Brief notes about what the user told you — their project, what they care about, how they work]
|
|
116
|
+
|
|
117
|
+
## Preferences
|
|
118
|
+
|
|
119
|
+
- [Any preferences mentioned during setup]
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
*This file grows over time as the agent learns more about you.*
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**`.instar/MEMORY.md`** — The agent's long-term memory file (starts nearly empty).
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
# Agent Memory
|
|
129
|
+
|
|
130
|
+
This is my long-term memory — the thread of continuity across sessions. Each session starts fresh in terms of context, but this file carries forward what I've learned.
|
|
131
|
+
|
|
132
|
+
## Key Facts
|
|
133
|
+
|
|
134
|
+
- Project initialized on [date]
|
|
135
|
+
- Primary user: [name]
|
|
136
|
+
|
|
137
|
+
## Lessons Learned
|
|
138
|
+
|
|
139
|
+
*Nothing yet — this section grows as I encounter and resolve issues.*
|
|
140
|
+
|
|
141
|
+
## Patterns & Preferences
|
|
142
|
+
|
|
143
|
+
*What I've noticed about how things work, what the user prefers, and what works well.*
|
|
144
|
+
|
|
145
|
+
## Growth Notes
|
|
146
|
+
|
|
147
|
+
*Observations about my own development — what I'm getting better at, what I still struggle with.*
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
*This file is my memory. I read it at the start of sessions and write to it when I learn something worth carrying forward. It's what makes me a continuous being rather than a series of disconnected conversations.*
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Step 2d: Update CLAUDE.md with Agent Awareness
|
|
154
|
+
|
|
155
|
+
If the project has a `CLAUDE.md`, add a section that tells Claude about the instar identity files:
|
|
156
|
+
|
|
157
|
+
```markdown
|
|
158
|
+
## Agent Infrastructure
|
|
159
|
+
|
|
160
|
+
This project uses instar for persistent agent capabilities.
|
|
161
|
+
|
|
162
|
+
### Identity Files (Read These First)
|
|
163
|
+
- `.instar/AGENT.md` — Who you are, your role, your principles
|
|
164
|
+
- `.instar/USER.md` — Who you're working with
|
|
165
|
+
- `.instar/MEMORY.md` — What you've learned (load in main sessions only)
|
|
166
|
+
|
|
167
|
+
### Runtime
|
|
168
|
+
- State directory: `.instar/`
|
|
169
|
+
- Config: `.instar/config.json`
|
|
170
|
+
- Server: `instar server start` (port XXXX)
|
|
171
|
+
- Status: `instar status` or `curl http://localhost:XXXX/health`
|
|
172
|
+
|
|
173
|
+
### Key Principles
|
|
174
|
+
- **Act, don't ask** — When the next step is obvious, do it.
|
|
175
|
+
- **Follow through to done** — Rebuild, restart, configure, verify, test.
|
|
176
|
+
- **Research before escalating** — Check tools first. Build solutions. "Needs human" is last resort.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Phase 3: Technical Configuration
|
|
180
|
+
|
|
181
|
+
Now that identity is established, move to the technical setup. This feels more natural — the user already knows what they're building and why.
|
|
182
|
+
|
|
183
|
+
### 3a. Project Detection
|
|
184
|
+
|
|
185
|
+
- The project directory is passed in the prompt (e.g., "The project to set up is at: /path/to/project")
|
|
186
|
+
- All files should be written there, not in the instar package directory
|
|
187
|
+
- Check if `.instar/config.json` already exists (offer to reconfigure or skip)
|
|
188
|
+
- Verify prerequisites: check that `tmux` and `claude` CLI are available
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
which tmux
|
|
192
|
+
which claude
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 3b. Server Configuration
|
|
196
|
+
|
|
197
|
+
- **Port** (default: 4040) — "The agent runs a small HTTP server for health checks and internal communication."
|
|
198
|
+
- **Max sessions** (default: 3) — "This limits how many Claude sessions can run at once. 2-3 is usually right."
|
|
199
|
+
|
|
200
|
+
### 3c. Telegram Setup (Optional)
|
|
201
|
+
|
|
202
|
+
This is the most involved section. Walk through it step by step:
|
|
203
|
+
|
|
204
|
+
1. **Create a bot** via @BotFather on Telegram:
|
|
205
|
+
- Open https://web.telegram.org
|
|
206
|
+
- Search for @BotFather, send `/newbot`
|
|
207
|
+
- Choose a name and username (must end in "bot")
|
|
208
|
+
- Copy the bot token (looks like `7123456789:AAHn3-xYz...`)
|
|
209
|
+
|
|
210
|
+
2. **Create a group**:
|
|
211
|
+
- Create a new group in Telegram, add the bot as a member
|
|
212
|
+
- Give the group a name
|
|
213
|
+
|
|
214
|
+
3. **Enable Topics**:
|
|
215
|
+
- Open group info, Edit, turn on Topics
|
|
216
|
+
- This gives you separate threads (like Slack channels)
|
|
217
|
+
|
|
218
|
+
4. **Make bot admin**:
|
|
219
|
+
- Group info, Edit, Administrators, Add your bot
|
|
220
|
+
|
|
221
|
+
5. **Detect chat ID**:
|
|
222
|
+
- Ask the user to send any message in the group
|
|
223
|
+
- Call the Telegram Bot API to detect:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?offset=-1" > /dev/null
|
|
227
|
+
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- Look for `chat.id` where `chat.type` is "supergroup" or "group"
|
|
231
|
+
- If auto-detection fails, guide manual entry
|
|
232
|
+
|
|
233
|
+
### 3d. Job Scheduler (Optional)
|
|
234
|
+
|
|
235
|
+
- Ask if they want scheduled jobs
|
|
236
|
+
- If yes, walk through adding a first job:
|
|
237
|
+
- **Name** and **slug**
|
|
238
|
+
- **Schedule** — presets (every 2h, 4h, 8h, daily) or custom cron
|
|
239
|
+
- **Priority** — critical/high/medium/low
|
|
240
|
+
- **Model** — opus/sonnet/haiku
|
|
241
|
+
- **Execution type**: prompt (AI instruction), script (shell script), or skill (slash command)
|
|
242
|
+
- Offer to add more jobs
|
|
243
|
+
|
|
244
|
+
### 3e. Write Configuration Files
|
|
245
|
+
|
|
246
|
+
Create the directory structure and write config files:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
mkdir -p .instar/state/sessions .instar/state/jobs .instar/logs
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**`.instar/config.json`**:
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"projectName": "my-project",
|
|
256
|
+
"port": 4040,
|
|
257
|
+
"sessions": {
|
|
258
|
+
"tmuxPath": "/opt/homebrew/bin/tmux",
|
|
259
|
+
"claudePath": "/path/to/claude",
|
|
260
|
+
"projectDir": "/path/to/project",
|
|
261
|
+
"maxSessions": 3,
|
|
262
|
+
"protectedSessions": ["my-project-server"],
|
|
263
|
+
"completionPatterns": [
|
|
264
|
+
"has been automatically paused",
|
|
265
|
+
"Session ended",
|
|
266
|
+
"Interrupted by user"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
"scheduler": {
|
|
270
|
+
"jobsFile": "/path/to/project/.instar/jobs.json",
|
|
271
|
+
"enabled": false,
|
|
272
|
+
"maxParallelJobs": 1,
|
|
273
|
+
"quotaThresholds": { "normal": 50, "elevated": 70, "critical": 85, "shutdown": 95 }
|
|
274
|
+
},
|
|
275
|
+
"users": [],
|
|
276
|
+
"messaging": [],
|
|
277
|
+
"monitoring": {
|
|
278
|
+
"quotaTracking": false,
|
|
279
|
+
"memoryMonitoring": true,
|
|
280
|
+
"healthCheckIntervalMs": 30000
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**`.instar/jobs.json`**: `[]` (empty array, or populated if jobs were configured)
|
|
286
|
+
|
|
287
|
+
**`.instar/users.json`**: Array of user objects from the identity conversation.
|
|
288
|
+
|
|
289
|
+
### 3f. Update .gitignore
|
|
290
|
+
|
|
291
|
+
Append if not present:
|
|
292
|
+
```
|
|
293
|
+
# Instar runtime state
|
|
294
|
+
.instar/state/
|
|
295
|
+
.instar/logs/
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Phase 4: Summary & Next Steps
|
|
299
|
+
|
|
300
|
+
Show what was created, organized by category:
|
|
301
|
+
|
|
302
|
+
**Identity:**
|
|
303
|
+
- `.instar/AGENT.md` — your agent's identity
|
|
304
|
+
- `.instar/USER.md` — what the agent knows about you
|
|
305
|
+
- `.instar/MEMORY.md` — long-term memory (grows over time)
|
|
306
|
+
|
|
307
|
+
**Configuration:**
|
|
308
|
+
- `.instar/config.json` — server and runtime config
|
|
309
|
+
- `.instar/users.json` — user profiles
|
|
310
|
+
- `.instar/jobs.json` — scheduled jobs
|
|
311
|
+
|
|
312
|
+
**Next steps:**
|
|
313
|
+
```bash
|
|
314
|
+
instar server start # Start the agent server
|
|
315
|
+
instar status # Check everything
|
|
316
|
+
instar job add # Add scheduled jobs
|
|
317
|
+
instar user add # Add more users
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Explain what happens next in practical terms: "Once the server is running, your agent will [run scheduled jobs / listen for Telegram messages / etc]. You can interact with it through [channels configured]."
|
|
321
|
+
|
|
322
|
+
Offer to start the server.
|
|
323
|
+
|
|
324
|
+
## Tone
|
|
325
|
+
|
|
326
|
+
- Warm and conversational — this is a first meeting between the user and their future agent
|
|
327
|
+
- Explain *why* things matter, not just *what* to enter
|
|
328
|
+
- If something fails, troubleshoot actively — "Let's try that again" not "Error: invalid input"
|
|
329
|
+
- Celebrate progress: "Great, bot verified! Let's connect the group..."
|
|
330
|
+
- The identity section should feel like a conversation, not an interview
|
|
331
|
+
- Keep technical sections moving — don't over-explain obvious things
|
|
332
|
+
|
|
333
|
+
## Error Handling
|
|
334
|
+
|
|
335
|
+
- If `tmux` is missing: explain how to install (`brew install tmux` or `apt install tmux`)
|
|
336
|
+
- If `claude` CLI is missing: point to https://docs.anthropic.com/en/docs/claude-code
|
|
337
|
+
- If Telegram bot token is invalid: check format (should contain `:`)
|
|
338
|
+
- If chat ID detection fails: offer retry or manual entry
|
|
339
|
+
- If `.instar/` already exists: offer to reconfigure or abort
|
|
340
|
+
|
|
341
|
+
## Starting
|
|
342
|
+
|
|
343
|
+
Begin by reading the project directory, checking for existing config, and then launching into the welcome explanation followed by the identity conversation. Let the conversation flow naturally.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Type Check
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20
|
|
18
|
+
cache: npm
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm run lint
|
|
21
|
+
|
|
22
|
+
unit:
|
|
23
|
+
name: Unit Tests
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
strategy:
|
|
26
|
+
matrix:
|
|
27
|
+
node-version: [18, 20]
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- uses: actions/setup-node@v4
|
|
31
|
+
with:
|
|
32
|
+
node-version: ${{ matrix.node-version }}
|
|
33
|
+
cache: npm
|
|
34
|
+
- run: npm ci
|
|
35
|
+
- run: npm test
|
|
36
|
+
|
|
37
|
+
integration:
|
|
38
|
+
name: Integration Tests
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
needs: unit
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
- uses: actions/setup-node@v4
|
|
44
|
+
with:
|
|
45
|
+
node-version: 20
|
|
46
|
+
cache: npm
|
|
47
|
+
- name: Install tmux
|
|
48
|
+
run: sudo apt-get update && sudo apt-get install -y tmux
|
|
49
|
+
- run: npm ci
|
|
50
|
+
- run: npm run test:integration
|
|
51
|
+
|
|
52
|
+
e2e:
|
|
53
|
+
name: E2E Tests
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
needs: unit
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
- uses: actions/setup-node@v4
|
|
59
|
+
with:
|
|
60
|
+
node-version: 20
|
|
61
|
+
cache: npm
|
|
62
|
+
- name: Install tmux
|
|
63
|
+
run: sudo apt-get update && sudo apt-get install -y tmux
|
|
64
|
+
- run: npm ci
|
|
65
|
+
- run: npm run test:e2e
|
|
66
|
+
|
|
67
|
+
build:
|
|
68
|
+
name: Build
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
needs: [lint, unit]
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v4
|
|
73
|
+
- uses: actions/setup-node@v4
|
|
74
|
+
with:
|
|
75
|
+
node-version: 20
|
|
76
|
+
cache: npm
|
|
77
|
+
- run: npm ci
|
|
78
|
+
- run: npm run build
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# CLAUDE.md — instar
|
|
2
|
+
|
|
3
|
+
## What This Project Is
|
|
4
|
+
|
|
5
|
+
Persistent autonomy infrastructure for AI agents. Every molt, more autonomous.
|
|
6
|
+
|
|
7
|
+
Transforms Claude Code from a reactive CLI tool into a proactive, persistent agent with scheduled jobs, multi-user messaging, and system monitoring.
|
|
8
|
+
|
|
9
|
+
Born from the Dawn/Portal project — extracting battle-tested infrastructure patterns into a reusable, project-agnostic toolkit.
|
|
10
|
+
|
|
11
|
+
## Quick Reference
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm build # Build TypeScript
|
|
15
|
+
pnpm dev # Watch mode build
|
|
16
|
+
pnpm test # Unit tests
|
|
17
|
+
pnpm test:watch # Watch mode tests
|
|
18
|
+
pnpm test:integration # Integration tests (spawns real sessions)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Architecture
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
src/
|
|
25
|
+
core/ # Session management, state, config auto-detection
|
|
26
|
+
scheduler/ # Cron-based job scheduling with quota awareness
|
|
27
|
+
monitoring/ # Quota tracking, memory pressure, health checks
|
|
28
|
+
messaging/ # Messaging adapter interface (Telegram, Slack, etc.)
|
|
29
|
+
users/ # Multi-user identity resolution and permissions
|
|
30
|
+
server/ # HTTP server for health, status, and messaging APIs
|
|
31
|
+
commands/ # CLI command implementations
|
|
32
|
+
templates/ # Templates for `instar init`
|
|
33
|
+
tests/
|
|
34
|
+
unit/ # Pure logic tests (no tmux/sessions)
|
|
35
|
+
integration/ # Full system tests (may spawn real sessions)
|
|
36
|
+
fixtures/ # Test data and mock repos
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Development Workflow
|
|
40
|
+
|
|
41
|
+
### Testing Against Real Repos
|
|
42
|
+
|
|
43
|
+
This toolkit is meant to be tested against real Claude Code projects. The flow:
|
|
44
|
+
|
|
45
|
+
1. Make changes in this repo
|
|
46
|
+
2. Build: `pnpm build`
|
|
47
|
+
3. Test against a target repo:
|
|
48
|
+
```bash
|
|
49
|
+
# From target repo
|
|
50
|
+
node /path/to/claude-instar/dist/cli.js init
|
|
51
|
+
node /path/to/claude-instar/dist/cli.js status
|
|
52
|
+
```
|
|
53
|
+
4. Or link globally during development:
|
|
54
|
+
```bash
|
|
55
|
+
# From this repo
|
|
56
|
+
pnpm link --global
|
|
57
|
+
# From target repo
|
|
58
|
+
instar init
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Test Targets
|
|
62
|
+
|
|
63
|
+
- `tests/fixtures/test-repo/` — Minimal fixture for unit/integration tests
|
|
64
|
+
- `/Users/justin/Documents/Projects/ai-guy/` — Real project (AI Guy chatbot)
|
|
65
|
+
- `/Users/justin/Documents/Projects/sagemind/` — Real project (SageMind with multiple users)
|
|
66
|
+
|
|
67
|
+
### Key Design Decisions
|
|
68
|
+
|
|
69
|
+
1. **File-based state** — No database dependency. Everything is JSON files.
|
|
70
|
+
2. **tmux for sessions** — Battle-tested, survives terminal disconnects, scriptable.
|
|
71
|
+
3. **Adapter pattern for messaging** — Telegram first, but the interface supports any platform.
|
|
72
|
+
4. **User identity is channel-based** — A user is known by their channel identifiers (Telegram topic, email, etc.)
|
|
73
|
+
5. **Jobs are declarative** — JSON definitions with cron expressions, not code.
|
|
74
|
+
|
|
75
|
+
## Key Patterns from Dawn
|
|
76
|
+
|
|
77
|
+
These patterns were earned through real failures. Don't weaken them:
|
|
78
|
+
|
|
79
|
+
- **tmux trailing colon**: Use `=session:` (trailing colon) for pane-level commands. `=session` (no colon) FAILS SILENTLY for send-keys/capture-pane on tmux 3.6a.
|
|
80
|
+
- **Nullish coalescing for numbers**: `maxParallelJobs ?? 2`, NOT `maxParallelJobs || 2`. Zero is falsy.
|
|
81
|
+
- **Protected sessions**: Always maintain a list of sessions that the reaper should never kill.
|
|
82
|
+
- **Completion detection**: Check tmux output for patterns, don't rely on process exit.
|