nccgs 2.1.0 → 2.1.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 (76) hide show
  1. package/.claude/agents/nccgs-adversarial-reviewer.md +1 -1
  2. package/.claude/agents/nccgs-engine-programmer.md +1 -1
  3. package/.claude/agents/nccgs-fast-implementer.md +1 -1
  4. package/.claude/agents/nccgs-game-designer.md +1 -1
  5. package/.claude/agents/nccgs-gameplay-programmer.md +1 -1
  6. package/.claude/agents/nccgs-qa-engineer.md +1 -1
  7. package/.claude/agents/nccgs-task-scout.md +1 -1
  8. package/.claude/agents/nccgs-ui-programmer.md +1 -1
  9. package/.claude/agents/nccgs-unity-build-specialist.md +1 -1
  10. package/.claude/agents/nccgs-unity-implementer.md +1 -1
  11. package/.claude/agents/nccgs-unity-systems-specialist.md +1 -1
  12. package/.claude/agents/nccgs-unity-ui-specialist.md +1 -1
  13. package/.claude/agents/nccgs-verification-engineer.md +1 -1
  14. package/.claude/nccgs/MEMORY.md +3 -1
  15. package/.claude/nccgs/VERSION +1 -1
  16. package/.claude/nccgs/constitution.md +187 -176
  17. package/.claude/nccgs/hooks/closure-guard.mjs +2 -0
  18. package/.claude/nccgs/hooks/unity-transport-guard.mjs +11 -0
  19. package/.claude/nccgs/pipeline.json +260 -260
  20. package/.claude/nccgs/protocols/context-packets.md +5 -0
  21. package/.claude/nccgs/protocols/model-routing.md +46 -46
  22. package/.claude/nccgs/protocols/review-handoff.md +21 -1
  23. package/.claude/nccgs/protocols/shared-workflow-context.md +33 -0
  24. package/.claude/nccgs/protocols/unity-boundary.md +20 -0
  25. package/.claude/nccgs/routing.generated.md +4 -4
  26. package/.claude/nccgs/settings.fragment.json +84 -24
  27. package/.claude/nccgs/studio.json +53 -53
  28. package/.claude/nccgs/tools/autonomy.mjs +13 -0
  29. package/.claude/nccgs/tools/command-tokens.mjs +22 -0
  30. package/.claude/nccgs/tools/hook-transport.mjs +34 -0
  31. package/.claude/nccgs/tools/native-completion.mjs +10 -1
  32. package/.claude/nccgs/tools/returned-handoff.mjs +11 -2
  33. package/.claude/nccgs/tools/shared-context-guard.mjs +60 -0
  34. package/.claude/nccgs/tools/shared-context.mjs +25 -0
  35. package/.claude/nccgs/tools/tool-guard.mjs +120 -131
  36. package/.claude/nccgs/tools/unity-transport.mjs +170 -0
  37. package/.claude/nccgs/workflow-catalog.json +4 -4
  38. package/CHANGELOG.md +235 -200
  39. package/CLAUDE.md +10 -8
  40. package/MEMORY.md +109 -60
  41. package/README.md +206 -191
  42. package/UPGRADING.md +130 -118
  43. package/VERSION +1 -1
  44. package/docs/ARCHITECTURE.md +131 -131
  45. package/docs/ASSET-PRODUCTION-GRAPHIFY-PLAN.md +230 -0
  46. package/docs/HUONG-DAN-MIGRATE-VA-SU-DUNG.md +117 -116
  47. package/docs/NCCGS-1.5.md +237 -237
  48. package/docs/PROJECT-POLICY.md +94 -94
  49. package/docs/RELEASE-STATUS.md +17 -9
  50. package/docs/UNINSTALL.md +3 -3
  51. package/docs/WFK17-HOOK-REPAIR.md +71 -0
  52. package/docs/WORKFLOWS.md +85 -85
  53. package/package.json +1 -1
  54. package/scaffold/.nccgs/project.yaml +109 -108
  55. package/scripts/benchmark-v15.mjs +173 -173
  56. package/scripts/doctor.mjs +261 -261
  57. package/scripts/install.mjs +530 -529
  58. package/scripts/run.mjs +5 -4
  59. package/scripts/supervise.mjs +4 -0
  60. package/scripts/uninstall.mjs +292 -292
  61. package/scripts/validate.mjs +285 -280
  62. package/tests/autonomy.test.mjs +126 -113
  63. package/tests/design-readiness.test.mjs +199 -199
  64. package/tests/fixtures/compiler-shutdown.cs +67 -64
  65. package/tests/fixtures/native-provider.mjs +61 -0
  66. package/tests/framework.test.mjs +740 -740
  67. package/tests/hook-repair.test.mjs +106 -0
  68. package/tests/lifecycle-v15.test.mjs +346 -300
  69. package/tests/native-completion-notices.test.mjs +181 -0
  70. package/tests/phase1.test.mjs +427 -416
  71. package/tests/phase2.test.mjs +250 -250
  72. package/tests/policy-v15.test.mjs +234 -234
  73. package/tests/returned-handoff-notices.test.mjs +170 -0
  74. package/tests/runtime-v15.test.mjs +1197 -1191
  75. package/tests/task-slices.test.mjs +285 -285
  76. package/tests/unity-transport.test.mjs +348 -0
