opencode-onboard 0.3.3 → 0.4.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.
Files changed (79) hide show
  1. package/README.md +266 -214
  2. package/content/.agents/agents/basic-engineer.md +30 -0
  3. package/content/.agents/agents/devops-manager.md +38 -29
  4. package/content/.agents/session-log.json +41 -0
  5. package/content/.agents/skills/ob-default/SKILL.md +21 -0
  6. package/content/.agents/skills/ob-generic-guardrails/SKILL.md +32 -0
  7. package/content/.agents/skills/ob-global/SKILL.md +49 -0
  8. package/content/.agents/skills/ob-pullrequest-az/SKILL.md +11 -21
  9. package/content/.agents/skills/ob-pullrequest-gh/SKILL.md +14 -24
  10. package/content/.agents/skills/ob-userstory-az/SKILL.md +8 -14
  11. package/content/.agents/skills/ob-userstory-gh/SKILL.md +6 -14
  12. package/content/.opencode/commands/opsx-apply.md +50 -33
  13. package/content/.opencode/plugins/session-log.js +1 -1
  14. package/content/.opencode/skills/openspec-apply-change/SKILL.md +50 -33
  15. package/content/AGENTS.md +94 -144
  16. package/content/skills-lock.json +4 -0
  17. package/package.json +6 -1
  18. package/src/index.js +13 -47
  19. package/src/presets/browser.json +18 -0
  20. package/src/presets/clean.json +21 -0
  21. package/src/presets/models.json +33 -0
  22. package/src/presets/optimization.json +22 -0
  23. package/src/presets/platforms.json +29 -2
  24. package/src/presets/quota.json +14 -0
  25. package/src/presets/source.json +17 -0
  26. package/src/steps/browser/browser.test.js +81 -0
  27. package/src/steps/{install-browser.js → browser/index.js} +12 -15
  28. package/src/steps/{__tests__/clean-ai-files.test.js → clean/clean.test.js} +28 -13
  29. package/src/steps/{clean-ai-files.js → clean/index.js} +32 -30
  30. package/src/steps/copy/agents.js +106 -0
  31. package/src/steps/{__tests__/copy-content.test.js → copy/copy.test.js} +10 -1
  32. package/src/steps/copy/index.js +33 -0
  33. package/src/steps/copy/skills.js +55 -0
  34. package/src/steps/{write-onboard-config.js → metadata/index.js} +3 -3
  35. package/src/steps/metadata/metadata.test.js +96 -0
  36. package/src/steps/models/format.js +60 -0
  37. package/src/steps/models/format.test.js +74 -0
  38. package/src/steps/models/index.js +52 -0
  39. package/src/steps/models/write.js +54 -0
  40. package/src/steps/models/write.test.js +119 -0
  41. package/src/steps/{init-openspec.js → openspec/ensemble.js} +20 -57
  42. package/src/steps/openspec/ensemble.test.js +79 -0
  43. package/src/steps/openspec/index.js +32 -0
  44. package/src/steps/optimization/caveman-guidance.js +11 -0
  45. package/src/steps/{install-caveman.js → optimization/caveman.js} +5 -19
  46. package/src/steps/optimization/global.js +64 -0
  47. package/src/steps/optimization/index.js +101 -0
  48. package/src/steps/{__tests__/token-optimization.test.js → optimization/optimization.test.js} +19 -24
  49. package/src/steps/{install-quota.js → optimization/quota.js} +12 -10
  50. package/src/steps/platform/index.js +81 -0
  51. package/src/steps/platform/platform.test.js +129 -0
  52. package/src/steps/{choose-source-scope.js → source/index.js} +11 -17
  53. package/src/steps/source/source.test.js +89 -0
  54. package/src/utils/__tests__/copy.test.js +12 -5
  55. package/src/utils/copy.js +4 -24
  56. package/src/utils/exec-spinner.js +47 -0
  57. package/src/utils/exec.js +120 -162
  58. package/src/utils/models-cache.js +25 -68
  59. package/src/utils/models-pricing.js +42 -0
  60. package/src/utils/models-pricing.test.js +94 -0
  61. package/content/.agents/agents/back-engineer.md +0 -87
  62. package/content/.agents/agents/front-engineer.md +0 -86
  63. package/content/.agents/agents/infra-engineer.md +0 -85
  64. package/content/.agents/agents/quality-engineer.md +0 -86
  65. package/content/.agents/agents/security-auditor.md +0 -86
  66. package/src/steps/__tests__/check-env.test.js +0 -70
  67. package/src/steps/__tests__/check-platform.test.js +0 -104
  68. package/src/steps/__tests__/check-rtk.test.js +0 -38
  69. package/src/steps/__tests__/choose-platform.test.js +0 -38
  70. package/src/steps/check-env.js +0 -26
  71. package/src/steps/check-platform.js +0 -80
  72. package/src/steps/check-rtk.js +0 -38
  73. package/src/steps/choose-models.js +0 -165
  74. package/src/steps/choose-platform.js +0 -22
  75. package/src/steps/choose-skills-provider.js +0 -79
  76. package/src/steps/copy-content.js +0 -89
  77. package/src/steps/enable-caveman-guidance.js +0 -78
  78. package/src/steps/patch-agents-md.js +0 -153
  79. package/src/steps/token-optimization.js +0 -59
