kitskill 0.0.0-stage → 0.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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +397 -2
  3. package/THIRD-PARTY-NOTICES.md +24 -0
  4. package/banner.jpeg +0 -0
  5. package/bin/cli.mjs +464 -0
  6. package/lib/fs-safe.mjs +136 -0
  7. package/lib/hook.mjs +79 -0
  8. package/lib/installer.mjs +449 -0
  9. package/lib/manifest.mjs +47 -0
  10. package/lib/permissions.mjs +175 -0
  11. package/lib/profile.mjs +124 -0
  12. package/lib/project-scan.mjs +186 -0
  13. package/lib/validator.mjs +72 -0
  14. package/logo.png +0 -0
  15. package/logohead.png +0 -0
  16. package/package.json +54 -4
  17. package/templates/core/memory/PROJECT.md +33 -0
  18. package/templates/core/memory/decisions/ADR.md +22 -0
  19. package/templates/core/profile.json +17 -0
  20. package/templates/core/router.md +89 -0
  21. package/templates/core/state/STATE.md +32 -0
  22. package/templates/opencode/policy-plugin.js +66 -0
  23. package/templates/scripts/graph-client.mjs +231 -0
  24. package/templates/scripts/review-packet.mjs +250 -0
  25. package/templates/scripts/shrink-output.mjs +159 -0
  26. package/templates/scripts/ui-audit.mjs +639 -0
  27. package/templates/scripts/verify.mjs +293 -0
  28. package/templates/skills/ks-api/SKILL.md +87 -0
  29. package/templates/skills/ks-api/references/api-contract.md +131 -0
  30. package/templates/skills/ks-build/SKILL.md +92 -0
  31. package/templates/skills/ks-data/SKILL.md +81 -0
  32. package/templates/skills/ks-data/references/data-migrations.md +120 -0
  33. package/templates/skills/ks-deliver/SKILL.md +99 -0
  34. package/templates/skills/ks-deliver/references/doc-patterns.md +180 -0
  35. package/templates/skills/ks-design/SKILL.md +147 -0
  36. package/templates/skills/ks-design/references/app-models.md +216 -0
  37. package/templates/skills/ks-design/references/design-contract.md +98 -0
  38. package/templates/skills/ks-design/references/visual-directions.md +159 -0
  39. package/templates/skills/ks-plan/SKILL.md +84 -0
  40. package/templates/skills/ks-review/SKILL.md +71 -0
  41. package/templates/skills/ks-secure/SKILL.md +55 -0
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { mkdir, writeFile } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+
7
+ const DEFAULT_MAX_LINES = 120;
8
+
9
+ const SIGNAL = /(FAIL|ERROR|Error:|error:|Traceback|AssertionError|panic:|fatal:|✗|✘|×|FAILED|FAILURES|Expected|Received|error TS\d+|SyntaxError|TypeError|ReferenceError|npm ERR!)/;
10
+ const SUMMARY = /(\d+\s+(passed|failed|skipped|errors?|warnings?)|tests?\s+(passed|failed)|Test Suites:|Ran \d+ test|BUILD (SUCCESS|FAILED)|Duration:|Time:\s|Done in|Finished in|exit code)/i;
11
+
12
+ function isNoise(line) {
13
+ return (
14
+ /^\s*$/.test(line) ||
15
+ /^\s*(PASS|OK)\b/.test(line) ||
16
+ /^\s*[✓✔]/.test(line) ||
17
+ /^\s*[.·]+\s*$/.test(line) ||
18
+ /^\s*\d+%/.test(line) ||
19
+ /^>\s/.test(line) ||
20
+ /^(Downloading|Collecting|Building|Compiling)\b/.test(line)
21
+ );
22
+ }
23
+
24
+ /**
25
+ * Compress noisy tool output while keeping failures, their context, and summaries.
26
+ * @param {string} text
27
+ * @param {{maxLines?: number}} [options]
28
+ * @returns {{text: string, totalLines: number, keptLines: number, omittedLines: number}}
29
+ */
30
+ export function filterOutput(text, { maxLines = DEFAULT_MAX_LINES } = {}) {
31
+ const lines = String(text).replace(/\r\n/g, '\n').split('\n');
32
+ const keep = new Set();
33
+
34
+ // Keep the first meaningful lines as a header, but never keep PASS/OK noise.
35
+ let headerKept = 0;
36
+ for (let i = 0; i < lines.length && headerKept < 3; i += 1) {
37
+ if (lines[i].trim() && !isNoise(lines[i])) {
38
+ keep.add(i);
39
+ headerKept += 1;
40
+ }
41
+ }
42
+
43
+ lines.forEach((line, index) => {
44
+ if (SIGNAL.test(line)) {
45
+ for (let i = Math.max(0, index - 1); i <= Math.min(lines.length - 1, index + 2); i += 1) {
46
+ if (!isNoise(lines[i])) keep.add(i);
47
+ }
48
+ }
49
+ if (SUMMARY.test(line)) keep.add(index);
50
+ });
51
+
52
+ const tail = lines
53
+ .map((line, index) => (line.trim() && !isNoise(line) ? index : -1))
54
+ .filter((i) => i >= 0)
55
+ .slice(-8);
56
+ for (const index of tail) keep.add(index);
57
+
58
+ let kept = [...keep].sort((a, b) => a - b).map((i) => lines[i]);
59
+
60
+ // Collapse runs of blank lines produced by dropping noise.
61
+ kept = kept.filter((line, index) => !(/^\s*$/.test(line) && /^\s*$/.test(kept[index - 1] ?? '')));
62
+
63
+ let omitted = lines.length - kept.length;
64
+ if (kept.length > maxLines) {
65
+ const head = Math.max(1, Math.floor(maxLines * 0.4));
66
+ const tail = Math.max(1, maxLines - head);
67
+ omitted += kept.length - maxLines;
68
+ kept = [
69
+ ...kept.slice(0, head),
70
+ `[kitskill] ... ${omitted} line(s) omitted; full output kept by the wrapper ...`,
71
+ ...kept.slice(-tail),
72
+ ];
73
+ }
74
+
75
+ return {
76
+ text: kept.join('\n'),
77
+ totalLines: lines.length,
78
+ keptLines: kept.length,
79
+ omittedLines: Math.max(0, omitted),
80
+ };
81
+ }
82
+
83
+ async function persistFull(text) {
84
+ const dir = path.join(process.cwd(), '.kitskill', 'artifacts');
85
+ const file = path.join(dir, 'last-output.log');
86
+ try {
87
+ await mkdir(dir, { recursive: true });
88
+ await writeFile(file, text, 'utf8');
89
+ return file;
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+
95
+ function splitArgv(argv) {
96
+ const separator = argv.indexOf('--');
97
+ const head = separator >= 0 ? argv.slice(0, separator) : argv;
98
+ const command = separator >= 0 ? argv.slice(separator + 1) : argv;
99
+ let maxLines = DEFAULT_MAX_LINES;
100
+ let raw = false;
101
+ for (let i = 0; i < head.length; i += 1) {
102
+ if (head[i] === '--max-lines') {
103
+ maxLines = Number.parseInt(head[i + 1], 10);
104
+ i += 1;
105
+ } else if (head[i] === '--raw') {
106
+ raw = true;
107
+ }
108
+ }
109
+ return { command, maxLines, raw };
110
+ }
111
+
112
+ async function main() {
113
+ const { command, maxLines, raw } = splitArgv(process.argv.slice(2));
114
+ if (command.length === 0) {
115
+ process.stderr.write(
116
+ 'Usage: node shrink-output.mjs [--max-lines N] [--raw] -- <command> [args...]\n',
117
+ );
118
+ process.exit(2);
119
+ }
120
+
121
+ const child = spawn(command[0], command.slice(1), { stdio: ['inherit', 'pipe', 'pipe'] });
122
+ let stdout = '';
123
+ let stderr = '';
124
+ child.stdout.on('data', (chunk) => {
125
+ stdout += chunk;
126
+ });
127
+ child.stderr.on('data', (chunk) => {
128
+ stderr += chunk;
129
+ });
130
+
131
+ const code = await new Promise((resolve, reject) => {
132
+ child.on('error', reject);
133
+ child.on('close', resolve);
134
+ });
135
+
136
+ const combined = [stdout, stderr].filter(Boolean).join('\n');
137
+ const fullLog = await persistFull(combined);
138
+
139
+ if (raw) {
140
+ process.stdout.write(combined);
141
+ } else {
142
+ const result = filterOutput(combined, { maxLines });
143
+ process.stdout.write(result.text.endsWith('\n') ? result.text : `${result.text}\n`);
144
+ process.stderr.write(
145
+ `[kitskill] ${result.totalLines} lines -> ${result.keptLines} ` +
146
+ `(${result.omittedLines} omitted)` +
147
+ `${fullLog ? `; full log: ${fullLog}` : ''}\n`,
148
+ );
149
+ }
150
+
151
+ process.exit(code ?? 1);
152
+ }
153
+
154
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
155
+ main().catch((error) => {
156
+ process.stderr.write(`${error.stack ?? error.message}\n`);
157
+ process.exit(1);
158
+ });
159
+ }