opencode-onboard 0.4.2 → 0.4.4

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +304 -301
  3. package/content/.agents/agents/basic-engineer.md +4 -2
  4. package/content/.agents/agents/devops-manager.md +123 -123
  5. package/content/.agents/skills/ob-default/SKILL.md +25 -21
  6. package/content/.agents/skills/ob-generic-guardrails/SKILL.md +36 -32
  7. package/content/.agents/skills/ob-global/SKILL.md +92 -49
  8. package/content/.agents/skills/ob-pullrequest-az/SKILL.md +168 -160
  9. package/content/.agents/skills/ob-pullrequest-gh/SKILL.md +140 -136
  10. package/content/.opencode/commands/create-engineer.md +109 -0
  11. package/content/.opencode/commands/init.md +1 -1
  12. package/content/.opencode/commands/main.md +1 -1
  13. package/content/.opencode/commands/opsx-apply.md +131 -70
  14. package/content/.opencode/commands/plan.md +1 -1
  15. package/content/.opencode/plugins/session-log.js +523 -519
  16. package/content/.opencode/skills/openspec-apply-change/SKILL.md +86 -64
  17. package/content/AGENTS.md +67 -39
  18. package/package.json +1 -1
  19. package/src/commands/join.js +3 -3
  20. package/src/commands/single.js +2 -0
  21. package/src/commands/wizard.js +124 -99
  22. package/src/presets/browser.json +22 -18
  23. package/src/presets/optimization.json +27 -22
  24. package/src/presets/source.json +7 -1
  25. package/src/steps/browser/browser.test.js +115 -81
  26. package/src/steps/browser/index.js +62 -54
  27. package/src/steps/clean/index.js +108 -107
  28. package/src/steps/copy/agents.js +28 -0
  29. package/src/steps/copy/copy.test.js +1 -0
  30. package/src/steps/copy/index.js +2 -1
  31. package/src/steps/metadata/index.js +63 -61
  32. package/src/steps/models/format.js +61 -60
  33. package/src/steps/models/write.test.js +117 -117
  34. package/src/steps/openspec/ensemble.js +30 -7
  35. package/src/steps/openspec/ensemble.test.js +79 -79
  36. package/src/steps/openspec/index.js +121 -32
  37. package/src/steps/openspec/index.test.js +63 -0
  38. package/src/steps/optimization/caveman.js +34 -29
  39. package/src/steps/optimization/codegraph.js +52 -0
  40. package/src/steps/optimization/global.js +88 -64
  41. package/src/steps/optimization/global.test.js +99 -0
  42. package/src/steps/optimization/index.js +109 -101
  43. package/src/steps/optimization/optimization.test.js +101 -93
  44. package/src/steps/optimization/quota.js +84 -84
  45. package/src/steps/source/index.js +48 -0
  46. package/src/steps/source/source.test.js +124 -91
  47. package/src/utils/__tests__/copy.test.js +117 -117
  48. package/src/utils/exec-spinner.js +47 -47
  49. package/src/utils/exec.js +134 -131
  50. package/src/utils/terminal.js +6 -0