@@ -1,9 +1,13 @@
1
1
  import { confirm } from '@inquirer/prompts'
2
2
  import fse from 'fs-extra'
3
3
  import path from 'node:path'
4
- import { error, header, info, loading, success, warn } from '../utils/exec.js'
4
+ import { fileURLToPath } from 'url'
5
+ import { error, header, info, loading, success, warn } from '../../utils/exec.js'
5
6
 
6
- const PLUGIN = '@slkiser/opencode-quota@latest'
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
+ const QUOTA_PRESET_PATH = path.resolve(__dirname, '../../presets/quota.json')
9
+ const quotaPreset = await fse.readJson(QUOTA_PRESET_PATH)
10
+ const PLUGIN = quotaPreset.plugin
7
11
 
8
12
  function ensurePlugin(config) {
9
13
  if (!Array.isArray(config.plugin)) config.plugin = []
@@ -19,11 +23,11 @@ export async function installQuota(options = {}) {
19
23
 
20
24
  let shouldInstall = true
21
25
  if (!options.skipPrompt && process.stdin.isTTY) {
22
- const timeoutMs = 20000
26
+ const timeoutMs = quotaPreset.prompt.timeoutMs
23
27
  const choice = await Promise.race([
24
28
  confirm({
25
- message: 'Install opencode-quota with recommended defaults?',
26
- default: true,
29
+ message: quotaPreset.prompt.message,
30
+ default: quotaPreset.prompt.default,
27
31
  }),
28
32
  new Promise(resolve => setTimeout(() => resolve(true), timeoutMs)),
29
33
  ])
@@ -63,11 +67,9 @@ export async function installQuota(options = {}) {
63
67
  ? await fse.readJson(quotaPath)
64
68
  : {}
65
69
 
66
- // Keep installer semantics append-only: add defaults only when missing.
67
- addIfMissing(quotaConfig, 'enabledProviders', 'auto')
68
- addIfMissing(quotaConfig, 'formatStyle', 'singleWindow')
69
- addIfMissing(quotaConfig, 'percentDisplayMode', 'used')
70
- addIfMissing(quotaConfig, 'showSessionTokens', true)
70
+ for (const [key, value] of Object.entries(quotaPreset.defaults)) {
71
+ addIfMissing(quotaConfig, key, value)
72
+ }
71
73
 
72
74
  await fse.ensureDir(quotaDir)
73
75
  await fse.writeJson(quotaPath, quotaConfig, { spaces: 2 })
@@ -0,0 +1,81 @@
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
+ await checkPlatformCli(preset)
16
+ }
17
+
18
+ export async function choosePlatform() {
19
+ header('Step 3, Version control platform')
20
+
21
+ const platform = await select({
22
+ message: 'Which platform are you using?',
23
+ choices: platformsPreset.map(p => ({ name: p.name, value: p.value })),
24
+ })
25
+
26
+ success(`Platform: ${platform === 'github' ? 'GitHub' : 'Azure DevOps'}`)
27
+ await checkPlatform(platform)
28
+ return platform
29
+ }
30
+
31
+ async function checkPlatformCli(platformPreset) {
32
+ const { cli } = platformPreset
33
+ header(`Step 4, Checking ${platformPreset.name} CLI`)
34
+
35
+ const hasCli = await commandExists(cli.command)
36
+ if (!hasCli) {
37
+ warn(`${cli.displayName} not found.`)
38
+ info(`Install from: ${cli.installUrl}`)
39
+ if (cli.authCheck?.commands?.length) {
40
+ console.log()
41
+ info('After installing, authenticate with:')
42
+ code(cli.authCheck.commands)
43
+ }
44
+ return
45
+ }
46
+ success(`${cli.displayName} available`)
47
+
48
+ if (cli.authCheck) await runAuthCheck(cli)
49
+ if (cli.extensionCheck) await runExtensionCheck(cli)
50
+ }
51
+
52
+ async function runAuthCheck(cli) {
53
+ try {
54
+ const result = await execa(cli.command, cli.authCheck.args, { reject: false })
55
+ if (result.exitCode === 0) {
56
+ success(`${cli.displayName} authenticated`)
57
+ } else {
58
+ warn(cli.authCheck.notAuthenticatedMessage)
59
+ code(cli.authCheck.commands)
60
+ }
61
+ } catch {
62
+ warn(`Could not check ${cli.command} auth status.`)
63
+ }
64
+ }
65
+
66
+ async function runExtensionCheck(cli) {
67
+ try {
68
+ const result = await execa(cli.command, cli.extensionCheck.args, { reject: false })
69
+ const hasExtension = result.stdout && result.stdout.includes(cli.extensionCheck.expectedOutput)
70
+
71
+ if (hasExtension) {
72
+ success(`${cli.extensionCheck.expectedOutput} extension installed`)
73
+ } else {
74
+ warn(cli.extensionCheck.missingMessage)
75
+ code(cli.extensionCheck.commands)
76
+ }
77
+ } catch {
78
+ warn(cli.extensionCheck.errorMessage)
79
+ code(cli.extensionCheck.commands)
80
+ }
81
+ }
@@ -0,0 +1,129 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest'
2
+
3
+ vi.mock('../../utils/exec.js', () => ({
4
+ code: vi.fn(),
5
+ commandExists: vi.fn(),
6
+ header: vi.fn(),
7
+ info: vi.fn(),
8
+ success: vi.fn(),
9
+ warn: vi.fn(),
10
+ }))
11
+
12
+ vi.mock('@inquirer/prompts', () => ({
13
+ select: vi.fn(),
14
+ }))
15
+
16
+ vi.mock('execa', () => ({
17
+ execa: vi.fn(),
18
+ }))
19
+
20
+ import { select } from '@inquirer/prompts'
21
+ import { execa } from 'execa'
22
+ import { commandExists, success, warn } from '../../utils/exec.js'
23
+ import { checkPlatform, choosePlatform } from './index.js'
24
+
25
+ describe('choosePlatform()', () => {
26
+ beforeEach(() => {
27
+ vi.clearAllMocks()
28
+ })
29
+
30
+ it('returns "github" when user selects GitHub', async () => {
31
+ select.mockResolvedValue('github')
32
+
33
+ const result = await choosePlatform()
34
+
35
+ expect(result).toBe('github')
36
+ expect(success).toHaveBeenCalledWith('Platform: GitHub')
37
+ })
38
+
39
+ it('returns "azure" when user selects Azure DevOps', async () => {
40
+ select.mockResolvedValue('azure')
41
+
42
+ const result = await choosePlatform()
43
+
44
+ expect(result).toBe('azure')
45
+ expect(success).toHaveBeenCalledWith('Platform: Azure DevOps')
46
+ })
47
+
48
+ describe('checkPlatform()', () => {
49
+ describe('github path', () => {
50
+ it('prints success when gh is installed and authenticated', async () => {
51
+ commandExists.mockResolvedValue(true)
52
+ execa.mockResolvedValue({ exitCode: 0, stdout: '' })
53
+
54
+ await checkPlatform('github')
55
+
56
+ expect(success).toHaveBeenCalledWith('GitHub CLI (gh) available')
57
+ expect(success).toHaveBeenCalledWith('GitHub CLI authenticated')
58
+ })
59
+
60
+ it('warns when gh is installed but not authenticated', async () => {
61
+ commandExists.mockResolvedValue(true)
62
+ execa.mockResolvedValue({ exitCode: 1, stdout: '' })
63
+
64
+ await checkPlatform('github')
65
+
66
+ expect(success).toHaveBeenCalledWith('GitHub CLI (gh) available')
67
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('not authenticated'))
68
+ })
69
+
70
+ it('warns when gh is not installed', async () => {
71
+ commandExists.mockResolvedValue(false)
72
+
73
+ await checkPlatform('github')
74
+
75
+ expect(warn).toHaveBeenCalledWith('GitHub CLI (gh) not found.')
76
+ expect(success).not.toHaveBeenCalled()
77
+ })
78
+
79
+ it('warns when gh auth status check throws', async () => {
80
+ commandExists.mockResolvedValue(true)
81
+ execa.mockRejectedValue(new Error('spawn error'))
82
+
83
+ await checkPlatform('github')
84
+
85
+ expect(warn).toHaveBeenCalledWith('Could not check gh auth status.')
86
+ })
87
+ })
88
+
89
+ describe('azure path', () => {
90
+ it('prints success when az is installed and azure-devops extension present', async () => {
91
+ commandExists.mockResolvedValue(true)
92
+ execa.mockResolvedValue({ exitCode: 0, stdout: 'azure-devops\tsome info' })
93
+
94
+ await checkPlatform('azure')
95
+
96
+ expect(success).toHaveBeenCalledWith('Azure CLI (az) available')
97
+ expect(success).toHaveBeenCalledWith('azure-devops extension installed')
98
+ })
99
+
100
+ it('warns when az is installed but azure-devops extension is missing', async () => {
101
+ commandExists.mockResolvedValue(true)
102
+ execa.mockResolvedValue({ exitCode: 0, stdout: '' })
103
+
104
+ await checkPlatform('azure')
105
+
106
+ expect(success).toHaveBeenCalledWith('Azure CLI (az) available')
107
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('azure-devops extension not found'))
108
+ })
109
+
110
+ it('warns when az is not installed', async () => {
111
+ commandExists.mockResolvedValue(false)
112
+
113
+ await checkPlatform('azure')
114
+
115
+ expect(warn).toHaveBeenCalledWith('Azure CLI (az) not found.')
116
+ expect(success).not.toHaveBeenCalled()
117
+ })
118
+
119
+ it('warns when extension check throws', async () => {
120
+ commandExists.mockResolvedValue(true)
121
+ execa.mockRejectedValue(new Error('spawn error'))
122
+
123
+ await checkPlatform('azure')
124
+
125
+ expect(warn).toHaveBeenCalledWith('Could not check azure-devops extension. Run:')
126
+ })
127
+ })
128
+ })
129
+ })
@@ -1,7 +1,12 @@
1
1
  import { checkbox, select } from '@inquirer/prompts'
2
2
  import fse from 'fs-extra'
3
3
  import path from 'path'
4
- import { header, info, success, warn } from '../utils/exec.js'
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)
5
10
 
