@plainconceptsplatform/agent-harness 2.2.1 → 2.4.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/README.md +23 -12
- package/{src → cli}/commands/join.js +3 -4
- package/{src → cli}/commands/migrate.js +1 -1
- package/{src → cli}/commands/update.js +13 -1
- package/{src → cli}/commands/wizard.js +1 -1
- package/{src → cli}/index.js +1 -1
- package/{src → cli}/presets/agents-content.json +4 -4
- package/cli/presets/browser.json +10 -0
- package/{src → cli}/presets/clean.json +21 -21
- package/{src → cli}/presets/optimization.json +37 -37
- package/{src → cli}/presets/platforms.json +76 -76
- package/{src → cli}/presets/quota.json +16 -16
- package/{src → cli}/presets/source.json +23 -23
- package/cli/steps/browser/index.js +48 -0
- package/{src → cli}/steps/clean/index.js +120 -120
- package/{src → cli}/steps/copy/agents.js +119 -119
- package/{src → cli}/steps/copy/commands.js +95 -95
- package/{src → cli}/steps/copy/fullstack-engineer.js +5 -1
- package/{src → cli}/steps/copy/index.js +1 -1
- package/{src → cli}/steps/copy/opencode-json.js +50 -1
- package/{src → cli}/steps/copy/skills.js +2 -2
- package/{src → cli}/steps/metadata/index.js +4 -0
- package/{src → cli}/steps/models/format.js +88 -88
- package/{src → cli}/steps/models/index.js +64 -64
- package/{src → cli}/steps/openspec/index.js +136 -136
- package/{src → cli}/steps/optimization/codegraph.js +127 -127
- package/cli/steps/optimization/detect.js +66 -0
- package/{src → cli}/steps/optimization/humanizer.js +17 -17
- package/{src → cli}/steps/optimization/index.js +163 -163
- package/{src → cli}/steps/optimization/memory.js +88 -88
- package/{src → cli}/steps/optimization/patch-guardrails.js +109 -109
- package/{src → cli}/steps/optimization/quota.js +119 -119
- package/{src → cli}/steps/optimization/simple-english.js +17 -17
- package/{src → cli}/steps/optimization/skills-lock.js +30 -30
- package/{src → cli}/steps/platform/index.js +109 -109
- package/{src → cli}/steps/source/index.js +123 -123
- package/cli/utils/agent-color.js +111 -0
- package/{src → cli}/utils/exec-spinner.js +47 -47
- package/{src → cli}/utils/exec.js +134 -134
- package/{src → cli}/utils/models-pricing.js +42 -42
- package/{src → cli}/utils/paths.js +1 -1
- package/{src → cli}/utils/process.js +3 -3
- package/{src → cli}/utils/terminal.js +6 -6
- package/harness/.agents/skills/browser-automation/SKILL.md +72 -0
- package/{src/content → harness}/.agents/skills/pc-make-engineer/SKILL.md +1 -1
- package/{src/content → harness}/.agents/skills/pc-make-engineer/template.md +1 -2
- package/{src/content → harness}/.agents/skills/pc-plan-archive/SKILL.md +3 -0
- package/{src/content → harness}/.agents/skills/pc-plan-explore/SKILL.md +3 -0
- package/{src/content → harness}/.agents/skills/pc-plan-goal/SKILL.md +5 -16
- package/{src/content → harness}/.agents/skills/pc-plan-goal/branching.md +1 -1
- package/{src/content → harness}/.agents/skills/pc-plan-goal/output.md +5 -8
- package/{src/content → harness}/.agents/skills/pc-plan-story/SKILL.md +3 -0
- package/{src/content → harness}/.agents/skills/pc-userstory-browser/SKILL.md +136 -132
- package/{src/content → harness}/.opencode/package.json +9 -10
- package/{src/content → harness}/.opencode/plugins/pc-subagent-tiers.js +91 -4
- package/{src/content → harness}/ARCHITECTURE.md +16 -16
- package/{src/content → harness}/DESIGN.md +16 -16
- package/{src/content → harness}/opencode.jsonc +11 -3
- package/{src/content → harness}/openspec/config.yaml +20 -20
- package/{src/content → harness}/skills-lock.json +17 -17
- package/package.json +7 -7
- package/src/content/.agents/skills/browser-automation/SKILL.md +0 -66
- package/src/presets/browser.json +0 -22
- package/src/steps/browser/index.js +0 -91
- /package/{src → cli}/commands/shared.js +0 -0
- /package/{src → cli}/commands/single.js +0 -0
- /package/{src → cli}/fragments/archive/az.md +0 -0
- /package/{src → cli}/fragments/archive/gh.md +0 -0
- /package/{src → cli}/fragments/archive/gl.md +0 -0
- /package/{src → cli}/fragments/archive/none.md +0 -0
- /package/{src → cli}/fragments/guardrails/codegraph.md +0 -0
- /package/{src → cli}/fragments/guardrails/humanizer.md +0 -0
- /package/{src → cli}/fragments/guardrails/memory.md +0 -0
- /package/{src → cli}/fragments/guardrails/rtk.md +0 -0
- /package/{src → cli}/fragments/guardrails/simple-english.md +0 -0
- /package/{src → cli}/fragments/ops-backlog/az.md +0 -0
- /package/{src → cli}/fragments/ops-backlog/gh.md +0 -0
- /package/{src → cli}/fragments/ops-backlog/jira.md +0 -0
- /package/{src → cli}/fragments/ops-evidence/az.md +0 -0
- /package/{src → cli}/fragments/ops-evidence/gh.md +0 -0
- /package/{src → cli}/fragments/ops-evidence/jira.md +0 -0
- /package/{src → cli}/fragments/ops-review/az.md +0 -0
- /package/{src → cli}/fragments/ops-review/gh.md +0 -0
- /package/{src → cli}/fragments/ops-review/gl.md +0 -0
- /package/{src → cli}/fragments/ops-ship/az.md +0 -0
- /package/{src → cli}/fragments/ops-ship/gh.md +0 -0
- /package/{src → cli}/fragments/ops-ship/gl.md +0 -0
- /package/{src → cli}/presets/models.json +0 -0
- /package/{src → cli}/presets/openspec.json +0 -0
- /package/{src → cli}/steps/models/write.js +0 -0
- /package/{src → cli}/utils/copy.js +0 -0
- /package/{src → cli}/utils/legacy-check.js +0 -0
- /package/{src → cli}/utils/models-cache.js +0 -0
- /package/{src → cli}/utils/update-manifest.js +0 -0
- /package/{src/content → harness}/.agents/skills/pc-guardrails-generic/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-guardrails-project/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-architecture/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-architecture/structure-template.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-design/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-engineer/signal-mapping.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-evidence-scaffold/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-evidence-scaffold/evidence-contract.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-guardrails/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-guardrails/category-reference.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-merge-risk-assess/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-merge-risk-assess/category-reference.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-make-user-model/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-ops-evidence/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-ops-ship/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-apply/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-apply/simple-mode.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-goal/failure-policy.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-goal/output-mode.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-propose/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-propose/task-annotation.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-plan-quick/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-repo-audit/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-repo-help/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-repo-initialize/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-repo-onboard/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-repo-verify/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-userstory-az/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-userstory-gh/SKILL.md +0 -0
- /package/{src/content → harness}/.agents/skills/pc-userstory-jira/SKILL.md +0 -0
- /package/{src/content → harness}/.opencode/_gitignore +0 -0
- /package/{src/content → harness}/.opencode/commands/init.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-architecture.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-design.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-engineer.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-evidence-scaffold.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-guardrails.md +0 -0
- /package/{src/content → harness}/.opencode/commands/make-user-model.md +0 -0
- /package/{src/content → harness}/.opencode/commands/ops-backlog.md +0 -0
- /package/{src/content → harness}/.opencode/commands/ops-evidence.md +0 -0
- /package/{src/content → harness}/.opencode/commands/ops-review.md +0 -0
- /package/{src/content → harness}/.opencode/commands/ops-ship.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-apply.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-archive.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-explore.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-goal.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-propose.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-quick.md +0 -0
- /package/{src/content → harness}/.opencode/commands/plan-story.md +0 -0
- /package/{src/content → harness}/.opencode/commands/repo-audit.md +0 -0
- /package/{src/content → harness}/.opencode/commands/repo-help.md +0 -0
- /package/{src/content → harness}/.opencode/commands/repo-initialize.md +0 -0
- /package/{src/content → harness}/.opencode/commands/repo-onboard.md +0 -0
- /package/{src/content → harness}/.opencode/commands/repo-verify.md +0 -0
- /package/{src/content → harness}/.opencode/plugins/pc-subagent-monitor.js +0 -0
- /package/{src/content → harness}/.opencode/plugins/pc-system-reminders.js +0 -0
- /package/{src/content → harness}/.opencode/tui/pc-subagents.tsx +0 -0
- /package/{src/content → harness}/.opencode/tui.json +0 -0
- /package/{src/content → harness}/AGENTS.md +0 -0
- /package/{src/content → harness}/openspec/changes/archive/.gitkeep +0 -0
- /package/{src/content → harness}/openspec/specs/.gitkeep +0 -0
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
import { checkbox } from '@inquirer/prompts'
|
|
2
|
-
import fse from 'fs-extra'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
import { findAiFiles } from '../../utils/copy.js'
|
|
6
|
-
import { header, info, success, warn } from '../../utils/exec.js'
|
|
7
|
-
import { MARKERS } from '../../utils/terminal.js'
|
|
8
|
-
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
const CLEAN_PRESET_PATH = path.resolve(__dirname, '../../presets/clean.json')
|
|
11
|
-
const cleanPreset = await fse.readJson(CLEAN_PRESET_PATH)
|
|
12
|
-
|
|
13
|
-
async function childrenExcludingPreserved(dir) {
|
|
14
|
-
const results = []
|
|
15
|
-
if (!await fse.pathExists(dir)) return results
|
|
16
|
-
const entries = await fse.readdir(dir)
|
|
17
|
-
for (const entry of entries) {
|
|
18
|
-
if (cleanPreset.preserveSubfolders.includes(entry)) continue
|
|
19
|
-
results.push(path.join(dir, entry))
|
|
20
|
-
}
|
|
21
|
-
return results
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function isPopulated(filePath) {
|
|
25
|
-
if (!await fse.pathExists(filePath)) return false
|
|
26
|
-
const content = await fse.readFile(filePath, 'utf-8')
|
|
27
|
-
const trimmed = content.trim()
|
|
28
|
-
if (!trimmed) return false
|
|
29
|
-
if (trimmed.startsWith('<!-- onboard-prompt')) return false
|
|
30
|
-
return true
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function hasOpenspecHistory(cwd) {
|
|
34
|
-
const changesDir = path.join(cwd, 'openspec', 'changes')
|
|
35
|
-
const archiveDir = path.join(cwd, 'openspec', 'archive')
|
|
36
|
-
if (await fse.pathExists(changesDir)) {
|
|
37
|
-
const entries = await fse.readdir(changesDir)
|
|
38
|
-
if (entries.length > 0) return true
|
|
39
|
-
}
|
|
40
|
-
if (await fse.pathExists(archiveDir)) {
|
|
41
|
-
const entries = await fse.readdir(archiveDir)
|
|
42
|
-
if (entries.length > 0) return true
|
|
43
|
-
}
|
|
44
|
-
return false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function cleanAiFiles({ removeLegacyConfig = false } = {}) {
|
|
48
|
-
header('Step 2, Existing AI config files')
|
|
49
|
-
|
|
50
|
-
const cwd = process.cwd()
|
|
51
|
-
const ctx = {
|
|
52
|
-
hasDesign: await isPopulated(path.join(cwd, 'DESIGN.md')),
|
|
53
|
-
hasArchitecture: await isPopulated(path.join(cwd, 'ARCHITECTURE.md')),
|
|
54
|
-
hasOpenspec: await hasOpenspecHistory(cwd),
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (ctx.hasDesign) info('DESIGN.md exists and is populated, keeping it')
|
|
58
|
-
if (ctx.hasArchitecture) info('ARCHITECTURE.md exists and is populated, keeping it')
|
|
59
|
-
if (ctx.hasOpenspec) info('openspec/ history exists, keeping it')
|
|
60
|
-
|
|
61
|
-
const legacyConfig = path.join(cwd, '.opencode', 'opencode.json')
|
|
62
|
-
if (removeLegacyConfig && await fse.pathExists(legacyConfig)) {
|
|
63
|
-
await fse.remove(legacyConfig)
|
|
64
|
-
info('Removed legacy .opencode/opencode.json')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const flatFiles = await findAiFiles(cwd, cleanPreset.detectFiles)
|
|
68
|
-
const dirTargets = cleanPreset.directoryTargets
|
|
69
|
-
const dirEntries = []
|
|
70
|
-
for (const dirName of dirTargets) {
|
|
71
|
-
const dirPath = path.join(cwd, dirName)
|
|
72
|
-
const children = await childrenExcludingPreserved(dirPath)
|
|
73
|
-
if (children.length > 0) {
|
|
74
|
-
dirEntries.push(...children)
|
|
75
|
-
} else if (await fse.pathExists(dirPath)) {
|
|
76
|
-
// Directory exists but all children are preserved (e.g. only skills/):
|
|
77
|
-
// still offer the directory itself as a removable option.
|
|
78
|
-
dirEntries.push(dirPath)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const filteredFlat = flatFiles.filter(f => {
|
|
83
|
-
const rel = path.relative(cwd, f)
|
|
84
|
-
if (dirTargets.includes(rel)) return false
|
|
85
|
-
if (cleanPreset.preserve.some(p => rel === p || rel.startsWith(p + path.sep))) return false
|
|
86
|
-
return true
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const allToRemove = [...filteredFlat, ...dirEntries]
|
|
90
|
-
|
|
91
|
-
if (allToRemove.length === 0) {
|
|
92
|
-
success('No existing AI config files to remove')
|
|
93
|
-
return ctx
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const choices = allToRemove.map(f => ({
|
|
97
|
-
name: path.relative(cwd, f).replace(/\\/g, '/'),
|
|
98
|
-
value: f,
|
|
99
|
-
checked: true,
|
|
100
|
-
}))
|
|
101
|
-
|
|
102
|
-
const selected = await checkbox({
|
|
103
|
-
message: cleanPreset.selectionMessage,
|
|
104
|
-
choices,
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
if (!selected || selected.length === 0) {
|
|
108
|
-
success('No AI config files selected for removal')
|
|
109
|
-
return ctx
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
warn('Removing selected AI config files:')
|
|
113
|
-
for (const f of selected) {
|
|
114
|
-
info(`${MARKERS.EMPTY}${f.replace(cwd + path.sep, '')}`)
|
|
115
|
-
await fse.remove(f)
|
|
116
|
-
}
|
|
117
|
-
success('Removed existing AI config files')
|
|
118
|
-
|
|
119
|
-
return ctx
|
|
120
|
-
}
|
|
1
|
+
import { checkbox } from '@inquirer/prompts'
|
|
2
|
+
import fse from 'fs-extra'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
import { findAiFiles } from '../../utils/copy.js'
|
|
6
|
+
import { header, info, success, warn } from '../../utils/exec.js'
|
|
7
|
+
import { MARKERS } from '../../utils/terminal.js'
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const CLEAN_PRESET_PATH = path.resolve(__dirname, '../../presets/clean.json')
|
|
11
|
+
const cleanPreset = await fse.readJson(CLEAN_PRESET_PATH)
|
|
12
|
+
|
|
13
|
+
async function childrenExcludingPreserved(dir) {
|
|
14
|
+
const results = []
|
|
15
|
+
if (!await fse.pathExists(dir)) return results
|
|
16
|
+
const entries = await fse.readdir(dir)
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
if (cleanPreset.preserveSubfolders.includes(entry)) continue
|
|
19
|
+
results.push(path.join(dir, entry))
|
|
20
|
+
}
|
|
21
|
+
return results
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function isPopulated(filePath) {
|
|
25
|
+
if (!await fse.pathExists(filePath)) return false
|
|
26
|
+
const content = await fse.readFile(filePath, 'utf-8')
|
|
27
|
+
const trimmed = content.trim()
|
|
28
|
+
if (!trimmed) return false
|
|
29
|
+
if (trimmed.startsWith('<!-- onboard-prompt')) return false
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function hasOpenspecHistory(cwd) {
|
|
34
|
+
const changesDir = path.join(cwd, 'openspec', 'changes')
|
|
35
|
+
const archiveDir = path.join(cwd, 'openspec', 'archive')
|
|
36
|
+
if (await fse.pathExists(changesDir)) {
|
|
37
|
+
const entries = await fse.readdir(changesDir)
|
|
38
|
+
if (entries.length > 0) return true
|
|
39
|
+
}
|
|
40
|
+
if (await fse.pathExists(archiveDir)) {
|
|
41
|
+
const entries = await fse.readdir(archiveDir)
|
|
42
|
+
if (entries.length > 0) return true
|
|
43
|
+
}
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function cleanAiFiles({ removeLegacyConfig = false } = {}) {
|
|
48
|
+
header('Step 2, Existing AI config files')
|
|
49
|
+
|
|
50
|
+
const cwd = process.cwd()
|
|
51
|
+
const ctx = {
|
|
52
|
+
hasDesign: await isPopulated(path.join(cwd, 'DESIGN.md')),
|
|
53
|
+
hasArchitecture: await isPopulated(path.join(cwd, 'ARCHITECTURE.md')),
|
|
54
|
+
hasOpenspec: await hasOpenspecHistory(cwd),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (ctx.hasDesign) info('DESIGN.md exists and is populated, keeping it')
|
|
58
|
+
if (ctx.hasArchitecture) info('ARCHITECTURE.md exists and is populated, keeping it')
|
|
59
|
+
if (ctx.hasOpenspec) info('openspec/ history exists, keeping it')
|
|
60
|
+
|
|
61
|
+
const legacyConfig = path.join(cwd, '.opencode', 'opencode.json')
|
|
62
|
+
if (removeLegacyConfig && await fse.pathExists(legacyConfig)) {
|
|
63
|
+
await fse.remove(legacyConfig)
|
|
64
|
+
info('Removed legacy .opencode/opencode.json')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const flatFiles = await findAiFiles(cwd, cleanPreset.detectFiles)
|
|
68
|
+
const dirTargets = cleanPreset.directoryTargets
|
|
69
|
+
const dirEntries = []
|
|
70
|
+
for (const dirName of dirTargets) {
|
|
71
|
+
const dirPath = path.join(cwd, dirName)
|
|
72
|
+
const children = await childrenExcludingPreserved(dirPath)
|
|
73
|
+
if (children.length > 0) {
|
|
74
|
+
dirEntries.push(...children)
|
|
75
|
+
} else if (await fse.pathExists(dirPath)) {
|
|
76
|
+
// Directory exists but all children are preserved (e.g. only skills/):
|
|
77
|
+
// still offer the directory itself as a removable option.
|
|
78
|
+
dirEntries.push(dirPath)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const filteredFlat = flatFiles.filter(f => {
|
|
83
|
+
const rel = path.relative(cwd, f)
|
|
84
|
+
if (dirTargets.includes(rel)) return false
|
|
85
|
+
if (cleanPreset.preserve.some(p => rel === p || rel.startsWith(p + path.sep))) return false
|
|
86
|
+
return true
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const allToRemove = [...filteredFlat, ...dirEntries]
|
|
90
|
+
|
|
91
|
+
if (allToRemove.length === 0) {
|
|
92
|
+
success('No existing AI config files to remove')
|
|
93
|
+
return ctx
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const choices = allToRemove.map(f => ({
|
|
97
|
+
name: path.relative(cwd, f).replace(/\\/g, '/'),
|
|
98
|
+
value: f,
|
|
99
|
+
checked: true,
|
|
100
|
+
}))
|
|
101
|
+
|
|
102
|
+
const selected = await checkbox({
|
|
103
|
+
message: cleanPreset.selectionMessage,
|
|
104
|
+
choices,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
if (!selected || selected.length === 0) {
|
|
108
|
+
success('No AI config files selected for removal')
|
|
109
|
+
return ctx
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
warn('Removing selected AI config files:')
|
|
113
|
+
for (const f of selected) {
|
|
114
|
+
info(`${MARKERS.EMPTY}${f.replace(cwd + path.sep, '')}`)
|
|
115
|
+
await fse.remove(f)
|
|
116
|
+
}
|
|
117
|
+
success('Removed existing AI config files')
|
|
118
|
+
|
|
119
|
+
return ctx
|
|
120
|
+
}
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
import fse from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
|
-
import { info, success, warn } from '../../utils/exec.js'
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
-
const agentsContent = await fse.readJson(path.resolve(__dirname, '../../presets/agents-content.json'))
|
|
8
|
-
|
|
9
|
-
// Steps are matched by their title text, not by exact heading string:
|
|
10
|
-
// heading level (###/####) and step numbers have drifted before and silently
|
|
11
|
-
// broke removal. Matching `^#{3,4} Step N, <title>` survives both.
|
|
12
|
-
const HISTORY_STEP_TITLE = 'Archive project history'
|
|
13
|
-
const CHAIN_STEP_TITLE = 'Chain make commands'
|
|
14
|
-
|
|
15
|
-
const CHAIN_CONFIRM_LINE = '- ARCHITECTURE.md generated'
|
|
16
|
-
|
|
17
|
-
function stepHeadingPattern(title) {
|
|
18
|
-
const escaped = title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
19
|
-
return new RegExp(`^#{2,4} Step \\d+, ${escaped}`)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// The step heading is kept and its body replaced with an explicit skip note.
|
|
23
|
-
// Removing the block and renumbering the remaining steps (the old approach)
|
|
24
|
-
// went stale against prose cross-references like "Skip steps 2, 3, and 4";
|
|
25
|
-
// stable numbering plus a visible reason is unambiguous for the agent.
|
|
26
|
-
export function skipStepBlock(content, title, note) {
|
|
27
|
-
const lines = content.split('\n')
|
|
28
|
-
const pattern = stepHeadingPattern(title)
|
|
29
|
-
const start = lines.findIndex(l => pattern.test(l.trim()))
|
|
30
|
-
if (start === -1) return { content, matched: false }
|
|
31
|
-
|
|
32
|
-
let end = lines.length
|
|
33
|
-
for (let i = start + 1; i < lines.length; i++) {
|
|
34
|
-
if (lines[i].trim() === '---') { end = i; break }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
lines.splice(start + 1, end - start - 1, '', `> ${note}`, '')
|
|
38
|
-
return { content: lines.join('\n'), matched: true }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function removeConfirmLine(content, line) {
|
|
42
|
-
return content.split('\n').filter(l => l.trim() !== line.trim()).join('\n')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const PLATFORM_WORKFLOW_START = '<!-- PC-PLATFORM-WORKFLOW-START -->'
|
|
46
|
-
const PLATFORM_WORKFLOW_END = '<!-- PC-PLATFORM-WORKFLOW-END -->'
|
|
47
|
-
const PLATFORM_SKILLS_GUIDE_START = '<!-- PC-PLATFORM-SKILLS-GUIDE-START -->'
|
|
48
|
-
const PLATFORM_SKILLS_GUIDE_END = '<!-- PC-PLATFORM-SKILLS-GUIDE-END -->'
|
|
49
|
-
|
|
50
|
-
function platformContent(platform, key) {
|
|
51
|
-
const p = agentsContent.platform[platform] ?? agentsContent.platform.github
|
|
52
|
-
return p[key] ?? ''
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function mixedPlatformContent(backlogPlatform, repoPlatform, key) {
|
|
56
|
-
if (backlogPlatform === repoPlatform) {
|
|
57
|
-
return platformContent(backlogPlatform, key)
|
|
58
|
-
}
|
|
59
|
-
const backlog = agentsContent.platform[backlogPlatform] ?? agentsContent.platform.github
|
|
60
|
-
const repo = agentsContent.platform[repoPlatform] ?? agentsContent.platform.github
|
|
61
|
-
const mixed = agentsContent.platform.mixed ?? {}
|
|
62
|
-
const mixedKey = `${backlogPlatform}-${repoPlatform}`
|
|
63
|
-
return mixed[mixedKey]?.[key] ?? mixed.default?.[key]?.replace('{backlog}', backlog[key] ?? '').replace('{repo}', repo[key] ?? '') ?? platformContent(repoPlatform, key)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function replaceBetween(content, start, end, replacement) {
|
|
67
|
-
if (!content.includes(start) || !content.includes(end)) return content
|
|
68
|
-
const pattern = new RegExp(`${start}[\\s\\S]*?${end}`)
|
|
69
|
-
// Replacer function so $&, $' and $` in injected content stay literal.
|
|
70
|
-
return content.replace(pattern, () => `${start}\n${replacement.trim()}\n${end}`)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function patchAgentsMd(ctx) {
|
|
74
|
-
const obInitSkillPath = path.join(process.cwd(), '.agents', 'skills', 'pc-repo-initialize', 'SKILL.md')
|
|
75
|
-
if (!await fse.pathExists(obInitSkillPath)) return
|
|
76
|
-
|
|
77
|
-
let content = await fse.readFile(obInitSkillPath, 'utf-8')
|
|
78
|
-
const patches = []
|
|
79
|
-
|
|
80
|
-
const skips = [
|
|
81
|
-
[ctx.hasOpenspec, HISTORY_STEP_TITLE, null,
|
|
82
|
-
'Skipped during onboarding: this project already had an openspec/ history. Do not archive again; continue with the next step.'],
|
|
83
|
-
[ctx.hasDesign || ctx.hasArchitecture, CHAIN_STEP_TITLE, CHAIN_CONFIRM_LINE,
|
|
84
|
-
'Skipped during onboarding: project files already exist. Run /make-architecture or /make-design individually to regenerate.'],
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
for (const [enabled, title, confirmLine, note] of skips) {
|
|
88
|
-
if (!enabled) continue
|
|
89
|
-
const result = skipStepBlock(content, title, note)
|
|
90
|
-
if (!result.matched) {
|
|
91
|
-
warn(`pc-repo-initialize SKILL.md step "${title}" not found: template drift? Skipping this patch.`)
|
|
92
|
-
continue
|
|
93
|
-
}
|
|
94
|
-
content = result.content
|
|
95
|
-
if (confirmLine) content = removeConfirmLine(content, confirmLine)
|
|
96
|
-
patches.push(`Step "${title}" marked as skipped, file already exists`)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (patches.length > 0) {
|
|
100
|
-
await fse.writeFile(obInitSkillPath, content, 'utf-8')
|
|
101
|
-
for (const msg of patches) info(msg)
|
|
102
|
-
success('pc-repo-initialize SKILL.md patched for existing project state')
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export async function patchAgentGuidance(backlogPlatform, repoPlatform, cwd = process.cwd()) {
|
|
107
|
-
const agentsMdPath = path.join(cwd, 'AGENTS.md')
|
|
108
|
-
if (await fse.pathExists(agentsMdPath)) {
|
|
109
|
-
const repo = repoPlatform ?? backlogPlatform ?? 'github'
|
|
110
|
-
let content = await fse.readFile(agentsMdPath, 'utf-8')
|
|
111
|
-
content = replaceBetween(content, PLATFORM_WORKFLOW_START, PLATFORM_WORKFLOW_END, mixedPlatformContent(backlogPlatform, repo, 'workflow'))
|
|
112
|
-
content = replaceBetween(content, PLATFORM_SKILLS_GUIDE_START, PLATFORM_SKILLS_GUIDE_END, mixedPlatformContent(backlogPlatform, repo, 'skillsGuide'))
|
|
113
|
-
await fse.writeFile(agentsMdPath, `${content.replace(/\s*$/, '')}\n`, 'utf-8')
|
|
114
|
-
const label = backlogPlatform === repo ? repo : `${backlogPlatform}→${repo}`
|
|
115
|
-
success(`AGENTS.md patched for platform workflow: ${label}`)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
import fse from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
import { info, success, warn } from '../../utils/exec.js'
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const agentsContent = await fse.readJson(path.resolve(__dirname, '../../presets/agents-content.json'))
|
|
8
|
+
|
|
9
|
+
// Steps are matched by their title text, not by exact heading string:
|
|
10
|
+
// heading level (###/####) and step numbers have drifted before and silently
|
|
11
|
+
// broke removal. Matching `^#{3,4} Step N, <title>` survives both.
|
|
12
|
+
const HISTORY_STEP_TITLE = 'Archive project history'
|
|
13
|
+
const CHAIN_STEP_TITLE = 'Chain make commands'
|
|
14
|
+
|
|
15
|
+
const CHAIN_CONFIRM_LINE = '- ARCHITECTURE.md generated'
|
|
16
|
+
|
|
17
|
+
function stepHeadingPattern(title) {
|
|
18
|
+
const escaped = title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
19
|
+
return new RegExp(`^#{2,4} Step \\d+, ${escaped}`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The step heading is kept and its body replaced with an explicit skip note.
|
|
23
|
+
// Removing the block and renumbering the remaining steps (the old approach)
|
|
24
|
+
// went stale against prose cross-references like "Skip steps 2, 3, and 4";
|
|
25
|
+
// stable numbering plus a visible reason is unambiguous for the agent.
|
|
26
|
+
export function skipStepBlock(content, title, note) {
|
|
27
|
+
const lines = content.split('\n')
|
|
28
|
+
const pattern = stepHeadingPattern(title)
|
|
29
|
+
const start = lines.findIndex(l => pattern.test(l.trim()))
|
|
30
|
+
if (start === -1) return { content, matched: false }
|
|
31
|
+
|
|
32
|
+
let end = lines.length
|
|
33
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
34
|
+
if (lines[i].trim() === '---') { end = i; break }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
lines.splice(start + 1, end - start - 1, '', `> ${note}`, '')
|
|
38
|
+
return { content: lines.join('\n'), matched: true }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function removeConfirmLine(content, line) {
|
|
42
|
+
return content.split('\n').filter(l => l.trim() !== line.trim()).join('\n')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PLATFORM_WORKFLOW_START = '<!-- PC-PLATFORM-WORKFLOW-START -->'
|
|
46
|
+
const PLATFORM_WORKFLOW_END = '<!-- PC-PLATFORM-WORKFLOW-END -->'
|
|
47
|
+
const PLATFORM_SKILLS_GUIDE_START = '<!-- PC-PLATFORM-SKILLS-GUIDE-START -->'
|
|
48
|
+
const PLATFORM_SKILLS_GUIDE_END = '<!-- PC-PLATFORM-SKILLS-GUIDE-END -->'
|
|
49
|
+
|
|
50
|
+
function platformContent(platform, key) {
|
|
51
|
+
const p = agentsContent.platform[platform] ?? agentsContent.platform.github
|
|
52
|
+
return p[key] ?? ''
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function mixedPlatformContent(backlogPlatform, repoPlatform, key) {
|
|
56
|
+
if (backlogPlatform === repoPlatform) {
|
|
57
|
+
return platformContent(backlogPlatform, key)
|
|
58
|
+
}
|
|
59
|
+
const backlog = agentsContent.platform[backlogPlatform] ?? agentsContent.platform.github
|
|
60
|
+
const repo = agentsContent.platform[repoPlatform] ?? agentsContent.platform.github
|
|
61
|
+
const mixed = agentsContent.platform.mixed ?? {}
|
|
62
|
+
const mixedKey = `${backlogPlatform}-${repoPlatform}`
|
|
63
|
+
return mixed[mixedKey]?.[key] ?? mixed.default?.[key]?.replace('{backlog}', backlog[key] ?? '').replace('{repo}', repo[key] ?? '') ?? platformContent(repoPlatform, key)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function replaceBetween(content, start, end, replacement) {
|
|
67
|
+
if (!content.includes(start) || !content.includes(end)) return content
|
|
68
|
+
const pattern = new RegExp(`${start}[\\s\\S]*?${end}`)
|
|
69
|
+
// Replacer function so $&, $' and $` in injected content stay literal.
|
|
70
|
+
return content.replace(pattern, () => `${start}\n${replacement.trim()}\n${end}`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function patchAgentsMd(ctx) {
|
|
74
|
+
const obInitSkillPath = path.join(process.cwd(), '.agents', 'skills', 'pc-repo-initialize', 'SKILL.md')
|
|
75
|
+
if (!await fse.pathExists(obInitSkillPath)) return
|
|
76
|
+
|
|
77
|
+
let content = await fse.readFile(obInitSkillPath, 'utf-8')
|
|
78
|
+
const patches = []
|
|
79
|
+
|
|
80
|
+
const skips = [
|
|
81
|
+
[ctx.hasOpenspec, HISTORY_STEP_TITLE, null,
|
|
82
|
+
'Skipped during onboarding: this project already had an openspec/ history. Do not archive again; continue with the next step.'],
|
|
83
|
+
[ctx.hasDesign || ctx.hasArchitecture, CHAIN_STEP_TITLE, CHAIN_CONFIRM_LINE,
|
|
84
|
+
'Skipped during onboarding: project files already exist. Run /make-architecture or /make-design individually to regenerate.'],
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
for (const [enabled, title, confirmLine, note] of skips) {
|
|
88
|
+
if (!enabled) continue
|
|
89
|
+
const result = skipStepBlock(content, title, note)
|
|
90
|
+
if (!result.matched) {
|
|
91
|
+
warn(`pc-repo-initialize SKILL.md step "${title}" not found: template drift? Skipping this patch.`)
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
94
|
+
content = result.content
|
|
95
|
+
if (confirmLine) content = removeConfirmLine(content, confirmLine)
|
|
96
|
+
patches.push(`Step "${title}" marked as skipped, file already exists`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (patches.length > 0) {
|
|
100
|
+
await fse.writeFile(obInitSkillPath, content, 'utf-8')
|
|
101
|
+
for (const msg of patches) info(msg)
|
|
102
|
+
success('pc-repo-initialize SKILL.md patched for existing project state')
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function patchAgentGuidance(backlogPlatform, repoPlatform, cwd = process.cwd()) {
|
|
107
|
+
const agentsMdPath = path.join(cwd, 'AGENTS.md')
|
|
108
|
+
if (await fse.pathExists(agentsMdPath)) {
|
|
109
|
+
const repo = repoPlatform ?? backlogPlatform ?? 'github'
|
|
110
|
+
let content = await fse.readFile(agentsMdPath, 'utf-8')
|
|
111
|
+
content = replaceBetween(content, PLATFORM_WORKFLOW_START, PLATFORM_WORKFLOW_END, mixedPlatformContent(backlogPlatform, repo, 'workflow'))
|
|
112
|
+
content = replaceBetween(content, PLATFORM_SKILLS_GUIDE_START, PLATFORM_SKILLS_GUIDE_END, mixedPlatformContent(backlogPlatform, repo, 'skillsGuide'))
|
|
113
|
+
await fse.writeFile(agentsMdPath, `${content.replace(/\s*$/, '')}\n`, 'utf-8')
|
|
114
|
+
const label = backlogPlatform === repo ? repo : `${backlogPlatform}→${repo}`
|
|
115
|
+
success(`AGENTS.md patched for platform workflow: ${label}`)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|