@@ -1,117 +1,117 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2
- import path from 'path'
3
- import os from 'os'
4
- import fse from 'fs-extra'
5
-
6
- // Use real fs-extra for file system tests (temp dirs)
7
- import { copyContent, findAiFiles } from '../copy.js'
8
-
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
- ]
17
-
18
- describe('copy utils', () => {
19
- describe('findAiFiles()', () => {
20
- let dir
21
-
22
- beforeEach(() => {
23
- dir = tmpDir()
24
- })
25
-
26
- afterEach(async () => {
27
- await fse.remove(dir)
28
- })
29
-
30
- it('returns empty array when no AI files exist', async () => {
31
- const found = await findAiFiles(dir, aiFiles)
32
- expect(found).toEqual([])
33
- })
34
-
35
- it('detects AGENTS.md', async () => {
36
- await fse.writeFile(path.join(dir, 'AGENTS.md'), '# agents')
37
- const found = await findAiFiles(dir, aiFiles)
38
- expect(found).toHaveLength(1)
39
- expect(found[0]).toContain('AGENTS.md')
40
- })
41
-
42
- it('detects CLAUDE.md', async () => {
43
- await fse.writeFile(path.join(dir, 'CLAUDE.md'), '# claude')
44
- const found = await findAiFiles(dir, aiFiles)
45
- expect(found).toHaveLength(1)
46
- expect(found[0]).toContain('CLAUDE.md')
47
- })
48
-
49
- it('detects multiple AI files at once', async () => {
50
- await fse.writeFile(path.join(dir, 'AGENTS.md'), '')
51
- await fse.writeFile(path.join(dir, '.cursorrules'), '')
52
- await fse.writeFile(path.join(dir, '.clinerules'), '')
53
- const found = await findAiFiles(dir, aiFiles)
54
- expect(found).toHaveLength(3)
55
- })
56
-
57
- it('detects nested copilot-instructions.md', async () => {
58
- const ghDir = path.join(dir, '.github')
59
- await fse.ensureDir(ghDir)
60
- await fse.writeFile(path.join(ghDir, 'copilot-instructions.md'), '')
61
- const found = await findAiFiles(dir, aiFiles)
62
- expect(found).toHaveLength(1)
63
- expect(found[0]).toContain('copilot-instructions.md')
64
- })
65
- })
66
-
67
- describe('copyContent()', () => {
68
- let src, dest
69
-
70
- beforeEach(async () => {
71
- src = tmpDir()
72
- dest = tmpDir()
73
- })
74
-
75
- afterEach(async () => {
76
- await fse.remove(src)
77
- await fse.remove(dest)
78
- })
79
-
80
- it('copies files that match neither platform exclusion', async () => {
81
- await fse.writeFile(path.join(src, 'AGENTS.md'), '# agents')
82
- await copyContent(src, dest, 'github')
83
- expect(await fse.pathExists(path.join(dest, 'AGENTS.md'))).toBe(true)
84
- })
85
-
86
- it('always excludes .bootstrap folder', async () => {
87
- await fse.ensureDir(path.join(src, '.bootstrap'))
88
- await fse.writeFile(path.join(src, '.bootstrap', 'secret.md'), 'internal')
89
-
90
- await copyContent(src, dest, 'github')
91
-
92
- expect(await fse.pathExists(path.join(dest, '.bootstrap', 'secret.md'))).toBe(false)
93
- })
94
-
95
- it('does not overwrite existing files', async () => {
96
- await fse.writeFile(path.join(src, 'AGENTS.md'), 'new content')
97
- await fse.writeFile(path.join(dest, 'AGENTS.md'), 'original content')
98
-
99
- await copyContent(src, dest, 'github')
100
-
101
- const content = await fse.readFile(path.join(dest, 'AGENTS.md'), 'utf-8')
102
- expect(content).toBe('original content')
103
- })
104
-
105
- it('copies github-specific files when platform is github', async () => {
106
- await fse.writeFile(path.join(src, 'agent-gh.md'), 'github agent')
107
- await copyContent(src, dest, 'github')
108
- expect(await fse.pathExists(path.join(dest, 'agent-gh.md'))).toBe(true)
109
- })
110
-
111
- it('copies azure-specific files when platform is azure', async () => {
112
- await fse.writeFile(path.join(src, 'agent-az.md'), 'azure agent')
113
- await copyContent(src, dest, 'azure')
114
- expect(await fse.pathExists(path.join(dest, 'agent-az.md'))).toBe(true)
115
- })
116
- })
117
- })
1
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest'
2
+ import path from 'path'
3
+ import os from 'os'
4
+ import fse from 'fs-extra'
5
+
6
+ // Use real fs-extra for file system tests (temp dirs)
7
+ import { copyContent, findAiFiles } from '../copy.js'
8
+
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
+ ]
17
+
18
+ describe('copy utils', () => {
19
+ describe('findAiFiles()', () => {
20
+ let dir
21
+
22
+ beforeEach(() => {
23
+ dir = tmpDir()
24
+ })
25
+
26
+ afterEach(async () => {
27
+ await fse.remove(dir)
28
+ })
29
+
30
+ it('returns empty array when no AI files exist', async () => {
31
+ const found = await findAiFiles(dir, aiFiles)
32
+ expect(found).toEqual([])
33
+ })
34
+
35
+ it('detects AGENTS.md', async () => {
36
+ await fse.writeFile(path.join(dir, 'AGENTS.md'), '# agents')
37
+ const found = await findAiFiles(dir, aiFiles)
38
+ expect(found).toHaveLength(1)
39
+ expect(found[0]).toContain('AGENTS.md')
40
+ })
41
+
42
+ it('detects CLAUDE.md', async () => {
43
+ await fse.writeFile(path.join(dir, 'CLAUDE.md'), '# claude')
44
+ const found = await findAiFiles(dir, aiFiles)
45
+ expect(found).toHaveLength(1)
46
+ expect(found[0]).toContain('CLAUDE.md')
47
+ })
48
+
49
+ it('detects multiple AI files at once', async () => {
50
+ await fse.writeFile(path.join(dir, 'AGENTS.md'), '')
51
+ await fse.writeFile(path.join(dir, '.cursorrules'), '')
52
+ await fse.writeFile(path.join(dir, '.clinerules'), '')
53
+ const found = await findAiFiles(dir, aiFiles)
54
+ expect(found).toHaveLength(3)
55
+ })
56
+
57
+ it('detects nested copilot-instructions.md', async () => {
58
+ const ghDir = path.join(dir, '.github')
59
+ await fse.ensureDir(ghDir)
60
+ await fse.writeFile(path.join(ghDir, 'copilot-instructions.md'), '')
61
+ const found = await findAiFiles(dir, aiFiles)
62
+ expect(found).toHaveLength(1)
63
+ expect(found[0]).toContain('copilot-instructions.md')
64
+ })
65
+ })
66
+
67
+ describe('copyContent()', () => {
68
+ let src, dest
69
+
70
+ beforeEach(async () => {
71
+ src = tmpDir()
72
+ dest = tmpDir()
73
+ })
74
+
75
+ afterEach(async () => {
76
+ await fse.remove(src)
77
+ await fse.remove(dest)
78
+ })
79
+
80
+ it('copies files that match neither platform exclusion', async () => {
81
+ await fse.writeFile(path.join(src, 'AGENTS.md'), '# agents')
82
+ await copyContent(src, dest, 'github')
83
+ expect(await fse.pathExists(path.join(dest, 'AGENTS.md'))).toBe(true)
84
+ })
85
+
86
+ it('always excludes .bootstrap folder', async () => {
87
+ await fse.ensureDir(path.join(src, '.bootstrap'))
88
+ await fse.writeFile(path.join(src, '.bootstrap', 'secret.md'), 'internal')
89
+
90
+ await copyContent(src, dest, 'github')
91
+
92
+ expect(await fse.pathExists(path.join(dest, '.bootstrap', 'secret.md'))).toBe(false)
93
+ })
94
+
95
+ it('does not overwrite existing files', async () => {
96
+ await fse.writeFile(path.join(src, 'AGENTS.md'), 'new content')
97
+ await fse.writeFile(path.join(dest, 'AGENTS.md'), 'original content')
98
+
99
+ await copyContent(src, dest, 'github')
100
+
101
+ const content = await fse.readFile(path.join(dest, 'AGENTS.md'), 'utf-8')
102
+ expect(content).toBe('original content')
103
+ })
104
+
105
+ it('copies github-specific files when platform is github', async () => {
106
+ await fse.writeFile(path.join(src, 'agent-gh.md'), 'github agent')
107
+ await copyContent(src, dest, 'github')
108
+ expect(await fse.pathExists(path.join(dest, 'agent-gh.md'))).toBe(true)
109
+ })
110
+
111
+ it('copies azure-specific files when platform is azure', async () => {
112
+ await fse.writeFile(path.join(src, 'agent-az.md'), 'azure agent')
113
+ await copyContent(src, dest, 'azure')
114
+ expect(await fse.pathExists(path.join(dest, 'agent-az.md'))).toBe(true)
115
+ })
116
+ })
117
+ })
@@ -1,47 +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
- }
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
+ }
package/src/utils/exec.js CHANGED
@@ -1,131 +1,134 @@
1
- import chalk from 'chalk'
2
- import { execa } from 'execa'
3
- import ora from 'ora'
4
- import { appendLine, redraw, rotateStep, startSpinner, stopSpinner } from './exec-spinner.js'
5
-
6
- // ── Public API ───────────────────────────────────────────────────────────────
7
-
8
- /**
9
- * Run a shell command with a spinner.
10
- * Returns { success, stdout, stderr }
11
- */
12
- export async function run(command, args = [], { label, cwd = process.cwd() } = {}) {
13
- const spinner = ora(label ?? `${command} ${args.join(' ')}`).start();
14
- try {
15
- const result = await execa(command, args, { cwd, reject: false });
16
- if (result.exitCode === 0) {
17
- spinner.succeed();
18
- } else {
19
- spinner.fail();
20
- }
21
- return { success: result.exitCode === 0, stdout: result.stdout, stderr: result.stderr };
22
- } catch (err) {
23
- spinner.fail();
24
- return { success: false, stdout: '', stderr: err.message };
25
- }
26
- }
27
-
28
- /**
29
- * Check if a command is available on PATH.
30
- * Returns true/false.
31
- */
32
- export async function commandExists(command) {
33
- try {
34
- const result = await execa(command, ['--version'], { reject: false });
35
- return result.exitCode === 0;
36
- } catch {
37
- return false;
38
- }
39
- }
40
-
41
- /**
42
- * Print a section header, clears screen, shows previous step dimmed, starts new step.
43
- */
44
- export function header(text) {
45
- rotateStep();
46
-
47
- const line1 = '';
48
- const line2 = chalk.bold.hex('#fe3d57')(`━━ ${text}`);
49
- const line3 = '';
50
-
51
- appendLine(line1);
52
- appendLine(line2);
53
- appendLine(line3);
54
-
55
- redraw();
56
-
57
- startSpinner('working...');
58
- }
59
-
60
- /**
61
- * Restart the step spinner after prompts or logs.
62
- */
63
- export function loading(text = 'working...') {
64
- startSpinner(text);
65
- }
66
-
67
- /**
68
- * Print a success line.
69
- */
70
- export function success(text) {
71
- stopSpinner();
72
- const line = chalk.green('✓ ') + text;
73
- appendLine(line);
74
- console.log(line);
75
- }
76
-
77
- /**
78
- * Print a warning line.
79
- */
80
- export function warn(text) {
81
- stopSpinner();
82
- const line = chalk.yellow('⚠ ') + text;
83
- appendLine(line);
84
- console.log(line);
85
- }
86
-
87
- /**
88
- * Print an error line.
89
- */
90
- export function error(text) {
91
- stopSpinner();
92
- const line = chalk.red('✗ ') + text;
93
- appendLine(line);
94
- console.log(line);
95
- }
96
-
97
- /**
98
- * Print an info line.
99
- */
100
- export function info(text) {
101
- stopSpinner();
102
- const line = chalk.dim(' ' + text);
103
- appendLine(line);
104
- console.log(line);
105
- }
106
-
107
- /**
108
- * Print an action prompt line (white bold, requires user interaction).
109
- */
110
- export function prompt(text) {
111
- stopSpinner();
112
- const line = chalk.bold(' ' + text);
113
- appendLine(line);
114
- console.log(line);
115
- }
116
-
117
- /**
118
- * Print a code block.
119
- */
120
- export function code(lines) {
121
- stopSpinner();
122
- appendLine('');
123
- console.log();
124
- for (const line of lines) {
125
- const formatted = chalk.bgGray.white(' ' + line + ' ');
126
- appendLine(formatted);
127
- console.log(formatted);
128
- }
129
- appendLine('');
130
- console.log();
131
- }
1
+ import chalk from 'chalk'
2
+ import { execa } from 'execa'
3
+ import ora from 'ora'
4
+ import { appendLine, redraw, rotateStep, startSpinner, stopSpinner } from './exec-spinner.js'
5
+ import { MARKERS } from './terminal.js';
6
+
7
+ // ── Public API ───────────────────────────────────────────────────────────────
8
+
9
+ /**
10
+ * Run a shell command with a spinner.
11
+ * Returns { success, stdout, stderr }
12
+ */
13
+ export async function run(command, args = [], { label, cwd = process.cwd() } = {}) {
14
+ const spinner = ora(label ?? `${command} ${args.join(' ')}`).start();
15
+ try {
16
+ const result = await execa(command, args, { cwd, reject: false });
17
+ if (result.exitCode === 0) {
18
+ spinner.succeed();
19
+ } else {
20
+ spinner.fail();
21
+ }
22
+ return { success: result.exitCode === 0, stdout: result.stdout, stderr: result.stderr };
23
+ } catch (err) {
24
+ spinner.fail();
25
+ return { success: false, stdout: '', stderr: err.message };
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Check if a command is available on PATH.
31
+ * Returns true/false.
32
+ */
33
+ export async function commandExists(command) {
34
+ try {
35
+ const result = await execa(command, ['--version'], { reject: false });
36
+ return result.exitCode === 0;
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Print a section header, clears screen, shows previous step dimmed, starts new step.
44
+ */
45
+ export function header(text) {
46
+ rotateStep();
47
+
48
+ const line1 = '';
49
+ const line2 = chalk.bold.hex('#fe3d57')(`━━ ${text}`);
50
+ const line3 = '';
51
+
52
+ appendLine(line1);
53
+ appendLine(line2);
54
+ appendLine(line3);
55
+
56
+ redraw();
57
+
58
+ startSpinner('working...');
59
+ }
60
+
61
+ /**
62
+ * Restart the step spinner after prompts or logs.
63
+ */
64
+ export function loading(text = 'working...') {
65
+ startSpinner(text);
66
+ }
67
+
68
+ /**
69
+ * Print a success line.
70
+ */
71
+ export function success(text) {
72
+ stopSpinner();
73
+ const line = chalk.green(`${MARKERS.OK_PREFIX}${text}`);
74
+ appendLine(line);
75
+ console.log(line);
76
+ }
77
+
78
+ /**
79
+ * Print a warning line.
80
+ */
81
+ export function warn(text) {
82
+ stopSpinner();
83
+ const line = chalk.yellow(`${MARKERS.WARN_PREFIX}${text}`);
84
+ appendLine(line);
85
+ console.log(line);
86
+ }
87
+
88
+ /**
89
+ * Print an error line.
90
+ */
91
+ export function error(text) {
92
+ stopSpinner();
93
+ const line = chalk.red(`${MARKERS.ERROR_PREFIX}${text}`);
94
+ appendLine(line);
95
+ console.log(line);
96
+ }
97
+
98
+ /**
99
+ * Print an info line.
100
+ */
101
+ export function info(text) {
102
+ stopSpinner();
103
+ const line = chalk.dim(`${MARKERS.EMPTY}${text}`);
104
+ appendLine(line);
105
+ console.log(line);
106
+ }
107
+
108
+ /**
109
+ * Print an action prompt line (white bold, requires user interaction).
110
+ */
111
+ export function prompt(text) {
112
+ stopSpinner();
113
+ const line = chalk.bold(`${MARKERS.EMPTY}${text}`);
114
+ appendLine(line);
115
+ console.log(line);
116
+ }
117
+
118
+ /**
119
+ * Print a code block.
120
+ */
121
+ export function code(lines) {
122
+ stopSpinner();
123
+ appendLine('');
124
+ console.log();
125
+ for (const line of lines) {
126
+ const formatted = chalk.bgGray.white(
127
+ `${MARKERS.EMPTY}${line}${MARKERS.EMPTY}`,
128
+ );
129
+ appendLine(formatted);
130
+ console.log(formatted);
131
+ }
132
+ appendLine('');
133
+ console.log();
134
+ }
@@ -0,0 +1,6 @@
1
+ export const MARKERS = {
2
+ EMPTY: " ",
3
+ OK_PREFIX: "✓ ",
4
+ WARN_PREFIX: "⚠ ",
5
+ ERROR_PREFIX: "✗ ",
6
+ };