@@ -35,7 +35,7 @@
35
35
  "standard": "opus",
36
36
  "deep": "opus",
37
37
  "leadership": "opus",
38
- "review": "opus"
38
+ "review": "fable"
39
39
  }
40
40
  },
41
41
  "orchestration": {
@@ -51,7 +51,7 @@
51
51
  "modelClass": "lightweight",
52
52
  "maxTurns": 12,
53
53
  "defaultModel": "sonnet",
54
- "defaultEffort": "medium"
54
+ "defaultEffort": "high"
55
55
  },
56
56
  {
57
57
  "name": "nccgs-task-scout",
@@ -59,7 +59,7 @@
59
59
  "modelClass": "lightweight",
60
60
  "maxTurns": 10,
61
61
  "defaultModel": "sonnet",
62
- "defaultEffort": "medium"
62
+ "defaultEffort": "high"
63
63
  },
64
64
  {
65
65
  "name": "nccgs-creative-director",
@@ -67,7 +67,7 @@
67
67
  "modelClass": "leadership",
68
68
  "defaultModel": "opus",
69
69
  "maxTurns": 24,
70
- "defaultEffort": "high"
70
+ "defaultEffort": "xhigh"
71
71
  },
72
72
  {
73
73
  "name": "nccgs-technical-director",
@@ -75,7 +75,7 @@
75
75
  "modelClass": "leadership",
76
76
  "defaultModel": "opus",
77
77
  "maxTurns": 24,
78
- "defaultEffort": "high"
78
+ "defaultEffort": "xhigh"
79
79
  },
80
80
  {
81
81
  "name": "nccgs-producer",
@@ -83,7 +83,7 @@
83
83
  "modelClass": "leadership",
84
84
  "defaultModel": "opus",
85
85
  "maxTurns": 20,
86
- "defaultEffort": "high"
86
+ "defaultEffort": "xhigh"
87
87
  },
88
88
  {
89
89
  "name": "nccgs-game-design-lead",
@@ -91,7 +91,7 @@
91
91
  "modelClass": "standard",
92
92
  "defaultModel": "opus",
93
93
  "maxTurns": 20,
94
- "defaultEffort": "medium"
94
+ "defaultEffort": "high"
95
95
  },
96
96
  {
97
97
  "name": "nccgs-programming-lead",
@@ -99,7 +99,7 @@
99
99
  "modelClass": "standard",
100
100
  "defaultModel": "opus",
101
101
  "maxTurns": 20,
102
- "defaultEffort": "medium"
102
+ "defaultEffort": "high"
103
103
  },
104
104
  {
105
105
  "name": "nccgs-art-direction-lead",
@@ -107,7 +107,7 @@
107
107
  "modelClass": "standard",
108
108
  "defaultModel": "opus",
109
109
  "maxTurns": 18,
110
- "defaultEffort": "medium"
110
+ "defaultEffort": "high"
111
111
  },
112
112
  {
113
113
  "name": "nccgs-audio-direction-lead",
@@ -115,7 +115,7 @@
115
115
  "modelClass": "standard",
116
116
  "defaultModel": "opus",
117
117
  "maxTurns": 18,
118
- "defaultEffort": "medium"
118
+ "defaultEffort": "high"
119
119
  },
120
120
  {
121
121
  "name": "nccgs-narrative-lead",
@@ -123,7 +123,7 @@
123
123
  "modelClass": "standard",
124
124
  "defaultModel": "opus",
125
125
  "maxTurns": 20,
126
- "defaultEffort": "medium"
126
+ "defaultEffort": "high"
127
127
  },
128
128
  {
129
129
  "name": "nccgs-qa-lead",
@@ -131,7 +131,7 @@
131
131
  "modelClass": "standard",
132
132
  "defaultModel": "opus",
133
133
  "maxTurns": 20,
134
- "defaultEffort": "medium"
134
+ "defaultEffort": "high"
135
135
  },
