check-post 0.1.0 → 0.2.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 +66 -60
- package/dist/cli.js +18 -18
- package/dist/commands/init.js +37 -36
- package/dist/commands/list.js +1 -1
- package/dist/commands/run.js +8 -8
- package/dist/commands/shared.js +2 -2
- package/dist/commands/status.js +3 -3
- package/dist/core/adapters/claude-code.js +12 -12
- package/dist/core/adapters/index.js +2 -2
- package/dist/core/discovery.js +8 -8
- package/dist/core/gate.js +13 -13
- package/dist/core/process.js +2 -2
- package/dist/core/project.js +5 -5
- package/dist/core/runners/ai.js +9 -9
- package/dist/core/runners/command.js +3 -3
- package/dist/core/scheduler.js +11 -10
- package/dist/core/stage-file.js +4 -4
- package/dist/core/types.js +4 -2
- package/dist/ui/format.js +1 -1
- package/dist/ui/plain.js +2 -2
- package/dist/ui/tui/App.js +13 -13
- package/package.json +2 -2
- package/presets/angular/04-security/01-secrets.md +12 -12
- package/presets/angular/04-security/02-xss-audit.md +9 -9
- package/presets/angular/04-security/03-env-audit.md +7 -7
- package/presets/angular/04-security/_group.md +1 -1
- package/presets/angular/05-code-standard.md +8 -8
- package/presets/angular/context.md +2 -2
- package/presets/nextjs/04-security/01-secrets.md +12 -12
- package/presets/nextjs/04-security/02-xss-audit.md +8 -8
- package/presets/nextjs/04-security/03-env-audit.md +7 -7
- package/presets/nextjs/04-security/_group.md +1 -1
- package/presets/nextjs/05-code-standard.md +8 -8
- package/presets/nextjs/context.md +1 -1
- package/presets/node/04-security/01-secrets.md +12 -12
- package/presets/node/04-security/02-injection-audit.md +7 -7
- package/presets/node/04-security/03-env-audit.md +7 -7
- package/presets/node/04-security/_group.md +1 -1
- package/presets/node/05-code-standard.md +8 -8
- package/presets/node/context.md +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# check-post
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A CI/CD-style pipeline that runs on your own machine. Stages are Markdown files, and stages that need judgment are run by an AI CLI (currently Claude Code). When every stage is green, the gate says the project is ready to deploy.
|
|
4
4
|
|
|
5
5
|
```
|
|
6
6
|
Checkpost · claude-code · main@a1b2c3d
|
|
@@ -8,73 +8,73 @@ Pipeline mirip CI/CD yang berjalan di komputer sendiri. Stage didefinisikan seba
|
|
|
8
8
|
✔ lint 4.1s
|
|
9
9
|
✔ unit-test 12.4s
|
|
10
10
|
✔ build 31.0s
|
|
11
|
-
⠹ security (
|
|
11
|
+
⠹ security (parallel)
|
|
12
12
|
├ ✔ secrets [AI] 9.8s
|
|
13
|
-
├ ✖ xss-audit [AI] 22.3s 2
|
|
13
|
+
├ ✖ xss-audit [AI] 22.3s 2 findings (1 blocking)
|
|
14
14
|
├ ⠹ env-audit [AI] 18.0s
|
|
15
15
|
○ code-standard [AI]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Requirements
|
|
19
19
|
- Node.js 22+
|
|
20
|
-
- [Claude Code](https://docs.claude.com/claude-code)
|
|
20
|
+
- [Claude Code](https://docs.claude.com/claude-code), installed and logged in (`claude`)
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
|
-
|
|
23
|
+
Use it without installing:
|
|
24
24
|
```bash
|
|
25
25
|
npx check-post init
|
|
26
26
|
npx check-post run
|
|
27
27
|
```
|
|
28
|
-
|
|
28
|
+
Or install it globally:
|
|
29
29
|
```bash
|
|
30
30
|
npm install -g check-post
|
|
31
31
|
```
|
|
32
|
-
|
|
32
|
+
The command is available as both `check-post` and `checkpost`.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Latest version straight from GitHub:
|
|
35
35
|
```bash
|
|
36
36
|
npx github:raisulkhairi/check-post init
|
|
37
37
|
```
|
|
38
|
-
|
|
38
|
+
Avoid `npm install -g github:…`: npm fails to build git packages in global mode (`tsc: not found`). For a permanent install of the GitHub version:
|
|
39
39
|
```bash
|
|
40
40
|
git clone https://github.com/raisulkhairi/check-post.git
|
|
41
41
|
cd check-post && npm install && npm link
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
##
|
|
45
|
-
|
|
44
|
+
## Getting started
|
|
45
|
+
Run these in the root of the project you want to check:
|
|
46
46
|
```bash
|
|
47
|
-
checkpost init # wizard:
|
|
48
|
-
checkpost list #
|
|
49
|
-
checkpost run #
|
|
47
|
+
checkpost init # wizard: detect the project, pick a preset and stages
|
|
48
|
+
checkpost list # check the stage order
|
|
49
|
+
checkpost run # run with the terminal UI
|
|
50
50
|
checkpost status # GREEN/RED, exit code 0/1
|
|
51
51
|
```
|
|
52
|
-
|
|
52
|
+
You don't need to open `claude` first. Checkpost calls Claude Code itself for AI stages.
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## Stages are Markdown files
|
|
55
55
|
```
|
|
56
56
|
checkpost/
|
|
57
|
-
pipeline.md # config
|
|
57
|
+
pipeline.md # global config + project context for every AI stage
|
|
58
58
|
01-lint.md
|
|
59
59
|
02-unit-test.md
|
|
60
60
|
03-build.md
|
|
61
|
-
04-security/ # subfolder =
|
|
61
|
+
04-security/ # subfolder = group
|
|
62
62
|
_group.md # parallel: true
|
|
63
63
|
01-secrets.md
|
|
64
64
|
02-xss-audit.md
|
|
65
65
|
05-code-standard.md
|
|
66
|
-
_draft.md #
|
|
66
|
+
_draft.md # a _ or . prefix = ignored
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
**
|
|
69
|
+
**Order** follows the numeric prefix (`2-` comes before `10-`). Items without a prefix go last, alphabetically. Prefixes are not shown in the UI.
|
|
70
70
|
|
|
71
|
-
**
|
|
71
|
+
**The stage type comes from the file's content:**
|
|
72
72
|
|
|
73
|
-
|
|
|
73
|
+
| Content | Behavior | Passes when |
|
|
74
74
|
|---|---|---|
|
|
75
|
-
| `run:`
|
|
76
|
-
| body
|
|
77
|
-
| `run:` + body |
|
|
75
|
+
| `run:` only | runs the command | exit code 0 |
|
|
76
|
+
| body only | the body becomes the AI's instructions | no findings ≥ `fail_on` |
|
|
77
|
+
| `run:` + body | runs the command, then the AI reviews its output | no findings ≥ `fail_on` |
|
|
78
78
|
|
|
79
79
|
```md
|
|
80
80
|
---
|
|
@@ -82,61 +82,67 @@ paths: ["src/**/*.ts", "src/**/*.html"]
|
|
|
82
82
|
fail_on: high
|
|
83
83
|
---
|
|
84
84
|
# XSS audit
|
|
85
|
-
|
|
85
|
+
Look for bypassSecurityTrustHtml and [innerHTML] bindings fed with user data...
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
AI summaries and findings are written in the language set by `language:` in `pipeline.md` (default `English`).
|
|
89
|
+
|
|
88
90
|
### Frontmatter
|
|
89
91
|
|
|
90
|
-
| Field |
|
|
92
|
+
| Field | Where | Default | Description |
|
|
91
93
|
|---|---|---|---|
|
|
92
|
-
| `run` | stage | – |
|
|
93
|
-
| `timeout` | stage | 15m (command), 10m (AI) | `30s`, `5m`, `1h`,
|
|
94
|
+
| `run` | stage | – | shell command |
|
|
95
|
+
| `timeout` | stage | 15m (command), 10m (AI) | `30s`, `5m`, `1h`, or a number of seconds |
|
|
94
96
|
| `fail_on` | stage | `high` | `critical`, `high`, `medium`, `low`, `info` |
|
|
95
|
-
| `paths` | stage | – |
|
|
96
|
-
| `allow_failure` | stage | `false` |
|
|
97
|
-
| `enabled` | stage,
|
|
98
|
-
| `name` | stage,
|
|
97
|
+
| `paths` | stage | – | limit the files the AI inspects |
|
|
98
|
+
| `allow_failure` | stage | `false` | a failure does not block the gate |
|
|
99
|
+
| `enabled` | stage, group | `true` | |
|
|
100
|
+
| `name` | stage, group | file name | display name |
|
|
99
101
|
| `model`, `max_budget_usd` | stage, pipeline | `sonnet`, `1` | |
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
102
|
+
| `language` | pipeline | `English` | language of AI summaries and findings |
|
|
103
|
+
| `parallel` | group | `false` | run the group's children concurrently |
|
|
104
|
+
| `fail_fast` | group, pipeline | `true` | stop at the first failure |
|
|
105
|
+
| `require_clean_tree` | pipeline | `true` | gate is RED when there are uncommitted changes |
|
|
106
|
+
| `sensitive_paths` | pipeline | `.env*`, `.npmrc`, `*.pem`, `*.key` | paths the AI must never read |
|
|
107
|
+
| `confirm_ai` | pipeline | `true` | ask once before using your AI quota |
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
The body of `pipeline.md` and `_group.md` is passed as context to every AI stage below it.
|
|
107
110
|
|
|
108
|
-
##
|
|
109
|
-
- AI
|
|
110
|
-
- `sensitive_paths`
|
|
111
|
-
- Claude Code
|
|
112
|
-
-
|
|
111
|
+
## AI stage safety
|
|
112
|
+
- The AI only gets read tools (Read, Grep, Glob). It cannot change files or run commands.
|
|
113
|
+
- `sensitive_paths` are blocked with Claude Code permission deny rules. Attempts to read them show up in the log as `access blocked`.
|
|
114
|
+
- Claude Code runs without MCP servers, plugins, or user settings, so the context stays small and a stage costs cents, not dollars.
|
|
115
|
+
- The AI must answer with validated, structured JSON. An invalid answer is retried once. If it is still invalid, the stage ends as `error`, never as passed.
|
|
113
116
|
|
|
114
117
|
## Gate
|
|
115
|
-
`checkpost status`
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
- working tree
|
|
118
|
+
`checkpost status` is only GREEN when:
|
|
119
|
+
- every stage passed (or is `allow_failure`),
|
|
120
|
+
- the results are for the same commit as `HEAD`,
|
|
121
|
+
- stage definitions have not changed since the run,
|
|
122
|
+
- the working tree is clean (turn off with `require_clean_tree: false`).
|
|
120
123
|
|
|
121
124
|
```bash
|
|
122
125
|
checkpost status && vercel --prod
|
|
123
126
|
```
|
|
124
127
|
|
|
125
|
-
##
|
|
128
|
+
## CI and scripts
|
|
126
129
|
```bash
|
|
127
|
-
checkpost run --ci # output
|
|
128
|
-
checkpost run --ci --json #
|
|
129
|
-
checkpost run security #
|
|
130
|
+
checkpost run --ci # plain output + exit code
|
|
131
|
+
checkpost run --ci --json # final JSON result on stdout, logs on stderr
|
|
132
|
+
checkpost run security # a single group/stage (id or name)
|
|
130
133
|
```
|
|
131
|
-
`init`
|
|
134
|
+
`init` can also install a `/checkpost` slash command for Claude Code.
|
|
132
135
|
|
|
133
|
-
##
|
|
134
|
-
`checkpost init --share local`
|
|
136
|
+
## Repos you don't own
|
|
137
|
+
`checkpost init --share local` adds `checkpost/`, `.checkpost/`, and the slash command to `.git/info/exclude`. The repo itself is not changed at all.
|
|
135
138
|
|
|
136
|
-
##
|
|
139
|
+
## Development
|
|
137
140
|
```bash
|
|
138
141
|
npm install
|
|
139
142
|
npm test # vitest
|
|
140
143
|
npm run build # tsc → dist/
|
|
141
|
-
npm link #
|
|
144
|
+
npm link # make the checkpost command available globally from this folder
|
|
142
145
|
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
MIT
|
package/dist/cli.js
CHANGED
|
@@ -7,43 +7,43 @@ import { statusCommand } from './commands/status.js';
|
|
|
7
7
|
const program = new Command();
|
|
8
8
|
program
|
|
9
9
|
.name('checkpost')
|
|
10
|
-
.description('
|
|
10
|
+
.description('Local CI/CD pipeline: stages are Markdown files, run by an AI CLI')
|
|
11
11
|
.version('0.1.0')
|
|
12
|
-
.option('-C, --cwd <dir>', 'root
|
|
12
|
+
.option('-C, --cwd <dir>', 'project root', process.cwd());
|
|
13
13
|
const cwd = () => program.opts().cwd;
|
|
14
14
|
const finish = (code) => {
|
|
15
15
|
process.exitCode = code;
|
|
16
16
|
};
|
|
17
17
|
program
|
|
18
18
|
.command('init')
|
|
19
|
-
.description('
|
|
20
|
-
.addOption(new Option('--preset <name>', 'preset
|
|
21
|
-
.addOption(new Option('--share <mode>', '
|
|
22
|
-
.option('--no-slash-command', '
|
|
23
|
-
.option('-y, --yes', '
|
|
24
|
-
.option('--force', '
|
|
19
|
+
.description('create the checkpost/ folder from a preset')
|
|
20
|
+
.addOption(new Option('--preset <name>', 'stage preset').choices(['angular', 'nextjs', 'node', 'empty']))
|
|
21
|
+
.addOption(new Option('--share <mode>', 'keep local only or share with the team').choices(['local', 'team']))
|
|
22
|
+
.option('--no-slash-command', 'do not install the /checkpost slash command')
|
|
23
|
+
.option('-y, --yes', 'use defaults without prompting')
|
|
24
|
+
.option('--force', 'overwrite an existing checkpost/ folder')
|
|
25
25
|
.action(async (o) => {
|
|
26
26
|
const slashCommand = process.argv.includes('--no-slash-command') ? false : o.yes ? true : undefined;
|
|
27
27
|
finish(await initCommand({ cwd: cwd(), preset: o.preset, share: o.share, slashCommand, yes: o.yes, force: o.force }));
|
|
28
28
|
});
|
|
29
29
|
program
|
|
30
30
|
.command('list')
|
|
31
|
-
.description('
|
|
32
|
-
.option('--json', 'output
|
|
31
|
+
.description('show the stage order without running it')
|
|
32
|
+
.option('--json', 'JSON output')
|
|
33
33
|
.action((o) => finish(listCommand({ cwd: cwd(), json: o.json })));
|
|
34
34
|
program
|
|
35
35
|
.command('run')
|
|
36
|
-
.argument('[stage]', '
|
|
37
|
-
.description('
|
|
38
|
-
.option('--ci', '
|
|
39
|
-
.option('--json', '
|
|
40
|
-
.option('-y, --yes', '
|
|
41
|
-
.option('-v, --verbose', '
|
|
36
|
+
.argument('[stage]', 'run a single stage or group (id or name)')
|
|
37
|
+
.description('run the pipeline')
|
|
38
|
+
.option('--ci', 'non-interactive mode (automatic when not a terminal)')
|
|
39
|
+
.option('--json', 'print the final result as JSON on stdout')
|
|
40
|
+
.option('-y, --yes', 'skip the AI usage confirmation')
|
|
41
|
+
.option('-v, --verbose', 'show full command logs in CI mode')
|
|
42
42
|
.action(async (stage, o) => finish(await runCommand(stage, { cwd: cwd(), ci: o.ci, json: o.json, yes: o.yes, verbose: o.verbose })));
|
|
43
43
|
program
|
|
44
44
|
.command('status')
|
|
45
|
-
.description('
|
|
46
|
-
.option('--json', 'output
|
|
45
|
+
.description('check the gate: GREEN (ok to deploy) or RED; exit code 0/1')
|
|
46
|
+
.option('--json', 'JSON output')
|
|
47
47
|
.action(async (o) => finish(await statusCommand({ cwd: cwd(), json: o.json })));
|
|
48
48
|
program.parseAsync().catch((err) => {
|
|
49
49
|
console.error(err instanceof Error ? err.message : err);
|
package/dist/commands/init.js
CHANGED
|
@@ -14,7 +14,7 @@ const PRESETS = [
|
|
|
14
14
|
{ id: 'angular', label: 'Angular' },
|
|
15
15
|
{ id: 'nextjs', label: 'Next.js' },
|
|
16
16
|
{ id: 'node', label: 'Node.js / API' },
|
|
17
|
-
{ id: 'empty', label: '
|
|
17
|
+
{ id: 'empty', label: 'Empty (one example stage)' },
|
|
18
18
|
];
|
|
19
19
|
const EXTRA_SENSITIVE = {
|
|
20
20
|
angular: ['src/environments/**'],
|
|
@@ -39,7 +39,7 @@ function presetStages(presetDir, scripts) {
|
|
|
39
39
|
const kind = data.run ? (body ? `${data.run} + AI` : data.run) : 'AI';
|
|
40
40
|
out.push({
|
|
41
41
|
rel,
|
|
42
|
-
label: `${groupName}${splitPrefix(name).name} ${pc.gray(kind)}${missingScript ? pc.yellow(` (
|
|
42
|
+
label: `${groupName}${splitPrefix(name).name} ${pc.gray(kind)}${missingScript ? pc.yellow(` (no "${missingScript}" script)`) : ''}`,
|
|
43
43
|
missingScript,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -52,36 +52,37 @@ function pipelineMd(opts) {
|
|
|
52
52
|
const front = [
|
|
53
53
|
'---',
|
|
54
54
|
'agent: claude-code',
|
|
55
|
-
'model: sonnet # model
|
|
56
|
-
'fail_fast: true #
|
|
57
|
-
'require_clean_tree: true # gate
|
|
58
|
-
'max_budget_usd: 1 #
|
|
55
|
+
'model: sonnet # model for AI stages (sonnet | opus | haiku)',
|
|
56
|
+
'fail_fast: true # stop at the first failing stage',
|
|
57
|
+
'require_clean_tree: true # gate is only green with no uncommitted changes',
|
|
58
|
+
'max_budget_usd: 1 # cost limit per AI stage',
|
|
59
|
+
'language: English # language of AI summaries and findings',
|
|
59
60
|
];
|
|
60
61
|
if (sensitive.length) {
|
|
61
|
-
front.push('sensitive_paths: #
|
|
62
|
+
front.push('sensitive_paths: # never read by the AI (in addition to .env*, .npmrc, *.pem, *.key)');
|
|
62
63
|
for (const s of sensitive)
|
|
63
64
|
front.push(` - ${s}`);
|
|
64
65
|
}
|
|
65
66
|
front.push('---', '');
|
|
66
67
|
const body = [`Project: ${opts.label}.`, opts.context.trim()];
|
|
67
68
|
if (opts.docs.length)
|
|
68
|
-
body.push(`
|
|
69
|
+
body.push(`Project conventions are documented in: ${opts.docs.join(', ')}. Read them when relevant.`);
|
|
69
70
|
return front.join('\n') + body.join('\n\n') + '\n';
|
|
70
71
|
}
|
|
71
72
|
const SLASH_COMMAND = `---
|
|
72
|
-
description:
|
|
73
|
+
description: Run Checkpost (stages in checkpost/) and summarize the result
|
|
73
74
|
allowed-tools: Bash(checkpost:*), Bash(npx checkpost:*)
|
|
74
75
|
---
|
|
75
|
-
|
|
76
|
+
Run this command in the project root (it can take a few minutes):
|
|
76
77
|
|
|
77
78
|
\`\`\`
|
|
78
79
|
checkpost run --ci --json --yes $ARGUMENTS
|
|
79
80
|
\`\`\`
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
1.
|
|
83
|
-
2.
|
|
84
|
-
3.
|
|
82
|
+
The JSON result is on stdout. Then summarize:
|
|
83
|
+
1. Gate status (GREEN = ok to deploy, RED = not yet) and why.
|
|
84
|
+
2. Failed stages with their main findings (severity, file:line, message).
|
|
85
|
+
3. Suggested next steps. Do not change code unless asked.
|
|
85
86
|
`;
|
|
86
87
|
export async function initCommand(flags) {
|
|
87
88
|
const root = path.resolve(flags.cwd);
|
|
@@ -89,29 +90,29 @@ export async function initCommand(flags) {
|
|
|
89
90
|
const targetDir = path.join(root, PIPELINE_DIR);
|
|
90
91
|
console.log(pc.bold('\n◆ Checkpost · setup\n'));
|
|
91
92
|
if (existsSync(targetDir) && !flags.force) {
|
|
92
|
-
console.error(pc.red(` ${PIPELINE_DIR}/
|
|
93
|
+
console.error(pc.red(` ${PIPELINE_DIR}/ already exists. Use --force to overwrite the preset files.`));
|
|
93
94
|
return 2;
|
|
94
95
|
}
|
|
95
96
|
const git = await readGitState(root);
|
|
96
|
-
console.log(git.isRepo ? pc.green(` ✔ Git repository (branch: ${git.branch})`) : pc.yellow(' ⚠
|
|
97
|
+
console.log(git.isRepo ? pc.green(` ✔ Git repository (branch: ${git.branch})`) : pc.yellow(' ⚠ Not a git repository: the gate cannot check commits'));
|
|
97
98
|
const project = detectProject(root);
|
|
98
|
-
console.log(project.kind === 'unknown' ? pc.yellow(' ⚠
|
|
99
|
+
console.log(project.kind === 'unknown' ? pc.yellow(' ⚠ Project type not recognized') : pc.green(` ✔ Project: ${project.label}`));
|
|
99
100
|
const claude = AGENTS['claude-code'].create();
|
|
100
101
|
const detected = await claude.detect();
|
|
101
102
|
if (!detected.installed) {
|
|
102
|
-
console.error(pc.red(' ✖ Claude Code
|
|
103
|
+
console.error(pc.red(' ✖ Claude Code not found. Install it: npm install -g @anthropic-ai/claude-code, then run "claude" once to log in.'));
|
|
103
104
|
return 2;
|
|
104
105
|
}
|
|
105
106
|
console.log(pc.green(` ✔ AI CLI: Claude Code ${detected.version ?? ''}`));
|
|
106
107
|
if (project.docs.length)
|
|
107
|
-
console.log(pc.green(` ✔
|
|
108
|
+
console.log(pc.green(` ✔ Convention docs: ${project.docs.join(', ')}`));
|
|
108
109
|
console.log('');
|
|
109
110
|
if (interactive) {
|
|
110
111
|
await select({
|
|
111
|
-
message: '
|
|
112
|
+
message: 'Choose an AI agent',
|
|
112
113
|
choices: Object.entries(AGENTS).map(([id, a]) => ({
|
|
113
114
|
value: id,
|
|
114
|
-
name: a.available ? a.label : `${a.label} ${pc.gray('(
|
|
115
|
+
name: a.available ? a.label : `${a.label} ${pc.gray('(coming soon)')}`,
|
|
115
116
|
disabled: !a.available,
|
|
116
117
|
})),
|
|
117
118
|
});
|
|
@@ -119,16 +120,16 @@ export async function initCommand(flags) {
|
|
|
119
120
|
const detectedPreset = PRESETS.find((p) => p.id === project.kind)?.id ?? 'empty';
|
|
120
121
|
let preset = (flags.preset ?? detectedPreset);
|
|
121
122
|
if (!PRESETS.some((p) => p.id === preset)) {
|
|
122
|
-
console.error(pc.red(`
|
|
123
|
+
console.error(pc.red(` Unknown preset "${preset}". Options: ${PRESETS.map((p) => p.id).join(', ')}`));
|
|
123
124
|
return 2;
|
|
124
125
|
}
|
|
125
126
|
if (interactive && !flags.preset) {
|
|
126
127
|
preset = await select({
|
|
127
|
-
message: '
|
|
128
|
+
message: 'Choose a stage preset',
|
|
128
129
|
default: detectedPreset,
|
|
129
130
|
choices: PRESETS.map((p) => ({
|
|
130
131
|
value: p.id,
|
|
131
|
-
name: p.id === detectedPreset && p.id !== 'empty' ? `${p.label} ${pc.green('(Recommended,
|
|
132
|
+
name: p.id === detectedPreset && p.id !== 'empty' ? `${p.label} ${pc.green('(Recommended, detected)')}` : p.label,
|
|
132
133
|
})),
|
|
133
134
|
});
|
|
134
135
|
}
|
|
@@ -141,7 +142,7 @@ export async function initCommand(flags) {
|
|
|
141
142
|
chosen = stages.filter((s) => !s.missingScript).map((s) => s.rel);
|
|
142
143
|
if (interactive) {
|
|
143
144
|
chosen = await checkbox({
|
|
144
|
-
message: '
|
|
145
|
+
message: 'Which stages should be enabled? (space = toggle, enter = continue)',
|
|
145
146
|
choices: stages.map((s) => ({ value: s.rel, name: s.label, checked: !s.missingScript })),
|
|
146
147
|
pageSize: 15,
|
|
147
148
|
});
|
|
@@ -150,18 +151,18 @@ export async function initCommand(flags) {
|
|
|
150
151
|
let share = flags.share ?? 'local';
|
|
151
152
|
if (interactive && !flags.share) {
|
|
152
153
|
share = await select({
|
|
153
|
-
message: '
|
|
154
|
+
message: 'How should the checkpost/ folder be kept?',
|
|
154
155
|
choices: [
|
|
155
|
-
{ value: 'local', name: `
|
|
156
|
-
{ value: 'team', name: `
|
|
156
|
+
{ value: 'local', name: `Only on this machine ${pc.gray('(.git/info/exclude, repo unchanged)')}` },
|
|
157
|
+
{ value: 'team', name: `Share with the team ${pc.gray('(commit checkpost/, state in .gitignore)')}` },
|
|
157
158
|
],
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
let installSlash = flags.slashCommand ?? true;
|
|
161
162
|
if (interactive && flags.slashCommand === undefined) {
|
|
162
|
-
installSlash = await confirm({ message: '
|
|
163
|
+
installSlash = await confirm({ message: 'Install the /checkpost slash command for Claude Code?', default: true });
|
|
163
164
|
}
|
|
164
|
-
//
|
|
165
|
+
// Write files
|
|
165
166
|
mkdirSync(targetDir, { recursive: true });
|
|
166
167
|
writeFileSync(path.join(targetDir, 'pipeline.md'), pipelineMd({ kind: preset === 'empty' ? project.kind : preset, context, docs: project.docs, label: project.label }));
|
|
167
168
|
const written = ['pipeline.md'];
|
|
@@ -199,20 +200,20 @@ export async function initCommand(flags) {
|
|
|
199
200
|
ignored.push(...(await ignorePaths(root, [`/${STATE_DIR}/`], 'gitignore')));
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
|
-
console.log(pc.green('\n ✔
|
|
203
|
+
console.log(pc.green('\n ✔ Created:'));
|
|
203
204
|
for (const f of written.sort())
|
|
204
205
|
console.log(pc.gray(` ${PIPELINE_DIR}/${f.split(path.sep).join('/')}`));
|
|
205
206
|
if (installSlash)
|
|
206
207
|
console.log(pc.gray(` ${SLASH_COMMAND_PATH}`));
|
|
207
208
|
if (ignored.length) {
|
|
208
209
|
const where = share === 'local' ? '.git/info/exclude' : '.gitignore';
|
|
209
|
-
console.log(pc.green(` ✔
|
|
210
|
+
console.log(pc.green(` ✔ Added to ${where}: ${ignored.join(', ')}`));
|
|
210
211
|
}
|
|
211
212
|
console.log(`
|
|
212
|
-
|
|
213
|
-
1.
|
|
214
|
-
2. checkpost list →
|
|
215
|
-
3. checkpost run →
|
|
213
|
+
Next steps:
|
|
214
|
+
1. Adjust the .md files in ${PIPELINE_DIR}/ (optional)
|
|
215
|
+
2. checkpost list → check the stage order
|
|
216
|
+
3. checkpost run → run the pipeline
|
|
216
217
|
`);
|
|
217
218
|
return 0;
|
|
218
219
|
}
|
package/dist/commands/list.js
CHANGED
|
@@ -31,7 +31,7 @@ export function listCommand(flags) {
|
|
|
31
31
|
const num = depth === 0 ? String(++top).padStart(2) : ' ';
|
|
32
32
|
const indent = depth === 0 ? '' : ' '.repeat(depth - 1) + '├ ';
|
|
33
33
|
const name = (indent + node.name).padEnd(24);
|
|
34
|
-
const kind = typeLabel(node).padEnd(
|
|
34
|
+
const kind = typeLabel(node).padEnd(15);
|
|
35
35
|
let detail = '';
|
|
36
36
|
if (node.kind === 'stage') {
|
|
37
37
|
const bits = [];
|
package/dist/commands/run.js
CHANGED
|
@@ -38,7 +38,7 @@ export async function runCommand(target, flags) {
|
|
|
38
38
|
if (target) {
|
|
39
39
|
const node = findNode(pipeline.children, target);
|
|
40
40
|
if (!node) {
|
|
41
|
-
console.error(pc.red(`Stage
|
|
41
|
+
console.error(pc.red(`Stage or group "${target}" not found. See "checkpost list".`));
|
|
42
42
|
return 2;
|
|
43
43
|
}
|
|
44
44
|
nodes = [node];
|
|
@@ -57,13 +57,13 @@ export async function runCommand(target, flags) {
|
|
|
57
57
|
}
|
|
58
58
|
const detected = await adapter.detect();
|
|
59
59
|
if (!detected.installed) {
|
|
60
|
-
console.error(pc.red(`${adapter.label}
|
|
60
|
+
console.error(pc.red(`${adapter.label} not found. Install it first: npm install -g @anthropic-ai/claude-code`));
|
|
61
61
|
return 2;
|
|
62
62
|
}
|
|
63
63
|
const ui = readUiState(root);
|
|
64
64
|
if (interactive && !flags.yes && pipeline.config.confirm_ai && !ui.aiConfirmed) {
|
|
65
65
|
const ok = await confirm({
|
|
66
|
-
message: `${aiStages.length} stage
|
|
66
|
+
message: `${aiStages.length} AI stage${aiStages.length === 1 ? '' : 's'} will use your ${adapter.label} quota (model: ${pipeline.config.model}, limit $${pipeline.config.max_budget_usd}/stage). Continue?`,
|
|
67
67
|
default: true,
|
|
68
68
|
});
|
|
69
69
|
if (!ok)
|
|
@@ -71,7 +71,7 @@ export async function runCommand(target, flags) {
|
|
|
71
71
|
writeUiState(root, { ...ui, aiConfirmed: true });
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
//
|
|
74
|
+
// Run state must not dirty the project's working tree.
|
|
75
75
|
await ignorePaths(root, [`${STATE_DIR}/`], 'exclude');
|
|
76
76
|
const git = await readGitState(root);
|
|
77
77
|
const header = [
|
|
@@ -99,7 +99,7 @@ export async function runCommand(target, flags) {
|
|
|
99
99
|
const gate = lastGate;
|
|
100
100
|
return gate?.green ? 0 : 1;
|
|
101
101
|
}
|
|
102
|
-
//
|
|
102
|
+
// CI / non-TTY mode
|
|
103
103
|
const write = flags.json ? (s) => process.stderr.write(s + '\n') : undefined;
|
|
104
104
|
const stageMap = new Map(allStages(pipeline.children).map((s) => [s.id, s]));
|
|
105
105
|
const renderer = createPlainRenderer(stageMap, { verbose: Boolean(flags.verbose), write });
|
|
@@ -135,15 +135,15 @@ export async function runCommand(target, flags) {
|
|
|
135
135
|
else {
|
|
136
136
|
out('');
|
|
137
137
|
if (gate.green)
|
|
138
|
-
out(pc.green(pc.bold('✔ GATE GREEN ·
|
|
138
|
+
out(pc.green(pc.bold('✔ GATE GREEN · ok to deploy')));
|
|
139
139
|
else {
|
|
140
|
-
out(pc.red(pc.bold('✖ GATE RED ·
|
|
140
|
+
out(pc.red(pc.bold('✖ GATE RED · not ready to deploy')));
|
|
141
141
|
for (const r of gate.reasons)
|
|
142
142
|
out(pc.gray(` • ${r}`));
|
|
143
143
|
}
|
|
144
144
|
const cost = Object.values(gate.lastRun?.results ?? {}).reduce((sum, r) => sum + (r.costUsd ?? 0), 0);
|
|
145
145
|
if (cost)
|
|
146
|
-
out(pc.gray(`
|
|
146
|
+
out(pc.gray(` AI cost: $${cost.toFixed(3)}`));
|
|
147
147
|
}
|
|
148
148
|
return gate.green ? 0 : 1;
|
|
149
149
|
}
|
package/dist/commands/shared.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
2
|
import { DefinitionError } from '../core/stage-file.js';
|
|
3
|
-
/**
|
|
3
|
+
/** Print stage definition errors and return exit code 2; rethrow anything else. */
|
|
4
4
|
export function printDefinitionError(err) {
|
|
5
5
|
if (err instanceof DefinitionError) {
|
|
6
|
-
console.error(pc.red(pc.bold('
|
|
6
|
+
console.error(pc.red(pc.bold('Invalid pipeline definition:')));
|
|
7
7
|
for (const p of err.problems)
|
|
8
8
|
console.error(pc.red(` • ${p}`));
|
|
9
9
|
return 2;
|
package/dist/commands/status.js
CHANGED
|
@@ -19,12 +19,12 @@ export async function statusCommand(flags) {
|
|
|
19
19
|
return gate.green ? 0 : 1;
|
|
20
20
|
}
|
|
21
21
|
const ref = gate.git.sha ? `${gate.git.branch}@${gate.git.sha.slice(0, 7)}` : '';
|
|
22
|
-
const ago = gate.lastRun ? ` ·
|
|
22
|
+
const ago = gate.lastRun ? ` · ran ${formatDuration(Date.now() - Date.parse(gate.lastRun.updatedAt))} ago` : '';
|
|
23
23
|
if (gate.green) {
|
|
24
|
-
console.log(pc.green(pc.bold(`✔ GREEN ·
|
|
24
|
+
console.log(pc.green(pc.bold(`✔ GREEN · ok to deploy`)) + pc.gray(` · ${ref}${ago}`));
|
|
25
25
|
return 0;
|
|
26
26
|
}
|
|
27
|
-
console.log(pc.red(pc.bold('✖ RED ·
|
|
27
|
+
console.log(pc.red(pc.bold('✖ RED · not ready to deploy')) + pc.gray(ref ? ` · ${ref}${ago}` : ''));
|
|
28
28
|
for (const r of gate.reasons)
|
|
29
29
|
console.log(pc.gray(` • ${r}`));
|
|
30
30
|
return 1;
|