@plainconceptsplatform/agent-harness 3.5.0 → 3.6.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.
Files changed (143) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +455 -454
  3. package/cli/commands/join.js +259 -259
  4. package/cli/commands/migrate.js +310 -310
  5. package/cli/commands/shared.js +27 -27
  6. package/cli/commands/single.js +79 -79
  7. package/cli/commands/update.js +121 -121
  8. package/cli/commands/wizard.js +134 -134
  9. package/cli/fragments/archive/az.md +97 -97
  10. package/cli/fragments/archive/gh.md +96 -96
  11. package/cli/fragments/archive/gl.md +96 -96
  12. package/cli/fragments/archive/none.md +75 -75
  13. package/cli/fragments/guardrails/codegraph.md +5 -5
  14. package/cli/fragments/guardrails/humanizer.md +4 -4
  15. package/cli/fragments/guardrails/memory.md +4 -4
  16. package/cli/fragments/guardrails/rtk.md +3 -3
  17. package/cli/fragments/guardrails/simple-english.md +4 -4
  18. package/cli/fragments/ops-backlog/az.md +28 -28
  19. package/cli/fragments/ops-backlog/gh.md +28 -28
  20. package/cli/fragments/ops-backlog/jira.md +28 -28
  21. package/cli/fragments/ops-review/az.md +62 -62
  22. package/cli/fragments/ops-review/gh.md +51 -51
  23. package/cli/fragments/ops-review/gl.md +55 -55
  24. package/cli/fragments/ops-ship/az.md +81 -81
  25. package/cli/fragments/ops-ship/gh.md +67 -67
  26. package/cli/fragments/ops-ship/gl.md +84 -84
  27. package/cli/index.js +116 -116
  28. package/cli/presets/agents-content.json +34 -34
  29. package/cli/presets/browser.json +10 -10
  30. package/cli/presets/clean.json +21 -21
  31. package/cli/presets/models.json +68 -68
  32. package/cli/presets/optimization.json +32 -32
  33. package/cli/presets/platforms.json +76 -76
  34. package/cli/presets/source.json +23 -23
  35. package/cli/steps/browser/index.js +48 -48
  36. package/cli/steps/clean/index.js +120 -120
  37. package/cli/steps/copy/agents.js +120 -120
  38. package/cli/steps/copy/commands.js +79 -79
  39. package/cli/steps/copy/fullstack-engineer.js +89 -89
  40. package/cli/steps/copy/index.js +88 -88
  41. package/cli/steps/copy/opencode-json.js +324 -324
  42. package/cli/steps/copy/skills.js +316 -316
  43. package/cli/steps/metadata/index.js +115 -115
  44. package/cli/steps/models/format.js +88 -88
  45. package/cli/steps/models/index.js +64 -64
  46. package/cli/steps/models/write.js +38 -38
  47. package/cli/steps/openspec/index.js +136 -136
  48. package/cli/steps/optimization/codegraph.js +141 -141
  49. package/cli/steps/optimization/detect.js +66 -66
  50. package/cli/steps/optimization/humanizer.js +17 -17
  51. package/cli/steps/optimization/index.js +158 -158
  52. package/cli/steps/optimization/memory.js +91 -91
  53. package/cli/steps/optimization/patch-guardrails.js +111 -111
  54. package/cli/steps/optimization/simple-english.js +17 -17
  55. package/cli/steps/optimization/skills-lock.js +30 -30
  56. package/cli/steps/platform/index.js +109 -109
  57. package/cli/steps/source/index.js +123 -123
  58. package/cli/utils/agent-color.js +111 -111
  59. package/cli/utils/copy.js +134 -134
  60. package/cli/utils/exec-spinner.js +47 -47
  61. package/cli/utils/exec.js +134 -134
  62. package/cli/utils/legacy-check.js +30 -30
  63. package/cli/utils/models-cache.js +58 -58
  64. package/cli/utils/models-pricing.js +42 -42
  65. package/cli/utils/paths.js +81 -81
  66. package/cli/utils/process.js +3 -3
  67. package/cli/utils/terminal.js +6 -6
  68. package/cli/utils/update-manifest.js +75 -75
  69. package/harness/.opencode/_gitignore +10 -10
  70. package/harness/.opencode/commands/init.md +5 -5
  71. package/harness/.opencode/commands/make-architecture.md +5 -5
  72. package/harness/.opencode/commands/make-design.md +5 -5
  73. package/harness/.opencode/commands/make-engineer.md +5 -5
  74. package/harness/.opencode/commands/make-guardrails.md +5 -5
  75. package/harness/.opencode/commands/make-user-model.md +5 -5
  76. package/harness/.opencode/commands/ops-backlog.md +10 -10
  77. package/harness/.opencode/commands/ops-review.md +10 -10
  78. package/harness/.opencode/commands/ops-ship.md +9 -9
  79. package/harness/.opencode/commands/plan-apply.md +9 -9
  80. package/harness/.opencode/commands/plan-archive.md +7 -7
  81. package/harness/.opencode/commands/plan-explore.md +11 -11
  82. package/harness/.opencode/commands/plan-goal.md +5 -5
  83. package/harness/.opencode/commands/plan-propose.md +11 -11
  84. package/harness/.opencode/commands/plan-quick.md +7 -7
  85. package/harness/.opencode/commands/plan-story.md +11 -11
  86. package/harness/.opencode/commands/repo-audit.md +7 -7
  87. package/harness/.opencode/commands/repo-help.md +5 -5
  88. package/harness/.opencode/commands/repo-initialize.md +5 -5
  89. package/harness/.opencode/commands/repo-onboard.md +5 -5
  90. package/harness/.opencode/commands/repo-verify.md +5 -5
  91. package/harness/.opencode/package.json +5 -5
  92. package/harness/.opencode/plugins/pc-commit-coauthor.js +41 -0
  93. package/harness/.opencode/plugins/pc-subagent-monitor.js +184 -184
  94. package/harness/.opencode/plugins/pc-subagent-tiers.js +367 -367
  95. package/harness/.opencode/plugins/pc-system-reminders.js +386 -386
  96. package/harness/.opencode/scripts/check-diff.mjs +252 -252
  97. package/harness/.opencode/scripts/code-rules.mjs +288 -288
  98. package/harness/AGENTS.md +49 -49
  99. package/harness/ARCHITECTURE.md +13 -13
  100. package/harness/DESIGN.md +13 -13
  101. package/harness/opencode.jsonc +36 -36
  102. package/harness/openspec/config.yaml +20 -20
  103. package/harness/skills-lock.json +17 -17
  104. package/package.json +14 -12
  105. package/skills/README.md +18 -18
  106. package/skills/agent-harness-cli/SKILL.md +86 -86
  107. package/skills/browser-automation/SKILL.md +72 -72
  108. package/skills/pc-guardrails-generic/SKILL.md +53 -53
  109. package/skills/pc-guardrails-project/SKILL.md +8 -8
  110. package/skills/pc-make-architecture/SKILL.md +32 -32
  111. package/skills/pc-make-architecture/structure-template.md +64 -64
  112. package/skills/pc-make-design/SKILL.md +45 -45
  113. package/skills/pc-make-engineer/SKILL.md +59 -59
  114. package/skills/pc-make-engineer/signal-mapping.md +53 -53
  115. package/skills/pc-make-engineer/template.md +36 -36
  116. package/skills/pc-make-guardrails/SKILL.md +44 -44
  117. package/skills/pc-make-guardrails/category-reference.md +112 -112
  118. package/skills/pc-make-merge-risk-assess/SKILL.md +70 -70
  119. package/skills/pc-make-merge-risk-assess/category-reference.md +114 -114
  120. package/skills/pc-make-user-model/SKILL.md +56 -56
  121. package/skills/pc-ops-ship/SKILL.md +22 -22
  122. package/skills/pc-plan-apply/SKILL.md +88 -88
  123. package/skills/pc-plan-apply/simple-mode.md +21 -21
  124. package/skills/pc-plan-archive/SKILL.md +66 -66
  125. package/skills/pc-plan-explore/SKILL.md +21 -21
  126. package/skills/pc-plan-goal/SKILL.md +91 -91
  127. package/skills/pc-plan-goal/branching.md +39 -39
  128. package/skills/pc-plan-goal/failure-policy.md +30 -30
  129. package/skills/pc-plan-goal/output-mode.md +10 -10
  130. package/skills/pc-plan-goal/output.md +71 -71
  131. package/skills/pc-plan-propose/SKILL.md +125 -125
  132. package/skills/pc-plan-propose/task-annotation.md +39 -39
  133. package/skills/pc-plan-quick/SKILL.md +46 -46
  134. package/skills/pc-plan-story/SKILL.md +93 -93
  135. package/skills/pc-repo-audit/SKILL.md +44 -44
  136. package/skills/pc-repo-help/SKILL.md +87 -87
  137. package/skills/pc-repo-initialize/SKILL.md +119 -119
  138. package/skills/pc-repo-onboard/SKILL.md +32 -32
  139. package/skills/pc-repo-verify/SKILL.md +150 -150
  140. package/skills/pc-userstory-az/SKILL.md +71 -71
  141. package/skills/pc-userstory-browser/SKILL.md +64 -64
  142. package/skills/pc-userstory-gh/SKILL.md +63 -63
  143. package/skills/pc-userstory-jira/SKILL.md +74 -74