136
136
  {
137
137
  "name": "nccgs-release-lead",
@@ -139,7 +139,7 @@
139
139
  "modelClass": "standard",
140
140
  "defaultModel": "opus",
141
141
  "maxTurns": 20,
142
- "defaultEffort": "medium"
142
+ "defaultEffort": "high"
143
143
  },
144
144
  {
145
145
  "name": "nccgs-localization-lead",
@@ -147,7 +147,7 @@
147
147
  "modelClass": "standard",
148
148
  "defaultModel": "opus",
149
149
  "maxTurns": 18,
150
- "defaultEffort": "medium"
150
+ "defaultEffort": "high"
151
151
  },
152
152
  {
153
153
  "name": "nccgs-game-designer",
@@ -155,7 +155,7 @@
155
155
  "modelClass": "standard",
156
156
  "defaultModel": "opus",
157
157
  "maxTurns": 48,
158
- "defaultEffort": "medium"
158
+ "defaultEffort": "high"
159
159
  },
160
160
  {
161
161
  "name": "nccgs-systems-designer",
@@ -163,7 +163,7 @@
163
163
  "modelClass": "standard",
164
164
  "defaultModel": "opus",
165
165
  "maxTurns": 18,
166
- "defaultEffort": "medium"
166
+ "defaultEffort": "high"
167
167
  },
168
168
  {
169
169
  "name": "nccgs-level-designer",
@@ -171,7 +171,7 @@
171
171
  "modelClass": "standard",
172
172
  "defaultModel": "opus",
173
173
  "maxTurns": 18,
174
- "defaultEffort": "medium"
174
+ "defaultEffort": "high"
175
175
  },
176
176
  {
177
177
  "name": "nccgs-economy-designer",
@@ -179,7 +179,7 @@
179
179
  "modelClass": "standard",
180
180
  "defaultModel": "opus",
181
181
  "maxTurns": 18,
182
- "defaultEffort": "medium"
182
+ "defaultEffort": "high"
183
183
  },
184
184
  {
185
185
  "name": "nccgs-ux-designer",
@@ -187,7 +187,7 @@
187
187
  "modelClass": "standard",
188
188
  "defaultModel": "opus",
189
189
  "maxTurns": 18,
190
- "defaultEffort": "medium"
190
+ "defaultEffort": "high"
191
191
  },
192
192
  {
193
193
  "name": "nccgs-accessibility-specialist",
@@ -195,7 +195,7 @@
195
195
  "modelClass": "standard",
196
196
  "defaultModel": "opus",
197
197
  "maxTurns": 18,
198
- "defaultEffort": "medium"
198
+ "defaultEffort": "high"
199
199
  },
200
200
  {
201
201
  "name": "nccgs-prototyper",
@@ -203,7 +203,7 @@
203
203
  "modelClass": "standard",
204
204
  "defaultModel": "opus",
205
205
  "maxTurns": 18,
206
- "defaultEffort": "medium"
206
+ "defaultEffort": "high"
207
207
  },
208
208
  {
209
209
  "name": "nccgs-technical-architect",
@@ -211,7 +211,7 @@
211
211
  "modelClass": "deep",
212
212
  "defaultModel": "opus",
213
213
  "maxTurns": 22,
214
- "defaultEffort": "high"
214
+ "defaultEffort": "xhigh"
215
215
  },
216
216
  {
217
217
  "name": "nccgs-gameplay-programmer",
@@ -219,7 +219,7 @@
219
219
  "modelClass": "standard",
220
220
  "defaultModel": "opus",
221
221
  "maxTurns": 120,
222
- "defaultEffort": "medium"
222
+ "defaultEffort": "high"
223
223
  },
224
224
  {
225
225
  "name": "nccgs-engine-programmer",
@@ -227,7 +227,7 @@
227
227
  "modelClass": "standard",
228
228
  "defaultModel": "opus",
229
229
  "maxTurns": 22,
230
- "defaultEffort": "medium"
230
+ "defaultEffort": "high"
231
231
  },
232
232
  {
233
233
  "name": "nccgs-ai-programmer",
@@ -235,7 +235,7 @@
235
235
  "modelClass": "standard",
236
236
  "defaultModel": "opus",
237
237
  "maxTurns": 22,
238
- "defaultEffort": "medium"
238
+ "defaultEffort": "high"
239
239
  },
