pantheon-opencode 2.0.0-rc.1 → 2.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.
- package/AGENTS.global.md +2 -2
- package/AGENTS.md +8 -8
- package/CHANGELOG.md +92 -0
- package/README.md +15 -2
- package/README.pt-BR.md +15 -2
- package/bin/pantheon-init.mjs +13 -0
- package/commands/pantheon-audit.md +1 -1
- package/commands/pantheon-deepwork.md +1 -1
- package/commands/pantheon-optimize.md +41 -63
- package/package.json +4 -3
- package/plugin.json +1 -1
- package/prompts/optimize-database.prompt.md +5 -5
- package/prompts/plan-architecture.prompt.md +6 -6
- package/pyproject.toml +1 -1
- package/scripts/build-agents-md.mjs +10 -10
- package/scripts/build-plugin.mjs +26 -0
- package/scripts/install/opencode-version.mjs +17 -5
- package/scripts/install/opencode.mjs +8 -1
- package/scripts/optimize.mjs +322 -0
- package/scripts/prune.mjs +105 -14
- package/scripts/update.mjs +20 -15
- package/skills-lock.json +11 -11
- package/src/agents/aphrodite.md +15 -14
- package/src/agents/apollo.md +2 -1
- package/src/agents/athena.md +19 -12
- package/src/agents/demeter.md +2 -0
- package/src/agents/hephaestus.md +1 -0
- package/src/agents/hermes.md +19 -95
- package/src/agents/iris.md +3 -0
- package/src/agents/nyx.md +1 -0
- package/src/agents/prometheus.md +2 -0
- package/src/agents/talos.md +3 -0
- package/src/agents/themis.md +91 -87
- package/src/agents/zeus.md +41 -266
- package/src/instructions/agent-return-format.instructions.md +1 -1
- package/src/instructions/memory-protocol.instructions.md +1 -1
- package/src/instructions/zeus-anti-stall.instructions.md +3 -3
- package/src/instructions/zeus-communication-rules.instructions.md +1 -1
- package/src/instructions/zeus-council-synthesis.instructions.md +29 -10
- package/src/instructions/zeus-timeout-retry.instructions.md +10 -10
- package/src/pantheon/model-command.ts +12 -12
- package/src/pantheon/tools.ts +4 -0
- package/src/pantheon/tui-version-check.ts +1 -1
- package/src/pantheon/update-notifier.ts +13 -8
- package/src/pantheon/vision.ts +20 -20
- package/src/plugin/index.js +14594 -0
- package/src/plugins/tui/dist/tui.d.ts +3 -3
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +1028 -393
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/autonomy-state.ts +66 -25
- package/src/plugins/tui/src/decision-router-state.ts +59 -24
- package/src/plugins/tui/src/index.tsx +44 -23
- package/src/plugins/tui/src/j1-gate-status.ts +26 -9
- package/src/plugins/tui/src/pantheon-settings.tsx +484 -124
- package/src/plugins/tui/src/settings-i18n.ts +203 -0
- package/src/plugins/tui/src/tui-prefs.ts +131 -4
- package/src/plugins/tui/src/update-notice.ts +9 -6
- package/src/plugins/tui/src/whats-new-open.ts +4 -4
- package/src/plugins/tui/src/whats-new.tsx +119 -17
- package/src/skills/agent-coordination/SKILL.md +6 -6
- package/src/skills/artifact-management/SKILL.md +43 -39
- package/src/skills/artifact-management/references/artifact-templates.md +103 -48
- package/src/skills/auto-continue/references/auto-continue-details.md +13 -13
- package/src/skills/code-review-checklist/SKILL.md +6 -6
- package/src/skills/incremental-implementation/SKILL.md +13 -13
- package/src/skills/memory-bank/references/anti-patterns.md +3 -3
- package/src/skills/spec-driven-development/SKILL.md +12 -14
- package/src/skills/tdd-with-agents/SKILL.md +6 -5
- package/src/skills/visual-review-pipeline/SKILL.md +1 -1
- package/src/skills/visual-review-pipeline/references/workflow-steps.md +1 -1
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* optimize.mjs — Pantheon project and deepwork optimizer CLI
|
|
4
|
+
*
|
|
5
|
+
* Scans, cleans, and archives Pantheon workspace artifacts:
|
|
6
|
+
* - Archives or cleans resolved/completed deepwork sessions in .pantheon/deepwork/
|
|
7
|
+
* - Prunes stale backups in .pantheon/backups/ older than threshold
|
|
8
|
+
* - Cleans old debug logs in .pantheon/logs/
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* pantheon-opencode optimize # dry-run preview (default)
|
|
12
|
+
* pantheon-opencode optimize --apply # archive completed deepwork + clean logs
|
|
13
|
+
* pantheon-opencode optimize --clean # permanently delete completed deepwork
|
|
14
|
+
* pantheon-opencode optimize --age <days> # custom age threshold (default: 7)
|
|
15
|
+
* pantheon-opencode optimize --target <d> # target workspace root
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { execSync } from 'node:child_process'
|
|
19
|
+
import {
|
|
20
|
+
existsSync,
|
|
21
|
+
mkdirSync,
|
|
22
|
+
readdirSync,
|
|
23
|
+
readFileSync,
|
|
24
|
+
renameSync,
|
|
25
|
+
rmSync,
|
|
26
|
+
statSync,
|
|
27
|
+
} from 'node:fs'
|
|
28
|
+
import { join, resolve } from 'node:path'
|
|
29
|
+
import { fileURLToPath } from 'node:url'
|
|
30
|
+
|
|
31
|
+
const DEFAULT_DEEPWORK_AGE_DAYS = 7
|
|
32
|
+
const DEFAULT_BACKUP_AGE_DAYS = 14
|
|
33
|
+
const MS_PER_DAY = 86_400_000
|
|
34
|
+
|
|
35
|
+
export function scanDeepwork(targetDir, ageDays = DEFAULT_DEEPWORK_AGE_DAYS) {
|
|
36
|
+
const deepworkDir = join(targetDir, '.pantheon', 'deepwork')
|
|
37
|
+
if (!existsSync(deepworkDir)) return []
|
|
38
|
+
|
|
39
|
+
const now = Date.now()
|
|
40
|
+
const cutoff = now - ageDays * MS_PER_DAY
|
|
41
|
+
const results = []
|
|
42
|
+
|
|
43
|
+
let entries = []
|
|
44
|
+
try {
|
|
45
|
+
entries = readdirSync(deepworkDir, { withFileTypes: true })
|
|
46
|
+
} catch {
|
|
47
|
+
return []
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
if (!entry.isDirectory() || entry.name === 'archive') continue
|
|
52
|
+
const slugDir = join(deepworkDir, entry.name)
|
|
53
|
+
|
|
54
|
+
// Never clean up directories containing tracked git files
|
|
55
|
+
try {
|
|
56
|
+
const gitTracked = execSync(`git ls-files "${slugDir}"`, {
|
|
57
|
+
encoding: 'utf8',
|
|
58
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
59
|
+
}).trim()
|
|
60
|
+
if (gitTracked.length > 0) continue
|
|
61
|
+
} catch {}
|
|
62
|
+
|
|
63
|
+
let isCompleted = false
|
|
64
|
+
let reason = 'in-progress'
|
|
65
|
+
const reviewPath = join(slugDir, 'REVIEW.md')
|
|
66
|
+
const statusPath = join(slugDir, 'STATUS.md')
|
|
67
|
+
|
|
68
|
+
if (existsSync(reviewPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const reviewText = readFileSync(reviewPath, 'utf8')
|
|
71
|
+
if (/APPROVED|PASS|COMPLETE/i.test(reviewText)) {
|
|
72
|
+
isCompleted = true
|
|
73
|
+
reason = 'reviewed and approved'
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!isCompleted && existsSync(statusPath)) {
|
|
79
|
+
try {
|
|
80
|
+
const statusText = readFileSync(statusPath, 'utf8')
|
|
81
|
+
if (/status:\s*(?:complete|finished|done)/i.test(statusText)) {
|
|
82
|
+
isCompleted = true
|
|
83
|
+
reason = 'status marked complete'
|
|
84
|
+
}
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Check directory modification age
|
|
89
|
+
let mtime = 0
|
|
90
|
+
try {
|
|
91
|
+
mtime = statSync(slugDir).mtimeMs
|
|
92
|
+
} catch {}
|
|
93
|
+
|
|
94
|
+
if (!isCompleted && mtime > 0 && mtime < cutoff) {
|
|
95
|
+
isCompleted = true
|
|
96
|
+
reason = `inactive for >${ageDays} days`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
results.push({
|
|
100
|
+
slug: entry.name,
|
|
101
|
+
path: slugDir,
|
|
102
|
+
completed: isCompleted,
|
|
103
|
+
reason,
|
|
104
|
+
mtime,
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return results
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function scanBackups(targetDir, ageDays = DEFAULT_BACKUP_AGE_DAYS) {
|
|
112
|
+
const backupsDir = join(targetDir, '.pantheon', 'backups')
|
|
113
|
+
if (!existsSync(backupsDir)) return []
|
|
114
|
+
|
|
115
|
+
const now = Date.now()
|
|
116
|
+
const cutoff = now - ageDays * MS_PER_DAY
|
|
117
|
+
const results = []
|
|
118
|
+
|
|
119
|
+
let entries = []
|
|
120
|
+
try {
|
|
121
|
+
entries = readdirSync(backupsDir, { withFileTypes: true })
|
|
122
|
+
} catch {
|
|
123
|
+
return []
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const dirs = entries
|
|
127
|
+
.filter((e) => e.isDirectory())
|
|
128
|
+
.map((e) => {
|
|
129
|
+
const p = join(backupsDir, e.name)
|
|
130
|
+
let mtime = 0
|
|
131
|
+
try {
|
|
132
|
+
mtime = statSync(p).mtimeMs
|
|
133
|
+
} catch {}
|
|
134
|
+
return { name: e.name, path: p, mtime }
|
|
135
|
+
})
|
|
136
|
+
.sort((a, b) => b.mtime - a.mtime) // newest first
|
|
137
|
+
|
|
138
|
+
// Keep at least the latest 3 backups regardless of age
|
|
139
|
+
for (let i = 3; i < dirs.length; i++) {
|
|
140
|
+
const item = dirs[i]
|
|
141
|
+
if (item.mtime > 0 && item.mtime < cutoff) {
|
|
142
|
+
results.push(item)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return results
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function scanLogs(targetDir, ageDays = 7) {
|
|
150
|
+
const logsDir = join(targetDir, '.pantheon', 'logs')
|
|
151
|
+
if (!existsSync(logsDir)) return []
|
|
152
|
+
|
|
153
|
+
const now = Date.now()
|
|
154
|
+
const cutoff = now - ageDays * MS_PER_DAY
|
|
155
|
+
const results = []
|
|
156
|
+
|
|
157
|
+
let entries = []
|
|
158
|
+
try {
|
|
159
|
+
entries = readdirSync(logsDir, { withFileTypes: true })
|
|
160
|
+
} catch {
|
|
161
|
+
return []
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (const entry of entries) {
|
|
165
|
+
if (!entry.isFile()) continue
|
|
166
|
+
const p = join(logsDir, entry.name)
|
|
167
|
+
let mtime = 0
|
|
168
|
+
try {
|
|
169
|
+
mtime = statSync(p).mtimeMs
|
|
170
|
+
} catch {}
|
|
171
|
+
if (mtime > 0 && mtime < cutoff) {
|
|
172
|
+
results.push({ name: entry.name, path: p, mtime })
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return results
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function runOptimize(options = {}) {
|
|
180
|
+
const targetDir = resolve(options.target || process.cwd())
|
|
181
|
+
const apply = Boolean(options.apply || options.yes)
|
|
182
|
+
const clean = Boolean(options.clean)
|
|
183
|
+
const ageDays = options.age ? Number(options.age) : DEFAULT_DEEPWORK_AGE_DAYS
|
|
184
|
+
|
|
185
|
+
console.log('Pantheon Optimizer — Workspace Inspection')
|
|
186
|
+
console.log(`Target: ${targetDir}`)
|
|
187
|
+
console.log(
|
|
188
|
+
`Mode: ${apply ? (clean ? 'apply (clean/delete)' : 'apply (archive)') : 'dry-run (preview only)'}`,
|
|
189
|
+
)
|
|
190
|
+
console.log('────────────────────────────────────────────────────────────')
|
|
191
|
+
|
|
192
|
+
const deepworks = scanDeepwork(targetDir, ageDays)
|
|
193
|
+
const completedDeepworks = deepworks.filter((d) => d.completed)
|
|
194
|
+
const activeDeepworks = deepworks.filter((d) => !d.completed)
|
|
195
|
+
const staleBackups = scanBackups(targetDir)
|
|
196
|
+
const staleLogs = scanLogs(targetDir)
|
|
197
|
+
|
|
198
|
+
console.log(`Deepwork sessions: ${deepworks.length} total`)
|
|
199
|
+
if (completedDeepworks.length > 0) {
|
|
200
|
+
console.log(` Resolvable candidates (${completedDeepworks.length}):`)
|
|
201
|
+
for (const d of completedDeepworks) {
|
|
202
|
+
console.log(` - ${d.slug} (${d.reason})`)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (activeDeepworks.length > 0) {
|
|
206
|
+
console.log(` Active sessions kept (${activeDeepworks.length}):`)
|
|
207
|
+
for (const d of activeDeepworks) {
|
|
208
|
+
console.log(` - ${d.slug} (in-progress)`)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
console.log(`Stale backups: ${staleBackups.length} candidates (>14 days, keeping 3 latest)`)
|
|
213
|
+
console.log(`Stale logs: ${staleLogs.length} candidates (>7 days)`)
|
|
214
|
+
|
|
215
|
+
if (!apply) {
|
|
216
|
+
console.log('────────────────────────────────────────────────────────────')
|
|
217
|
+
console.log('[DRY-RUN] No changes made.')
|
|
218
|
+
console.log('To archive resolved deepworks: pantheon-opencode optimize --apply')
|
|
219
|
+
console.log(
|
|
220
|
+
'To permanently delete resolved deepworks: pantheon-opencode optimize --clean --apply',
|
|
221
|
+
)
|
|
222
|
+
return { ok: true, changed: false }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
console.log('────────────────────────────────────────────────────────────')
|
|
226
|
+
console.log('Applying optimization plan...')
|
|
227
|
+
|
|
228
|
+
// 1. Deepwork
|
|
229
|
+
if (completedDeepworks.length > 0) {
|
|
230
|
+
if (clean) {
|
|
231
|
+
for (const d of completedDeepworks) {
|
|
232
|
+
try {
|
|
233
|
+
rmSync(d.path, { recursive: true, force: true })
|
|
234
|
+
console.log(` [CLEAN] Removed ${d.slug}`)
|
|
235
|
+
} catch (e) {
|
|
236
|
+
console.error(` [ERROR] Failed to remove ${d.slug}: ${e.message}`)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
const archiveDir = join(targetDir, '.pantheon', 'deepwork', 'archive')
|
|
241
|
+
mkdirSync(archiveDir, { recursive: true })
|
|
242
|
+
for (const d of completedDeepworks) {
|
|
243
|
+
try {
|
|
244
|
+
const dest = join(archiveDir, d.slug)
|
|
245
|
+
if (existsSync(dest)) {
|
|
246
|
+
rmSync(dest, { recursive: true, force: true })
|
|
247
|
+
}
|
|
248
|
+
renameSync(d.path, dest)
|
|
249
|
+
console.log(` [ARCHIVE] Moved ${d.slug} -> archive/${d.slug}`)
|
|
250
|
+
} catch (e) {
|
|
251
|
+
console.error(` [ERROR] Failed to archive ${d.slug}: ${e.message}`)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 2. Backups
|
|
258
|
+
for (const b of staleBackups) {
|
|
259
|
+
try {
|
|
260
|
+
rmSync(b.path, { recursive: true, force: true })
|
|
261
|
+
console.log(` [CLEAN] Removed stale backup ${b.name}`)
|
|
262
|
+
} catch (e) {
|
|
263
|
+
console.error(` [ERROR] Failed to remove backup ${b.name}: ${e.message}`)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 3. Logs
|
|
268
|
+
for (const l of staleLogs) {
|
|
269
|
+
try {
|
|
270
|
+
rmSync(l.path, { force: true })
|
|
271
|
+
console.log(` [CLEAN] Removed stale log ${l.name}`)
|
|
272
|
+
} catch (e) {
|
|
273
|
+
console.error(` [ERROR] Failed to remove log ${l.name}: ${e.message}`)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
console.log('────────────────────────────────────────────────────────────')
|
|
278
|
+
console.log('[OK] Workspace optimization complete.')
|
|
279
|
+
return { ok: true, changed: true }
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function printUsage() {
|
|
283
|
+
console.log('Usage: pantheon-opencode optimize [options]')
|
|
284
|
+
console.log('')
|
|
285
|
+
console.log('Options:')
|
|
286
|
+
console.log(' --apply, --yes Apply the changes (default: dry-run)')
|
|
287
|
+
console.log(' --clean Delete completed deepwork instead of archiving')
|
|
288
|
+
console.log(' --age <days> Inactivity threshold in days (default: 7)')
|
|
289
|
+
console.log(' --target <dir> Target workspace directory (default: cwd)')
|
|
290
|
+
console.log(' --help Show this help message')
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// CLI entry point when run directly
|
|
294
|
+
if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
|
|
295
|
+
const args = process.argv.slice(2)
|
|
296
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
297
|
+
printUsage()
|
|
298
|
+
process.exit(0)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const options = {
|
|
302
|
+
apply: args.includes('--apply') || args.includes('--yes') || args.includes('-y'),
|
|
303
|
+
clean: args.includes('--clean'),
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
for (let i = 0; i < args.length; i++) {
|
|
307
|
+
if (args[i] === '--age' && args[i + 1]) {
|
|
308
|
+
options.age = Number(args[i + 1])
|
|
309
|
+
i++
|
|
310
|
+
} else if (args[i].startsWith('--age=')) {
|
|
311
|
+
options.age = Number(args[i].split('=')[1])
|
|
312
|
+
} else if (args[i] === '--target' && args[i + 1]) {
|
|
313
|
+
options.target = args[i + 1]
|
|
314
|
+
i++
|
|
315
|
+
} else if (args[i].startsWith('--target=')) {
|
|
316
|
+
options.target = args[i].split('=')[1]
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const result = runOptimize(options)
|
|
321
|
+
process.exit(result.ok ? 0 : 1)
|
|
322
|
+
}
|
package/scripts/prune.mjs
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import { execSync } from 'node:child_process'
|
|
34
34
|
import { existsSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs'
|
|
35
35
|
import { homedir } from 'node:os'
|
|
36
|
-
import { dirname, join, resolve } from 'node:path'
|
|
36
|
+
import { basename, dirname, join, resolve } from 'node:path'
|
|
37
37
|
import { fileURLToPath } from 'node:url'
|
|
38
38
|
|
|
39
39
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
@@ -232,28 +232,104 @@ export function findLegacyInstallDir(configDir) {
|
|
|
232
232
|
)
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// Deepwork & Worktrees prune
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
export function findStaleDeepwork(repoDir, maxAgeDays, deepworkFlag = false) {
|
|
240
|
+
const deepworkDir = join(repoDir, '.pantheon', 'deepwork')
|
|
241
|
+
if (!existsSync(deepworkDir)) return
|
|
242
|
+
try {
|
|
243
|
+
const entries = readdirSync(deepworkDir, { withFileTypes: true })
|
|
244
|
+
const now = Date.now()
|
|
245
|
+
const maxAgeMs = maxAgeDays * 86_400_000
|
|
246
|
+
for (const entry of entries) {
|
|
247
|
+
if (!entry.isDirectory()) continue
|
|
248
|
+
const targetDir = join(deepworkDir, entry.name)
|
|
249
|
+
const st = statSync(targetDir)
|
|
250
|
+
const ageDays = Math.round((now - st.mtimeMs) / 86_400_000)
|
|
251
|
+
const isStale = now - st.mtimeMs > maxAgeMs
|
|
252
|
+
if (isStale || deepworkFlag) {
|
|
253
|
+
add(
|
|
254
|
+
'deepwork',
|
|
255
|
+
targetDir,
|
|
256
|
+
`deepwork session directory (${ageDays}d old)`,
|
|
257
|
+
deepworkFlag ? 'remove' : 'list',
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} catch {
|
|
262
|
+
// best-effort
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function findStaleWorktrees(repoDir, worktreesFlag = false) {
|
|
267
|
+
const repoParent = dirname(resolve(repoDir))
|
|
268
|
+
const repoBase = basename(resolve(repoDir))
|
|
269
|
+
const worktreeParent = join(repoParent, '.pantheon-worktrees', repoBase)
|
|
270
|
+
if (!existsSync(worktreeParent)) return
|
|
271
|
+
try {
|
|
272
|
+
const entries = readdirSync(worktreeParent, { withFileTypes: true })
|
|
273
|
+
for (const entry of entries) {
|
|
274
|
+
if (!entry.isDirectory()) continue
|
|
275
|
+
const targetDir = join(worktreeParent, entry.name)
|
|
276
|
+
add(
|
|
277
|
+
'worktree',
|
|
278
|
+
targetDir,
|
|
279
|
+
`worktree directory for task '${entry.name}'`,
|
|
280
|
+
worktreesFlag ? 'remove' : 'list',
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
} catch {
|
|
284
|
+
// best-effort
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
235
288
|
// ---------------------------------------------------------------------------
|
|
236
289
|
// Actions
|
|
237
290
|
// ---------------------------------------------------------------------------
|
|
238
291
|
|
|
239
292
|
function format(f) {
|
|
240
|
-
const
|
|
241
|
-
f.action === 'remove'
|
|
242
|
-
|
|
293
|
+
const marker =
|
|
294
|
+
f.action === 'remove'
|
|
295
|
+
? '[-]'
|
|
296
|
+
: f.action === 'suggest'
|
|
297
|
+
? '[?]'
|
|
298
|
+
: f.action === 'keep'
|
|
299
|
+
? '[+]'
|
|
300
|
+
: '[*]'
|
|
301
|
+
return `${marker} [${f.type}] ${f.target} — ${f.detail}`
|
|
243
302
|
}
|
|
244
303
|
|
|
245
|
-
export function runPrune({
|
|
304
|
+
export function runPrune({
|
|
305
|
+
configDir,
|
|
306
|
+
repoDir,
|
|
307
|
+
maxAgeDays,
|
|
308
|
+
apply,
|
|
309
|
+
removeDirs,
|
|
310
|
+
deepwork,
|
|
311
|
+
worktrees,
|
|
312
|
+
}) {
|
|
313
|
+
findings.length = 0
|
|
246
314
|
findLegacyGlobalInstalls()
|
|
247
315
|
findStaleBackups(configDir, maxAgeDays)
|
|
248
316
|
findLegacyDirs(configDir)
|
|
249
317
|
findLegacyInstallDir(configDir)
|
|
318
|
+
if (deepwork || repoDir) {
|
|
319
|
+
findStaleDeepwork(repoDir || _ROOT, maxAgeDays, deepwork)
|
|
320
|
+
}
|
|
321
|
+
if (worktrees || repoDir) {
|
|
322
|
+
findStaleWorktrees(repoDir || _ROOT, worktrees)
|
|
323
|
+
}
|
|
250
324
|
|
|
251
325
|
console.log(`Pantheon prune — config dir: ${configDir}`)
|
|
252
|
-
console.log(
|
|
326
|
+
console.log(
|
|
327
|
+
` mode: ${apply ? 'APPLY' : 'DRY-RUN'}${removeDirs ? ' + REMOVE-DIRS' : ''}${deepwork ? ' + DEEPWORK' : ''}${worktrees ? ' + WORKTREES' : ''}`,
|
|
328
|
+
)
|
|
253
329
|
console.log('')
|
|
254
330
|
|
|
255
331
|
if (findings.length === 0) {
|
|
256
|
-
console.log('
|
|
332
|
+
console.log(' Nothing to clean.')
|
|
257
333
|
return { removed: 0, remain: 0 }
|
|
258
334
|
}
|
|
259
335
|
|
|
@@ -263,12 +339,12 @@ export function runPrune({ configDir, maxAgeDays, apply, removeDirs }) {
|
|
|
263
339
|
console.log(` ${format(f)}`)
|
|
264
340
|
if (f.action === 'remove' && apply) {
|
|
265
341
|
try {
|
|
266
|
-
rmSync(f.target, { force: true })
|
|
267
|
-
console.log(
|
|
342
|
+
rmSync(f.target, { recursive: true, force: true })
|
|
343
|
+
console.log(' → removed')
|
|
268
344
|
removed++
|
|
269
345
|
continue
|
|
270
346
|
} catch (err) {
|
|
271
|
-
console.log(` →
|
|
347
|
+
console.log(` → failed: ${err.message}`)
|
|
272
348
|
remain++
|
|
273
349
|
continue
|
|
274
350
|
}
|
|
@@ -281,11 +357,11 @@ export function runPrune({ configDir, maxAgeDays, apply, removeDirs }) {
|
|
|
281
357
|
if (f.action === 'list' && apply && removeDirs) {
|
|
282
358
|
try {
|
|
283
359
|
rmSync(f.target, { recursive: true, force: true })
|
|
284
|
-
console.log(
|
|
360
|
+
console.log(' → removed (--remove-dirs)')
|
|
285
361
|
removed++
|
|
286
362
|
continue
|
|
287
363
|
} catch (err) {
|
|
288
|
-
console.log(` →
|
|
364
|
+
console.log(` → failed: ${err.message}`)
|
|
289
365
|
remain++
|
|
290
366
|
continue
|
|
291
367
|
}
|
|
@@ -323,7 +399,10 @@ Options:
|
|
|
323
399
|
--apply Remove stale backups (default: dry-run, list only)
|
|
324
400
|
--remove-dirs With --apply, also remove legacy directories
|
|
325
401
|
(explicit confirmation; default: list only)
|
|
402
|
+
--deepwork Find and remove stale deepwork session artifacts
|
|
403
|
+
--worktrees Find and clean up detached worktree directories
|
|
326
404
|
--target <dir> Override the config directory (XDG-aware by default)
|
|
405
|
+
--repo <dir> Override the project repository directory
|
|
327
406
|
--age <days> Backup age threshold in days (default: ${DEFAULT_BACKUP_AGE_DAYS})
|
|
328
407
|
--help Show this help
|
|
329
408
|
|
|
@@ -344,17 +423,29 @@ function main() {
|
|
|
344
423
|
|
|
345
424
|
const apply = args.includes('--apply') || args.includes('-y')
|
|
346
425
|
const removeDirs = args.includes('--remove-dirs')
|
|
426
|
+
const deepwork = args.includes('--deepwork')
|
|
427
|
+
const worktrees = args.includes('--worktrees')
|
|
347
428
|
const targetIdx = args.indexOf('--target')
|
|
348
429
|
const target = targetIdx >= 0 ? args[targetIdx + 1] : undefined
|
|
430
|
+
const repoIdx = args.indexOf('--repo')
|
|
431
|
+
const repoDir = repoIdx >= 0 ? args[repoIdx + 1] : undefined
|
|
349
432
|
const ageIdx = args.indexOf('--age')
|
|
350
433
|
const age = ageIdx >= 0 ? Number(args[ageIdx + 1]) : DEFAULT_BACKUP_AGE_DAYS
|
|
351
434
|
if (!Number.isFinite(age) || age < 0) {
|
|
352
|
-
console.error('
|
|
435
|
+
console.error('ERROR: --age must be a non-negative number of days')
|
|
353
436
|
process.exit(2)
|
|
354
437
|
}
|
|
355
438
|
|
|
356
439
|
const configDir = resolveConfigDir(target)
|
|
357
|
-
const result = runPrune({
|
|
440
|
+
const result = runPrune({
|
|
441
|
+
configDir,
|
|
442
|
+
repoDir,
|
|
443
|
+
maxAgeDays: age,
|
|
444
|
+
apply,
|
|
445
|
+
removeDirs,
|
|
446
|
+
deepwork,
|
|
447
|
+
worktrees,
|
|
448
|
+
})
|
|
358
449
|
|
|
359
450
|
// 0 = clean/cleaned; 1 = findings remain; 2 = usage error (handled above)
|
|
360
451
|
process.exit(result.remain > 0 ? 1 : 0)
|
package/scripts/update.mjs
CHANGED
|
@@ -6,11 +6,15 @@ import { assertNoSymlinkAncestors } from './install/verify.mjs'
|
|
|
6
6
|
function parseVersion(version) {
|
|
7
7
|
const match = String(version)
|
|
8
8
|
.trim()
|
|
9
|
-
.match(/^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/)
|
|
9
|
+
.match(/^(\d+)\.(\d+)\.(\d+)(?:-(beta|rc)\.(\d+))?$/)
|
|
10
10
|
if (!match) return null
|
|
11
|
+
const stage = match[4]
|
|
12
|
+
const stageNum = match[5] !== undefined ? +match[5] : 0
|
|
13
|
+
const stageRank = stage === 'beta' ? 1 : stage === 'rc' ? 2 : 3
|
|
11
14
|
return {
|
|
12
15
|
core: [+match[1], +match[2], +match[3]],
|
|
13
|
-
|
|
16
|
+
stageRank,
|
|
17
|
+
stageNum: stage ? stageNum : Number.POSITIVE_INFINITY,
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -21,7 +25,8 @@ function compareVersions(left, right) {
|
|
|
21
25
|
for (let index = 0; index < 3; index += 1) {
|
|
22
26
|
if (a.core[index] !== b.core[index]) return a.core[index] - b.core[index]
|
|
23
27
|
}
|
|
24
|
-
return a.
|
|
28
|
+
if (a.stageRank !== b.stageRank) return a.stageRank - b.stageRank
|
|
29
|
+
return a.stageNum - b.stageNum
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/** Update only the authorized global installation, then refresh its config. */
|
|
@@ -36,7 +41,7 @@ export function runUpdate(
|
|
|
36
41
|
refresh,
|
|
37
42
|
},
|
|
38
43
|
) {
|
|
39
|
-
const channel = args.includes('--stable') ? 'latest' : 'beta'
|
|
44
|
+
const channel = args.includes('--stable') ? 'latest' : args.includes('--rc') ? 'rc' : 'beta'
|
|
40
45
|
const globalRootResult = spawnSync('npm', ['root', '-g'], {
|
|
41
46
|
encoding: 'utf8',
|
|
42
47
|
timeout: 10_000,
|
|
@@ -87,7 +92,7 @@ export function runUpdate(
|
|
|
87
92
|
runningScriptPath !== path.join(globalPackageRoot, 'bin', 'pantheon-init.mjs')
|
|
88
93
|
) {
|
|
89
94
|
console.error(
|
|
90
|
-
'
|
|
95
|
+
'[ERROR] update is available only from the global Pantheon installation; local, workspace, and npx copies are refused. ' +
|
|
91
96
|
'Install globally with `npm install -g pantheon-opencode@beta`, then run `pantheon-opencode update`.',
|
|
92
97
|
)
|
|
93
98
|
return 1
|
|
@@ -101,14 +106,14 @@ export function runUpdate(
|
|
|
101
106
|
const latest = (view.stdout || '').trim().split('\n').filter(Boolean).pop()
|
|
102
107
|
if (view.status !== 0 || !latest) {
|
|
103
108
|
console.error(
|
|
104
|
-
|
|
109
|
+
`[ERROR] Could not reach the npm registry: ${(view.stderr || view.stdout || '').trim() || 'no version returned'}`,
|
|
105
110
|
)
|
|
106
111
|
return 1
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
if (compareVersions(latest, currentVersion) <= 0) {
|
|
110
115
|
console.log(
|
|
111
|
-
|
|
116
|
+
`[OK] Already up to date (installed v${currentVersion}; ${channel} channel: v${latest}).`,
|
|
112
117
|
)
|
|
113
118
|
return 0
|
|
114
119
|
}
|
|
@@ -116,15 +121,15 @@ export function runUpdate(
|
|
|
116
121
|
// A stable installation never jumps to a prerelease silently (you stay
|
|
117
122
|
// in charge): the jump needs explicit opt-in via --allow-prerelease. The
|
|
118
123
|
// remedy is printed, never guessed.
|
|
119
|
-
const isPrerelease = (version) => /-beta\.\d+$/.test(version)
|
|
124
|
+
const isPrerelease = (version) => /-(?:beta|rc)\.\d+$/.test(version)
|
|
120
125
|
const crossingToPrerelease = isPrerelease(latest) && !isPrerelease(currentVersion)
|
|
121
126
|
if (crossingToPrerelease && !args.includes('--allow-prerelease')) {
|
|
122
127
|
console.error(
|
|
123
|
-
'
|
|
128
|
+
'[ERROR] v' +
|
|
124
129
|
latest +
|
|
125
|
-
' is a
|
|
130
|
+
' is a prerelease and your installed v' +
|
|
126
131
|
currentVersion +
|
|
127
|
-
' is stable. A stable
|
|
132
|
+
' is stable. A stable->prerelease jump needs explicit opt-in: rerun with `update --allow-prerelease`, or stay on the stable line with `update --stable`.',
|
|
128
133
|
)
|
|
129
134
|
return 1
|
|
130
135
|
}
|
|
@@ -135,7 +140,7 @@ export function runUpdate(
|
|
|
135
140
|
})
|
|
136
141
|
if (install.status !== 0) {
|
|
137
142
|
console.error(
|
|
138
|
-
'
|
|
143
|
+
'[ERROR] npm install failed; npm global replacement is not atomic and may have partially changed the package. ' +
|
|
139
144
|
'Verify the global install with `pantheon-opencode --version` or reinstall the package.',
|
|
140
145
|
)
|
|
141
146
|
return install.status ?? 1
|
|
@@ -165,7 +170,7 @@ export function runUpdate(
|
|
|
165
170
|
}
|
|
166
171
|
if (refreshedVersion !== latest || !refreshedPackageRoot) {
|
|
167
172
|
console.error(
|
|
168
|
-
|
|
173
|
+
`[ERROR] npm reported success, but the global package is v${refreshedVersion ?? 'unknown'} (expected v${latest}); config refresh was not run.`,
|
|
169
174
|
)
|
|
170
175
|
return 1
|
|
171
176
|
}
|
|
@@ -183,10 +188,10 @@ export function runUpdate(
|
|
|
183
188
|
})
|
|
184
189
|
if (init.status !== 0 || init.error) {
|
|
185
190
|
console.error(
|
|
186
|
-
'
|
|
191
|
+
'[WARN] Updated, but the config refresh did not complete — run `npx pantheon-opencode init` manually.',
|
|
187
192
|
)
|
|
188
193
|
return init.status ?? 1
|
|
189
194
|
}
|
|
190
|
-
console.log(
|
|
195
|
+
console.log(`[OK] Updated to v${latest}.`)
|
|
191
196
|
return 0
|
|
192
197
|
}
|
package/skills-lock.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"src/skills/agent-coordination/SKILL.md": "
|
|
2
|
+
"src/skills/agent-coordination/SKILL.md": "0b002b322c2b35bf11bc3beb56de37a9614311d3883f0fa399f6dcbc5c8758af",
|
|
3
3
|
"src/skills/agent-forge/SKILL.md": "cbe09946a59fa45b471828d9de6e7bc5c4b2fa29e0ce48e21d188593ece6c046",
|
|
4
|
-
"src/skills/artifact-management/references/artifact-templates.md": "
|
|
5
|
-
"src/skills/artifact-management/SKILL.md": "
|
|
6
|
-
"src/skills/auto-continue/references/auto-continue-details.md": "
|
|
4
|
+
"src/skills/artifact-management/references/artifact-templates.md": "d1a5d082266311c362e63e097f461fe993a4eac7485c4a445fba7993c404e1c7",
|
|
5
|
+
"src/skills/artifact-management/SKILL.md": "d11bc6a9968758294bd9ae56dfa8df43090c5f1f7c4f706861687d8ac3bb88a2",
|
|
6
|
+
"src/skills/auto-continue/references/auto-continue-details.md": "3064ee565c9e6dd2724d1170404888a65d700aaec0058d3aa2be1acce4771e72",
|
|
7
7
|
"src/skills/auto-continue/SKILL.md": "7bfddd84f96b657043074a35ef2f524913ccbed2689fc8a26ad425167f4b77c5",
|
|
8
8
|
"src/skills/clonedeps/SKILL.md": "3e0b43cf96da98c83699dc48db3fd58fbfda84b9022bb70d3747875c81c3e124",
|
|
9
9
|
"src/skills/code-review-checklist/references/review-checklists.md": "ca5e8059e46052b88489cdc3ffcd009fa2b33f6bcff0493ded47a3ae12c6b94e",
|
|
10
|
-
"src/skills/code-review-checklist/SKILL.md": "
|
|
10
|
+
"src/skills/code-review-checklist/SKILL.md": "b34c95ae935c2e57b302b68a42606e52d43d078276ad1dbaf0af15ad9ef6d2f8",
|
|
11
11
|
"src/skills/codemap/SKILL.md": "d21b3fa66b931b29dcf1ec0f0fcf1ec28514642a9f33f96e4b2901a0be74c72d",
|
|
12
12
|
"src/skills/context-compression/SKILL.md": "4d8368309ec72fefac69ad5cddd43650647d0bc684b6f8bf3cacc004edb56ef5",
|
|
13
13
|
"src/skills/fast-path-execution/SKILL.md": "040bb97ac5d930dcee47d5d0e2fc1ef637a4762998990475d876ec7f17977c69",
|
|
14
14
|
"src/skills/git-workflow-and-versioning/SKILL.md": "685a94041f1b4ce2a430301f517b89102055696267c369a7e8fb191606659276",
|
|
15
|
-
"src/skills/incremental-implementation/SKILL.md": "
|
|
15
|
+
"src/skills/incremental-implementation/SKILL.md": "28157b3cbb728055d4298ed54e02b7e9c93f13da7bd39ec0bb8806eb96803e03",
|
|
16
16
|
"src/skills/instruction-forge/references/agents-md-doctrine.md": "23623cc40e830ba5f2f11b7b005e85b3f4d260428f1c31cb9840e7b9baa81360",
|
|
17
17
|
"src/skills/instruction-forge/references/eval-doctrine.md": "87412d9c9afb16a0cc9eab145df45518805d0e967fe736d65bae9f5cd6a19782",
|
|
18
18
|
"src/skills/instruction-forge/references/skill-doctrine.md": "9ad4f1c249595f934bd6397afd36017a6a61068c1c21ee0bee11952cb14dc4a1",
|
|
19
19
|
"src/skills/instruction-forge/SKILL.md": "e6d45074f959033359010c936346d6718c50b4700e98566bf9ca6ab36bd60951",
|
|
20
20
|
"src/skills/loop-engineering/SKILL.md": "f804e545821b9cca8fe0ec517307ed902446f28c2ca8ff9194c0f987cf7229e3",
|
|
21
|
-
"src/skills/memory-bank/references/anti-patterns.md": "
|
|
21
|
+
"src/skills/memory-bank/references/anti-patterns.md": "f44615f724ba4fcf43035dd43693b2629ba2005d1402a08f916178c4505ee66e",
|
|
22
22
|
"src/skills/memory-bank/references/product-adoption.md": "56a0608d757090e51596e484a8a9fb0cc72c9ca3b204afb803fbec4a993acd3d",
|
|
23
23
|
"src/skills/memory-bank/references/storage-model.md": "728a9e5f2055ce0f74c759405072a6fe57f65587bdb7b9e5e7fa90b60528b085",
|
|
24
24
|
"src/skills/memory-bank/references/structure-and-frequency.md": "09caedf905870c688401a2e58b2776a9c6187fe724c576019c58c3b80fe1b98f",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"src/skills/session-goal/references/session-reuse.md": "38b9bc7b47cf8bdd47721bd5e501df420982776ce25b155228fd81795d7d0ef2",
|
|
31
31
|
"src/skills/session-goal/SKILL.md": "fda6e39c731ab803a980a213086758d55fedcdbd8cf6dd2ce095047da9226f5a",
|
|
32
32
|
"src/skills/simplify/SKILL.md": "1f3c06f4f856cbc8cdefcfe7fd260ad7382a441d8d9d9162671b17dc33aa6edd",
|
|
33
|
-
"src/skills/spec-driven-development/SKILL.md": "
|
|
33
|
+
"src/skills/spec-driven-development/SKILL.md": "2f39bb21528f05ccb1a1e854c5797f5f1ba40377806fbd88ae5714ab584a3487",
|
|
34
34
|
"src/skills/tdd-with-agents/references/advanced-testing-patterns.md": "4aac82748bb670a61d67732168f8a265d5e66895a9183029e3da03de8e024788",
|
|
35
35
|
"src/skills/tdd-with-agents/references/testing-by-layer.md": "545291301661e57d846b2db2acca1edb1219a102dce4aad7e0c3cc1a250b570a",
|
|
36
|
-
"src/skills/tdd-with-agents/SKILL.md": "
|
|
36
|
+
"src/skills/tdd-with-agents/SKILL.md": "107495b0473a561dd570d2c25420329d68712776524a736ccc415171f7aa6c00",
|
|
37
37
|
"src/skills/test-slicing/SKILL.md": "ff70cddc66261049250b82f7aeabbfd6bcd00f9abe34cc8d5f20aa35333b1590",
|
|
38
38
|
"src/skills/verification-planning/SKILL.md": "6a3c6cb5bd5076862d369885bf0b3ba086b625495fe7a42f3f5116d07b470f3e",
|
|
39
39
|
"src/skills/visual-review-pipeline/references/findings-schema.md": "776511757c0d8387fab232fced8ac9ce031a03f62b6ca539e3c38b0d45035c8e",
|
|
40
|
-
"src/skills/visual-review-pipeline/references/workflow-steps.md": "
|
|
41
|
-
"src/skills/visual-review-pipeline/SKILL.md": "
|
|
40
|
+
"src/skills/visual-review-pipeline/references/workflow-steps.md": "13796a32076dd4d04d37a50927169929ba44a332302bd98f72ec61482ceedc09",
|
|
41
|
+
"src/skills/visual-review-pipeline/SKILL.md": "f218252c0773c2f880a736493d7e0630e7d0678fe27beb9687053e6db6054e27",
|
|
42
42
|
"src/skills/worktrees/SKILL.md": "9cf2b036e90d9ff7c6deb786ad7bab2cb78d6bf39166a67d5cbeafc29f593c6e"
|
|
43
43
|
}
|