@@ -1,109 +1,109 @@
1
- import { select } from '@inquirer/prompts'
2
- import { execa } from 'execa'
3
- import fse from 'fs-extra'
4
- import path from 'path'
5
- import { fileURLToPath } from 'url'
6
- import { code, commandExists, header, info, success, warn } from '../../utils/exec.js'
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
- const PLATFORMS_PRESET_PATH = path.resolve(__dirname, '../../presets/platforms.json')
10
- const platformsPreset = await fse.readJson(PLATFORMS_PRESET_PATH)
11
-
12
-
13
- export async function checkPlatform(platform) {
14
- const preset = platformsPreset.find(p => p.value === platform) || platformsPreset[0]
15
- if (!preset.cli) {
16
- header(`Step 4, Checking ${preset.name} CLI`)
17
- info('No platform integration selected, skipping CLI checks.')
18
- success(`Platform: ${preset.name}`)
19
- return
20
- }
21
- await checkPlatformCli(preset)
22
- }
23
-
24
- export async function choosePlatform() {
25
- header('Step 3, Version control platform')
26
-
27
- const backlogChoices = platformsPreset.filter(p => !p.repoOnly)
28
- const backlogPlatform = await select({
29
- message: 'Where is your backlog (work items / issues)?',
30
- choices: backlogChoices.map(p => ({ name: p.name, value: p.value })),
31
- })
32
-
33
- const backlogPreset = platformsPreset.find(p => p.value === backlogPlatform)
34
- success(`Backlog platform: ${backlogPreset?.name || backlogPlatform}`)
35
-
36
- let repoPlatform = backlogPlatform
37
- if (backlogPlatform !== 'none') {
38
- // Exclude backlog-only platforms (e.g. Jira) from repo choices
39
- const repoChoices = platformsPreset.filter(p => !p.backlogOnly)
40
- repoPlatform = await select({
41
- message: 'Where is your code repository (PRs / code reviews)?',
42
- choices: repoChoices.map(p => ({ name: p.name, value: p.value })),
43
- default: backlogPreset.backlogOnly ? 'github' : backlogPlatform,
44
- })
45
- const repoPreset = platformsPreset.find(p => p.value === repoPlatform)
46
- success(`Repo platform: ${repoPreset?.name || repoPlatform}`)
47
- }
48
-
49
- // Check CLIs for both platforms (deduped)
50
- const platformsToCheck = [...new Set([backlogPlatform, repoPlatform])].filter(p => p !== 'none')
51
- for (const p of platformsToCheck) {
52
- const preset = platformsPreset.find(x => x.value === p)
53
- if (preset?.cli) await checkPlatformCli(preset)
54
- }
55
-
56
- return { backlogPlatform, repoPlatform }
57
- }
58
-
59
- async function checkPlatformCli(platformPreset) {
60
- const { cli } = platformPreset
61
- header(`Step 4, Checking ${platformPreset.name} CLI`)
62
-
63
- const hasCli = await commandExists(cli.command)
64
- if (!hasCli) {
65
- warn(`${cli.displayName} not found.`)
66
- info(`Install from: ${cli.installUrl}`)
67
- if (cli.authCheck?.commands?.length) {
68
- console.log()
69
- info('After installing, authenticate with:')
70
- code(cli.authCheck.commands)
71
- }
72
- return
73
- }
74
- success(`${cli.displayName} available`)
75
-
76
- if (cli.authCheck) await runAuthCheck(cli)
77
- if (cli.extensionCheck) await runExtensionCheck(cli)
78
- }
79
-
80
- async function runAuthCheck(cli) {
81
- try {
82
- const result = await execa(cli.command, cli.authCheck.args, { reject: false })
83
- if (result.exitCode === 0) {
84
- success(`${cli.displayName} authenticated`)
85
- } else {
86
- warn(cli.authCheck.notAuthenticatedMessage)
87
- code(cli.authCheck.commands)
88
- }
89
- } catch {
90
- warn(`Could not check ${cli.command} auth status.`)
91
- }
92
- }
93
-
94
- async function runExtensionCheck(cli) {
95
- try {
96
- const result = await execa(cli.command, cli.extensionCheck.args, { reject: false })
97
- const hasExtension = result.stdout && result.stdout.includes(cli.extensionCheck.expectedOutput)
98
-
99
- if (hasExtension) {
100
- success(`${cli.extensionCheck.expectedOutput} extension installed`)
101
- } else {
102
- warn(cli.extensionCheck.missingMessage)
103
- code(cli.extensionCheck.commands)
104
- }
105
- } catch {
106
- warn(cli.extensionCheck.errorMessage)
107
- code(cli.extensionCheck.commands)
108
- }
109
- }
1
+ import { select } from '@inquirer/prompts'
2
+ import { execa } from 'execa'
3
+ import fse from 'fs-extra'
4
+ import path from 'path'
5
+ import { fileURLToPath } from 'url'
6
+ import { code, commandExists, header, info, success, warn } from '../../utils/exec.js'
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
+ const PLATFORMS_PRESET_PATH = path.resolve(__dirname, '../../presets/platforms.json')
10
+ const platformsPreset = await fse.readJson(PLATFORMS_PRESET_PATH)
11
+
12
+
13
+ export async function checkPlatform(platform) {
14
+ const preset = platformsPreset.find(p => p.value === platform) || platformsPreset[0]
15
+ if (!preset.cli) {
16
+ header(`Step 4, Checking ${preset.name} CLI`)
17
+ info('No platform integration selected, skipping CLI checks.')
18
+ success(`Platform: ${preset.name}`)
19
+ return
20
+ }
21
+ await checkPlatformCli(preset)
22
+ }
23
+
24
+ export async function choosePlatform() {
25
+ header('Step 3, Version control platform')
26
+
27
+ const backlogChoices = platformsPreset.filter(p => !p.repoOnly)
28
+ const backlogPlatform = await select({
29
+ message: 'Where is your backlog (work items / issues)?',
30
+ choices: backlogChoices.map(p => ({ name: p.name, value: p.value })),
31
+ })
32
+
33
+ const backlogPreset = platformsPreset.find(p => p.value === backlogPlatform)
34
+ success(`Backlog platform: ${backlogPreset?.name || backlogPlatform}`)
35
+
36
+ let repoPlatform = backlogPlatform
37
+ if (backlogPlatform !== 'none') {
38
+ // Exclude backlog-only platforms (e.g. Jira) from repo choices
39
+ const repoChoices = platformsPreset.filter(p => !p.backlogOnly)
40
+ repoPlatform = await select({
41
+ message: 'Where is your code repository (PRs / code reviews)?',
42
+ choices: repoChoices.map(p => ({ name: p.name, value: p.value })),
43
+ default: backlogPreset.backlogOnly ? 'github' : backlogPlatform,
44
+ })
45
+ const repoPreset = platformsPreset.find(p => p.value === repoPlatform)
46
+ success(`Repo platform: ${repoPreset?.name || repoPlatform}`)
47
+ }
48
+
49
+ // Check CLIs for both platforms (deduped)
50
+ const platformsToCheck = [...new Set([backlogPlatform, repoPlatform])].filter(p => p !== 'none')
51
+ for (const p of platformsToCheck) {
52
+ const preset = platformsPreset.find(x => x.value === p)
53
+ if (preset?.cli) await checkPlatformCli(preset)
54
+ }
55
+
56
+ return { backlogPlatform, repoPlatform }
57
+ }
58
+
59
+ async function checkPlatformCli(platformPreset) {
60
+ const { cli } = platformPreset
61
+ header(`Step 4, Checking ${platformPreset.name} CLI`)
62
+
63
+ const hasCli = await commandExists(cli.command)
64
+ if (!hasCli) {
65
+ warn(`${cli.displayName} not found.`)
66
+ info(`Install from: ${cli.installUrl}`)
67
+ if (cli.authCheck?.commands?.length) {
68
+ console.log()
69
+ info('After installing, authenticate with:')
70
+ code(cli.authCheck.commands)
71
+ }
72
+ return
73
+ }
74
+ success(`${cli.displayName} available`)
75
+
76
+ if (cli.authCheck) await runAuthCheck(cli)
77
+ if (cli.extensionCheck) await runExtensionCheck(cli)
78
+ }
79
+
80
+ async function runAuthCheck(cli) {
81
+ try {
82
+ const result = await execa(cli.command, cli.authCheck.args, { reject: false })
83
+ if (result.exitCode === 0) {
84
+ success(`${cli.displayName} authenticated`)
85
+ } else {
86
+ warn(cli.authCheck.notAuthenticatedMessage)
87
+ code(cli.authCheck.commands)
88
+ }
89
+ } catch {
90
+ warn(`Could not check ${cli.command} auth status.`)
91
+ }
92
+ }
93
+
94
+ async function runExtensionCheck(cli) {
95
+ try {
96
+ const result = await execa(cli.command, cli.extensionCheck.args, { reject: false })
97
+ const hasExtension = result.stdout && result.stdout.includes(cli.extensionCheck.expectedOutput)
98
+
99
+ if (hasExtension) {
100
+ success(`${cli.extensionCheck.expectedOutput} extension installed`)
101
+ } else {
102
+ warn(cli.extensionCheck.missingMessage)
103
+ code(cli.extensionCheck.commands)
104
+ }
105
+ } catch {
106
+ warn(cli.extensionCheck.errorMessage)
107
+ code(cli.extensionCheck.commands)
108
+ }
109
+ }
@@ -1,123 +1,123 @@
1
- import { checkbox, select } from '@inquirer/prompts'
2
- import fse from 'fs-extra'
3
- import path from 'path'
4
- import { fileURLToPath } from 'url'
5
- import { header, info, success, warn } from '../../utils/exec.js'
6
-
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
- const SOURCE_PRESET_PATH = path.resolve(__dirname, '../../presets/source.json')
9
- const sourcePreset = await fse.readJson(SOURCE_PRESET_PATH)
10
-
11
- async function listChildFolders(cwd) {
12
- const entries = await fse.readdir(cwd)
13
- const dirs = []
14
-
15
- for (const name of entries) {
16
- if (name.startsWith('.')) continue
17
- const abs = path.join(cwd, name)
18
- try {
19
- const stat = await fse.stat(abs)
20
- if (!stat.isDirectory()) continue
21
- dirs.push({ name, abs })
22
- } catch {
23
- // ignore invalid entries
24
- }
25
- }
26
-
27
- dirs.sort((a, b) => a.name.localeCompare(b.name))
28
- return dirs
29
- }
30
-
31
- async function listParentFolders(cwd) {
32
- const parent = path.resolve(cwd, '..')
33
- const entries = await fse.readdir(parent)
34
- const dirs = []
35
-
36
- for (const name of entries) {
37
- if (name.startsWith('.')) continue
38
- const abs = path.join(parent, name)
39
- try {
40
- const stat = await fse.stat(abs)
41
- if (!stat.isDirectory()) continue
42
- if (path.resolve(abs) === path.resolve(cwd)) continue
43
- dirs.push({ name, abs })
44
- } catch {
45
- // ignore invalid entries
46
- }
47
- }
48
-
49
- dirs.sort((a, b) => a.name.localeCompare(b.name))
50
- return dirs
51
- }
52
-
53
- export async function chooseSourceScope() {
54
- header('Step 1, Source code scope')
55
-
56
- const cwd = process.cwd()
57
- info('Choose where agents should read source code from during init analysis.')
58
-
59
- const mode = await select({
60
- message: sourcePreset.message,
61
- default: sourcePreset.default,
62
- choices: sourcePreset.choices,
63
- })
64
-
65
- if (mode === 'current') {
66
- success(`Source scope: ${cwd}`)
67
- return { sourceMode: 'current', sourceRoots: [cwd] }
68
- }
69
-
70
- if (mode === 'children') {
71
- const childFolders = await listChildFolders(cwd)
72
- if (childFolders.length === 0) {
73
- warn('No child folders found in current directory. Falling back to current folder.')
74
- success(`Source scope: ${cwd}`)
75
- return { sourceMode: 'current', sourceRoots: [cwd] }
76
- }
77
-
78
- const selected = await checkbox({
79
- message: sourcePreset.childrenSelectionMessage,
80
- choices: childFolders.map(d => ({
81
- name: `./${d.name}`,
82
- value: d.abs,
83
- checked: true,
84
- })),
85
- required: true,
86
- })
87
-
88
- if (!selected || selected.length === 0) {
89
- warn('No folders selected. Falling back to current folder.')
90
- success(`Source scope: ${cwd}`)
91
- return { sourceMode: 'current', sourceRoots: [cwd] }
92
- }
93
-
94
- success(`Source scope: ${selected.map(p => path.basename(p)).join(', ')}`)
95
- return { sourceMode: 'children-selected', sourceRoots: selected }
96
- }
97
-
98
- const parentFolders = await listParentFolders(cwd)
99
- if (parentFolders.length === 0) {
100
- warn('No sibling folders found in parent directory. Falling back to current folder.')
101
- success(`Source scope: ${cwd}`)
102
- return { sourceMode: 'current', sourceRoots: [cwd] }
103
- }
104
-
105
- const selected = await checkbox({
106
- message: sourcePreset.parentSelectionMessage,
107
- choices: parentFolders.map(d => ({
108
- name: `../${d.name}`,
109
- value: d.abs,
110
- checked: true,
111
- })),
112
- required: true,
113
- })
114
-
115
- if (!selected || selected.length === 0) {
116
- warn('No folders selected. Falling back to current folder.')
117
- success(`Source scope: ${cwd}`)
118
- return { sourceMode: 'current', sourceRoots: [cwd] }
119
- }
120
-
121
- success(`Source scope: ${selected.map(p => path.basename(p)).join(', ')}`)
122
- return { sourceMode: 'parent-selected', sourceRoots: selected }
123
- }
1
+ import { checkbox, select } from '@inquirer/prompts'
2
+ import fse from 'fs-extra'
3
+ import path from 'path'
4
+ import { fileURLToPath } from 'url'
5
+ import { header, info, success, warn } from '../../utils/exec.js'
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
+ const SOURCE_PRESET_PATH = path.resolve(__dirname, '../../presets/source.json')
9
+ const sourcePreset = await fse.readJson(SOURCE_PRESET_PATH)
10
+
11
+ async function listChildFolders(cwd) {
12
+ const entries = await fse.readdir(cwd)
13
+ const dirs = []
14
+
15
+ for (const name of entries) {
16
+ if (name.startsWith('.')) continue
17
+ const abs = path.join(cwd, name)
18
+ try {
19
+ const stat = await fse.stat(abs)
20
+ if (!stat.isDirectory()) continue
21
+ dirs.push({ name, abs })
22
+ } catch {
23
+ // ignore invalid entries
24
+ }
25
+ }
26
+
27
+ dirs.sort((a, b) => a.name.localeCompare(b.name))
28
+ return dirs
29
+ }
30
+
31
+ async function listParentFolders(cwd) {
32
+ const parent = path.resolve(cwd, '..')
33
+ const entries = await fse.readdir(parent)
34
+ const dirs = []
35
+
36
+ for (const name of entries) {
37
+ if (name.startsWith('.')) continue
38
+ const abs = path.join(parent, name)
39
+ try {
40
+ const stat = await fse.stat(abs)
41
+ if (!stat.isDirectory()) continue
42
+ if (path.resolve(abs) === path.resolve(cwd)) continue
43
+ dirs.push({ name, abs })
44
+ } catch {
45
+ // ignore invalid entries
46
+ }
47
+ }
48
+
49
+ dirs.sort((a, b) => a.name.localeCompare(b.name))
50
+ return dirs
51
+ }
52
+
53
+ export async function chooseSourceScope() {
54
+ header('Step 1, Source code scope')
55
+
56
+ const cwd = process.cwd()
57
+ info('Choose where agents should read source code from during init analysis.')
58
+
59
+ const mode = await select({
60
+ message: sourcePreset.message,
61
+ default: sourcePreset.default,
62
+ choices: sourcePreset.choices,
63
+ })
64
+
65
+ if (mode === 'current') {
66
+ success(`Source scope: ${cwd}`)
67
+ return { sourceMode: 'current', sourceRoots: [cwd] }
68
+ }
69
+
70
+ if (mode === 'children') {
71
+ const childFolders = await listChildFolders(cwd)
72
+ if (childFolders.length === 0) {
73
+ warn('No child folders found in current directory. Falling back to current folder.')
74
+ success(`Source scope: ${cwd}`)
75
+ return { sourceMode: 'current', sourceRoots: [cwd] }
76
+ }
77
+
78
+ const selected = await checkbox({
79
+ message: sourcePreset.childrenSelectionMessage,
80
+ choices: childFolders.map(d => ({
81
+ name: `./${d.name}`,
82
+ value: d.abs,
83
+ checked: true,
84
+ })),
85
+ required: true,
86
+ })
87
+
88
+ if (!selected || selected.length === 0) {
89
+ warn('No folders selected. Falling back to current folder.')
90
+ success(`Source scope: ${cwd}`)
91
+ return { sourceMode: 'current', sourceRoots: [cwd] }
92
+ }
93
+
94
+ success(`Source scope: ${selected.map(p => path.basename(p)).join(', ')}`)
95
+ return { sourceMode: 'children-selected', sourceRoots: selected }
96
+ }
97
+
98
+ const parentFolders = await listParentFolders(cwd)
99
+ if (parentFolders.length === 0) {
100
+ warn('No sibling folders found in parent directory. Falling back to current folder.')
101
+ success(`Source scope: ${cwd}`)
102
+ return { sourceMode: 'current', sourceRoots: [cwd] }
103
+ }
104
+
105
+ const selected = await checkbox({
106
+ message: sourcePreset.parentSelectionMessage,
107
+ choices: parentFolders.map(d => ({
108
+ name: `../${d.name}`,
109
+ value: d.abs,
110
+ checked: true,
111
+ })),
112
+ required: true,
113
+ })
114
+
115
+ if (!selected || selected.length === 0) {
116
+ warn('No folders selected. Falling back to current folder.')
117
+ success(`Source scope: ${cwd}`)
118
+ return { sourceMode: 'current', sourceRoots: [cwd] }
119
+ }
120
+
121
+ success(`Source scope: ${selected.map(p => path.basename(p)).join(', ')}`)
122
+ return { sourceMode: 'parent-selected', sourceRoots: selected }
123
+ }