240
240
  {
241
241
  "name": "nccgs-network-programmer",
@@ -243,7 +243,7 @@
243
243
  "modelClass": "standard",
244
244
  "defaultModel": "opus",
245
245
  "maxTurns": 24,
246
- "defaultEffort": "medium"
246
+ "defaultEffort": "high"
247
247
  },
248
248
  {
249
249
  "name": "nccgs-tools-programmer",
@@ -251,7 +251,7 @@
251
251
  "modelClass": "standard",
252
252
  "defaultModel": "opus",
253
253
  "maxTurns": 20,
254
- "defaultEffort": "medium"
254
+ "defaultEffort": "high"
255
255
  },
256
256
  {
257
257
  "name": "nccgs-ui-programmer",
@@ -259,7 +259,7 @@
259
259
  "modelClass": "standard",
260
260
  "defaultModel": "opus",
261
261
  "maxTurns": 22,
262
- "defaultEffort": "medium"
262
+ "defaultEffort": "high"
263
263
  },
264
264
  {
265
265
  "name": "nccgs-security-engineer",
@@ -267,7 +267,7 @@
267
267
  "modelClass": "standard",
268
268
  "defaultModel": "opus",
269
269
  "maxTurns": 20,
270
- "defaultEffort": "medium"
270
+ "defaultEffort": "high"
271
271
  },
272
272
  {
273
273
  "name": "nccgs-performance-analyst",
@@ -275,7 +275,7 @@
275
275
  "modelClass": "standard",
276
276
  "defaultModel": "opus",
277
277
  "maxTurns": 20,
278
- "defaultEffort": "medium"
278
+ "defaultEffort": "high"
279
279
  },
280
280
  {
281
281
  "name": "nccgs-technical-artist",
@@ -283,7 +283,7 @@
283
283
  "modelClass": "standard",
284
284
  "defaultModel": "opus",
285
285
  "maxTurns": 20,
286
- "defaultEffort": "medium"
286
+ "defaultEffort": "high"
287
287
  },
288
288
  {
289
289
  "name": "nccgs-sound-designer",
@@ -291,7 +291,7 @@
291
291
  "modelClass": "standard",
292
292
  "defaultModel": "opus",
293
293
  "maxTurns": 18,
294
- "defaultEffort": "medium"
294
+ "defaultEffort": "high"
295
295
  },
296
296
  {
297
297
  "name": "nccgs-writer",
@@ -299,7 +299,7 @@
299
299
  "modelClass": "standard",
300
300
  "defaultModel": "opus",
301
301
  "maxTurns": 18,
302
- "defaultEffort": "medium"
302
+ "defaultEffort": "high"
303
303
  },
304
304
  {
305
305
  "name": "nccgs-world-builder",
@@ -307,7 +307,7 @@
307
307
  "modelClass": "standard",
308
308
  "defaultModel": "opus",
309
309
  "maxTurns": 18,
310
- "defaultEffort": "medium"
310
+ "defaultEffort": "high"
311
311
  },
312
312
  {
313
313
  "name": "nccgs-analytics-engineer",
@@ -315,7 +315,7 @@
315
315
  "modelClass": "standard",
316
316
  "defaultModel": "opus",
317
317
  "maxTurns": 18,
318
- "defaultEffort": "medium"
318
+ "defaultEffort": "high"
319
319
  },
320
320
  {
321
321
  "name": "nccgs-live-ops-designer",
@@ -323,7 +323,7 @@
323
323
  "modelClass": "standard",
324
324
  "defaultModel": "opus",
325
325
  "maxTurns": 18,
326
- "defaultEffort": "medium"
326
+ "defaultEffort": "high"
327
327
  },
328
328
  {
329
329
  "name": "nccgs-qa-engineer",
@@ -331,7 +331,7 @@
331
331
  "modelClass": "standard",
332
332
  "defaultModel": "opus",
333
333
  "maxTurns": 22,
334
- "defaultEffort": "medium"
334
+ "defaultEffort": "high"
335
335
  },
336
336
  {
337
337
  "name": "nccgs-verification-engineer",
@@ -339,13 +339,13 @@
339
339
  "modelClass": "standard",
340
340
  "defaultModel": "opus",
341
341
  "maxTurns": 22,
342
- "defaultEffort": "medium"
342
+ "defaultEffort": "high"
343
343
  },
344
344
  {
345
345
  "name": "nccgs-adversarial-reviewer",
346
346
  "department": "quality",
347
347
  "modelClass": "review",
348
- "defaultModel": "opus",
348
+ "defaultModel": "fable",
349
349
  "maxTurns": 200,
350
350
  "defaultEffort": "high"
351
351
  },
