@pan-stack/cli 0.3.45 → 0.3.46
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/bin/pan.js +4474 -534
- package/dist/agent-plugin/plugins/pan/.claude-plugin/plugin.json +1 -1
- package/dist/agent-plugin/plugins/pan/.codex-plugin/plugin.json +1 -1
- package/dist/agent-plugin/plugins/pan/.cursor-plugin/plugin.json +1 -1
- package/dist/agent-plugin/plugins/pan/scripts/hook.mjs +57 -10
- package/package.json +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pan",
|
|
3
3
|
"displayName": "PAN",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.46",
|
|
5
5
|
"description": "Harness cho workspace PAN Stack: mọi commit của Claude mang danh tính AI + người chủ quản + máy; nguồn tài liệu (Pan Lineage) của tệp hiện ra trước khi sửa.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "n46-labs"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pan",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.46",
|
|
4
4
|
"description": "PAN Stack harness for AI agents: every commit carries AI + owner + machine identity, document sources (Pan Lineage) show before edits, and PAN skills load on their own.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "n46-labs"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pan",
|
|
3
3
|
"displayName": "PAN",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.46",
|
|
5
5
|
"description": "PAN Stack harness for AI agents: every commit carries AI + owner + machine identity, document sources (Pan Lineage) show before edits, and PAN skills load on their own.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "n46-labs"
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// `--no-verify` trong message commit không bị chặn nhầm. Sau đó với Edit/Write: lineage strict như cũ.
|
|
16
16
|
// after-edit (PostToolUse của Edit/Write/MultiEdit) khối C — `pan harness lint <tệp>` theo `lint:` của
|
|
17
17
|
// .pan-harness.yaml; vi phạm → nạp cho agent tự sửa, không chặn. Không khai `lint:` thì không gọi pan.
|
|
18
|
+
// Tệp nằm trong repo tài liệu BA (`.panba.yaml`, products/<slug>/) → thêm `pan ba check --json` và nạp
|
|
19
|
+
// lỗi/cảnh báo của chính tệp đó (Pan BA, GP 073 §8.9) — chạy cả khi repo BA không phải workspace PAN.
|
|
18
20
|
// before-edit (giữ tên cũ) chỉ khi bật strict_lineage hoặc PAN_LINEAGE_STRICT=1: tệp có nguồn đã đổi → deny.
|
|
19
21
|
// stop (Stop) khối D — cổng xong: `pan harness status --json`; cổng có sửa chưa commit trong phạm vi
|
|
20
22
|
// (`changed`) mà chưa qua → mode enforce: chặn báo xong kèm cách làm; mode warn: chỉ nhắc người dùng.
|
|
@@ -52,6 +54,8 @@ const MESSAGES = {
|
|
|
52
54
|
gatesWarn: 'pan-harness: còn cổng chưa qua ở phần vừa sửa — {gates}. Chạy {commands} (hoặc nút Chạy cổng trên dashboard).',
|
|
53
55
|
gate: { fail: 'đỏ', outdated: 'cũ', never: 'chưa chạy' },
|
|
54
56
|
lint: '[pan-harness] lint {file}: {count} vi phạm luật của workspace (.pan-harness.yaml › lint) — sửa luôn:',
|
|
57
|
+
ba: '[pan ba] {file}: {errors} lỗi, {warnings} cảnh báo (`pan ba check --product {slug}`) — sửa luôn để web đọc tài liệu và bản xuất không vỡ; tham chiếu viết [[MÃ]], không gõ số mục:',
|
|
58
|
+
baError: 'LỖI',
|
|
55
59
|
},
|
|
56
60
|
en: {
|
|
57
61
|
head: '[pan-harness] workspace {ws} · principal {principal} · agent {agent}{mode}',
|
|
@@ -74,6 +78,8 @@ const MESSAGES = {
|
|
|
74
78
|
gatesWarn: 'pan-harness: gates not passing in what was just changed — {gates}. Run {commands} (or Run gates on the dashboard).',
|
|
75
79
|
gate: { fail: 'failing', outdated: 'outdated', never: 'not run' },
|
|
76
80
|
lint: '[pan-harness] lint {file}: {count} violation(s) of workspace rules (.pan-harness.yaml › lint) — fix them now:',
|
|
81
|
+
ba: '[pan ba] {file}: {errors} error(s), {warnings} warning(s) (`pan ba check --product {slug}`) — fix them now so the doc viewer and exports stay intact; write references as [[CODE]], never type section numbers:',
|
|
82
|
+
baError: 'ERROR',
|
|
77
83
|
},
|
|
78
84
|
};
|
|
79
85
|
const MAX_DIFF_LINES = 60;
|
|
@@ -209,24 +215,65 @@ function afterRead(input) {
|
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
const MAX_LINT_LINES = 20;
|
|
218
|
+
const clip = (lines) => [...lines.slice(0, MAX_LINT_LINES), ...(lines.length > MAX_LINT_LINES ? ['…'] : [])];
|
|
219
|
+
|
|
220
|
+
const baRootOf = (start) => findUp(start, (dir) => fs.existsSync(path.join(dir, '.panba.yaml')));
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Repo tài liệu BA (Pan BA, GP 073 §8.9): tệp trong `products/<slug>/` vừa sửa → `pan ba check --json --product <slug>`,
|
|
224
|
+
* nạp lỗi/cảnh báo CỦA TỆP ĐÓ (tệp:dòng) cho agent sửa luôn — tham chiếu gãy, số mục, khối YAML sai làm vỡ web đọc
|
|
225
|
+
* tài liệu và bản xuất. Không chặn; pan cũ chưa có `ba check --json` thì im lặng. Ngôn ngữ: PAN_LANG → `language:`
|
|
226
|
+
* của `.panba.yaml`.
|
|
227
|
+
*/
|
|
228
|
+
function baCheckLines(file) {
|
|
229
|
+
if (!/\.(md|ya?ml)$/i.test(file)) return [];
|
|
230
|
+
const root = baRootOf(path.dirname(file));
|
|
231
|
+
if (!root) return [];
|
|
232
|
+
const rel = path.relative(root, file).split(path.sep).join('/');
|
|
233
|
+
const slug = /^products\/([^/]+)\//.exec(rel)?.[1];
|
|
234
|
+
if (!slug) return [];
|
|
235
|
+
let out = '';
|
|
236
|
+
try {
|
|
237
|
+
out = execFileSync('pan', ['ba', 'check', root, '--product', slug, '--json'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 30000 });
|
|
238
|
+
} catch (error) {
|
|
239
|
+
out = error?.status === 1 && typeof error.stdout === 'string' ? error.stdout : '';
|
|
240
|
+
}
|
|
241
|
+
let rows;
|
|
242
|
+
try {
|
|
243
|
+
rows = JSON.parse(out).rows;
|
|
244
|
+
} catch {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
const mine = Array.isArray(rows) ? rows.filter((r) => r && r.tep === rel && r.muc !== 'info') : [];
|
|
248
|
+
if (!mine.length) return [];
|
|
249
|
+
let code = (process.env.PAN_LANG || '').toLowerCase();
|
|
250
|
+
if (!code) code = /^language\s*:\s*(\w+)/m.exec(fs.readFileSync(path.join(root, '.panba.yaml'), 'utf8'))?.[1] ?? '';
|
|
251
|
+
const m = MESSAGES[code] ?? MESSAGES.en;
|
|
252
|
+
const errors = mine.filter((r) => r.muc === 'error').length;
|
|
253
|
+
const lines = [format(m.ba, { file: rel, errors, warnings: mine.length - errors, slug })];
|
|
254
|
+
for (const r of mine) lines.push(` - ${r.tep}${r.dong ? `:${r.dong}` : ''} [${r.ma}${r.muc === 'error' ? ` ${m.baError}` : ''}] ${r.cau}`);
|
|
255
|
+
return clip(lines);
|
|
256
|
+
}
|
|
212
257
|
|
|
213
258
|
function afterEdit(input) {
|
|
214
259
|
const file = input.tool_input?.file_path;
|
|
215
260
|
if (!file) return;
|
|
261
|
+
const lines = baCheckLines(file);
|
|
216
262
|
const root = workspaceOf(path.dirname(file));
|
|
217
263
|
const repo = repoOf(path.dirname(file));
|
|
218
264
|
const declares = (dir) => dir && /^lint\s*:/m.test(workspaceConfig(dir));
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
265
|
+
const violations = root && (declares(root) || declares(repo)) ? (pan(['harness', 'lint', file], root) ?? []) : [];
|
|
266
|
+
if (violations.length) {
|
|
267
|
+
const m = messagesFor(root);
|
|
268
|
+
const lint = [format(m.lint, { file: violations[0].file, count: violations.length })];
|
|
269
|
+
for (const item of violations) {
|
|
270
|
+
const where = `${item.file}${item.line ? `:${item.line}` : ''}`;
|
|
271
|
+
lint.push(` - ${where} ${item.rule}${item.message ? ` — ${item.message}` : ''}`);
|
|
272
|
+
if (item.text) lint.push(...item.text.split('\n').map((text) => ` ${text}`));
|
|
273
|
+
}
|
|
274
|
+
lines.push(...clip(lint));
|
|
228
275
|
}
|
|
229
|
-
emit('PostToolUse', { additionalContext:
|
|
276
|
+
if (lines.length) emit('PostToolUse', { additionalContext: lines.join('\n') });
|
|
230
277
|
}
|
|
231
278
|
|
|
232
279
|
function beforeEdit(input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pan-stack/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.46",
|
|
4
4
|
"description": "PAN Stack CLI — multi-repo git and project commands from .project.yaml",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build:agent-plugin": "node tools/pan-stack-cli/build-agent-plugin.ts",
|
|
20
20
|
"prepare": "node tools/pan-stack-cli/build.mjs",
|
|
21
21
|
"prepublishOnly": "node tools/pan-stack-cli/build.mjs",
|
|
22
|
-
"test": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && node --test \"tools/pan-stack-plan/test/*.test.ts\" \"tools/pan-stack-cli/test/*.test.ts\" \"tools/pan-lineage/test/*.test.ts\" \"tools/pan-harness/test/*.test.ts\" \"tools/pan-program/test/*.test.ts\" \"tools/pan-handover/test/*.test.ts\" \"agent-plugin/plugins/pan/test/*.test.mjs\" && node --test \"tools/pan-cicd/test/*.test.mjs\"",
|
|
22
|
+
"test": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && node --test \"tools/pan-stack-plan/test/*.test.ts\" \"tools/pan-stack-cli/test/*.test.ts\" \"tools/pan-lineage/test/*.test.ts\" \"tools/pan-harness/test/*.test.ts\" \"tools/pan-program/test/*.test.ts\" \"tools/pan-handover/test/*.test.ts\" \"tools/pan-ba-core/test/*.test.ts\" \"tools/pan-ba/test/*.test.ts\" \"agent-plugin/plugins/pan/test/*.test.mjs\" && node --test \"tools/pan-cicd/test/*.test.mjs\"",
|
|
23
23
|
"test:pan-cicd": "node tools/pan-stack-cli/build.mjs && node --test \"tools/pan-cicd/test/*.test.mjs\"",
|
|
24
24
|
"test:pan-stack-plan": "node --test \"tools/pan-stack-plan/test/*.test.ts\"",
|
|
25
25
|
"test:pan-stack-cli": "node --test \"tools/pan-stack-cli/test/*.test.ts\"",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"cmdk": "1.1.1",
|
|
63
63
|
"csv-parse": "7.0.1",
|
|
64
64
|
"csv-stringify": "6.8.1",
|
|
65
|
+
"docx": "9.15.2",
|
|
65
66
|
"esbuild": "0.28.1",
|
|
66
67
|
"marked": "15.0.12",
|
|
67
68
|
"picomatch": "4.0.2",
|