@pazmo/ai-workflow-kit 3.0.2 → 3.0.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.
package/README.md CHANGED
@@ -147,8 +147,14 @@ G4: PASS — 환불은 결제수단으로만 돌아간다는 규칙을 담당자
147
147
 
148
148
  ```bash
149
149
  node .ai-workflow/bin/check.mjs story docs/STORY.md
150
+ node .ai-workflow/bin/check.mjs gate G1 docs/STORY.md
150
151
  ```
151
152
 
153
+ `story`는 합의서의 **모양**을, `gate`는 **사람이 실제로 확인했는지**를 봅니다. 아직 `Draft`인
154
+ 파일에 `story`를 돌리면 모양만 맞아도 통과합니다 — 그건 승인이 아니고, 통과 메시지가 어느
155
+ 게이트를 건너뛰었는지 `NOTE`로 알려줍니다. 승인을 확인하려면 `gate G1`을, 이해 게이트를
156
+ 확인하려면 `gate G4`를 함께 돌리세요.
157
+
152
158
  이 검사기가 잡는 것:
153
159
 
154
160
  | 검사 | 막는 상황 |
@@ -185,6 +191,21 @@ AGENTS.md · CLAUDE.md 정해진 표시 사이에 짧은 규칙 블록 (바
185
191
  templates/ai-workflow/ 합의서 · 작업 조각 서식
186
192
  ```
187
193
 
194
+ ### 설치 후 한 번 확인하세요
195
+
196
+ ```bash
197
+ npx @pazmo/ai-workflow-kit doctor
198
+ ```
199
+
200
+ 자바 계열 저장소에는 `.gitignore`에 `bin/` 규칙이 흔히 들어 있습니다. 이게 **검사기(`.ai-workflow/bin/check.mjs`)를 통째로 삼킵니다.** 파일은 디스크에 멀쩡히 있는데 `git add`가 말없이 건너뛰어서, 저장소를 받는 사람에게는 검사기가 없습니다.
201
+
202
+ `init`과 `doctor`가 이걸 잡아내고 고칠 줄을 알려줍니다:
203
+
204
+ ```text
205
+ MISS Checker reaches git: .gitignore:21:bin/
206
+ Fix: add "!.ai-workflow/bin/" to .gitignore, below the rule above.
207
+ ```
208
+
188
209
  한쪽 도구만 쓴다면:
189
210
 
190
211
  ```bash
@@ -243,14 +264,14 @@ ai-workflow-kit remove # 제거
243
264
  ## 개발
244
265
 
245
266
  ```bash
246
- npm test # 34 checks
267
+ npm test # 39 checks
247
268
  npm pack # 로컬 tarball
248
269
  ```
249
270
 
250
271
  로컬 tarball로 시험 설치:
251
272
 
252
273
  ```bash
253
- npx --package ./pazmo-ai-workflow-kit-3.0.2.tgz ai-workflow-kit init
274
+ npx --package ./pazmo-ai-workflow-kit-3.0.3.tgz ai-workflow-kit init
254
275
  ```
255
276
 
256
277
  배포는 scope 소유자 인증 후:
package/assets/check.mjs CHANGED
@@ -205,7 +205,7 @@ function checkStoryShape(text) {
205
205
  const errors = [];
206
206
  requireOrderedHeadings(text, REQUIRED_STORY_HEADINGS, errors, 'Story');
207
207
 
208
- if (!/^#\s+Story:\s*\S.+$/imu.test(text)) errors.push('Story needs a descriptive “# Story:” title.');
208
+ if (!/^#\s+Story:\s*(?!<|pending\b)\S.+$/imu.test(text)) errors.push('Story needs a descriptive “# Story:” title.');
209
209
  if (!/^Status:\s*(Draft|Approved|Delivered)\s*$/imu.test(text)) {
210
210
  errors.push('Status must be Draft, Approved, or Delivered.');
211
211
  }
@@ -266,15 +266,30 @@ export async function checkArtifact({ root = process.cwd(), file, kind = 'story'
266
266
  if (kind !== 'story') return { ok: false, errors: [`Unsupported artifact kind: ${kind}`] };
267
267
 
268
268
  const errors = checkStoryShape(text);
269
- if (/^Status:\s*(Approved|Delivered)\s*$/imu.test(text)) {
269
+
270
+ // Status decides which gates are due. A Story that has not reached a gate cannot
271
+ // fail it — but then exit 0 only means the shape is right, and a caller who was
272
+ // told "exit 0 is the only pass" will read it as approval. Say which gate went
273
+ // unchecked, so a pass can never be quoted as one that was.
274
+ const notes = [];
275
+ const approved = /^Status:\s*(Approved|Delivered)\s*$/imu.test(text);
276
+ const delivered = /^Status:\s*Delivered\s*$/imu.test(text);
277
+
278
+ if (approved) {
270
279
  const g1 = await checkGate({ root, file: artifactFile, gate: 'G1' });
271
280
  errors.push(...g1.errors);
281
+ } else {
282
+ notes.push('Status is not Approved, so the G1 approval gate was not checked. Exit 0 means the Story is well formed, not that a human approved it.');
272
283
  }
273
- if (/^Status:\s*Delivered\s*$/imu.test(text)) {
284
+
285
+ if (delivered) {
274
286
  const g4 = await checkGate({ root, file: artifactFile, gate: 'G4' });
275
287
  errors.push(...g4.errors);
288
+ } else {
289
+ notes.push('Status is not Delivered, so the G4 understanding gate was not checked.');
276
290
  }
277
- return { ok: errors.length === 0, errors };
291
+
292
+ return { ok: errors.length === 0, errors, notes };
278
293
  }
279
294
 
280
295
  async function runCli(argv) {
@@ -291,6 +306,7 @@ async function runCli(argv) {
291
306
 
292
307
  if (result.ok) {
293
308
  console.log('PASS');
309
+ for (const note of result.notes ?? []) console.log(`NOTE ${note}`);
294
310
  return 0;
295
311
  }
296
312
  for (const error of result.errors) console.error(`- ${error}`);
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { checkArtifact, checkGate } from '../assets/check.mjs';
6
6
  import { installWorkflow, removeWorkflow } from '../src/install.mjs';
7
+ import { checkerVisibility, ignoredCheckerAdvice } from '../src/git-visibility.mjs';
7
8
  import { END_MARKER, START_MARKER } from '../src/managed-block.mjs';
8
9
  import { HOSTS } from '../src/paths.mjs';
9
10
 
@@ -90,6 +91,16 @@ async function doctor(root) {
90
91
  console.log(`${present ? 'PASS' : 'MISS'} ${label}: ${relative}`);
91
92
  ok &&= present;
92
93
  }
94
+
95
+ const visibility = await checkerVisibility(root);
96
+ if (visibility.status === 'ignored') {
97
+ console.log(`MISS Checker reaches git: ${visibility.source}`);
98
+ for (const line of ignoredCheckerAdvice(visibility)) console.log(` ${line}`);
99
+ ok = false;
100
+ } else if (visibility.status !== 'no-git') {
101
+ console.log('PASS Checker reaches git: .ai-workflow/bin/check.mjs');
102
+ }
103
+
93
104
  return ok;
94
105
  }
95
106
 
@@ -112,6 +123,13 @@ async function main(argv) {
112
123
  console.log(result.changed ? 'Installed/updated AI Workflow Kit.' : 'AI Workflow Kit is already up to date.');
113
124
  console.log(`Hosts: ${result.hosts.join(', ')}`);
114
125
  if (result.preserved.length) console.log(`Preserved modified files: ${result.preserved.join(', ')}`);
126
+ const visibility = await checkerVisibility(root);
127
+ if (visibility.status === 'ignored') {
128
+ console.log('');
129
+ console.log('WARNING');
130
+ for (const line of ignoredCheckerAdvice(visibility)) console.log(` ${line}`);
131
+ console.log('');
132
+ }
115
133
  if (result.hosts.includes('claude')) console.log('Next (Claude Code): /workflow <request>');
116
134
  if (result.hosts.includes('codex')) console.log('Next (Codex): $workflow <request>');
117
135
  return 0;
@@ -135,6 +153,7 @@ async function main(argv) {
135
153
  }
136
154
  if (result.ok) {
137
155
  console.log('PASS');
156
+ for (const note of result.notes ?? []) console.log(`NOTE ${note}`);
138
157
  return 0;
139
158
  }
140
159
  for (const error of result.errors) console.error(`- ${error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pazmo/ai-workflow-kit",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Portable DDD-inspired AI engineering workflow with concise contracts and a human understanding gate.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,9 +32,17 @@ Show the full concise draft and ask: “이 내용이 이번 구현의 범위와
32
32
 
33
33
  `Understanding gate (G1): <artifact> · <date> · Check-in: accepted`
34
34
 
35
- Then verify instead of assuming: run `node .ai-workflow/bin/check.mjs story <story-file>`
36
- and report the exit code. Exit 0 means the contract is well formed and G1 is valid; any
37
- other exit names what is wrong. Do not start implementation on a non-zero exit, and never
38
- claim the gate passed without that output.
35
+ Then verify instead of assuming. Write `Status: Approved` and the G1 record first, then run
36
+ both checks and report both exit codes:
37
+
38
+ ```
39
+ node .ai-workflow/bin/check.mjs story <story-file>
40
+ node .ai-workflow/bin/check.mjs gate G1 <story-file>
41
+ ```
42
+
43
+ `story` checks that the contract is well formed. `gate G1` checks that a human actually
44
+ approved it. Run `story` while the file still says `Draft` and it exits 0 on shape alone —
45
+ that is not approval, and the output says which gate it skipped. Do not start implementation
46
+ unless both exit 0, and never claim the gate passed without that output.
39
47
 
40
48
  No approval means no implementation.
@@ -16,4 +16,11 @@ Save the raw evidence, human answer, and evaluation to `docs/understanding/<slug
16
16
 
17
17
  `Understanding gate (G4): <artifact> · <date> · Check-in: accepted`
18
18
 
19
- Also append `G4: PASS — <what the human correctly restated>`. Set `Status: Delivered` only after both records exist and `node .ai-workflow/bin/check.mjs story <story-file>` exits 0. Run it and report the exit code; never claim the gate passed without that output. Use `G4: N/A — <specific reason>` only when no implementation behavior changed; never use it to bypass uncertainty.
19
+ Also append `G4: PASS — <what the human correctly restated>`. Set `Status: Delivered` only after both records exist and both of these exit 0:
20
+
21
+ ```
22
+ node .ai-workflow/bin/check.mjs story <story-file>
23
+ node .ai-workflow/bin/check.mjs gate G4 <story-file>
24
+ ```
25
+
26
+ Run them and report both exit codes; never claim the gate passed without that output. A `story` run on a Story that is not yet `Delivered` does not check G4 at all, and says so. Use `G4: N/A — <specific reason>` only when no implementation behavior changed; never use it to bypass uncertainty.
@@ -0,0 +1,59 @@
1
+ import { spawn } from 'node:child_process';
2
+
3
+ export const CHECKER_PATH = '.ai-workflow/bin/check.mjs';
4
+ export const GITIGNORE_EXCEPTION = '!.ai-workflow/bin/';
5
+
6
+ function git(args, cwd) {
7
+ return new Promise((resolve) => {
8
+ let child;
9
+ try {
10
+ child = spawn('git', args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
11
+ } catch {
12
+ resolve({ code: null, stdout: '' });
13
+ return;
14
+ }
15
+ let stdout = '';
16
+ child.stdout.on('data', (chunk) => { stdout += chunk; });
17
+ child.stderr.on('data', () => {});
18
+ child.on('error', () => resolve({ code: null, stdout: '' }));
19
+ child.on('close', (code) => resolve({ code, stdout }));
20
+ });
21
+ }
22
+
23
+ /**
24
+ * Whether the gate checker can actually reach the repository.
25
+ *
26
+ * A checker sitting on disk that `git add` silently skips is the worst kind of
27
+ * install: every file-existence check passes and the gates still cannot be
28
+ * enforced for anyone who clones. Common Java and build .gitignore templates
29
+ * carry a bare `bin/` rule, which swallows `.ai-workflow/bin/` along with it.
30
+ *
31
+ * Returns one of:
32
+ * { status: 'tracked' } already committed, so no rule can hide it
33
+ * { status: 'visible' } not ignored
34
+ * { status: 'ignored', source } source is "<file>:<line>:<pattern>"
35
+ * { status: 'no-git' } no git, or not a work tree — nothing to say
36
+ */
37
+ export async function checkerVisibility(root) {
38
+ const inside = await git(['rev-parse', '--is-inside-work-tree'], root);
39
+ if (inside.code !== 0 || inside.stdout.trim() !== 'true') return { status: 'no-git' };
40
+
41
+ const tracked = await git(['ls-files', '--error-unmatch', '--', CHECKER_PATH], root);
42
+ if (tracked.code === 0) return { status: 'tracked' };
43
+
44
+ const ignored = await git(['check-ignore', '-v', '--', CHECKER_PATH], root);
45
+ if (ignored.code !== 0) return { status: 'visible' };
46
+
47
+ const first = ignored.stdout.split('\n')[0] ?? '';
48
+ const source = first.split('\t')[0].trim();
49
+ return { status: 'ignored', source: source || 'a .gitignore rule' };
50
+ }
51
+
52
+ export function ignoredCheckerAdvice({ source }) {
53
+ return [
54
+ `${source} hides ${CHECKER_PATH} from git.`,
55
+ `The file is on disk, but \`git add\` skips it without a word, so the gate`,
56
+ `checker never reaches anyone who clones this repository.`,
57
+ `Fix: add "${GITIGNORE_EXCEPTION}" to .gitignore, below the rule above.`,
58
+ ];
59
+ }
package/src/install.mjs CHANGED
@@ -263,7 +263,9 @@ async function removeEmptyParents(file, stopAt) {
263
263
  while (current.startsWith(stopAt) && current !== stopAt) {
264
264
  try {
265
265
  if ((await readdir(current)).length > 0) break;
266
- await rm(current, { recursive: false });
266
+ // fs.rm refuses a directory without `recursive`, and the catch below would
267
+ // swallow the EISDIR — leaving every emptied parent on disk, silently.
268
+ await rm(current, { recursive: true });
267
269
  current = path.dirname(current);
268
270
  } catch {
269
271
  break;