@@ -355,7 +355,7 @@
355
355
  "modelClass": "lightweight",
356
356
  "defaultModel": "sonnet",
357
357
  "maxTurns": 14,
358
- "defaultEffort": "medium"
358
+ "defaultEffort": "high"
359
359
  },
360
360
  {
361
361
  "name": "nccgs-release-engineer",
@@ -363,7 +363,7 @@
363
363
  "modelClass": "standard",
364
364
  "defaultModel": "opus",
365
365
  "maxTurns": 24,
366
- "defaultEffort": "medium"
366
+ "defaultEffort": "high"
367
367
  },
368
368
  {
369
369
  "name": "nccgs-unity-implementer",
@@ -371,7 +371,7 @@
371
371
  "modelClass": "deep",
372
372
  "defaultModel": "opus",
373
373
  "maxTurns": 120,
374
- "defaultEffort": "high"
374
+ "defaultEffort": "xhigh"
375
375
  },
376
376
  {
377
377
  "name": "nccgs-unity-systems-specialist",
@@ -379,7 +379,7 @@
379
379
  "modelClass": "standard",
380
380
  "defaultModel": "opus",
381
381
  "maxTurns": 22,
382
- "defaultEffort": "medium"
382
+ "defaultEffort": "high"
383
383
  },
384
384
  {
385
385
  "name": "nccgs-unity-ui-specialist",
@@ -387,7 +387,7 @@
387
387
  "modelClass": "standard",
388
388
  "defaultModel": "opus",
389
389
  "maxTurns": 22,
390
- "defaultEffort": "medium"
390
+ "defaultEffort": "high"
391
391
  },
392
392
  {
393
393
  "name": "nccgs-unity-rendering-specialist",
@@ -395,7 +395,7 @@
395
395
  "modelClass": "standard",
396
396
  "defaultModel": "opus",
397
397
  "maxTurns": 22,
398
- "defaultEffort": "medium"
398
+ "defaultEffort": "high"
399
399
  },
400
400
  {
401
401
  "name": "nccgs-unity-content-specialist",
@@ -403,7 +403,7 @@
403
403
  "modelClass": "standard",
404
404
  "defaultModel": "opus",
405
405
  "maxTurns": 22,
406
- "defaultEffort": "medium"
406
+ "defaultEffort": "high"
407
407
  },
408
408
  {
409
409
  "name": "nccgs-unity-build-specialist",
@@ -411,7 +411,7 @@
411
411
  "modelClass": "standard",
412
412
  "defaultModel": "opus",
413
413
  "maxTurns": 24,
414
- "defaultEffort": "medium"
414
+ "defaultEffort": "high"
415
415
  },
416
416
  {
417
417
  "name": "nccgs-production-coordinator",
@@ -419,7 +419,7 @@
419
419
  "modelClass": "standard",
420
420
  "defaultModel": "opus",
421
421
  "maxTurns": 18,
422
- "defaultEffort": "medium"
422
+ "defaultEffort": "high"
423
423
  }
424
424
  ],
425
425
  "effortProfiles": {
@@ -452,10 +452,10 @@
452
452
  "review": null
453
453
  },
454
454
  "claude-standalone": {
455
- "lightweight": "medium",
456
- "standard": "medium",
457
- "deep": "high",
458
- "leadership": "high",
455
+ "lightweight": "high",
456
+ "standard": "high",
457
+ "deep": "xhigh",
458
+ "leadership": "xhigh",
459
459
  "review": "high"
460
460
  }
461
461
  },
@@ -466,7 +466,7 @@
466
466
  },
467
467
  "claude-standalone": {
468
468
  "model": "opus",
469
- "effortLevel": "medium"
469
+ "effortLevel": "high"
470
470
  }
471
471
  }
472
472
  }
@@ -10,6 +10,19 @@ export function autonomyPolicy(project) {
10
10
  return { schemaVersion: 1, mode: value.mode };
11
11
  }
12
12
 