6
11
  async function listParentFolders(cwd) {
7
12
  const parent = path.resolve(cwd, '..')
@@ -26,26 +31,15 @@ async function listParentFolders(cwd) {
26
31
  }
27
32
 
28
33
  export async function chooseSourceScope() {
29
- header('Step 2, Source code scope')
34
+ header('Step 1, Source code scope')
30
35
 
31
36
  const cwd = process.cwd()
32
37
  info('Choose where agents should read source code from during init analysis.')
33
38
 
34
39
  const mode = await select({
35
- message: 'Source code location:',
36
- default: 'current',
37
- choices: [
38
- {
39
- name: 'Current folder (default)',
40
- value: 'current',
41
- description: 'Use this repository only',
42
- },
43
- {
44
- name: 'Select folders in parent (../)',
45
- value: 'parent',
46
- description: 'Use when this repo only contains agent config',
47
- },
48
- ],
40
+ message: sourcePreset.message,
41
+ default: sourcePreset.default,
42
+ choices: sourcePreset.choices,
49
43
  })
50
44
 
51
45
  if (mode === 'current') {
@@ -61,7 +55,7 @@ export async function chooseSourceScope() {
61
55
  }
62
56
 
63
57
  const selected = await checkbox({
64
- message: 'Select source folders from parent directory:',
58
+ message: sourcePreset.parentSelectionMessage,
65
59
  choices: parentFolders.map(d => ({
66
60
  name: `../${d.name}`,
67
61
  value: d.abs,
@@ -0,0 +1,89 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import os from 'node:os'
5
+
6
+ vi.mock('../../utils/exec.js', () => ({
7
+ header: vi.fn(),
8
+ info: vi.fn(),
9
+ success: vi.fn(),
10
+ warn: vi.fn(),
11
+ }))
12
+
13
+ vi.mock('@inquirer/prompts', () => ({
14
+ select: vi.fn(),
15
+ checkbox: vi.fn(),
16
+ }))
17
+
18
+ vi.mock('fs-extra', () => ({
19
+ default: {
20
+ readJson: vi.fn().mockResolvedValue({
21
+ message: 'Select source scope',
22
+ default: 'current',
23
+ choices: [
24
+ { name: 'Current folder', value: 'current' },
25
+ { name: 'Parent folder', value: 'parent' },
26
+ ],
27
+ parentSelectionMessage: 'Select sibling folders',
28
+ }),
29
+ readdir: vi.fn(),
30
+ stat: vi.fn(),
31
+ },
32
+ }))
33
+
34
+ import { select, checkbox } from '@inquirer/prompts'
35
+ import fse from 'fs-extra'
36
+ import { chooseSourceScope } from './index.js'
37
+
38
+ describe('chooseSourceScope()', () => {
39
+ let tmpDir
40
+
41
+ beforeEach(() => {
42
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'source-test-'))
43
+ process.chdir(tmpDir)
44
+ vi.clearAllMocks()
45
+ })
46
+
47
+ afterEach(() => {
48
+ fs.rmSync(tmpDir, { recursive: true, force: true })
49
+ })
50
+
51
+ it('returns current folder when user selects current mode', async () => {
52
+ select.mockResolvedValue('current')
53
+
54
+ const result = await chooseSourceScope()
55
+
56
+ expect(result.sourceMode).toBe('current')
57
+ expect(result.sourceRoots).toContain(tmpDir)
58
+ })
59
+
60
+ it('lists parent folders when user selects parent mode', async () => {
61
+ select.mockResolvedValue('parent')
62
+ const parentDir = path.dirname(tmpDir)
63
+ const siblingDir = path.join(parentDir, 'sibling-project')
64
+ fs.mkdirSync(siblingDir)
65
+ fse.readdir.mockResolvedValue(['sibling-project'])
66
+
67
+ await chooseSourceScope()
68
+
69
+ expect(checkbox).toHaveBeenCalled()
70
+ })
71
+
72
+ it('falls back to current when no siblings found', async () => {
73
+ select.mockResolvedValue('parent')
74
+ fse.readdir.mockResolvedValue([])
75
+
76
+ const result = await chooseSourceScope()
77
+
78
+ expect(result.sourceMode).toBe('current')
79
+ })
80
+
81
+ it('falls back to current when no folders selected', async () => {
82
+ select.mockResolvedValue('parent')
83
+ checkbox.mockResolvedValue([])
84
+
85
+ const result = await chooseSourceScope()
86
+
87
+ expect(result.sourceMode).toBe('current')
88
+ })
89
+ })
@@ -7,6 +7,13 @@ import fse from 'fs-extra'
7
7
  import { copyContent, findAiFiles } from '../copy.js'
8
8
 
9
9
  const tmpDir = () => fse.mkdtempSync(path.join(os.tmpdir(), 'ob-test-'))
10
+ const aiFiles = [
11
+ 'AGENTS.md',
12
+ 'CLAUDE.md',
13
+ '.cursorrules',
14
+ '.clinerules',
15
+ '.github/copilot-instructions.md',
16
+ ]
10
17
 
11
18
  describe('copy utils', () => {
12
19
  describe('findAiFiles()', () => {
@@ -21,20 +28,20 @@ describe('copy utils', () => {
21
28
  })
22
29
 
23
30
  it('returns empty array when no AI files exist', async () => {
24
- const found = await findAiFiles(dir)
31
+ const found = await findAiFiles(dir, aiFiles)
25
32
  expect(found).toEqual([])
26
33
  })
27
34
 
28
35
  it('detects AGENTS.md', async () => {
29
36
  await fse.writeFile(path.join(dir, 'AGENTS.md'), '# agents')
30
- const found = await findAiFiles(dir)
37
+ const found = await findAiFiles(dir, aiFiles)
31
38
  expect(found).toHaveLength(1)
32
39
  expect(found[0]).toContain('AGENTS.md')
33
40
  })
34
41
 
35
42
  it('detects CLAUDE.md', async () => {
36
43
  await fse.writeFile(path.join(dir, 'CLAUDE.md'), '# claude')
37
- const found = await findAiFiles(dir)
44
+ const found = await findAiFiles(dir, aiFiles)
38
45
  expect(found).toHaveLength(1)
39
46
  expect(found[0]).toContain('CLAUDE.md')
40
47
  })
@@ -43,7 +50,7 @@ describe('copy utils', () => {
43
50
  await fse.writeFile(path.join(dir, 'AGENTS.md'), '')
44
51
  await fse.writeFile(path.join(dir, '.cursorrules'), '')
45
52
  await fse.writeFile(path.join(dir, '.clinerules'), '')
46
- const found = await findAiFiles(dir)
53
+ const found = await findAiFiles(dir, aiFiles)
47
54
  expect(found).toHaveLength(3)
48
55
  })
49
56
 
@@ -51,7 +58,7 @@ describe('copy utils', () => {
51
58
  const ghDir = path.join(dir, '.github')
52
59
  await fse.ensureDir(ghDir)
53
60
  await fse.writeFile(path.join(ghDir, 'copilot-instructions.md'), '')
54
- const found = await findAiFiles(dir)
61
+ const found = await findAiFiles(dir, aiFiles)
55
62
  expect(found).toHaveLength(1)
56
63
  expect(found[0]).toContain('copilot-instructions.md')
57
64
  })
package/src/utils/copy.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fse from 'fs-extra'
2
2
  import path from 'path'
3
3
 
4
- // Folders never copied (skills handled separately by chooseSkillsProvider, .bootstrap is internal tooling)
4
+ // Folders never copied (skills handled separately by installSkills, .bootstrap is internal tooling)
5
5
  // These are excluded from the general content copy, they are installed separately
6
6
  // by initOpenspec after openspec init runs, so our versions win over the generated ones.
7
7
  const ALWAYS_EXCLUDE = ['.bootstrap', 'skills', 'node_modules']
@@ -29,7 +29,7 @@ export async function copyContent(contentDir, destDir, platform, ctx = {}) {
29
29
  filter: (src) => {
30
30
  const rel = path.relative(contentDir, src)
31
31
  const parts = rel.split(path.sep)
32
- if (parts.some(part => ALWAYS_EXCLUDE.some(pattern => part.includes(pattern)))) return false
32
+ if (parts.some(part => ALWAYS_EXCLUDE.includes(part))) return false
33
33
  if (OPENSPEC_APPLY_FILES.some(f => rel === f)) return false
34
34
  if (ctx.hasDesign && rel === 'DESIGN.md') return false
35
35
  if (ctx.hasArchitecture && rel === 'ARCHITECTURE.md') return false
@@ -38,29 +38,9 @@ export async function copyContent(contentDir, destDir, platform, ctx = {}) {
38
38
  })
39
39
  }
40
40
 
41
- /**
42
- * Scan a directory for known AI config files.
43
- * Returns array of absolute paths found.
44
- */
45
- const AI_FILES = [
46
- 'AGENTS.md',
47
- 'CLAUDE.md',
48
- 'ARCHITECTURE.md',
49
- 'DESIGN.md',
50
- '.cursorrules',
51
- '.clinerules',
52
- '.windsurfrules',
53
- '.github/copilot-instructions.md',
54
- 'copilot-instructions.md',
55
- '.aider.conf.yml',
56
- '.aider',
57
- '.opencode',
58
- '.agents'
59
- ]
60
-
61
- export async function findAiFiles(dir) {
41
+ export async function findAiFiles(dir, files) {
62
42
  const found = []
63
- for (const file of AI_FILES) {
43
+ for (const file of files) {
64
44
  const fullPath = path.join(dir, file)
65
45
  if (await fse.pathExists(fullPath)) {
66
46
  found.push(fullPath)
@@ -0,0 +1,47 @@
1
+ import chalk from 'chalk'
2
+ import ora from 'ora'
3
+
4
+ // ── Screen / step state ──────────────────────────────────────────────────────
5
+
6
+ const previousSteps = []; // up to 2 completed steps, each is an array of lines
7
+ let currentStepLines = []; // lines accumulated in the current step
8
+ let stepSpinner = null; // ora spinner shown while step is working
9
+
10
+ export function appendLine(line) {
11
+ currentStepLines.push(line);
12
+ }
13
+
14
+ export function stopSpinner() {
15
+ if (stepSpinner) {
16
+ stepSpinner.stop();
17
+ stepSpinner = null;
18
+ }
19
+ }
20
+
21
+ export function startSpinner(text = 'working...') {
22
+ stopSpinner();
23
+ stepSpinner = ora({ text: chalk.dim(text), color: 'red' }).start();
24
+ }
25
+
26
+ export function redraw() {
27
+ if (process.stdout.isTTY) console.clear();
28
+
29
+ // Show up to 2 previous steps dimmed
30
+ for (const stepLines of previousSteps) {
31
+ for (const line of stepLines) {
32
+ process.stdout.write(chalk.dim(line) + '\n');
33
+ }
34
+ process.stdout.write('\n');
35
+ }
36
+
37
+ // Current step output
38
+ for (const line of currentStepLines) {
39
+ process.stdout.write(line + '\n');
40
+ }
41
+ }
42
+
43
+ export function rotateStep() {
44
+ previousSteps.push(currentStepLines);
45
+ if (previousSteps.length > 2) previousSteps.shift();
46
+ currentStepLines = [];
47
+ }