@produck/agent-toolkit 0.1.0 → 0.1.2

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 CHANGED
@@ -40,12 +40,30 @@ npm --prefix tools/agent-toolkit run pack:check
40
40
 
41
41
  ## Manual publish
42
42
 
43
- Dry-run publish:
43
+ Lerna-like release flow (recommended):
44
44
 
45
- npm --prefix tools/agent-toolkit run publish:dry-run
45
+ 0) Interactive mode (TTY):
46
+
47
+ npm --prefix tools/agent-toolkit run release
48
+
49
+ Interactive prompts let you choose:
50
+
51
+ - version level: patch/minor/major
52
+ - action: dry-run or publish
53
+
54
+ Default choices:
46
55
 
47
- Publish latest:
56
+ - patch
57
+ - dry-run
48
58
 
59
+ Interactive mode handles both:
60
+
61
+ - version bump level (patch/minor/major)
62
+ - action mode (dry-run or publish)
63
+
64
+ Low-level commands (optional):
65
+
66
+ npm --prefix tools/agent-toolkit run publish:dry-run
49
67
  npm --prefix tools/agent-toolkit run publish:latest
50
68
 
51
69
  ## GitHub workflow
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { spawnSync } from 'node:child_process';
5
+ import readline from 'node:readline/promises';
6
+
7
+ const LEVELS = new Set(['patch', 'minor', 'major']);
8
+
9
+ function usage() {
10
+ console.log([
11
+ 'Usage:',
12
+ ' node ./bin/release.mjs',
13
+ ' node ./bin/release.mjs <patch|minor|major> [--publish]',
14
+ ' node ./bin/release.mjs --interactive',
15
+ '',
16
+ 'Behavior:',
17
+ ' 1) bump version (no git tag)',
18
+ ' 2) run verify',
19
+ ' 3) run publish:dry-run',
20
+ ' 4) optionally publish latest when --publish is set',
21
+ '',
22
+ 'Interactive mode defaults:',
23
+ ' - release level: patch',
24
+ ' - publish mode: dry-run',
25
+ ].join('\n'));
26
+ }
27
+
28
+ function runNpm(args) {
29
+ const result = spawnSync('npm', args, {
30
+ stdio: 'inherit',
31
+ cwd: process.cwd(),
32
+ shell: true,
33
+ });
34
+
35
+ if (result.error) {
36
+ console.error(`[release] failed to run npm ${args.join(' ')}:`);
37
+ console.error(result.error.message);
38
+ process.exit(1);
39
+ }
40
+
41
+ if (result.status !== 0) {
42
+ process.exit(result.status ?? 1);
43
+ }
44
+ }
45
+
46
+ function bumpPreview(version, level) {
47
+ const parts = version.split('.').map((v) => Number(v));
48
+ if (parts.length !== 3 || parts.some((v) => Number.isNaN(v))) {
49
+ return `unknown (${version})`;
50
+ }
51
+
52
+ const [major, minor, patch] = parts;
53
+ if (level === 'patch') {
54
+ return `${major}.${minor}.${patch + 1}`;
55
+ }
56
+ if (level === 'minor') {
57
+ return `${major}.${minor + 1}.0`;
58
+ }
59
+ return `${major + 1}.0.0`;
60
+ }
61
+
62
+ async function askInteractive(currentVersion) {
63
+ const rl = readline.createInterface({
64
+ input: process.stdin,
65
+ output: process.stdout,
66
+ });
67
+
68
+ try {
69
+ console.log(`[release] current version: ${currentVersion}`);
70
+ console.log('[release] select release level:');
71
+ console.log(` 1) patch (default) -> ${bumpPreview(currentVersion, 'patch')}`);
72
+ console.log(` 2) minor -> ${bumpPreview(currentVersion, 'minor')}`);
73
+ console.log(` 3) major -> ${bumpPreview(currentVersion, 'major')}`);
74
+
75
+ const levelAnswer = (
76
+ await rl.question('Choose level [1/2/3] (default: 1): ')
77
+ ).trim();
78
+
79
+ let level = 'patch';
80
+ if (levelAnswer === '2') {
81
+ level = 'minor';
82
+ } else if (levelAnswer === '3') {
83
+ level = 'major';
84
+ } else if (levelAnswer && levelAnswer !== '1') {
85
+ console.error(`Invalid level choice: ${levelAnswer}`);
86
+ process.exit(2);
87
+ }
88
+
89
+ console.log('[release] select publish mode:');
90
+ console.log(' 1) dry-run only (default)');
91
+ console.log(' 2) publish latest after dry-run');
92
+
93
+ const publishAnswer = (
94
+ await rl.question('Choose mode [1/2] (default: 1): ')
95
+ ).trim();
96
+
97
+ let shouldPublish = false;
98
+ if (publishAnswer === '2') {
99
+ shouldPublish = true;
100
+ } else if (publishAnswer && publishAnswer !== '1') {
101
+ console.error(`Invalid publish choice: ${publishAnswer}`);
102
+ process.exit(2);
103
+ }
104
+
105
+ return { level, shouldPublish };
106
+ } finally {
107
+ rl.close();
108
+ }
109
+ }
110
+
111
+ function runRelease(level, shouldPublish) {
112
+ if (!LEVELS.has(level)) {
113
+ console.error(`Invalid release level: ${level}`);
114
+ usage();
115
+ process.exit(2);
116
+ }
117
+
118
+ const pkgFile = path.resolve('package.json');
119
+ const before = JSON.parse(fs.readFileSync(pkgFile, 'utf8')).version;
120
+
121
+ console.log(`[release] bump version: ${level}`);
122
+ runNpm(['version', level, '--no-git-tag-version']);
123
+
124
+ const after = JSON.parse(fs.readFileSync(pkgFile, 'utf8')).version;
125
+ console.log(`[release] version ${before} -> ${after}`);
126
+
127
+ console.log('[release] verify toolkit');
128
+ runNpm(['run', 'verify']);
129
+
130
+ console.log('[release] publish dry-run');
131
+ runNpm(['run', 'publish:dry-run']);
132
+
133
+ if (shouldPublish) {
134
+ console.log('[release] publish latest');
135
+ runNpm(['run', 'publish:latest']);
136
+ } else {
137
+ console.log('[release] publish skipped (interactive default: dry-run)');
138
+ }
139
+ }
140
+
141
+ const args = process.argv.slice(2);
142
+ if (args.includes('--help') || args.includes('-h')) {
143
+ usage();
144
+ process.exit(0);
145
+ }
146
+
147
+ const interactiveRequested = args.length === 0 || args.includes('--interactive');
148
+ if (interactiveRequested) {
149
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
150
+ console.error('Interactive mode requires a TTY.');
151
+ usage();
152
+ process.exit(2);
153
+ }
154
+
155
+ const pkgFile = path.resolve('package.json');
156
+ const currentVersion = JSON.parse(fs.readFileSync(pkgFile, 'utf8')).version;
157
+ const interactive = await askInteractive(currentVersion);
158
+ runRelease(interactive.level, interactive.shouldPublish);
159
+ process.exit(0);
160
+ }
161
+
162
+ const level = args[0];
163
+ const shouldPublish = args.includes('--publish');
164
+ runRelease(level, shouldPublish);
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@produck/agent-toolkit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Central CLI toolkit for organization AI execution workflows",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/produck/.github.git",
8
+ "url": "git+https://github.com/produck/.github.git",
9
9
  "directory": "tools/agent-toolkit"
10
10
  },
11
11
  "bin": {
12
- "agent-toolkit": "./bin/agent-toolkit.mjs"
12
+ "agent-toolkit": "bin/agent-toolkit.mjs"
13
13
  },
14
14
  "scripts": {
15
15
  "verify": "node ./bin/agent-toolkit.mjs --help && node ./bin/agent-toolkit.mjs preflight --cwd . --require package.json",
16
16
  "pack:check": "npm pack --dry-run",
17
17
  "publish:dry-run": "npm publish --dry-run --access public",
18
- "publish:latest": "npm publish --access public"
18
+ "publish:latest": "npm publish --access public",
19
+ "release": "node ./bin/release.mjs"
19
20
  },
20
21
  "files": [
21
22
  "bin"