13
+ // Fixed framework-owned launch prefix. It has exactly one fixed value and is the
14
+ // only argv permitted before strict MCP isolation (see unity-transport.mjs).
15
+ export function permissionModeArgs(mode) {
16
+ if (!["full", "guarded"].includes(mode)) throw new Error("Invalid NCCGS autonomy policy");
17
+ return ["--permission-mode", mode === "full" ? "bypassPermissions" : "default"];
18
+ }
19
+
20
+ // NCCGS owns session permission, root, settings and hook activation. --bare and
21
+ // --safe-mode skip project hooks; --restricted ignores project settings and hooks
22
+ // (installed CLI 2.1.316 help). The installed CLI documents no short aliases.
23
+ // Retained recovery reuses this policy through unity-transport.mjs.
24
+ export const conflictingLaunchOption = /^(?:--permission-mode|--dangerously-skip-permissions|--allow-dangerously-skip-permissions|--settings|--setting-sources|--worktree|--agent|--bare|--safe-mode|--restricted)(?:=|$)|^-w$/;
25
+
13
26
  // Session markers are workflow context, not a sandbox against arbitrary code.
14
27
  // Project configuration alone cannot activate Claude's native permission mode.
15
28
  export function fullTaskAutonomy(project, env = process.env) {
@@ -0,0 +1,22 @@
1
+ export function commandTokens(command) {
2
+ if (typeof command !== "string") return null;
3
+ // Parse data quotes without interpreting a shell. Punctuation inside report
4
+ // text is data; composition/redirection/expansion outside quotes stays blocked.
5
+ const tokens = []; let token = "", quote = null, started = false;
6
+ for (let i = 0; i < command.length; i++) {
7
+ const c = command[i];
8
+ if (quote) {
9
+ if (c === quote) { quote = null; continue; }
10
+ if (quote === '"' && /[`$]/.test(c)) return null;
11
+ if (quote === '"' && c === "\\" && ['"', "\\"].includes(command[i + 1])) { token += command[++i]; continue; }
12
+ token += c; continue;
13
+ }
14
+ if (/[;&|<>`$\r\n]/.test(c)) return null;
15
+ if (c === '"' || c === "'") { quote = c; started = true; continue; }
16
+ if (/\s/.test(c)) { if (started) { tokens.push(token); token = ""; started = false; } continue; }
17
+ token += c; started = true;
18
+ }
19
+ if (quote) return null;
20
+ if (started) tokens.push(token);
21
+ return tokens;
22
+ }
@@ -0,0 +1,34 @@
1
+ // Exact managed-hook identity across legacy shell and direct-executable forms.
2
+ // Never identify a hook by the executable alone: many custom hooks use node.
3
+ const scriptPattern = /^(?:\$\{CLAUDE_PROJECT_DIR\}\/)?(\.claude\/nccgs\/hooks\/[\w-]+\.mjs)$/;
4
+ const phases = new Set(['pre', 'stop', 'start', 'failure']);
5
+
6
+ export function managedHookKey(hook) {
7
+ if (!hook || hook.type !== 'command' || typeof hook.command !== 'string') return null;
8
+ let script, args;
9
+ if (Object.hasOwn(hook, 'args')) {
10
+ if (hook.command !== 'node' || !Array.isArray(hook.args) || !hook.args.every(x => typeof x === 'string')) return null;
11
+ [script, ...args] = hook.args;
12
+ } else {
13
+ const match = hook.command.match(/^node (?:"([^"\r\n]+)"|([^\s"'`$;&|<>]+))(?: (pre|stop|start|failure))?$/);
14
+ if (!match) return null;
15
+ script = match[1] ?? match[2];
16
+ args = match[3] ? [match[3]] : [];
17
+ }
18
+ const relative = typeof script === 'string' ? script.match(scriptPattern)?.[1] : null;
19
+ if (!relative || args.length > 1 || args.some(x => !phases.has(x))) return null;
20
+ return JSON.stringify([relative, ...args]);
21
+ }
22
+
23
+ export function requiredHookPresent(actual, expected) {
24
+ return actual && actual.type === expected.type && actual.command === expected.command
25
+ && JSON.stringify(actual.args) === JSON.stringify(expected.args)
26
+ && actual.onFailure === expected.onFailure
27
+ && actual.if === undefined && actual.once !== true && actual.async !== true
28
+ && (actual.timeout === undefined || actual.timeout >= expected.timeout);
29
+ }
30
+
31
+ export function referencesNccgsHook(hook) {
32
+ return [hook?.command, ...(Array.isArray(hook?.args) ? hook.args : [])]
33
+ .some(x => typeof x === 'string' && /(?:^|[\\/])\.claude[\\/]nccgs[\\/]/i.test(x));
34
+ }
@@ -1,5 +1,13 @@
1
1
  import { hash } from "./policy.mjs";
2
2
 
3
+ // This provider-designated block is an inventory, not an incomplete-run notice.
4
+ // Match the entire block and a bounded identifier list; unknown mixed text must
5
+ // continue to fail closed. Never recognize this marker in model-authored prose.
6
+ const toolSummary = /^\s*<tools-used-before-summary>[A-Za-z][A-Za-z0-9_.:-]*(?:\s*,\s*[A-Za-z][A-Za-z0-9_.:-]*)*<\/tools-used-before-summary>\s*$/;
7
+ const informationalNote = block => block?.type === "text"
8
+ && typeof block.text === "string" && block.text.length <= 4096
9
+ && toolSummary.test(block.text);
10
+
3
11
  // The native harness reports an ended invocation as "completed" even when its
4
12
  // worker hit maxTurns. Inspect only harness-designated blocks, never the model's
5
13
  // prose. Store a diagnosis/hash, not prompts or arbitrary tool-result content.
@@ -15,7 +23,8 @@ export function nativeCompletion(response) {
15
23
  const limit = noteText.match(/\bthis agent stopped at its (\d+)-turn limit before finishing\b/i);
16
24
  // A previously unseen harness advisory needs reconciliation; it cannot silently
17
25
  // certify completion. Text outside these provider-designated blocks is ignored.
18
- const reason = limit ? "turn-limit" : notes.length ? "unrecognized-harness-notice" : null;
26
+ const reason = limit ? "turn-limit"
27
+ : notes.length && !notes.every(informationalNote) ? "unrecognized-harness-notice" : null;
19
28
  return { reportedStatus, status: reason ? "failed" : reportedStatus, reason,
20
29
  turnLimit: limit ? Number(limit[1]) : null, noteHash: notes.length ? hash(noteText) : null };
21
30
  }
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { artifact, contained } from "./policy.mjs";
4
+ import { nativeCompletion } from "./native-completion.mjs";
4
5
 
5
6
  // Opt-in transport for read-only workers whose native client returns reports as
6
7
  // text. Copy the sole model text block verbatim; never synthesize a verdict,
@@ -15,9 +16,17 @@ export function captureReturnedHandoff(project, dispatch, input, completion, cur
15
16
  || !dispatch.agentId || dispatch.agentId !== response?.agentId
16
17
  || dispatch.agent !== input.tool_input?.subagent_type || dispatch.snapshot !== currentSnapshot)
17
18
  return reject("identity-or-snapshot-mismatch");
18
- if (completion?.status !== "completed" || completion.reason || response?.harnessNoteCount || response?.harnessTailCount)
19
+ // Preserve an upstream failure and independently classify the actual response.
20
+ // A caller-supplied completion cannot certify unknown or incomplete metadata.
21
+ if (completion?.status !== "completed" || completion.reason)
19
22
  return reject("native-incomplete");
20
- const blocks = response?.content;
23
+ const actual = nativeCompletion(response);
24
+ if (actual.status !== "completed" || actual.reason) return reject("native-incomplete");
25
+ // Classification validates every designated note and both counts. Strip only
26
+ // those blocks; model text, including lookalike tags, remains byte-for-byte.
27
+ const all = response.content;
28
+ const leading = response.harnessNoteCount ?? 0, tail = response.harnessTailCount ?? 0;
29
+ const blocks = Array.isArray(all) ? all.slice(leading, all.length - tail) : null;
21
30
  if (!Array.isArray(blocks) || blocks.length !== 1 || blocks[0]?.type !== "text"
22
31
  || typeof blocks[0].text !== "string" || !blocks[0].text.trim()
23
32
  || Buffer.byteLength(blocks[0].text, "utf8") > 262144)
@@ -0,0 +1,60 @@
1
+ // Coordinator-only read admission. Trust comes from the external operator's
2
+ // process environment, never an argument, task label, model claim or new graph.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import crypto from 'node:crypto';
6
+ import { commandTokens } from './command-tokens.mjs';
7
+ import { containedPath } from './paths.mjs';
8
+ import { matchesFingerprint } from './integrity.mjs';
9
+
10
+ const hash = file => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
11
+ const same = (a, b) => fs.realpathSync(a) === fs.realpathSync(b);
12
+
13
+ export function safeSharedContextCommand(command, project, env = process.env) {
14
+ try {
15
+ const tokens = commandTokens(command);
16
+ if (!tokens || tokens[0] !== 'node') return false;
17
+ const root = env.NCCGS_SHARED_WORKFLOW_ROOT;
18
+ const expected = env.NCCGS_SHARED_WORKFLOW_MANIFEST_SHA256;
19
+ if (!root || !path.isAbsolute(root) || !/^[a-f0-9]{64}$/.test(expected ?? '')) return false;
20
+ const config = containedPath(project, 'docs/workflow/workflow.config.json');
21
+ if (!fs.statSync(config).isFile()) return false;
22
+ const bridge = containedPath(project, '.claude/nccgs/tools/shared-context.mjs');
23
+ const script = path.resolve(project, tokens[1]);
24
+ const common = containedPath(root, 'tools/workflow.mjs');
25
+ if (same(script, bridge)) {
26
+ if (![8, 10].includes(tokens.length)) return false;
27
+ const options = {};
28
+ for (let i = 2; i < tokens.length; i += 2) {
29
+ const key = tokens[i];
30
+ if (!['--project', '--workflow-root', '--action', '--text'].includes(key) || Object.hasOwn(options, key)) return false;
31
+ options[key] = tokens[i + 1];
32
+ }
33
+ if (!same(options['--project'], project) || !same(options['--workflow-root'], root)) return false;
34
+ if (options['--action'] === 'status') {
35
+ if (tokens.length !== 8 || options['--text'] !== undefined) return false;
36
+ } else if (options['--action'] === 'query') {
37
+ if (tokens.length !== 10 || !/^[\p{L}\p{N}_.:/ -]{1,200}$/u.test(options['--text'] ?? '')) return false;
38
+ } else return false;
39
+ const installed = JSON.parse(fs.readFileSync(containedPath(project, '.claude/nccgs/install-state.json')));
40
+ const record = installed.files.find(x => x.relative === '.claude/nccgs/tools/shared-context.mjs');
41
+ if (!record || !matchesFingerprint(bridge, record)) return false;
42
+ } else if (same(script, common)) {
43
+ if (tokens.length !== 5 || tokens[2] !== 'status' || tokens[3] !== '--config' || !same(tokens[4], config)) return false;
44
+ } else return false;
45
+
46
+ const file = containedPath(root, 'implementation/ARTIFACT_MANIFEST.json');
47
+ if (hash(file) !== expected) return false;
48
+ const manifest = JSON.parse(fs.readFileSync(file));
49
+ if (!Array.isArray(manifest.files) || manifest.files.length === 0) return false;
50
+ // Verify the actual reader bytes before admitting any external executable.
51
+ for (const entry of manifest.files) {
52
+ const source = containedPath(root, entry.path);
53
+ if (!fs.statSync(source).isFile() || fs.statSync(source).size !== entry.size || hash(source) !== entry.sha256) return false;
54
+ }
55
+ const pkg = JSON.parse(fs.readFileSync(containedPath(root, 'package.json')));
56
+ return pkg.name === 'agent-project-workflow-candidate' && pkg.version.startsWith('1.7.');
57
+ } catch {
58
+ return false;
59
+ }
60
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // Optional explicit shared-workflow consumer. No hooks, native task or model changes.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+
7
+ try {
8
+ const args=process.argv.slice(2), options={};
9
+ for(let i=0;i<args.length;i+=2) {
10
+ const key=args[i]?.replace(/^--/,'');
11
+ if(!['project','workflow-root','action','text','hold','secret','constraints'].includes(key)||!args[i+1]||options[key])throw new Error('Invalid shared context arguments');
12
+ options[key]=args[i+1];
13
+ }
14
+ if(!options.project)throw new Error('Use --project with the actual target root');
15
+ const config=path.resolve(options.project,'docs/workflow/workflow.config.json');
16
+ if(!fs.existsSync(config))console.log(JSON.stringify({state:'skipped',reason:'No accepted common project configuration',installedOrBootstrapped:false}));
17
+ else {
18
+ if(!options['workflow-root'])throw new Error('Resolve --workflow-root from the accepted external binding');
19
+ const root=path.resolve(options['workflow-root']), pkg=JSON.parse(fs.readFileSync(path.join(root,'package.json'),'utf8'));
20
+ if(pkg.name!=='agent-project-workflow-candidate'||!pkg.version.startsWith('1.7.'))throw new Error('Unsupported common workflow identity');
21
+ const {consume}=await import(pathToFileURL(path.join(root,'tools/adapters/nccgs-context.mjs')));
22
+ const result=await consume(config,{action:options.action||'status',text:options.text,holdId:options.hold,secret:options.secret,constraints:options.constraints});
23
+ console.log(JSON.stringify(result,null,2));
24
+ }
25
+ }catch(error){console.error(JSON.stringify({ok:false,code:error.code||'SHARED_CONTEXT',message:error.message,externalAcceptance:'PENDING'}));process.exitCode=1;}