@pigcloud/skills 1.0.3 → 1.0.5

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 (54) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/README.en.md +74 -83
  3. package/README.md +74 -85
  4. package/bin/cli.js +114 -89
  5. package/bin/postinstall.js +1 -1
  6. package/package.json +1 -1
  7. package/rules/skill-profile-map.json +5 -5
  8. package/rules/skill-profile-map.md +2 -2
  9. package/scripts/validate-skill-shapes.js +2 -1
  10. package/scripts/validate-skills.ps1 +6 -6
  11. package/scripts/validate-skills.sh +5 -5
  12. package/skills/api-docs/SKILL.md +2 -2
  13. package/skills/domain-modeling/SKILL.md +4 -4
  14. package/skills/extract-business-facts/SKILL.md +336 -0
  15. package/skills/extract-business-facts/scripts/write-knowledge-base.js +227 -0
  16. package/skills/knowledge-capture/SKILL.md +16 -7
  17. package/skills/project-bootstrap/SKILL.md +2 -2
  18. package/skills/references/business-fact-extraction.md +414 -0
  19. package/skills/references/golden-prompt-suite.js +64 -14
  20. package/skills/references/rule-loading-map.md +18 -18
  21. package/skills/references/skill-authoring-standard.md +2 -2
  22. package/skills/references/skill-boundary-template.md +56 -23
  23. package/skills/references/skill-enhanced-template.md +80 -30
  24. package/skills/references/skill-reference-matrix.md +21 -20
  25. package/skills/{spec-refinement → spec}/SKILL.md +19 -14
  26. package/skills/technical-design/SKILL.md +4 -4
  27. package/pig-cloud-skills-commands/.codex-plugin/plugin.json +0 -35
  28. package/pig-cloud-skills-commands/README.md +0 -24
  29. package/pig-cloud-skills-commands/commands/analyze.md +0 -21
  30. package/pig-cloud-skills-commands/commands/build.md +0 -21
  31. package/pig-cloud-skills-commands/commands/design.md +0 -21
  32. package/pig-cloud-skills-commands/commands/distill.md +0 -21
  33. package/pig-cloud-skills-commands/commands/doc.md +0 -21
  34. package/pig-cloud-skills-commands/commands/infra.md +0 -21
  35. package/pig-cloud-skills-commands/commands/init.md +0 -20
  36. package/pig-cloud-skills-commands/commands/kb.md +0 -20
  37. package/pig-cloud-skills-commands/commands/perf.md +0 -20
  38. package/pig-cloud-skills-commands/commands/prd.md +0 -21
  39. package/pig-cloud-skills-commands/commands/review.md +0 -21
  40. package/pig-cloud-skills-commands/commands/security.md +0 -21
  41. package/pig-cloud-skills-commands/commands/test.md +0 -21
  42. package/pig-cloud-skills-commands/commands/workflow.md +0 -20
  43. package/skills/product-intake/SKILL.md +0 -98
  44. package/skills/references/agent-personas.md +0 -34
  45. package/skills/references/flow-test-cases.md +0 -62
  46. package/skills/references/full-chain-replay-scenarios.md +0 -79
  47. package/skills/references/hooks.md +0 -67
  48. package/skills/references/negative-replay-scenarios.md +0 -49
  49. package/skills/references/prompt-replay-checklist.md +0 -128
  50. package/skills/references/requirements-separation-map.md +0 -71
  51. package/skills/references/slash-commands.md +0 -34
  52. package/skills/spec-refinement/references/ears-syntax.md +0 -127
  53. package/skills/spec-refinement/references/requirement-checklist.md +0 -139
  54. package/skills/spec-refinement/references/spec-workbook.md +0 -75
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const REPO_ROOT = path.join(__dirname, '..', '..', '..');
7
+ const START_MARKER = '<!-- extract-business-facts:start -->';
8
+ const END_MARKER = '<!-- extract-business-facts:end -->';
9
+
10
+ const FILE_FIELD_ORDER = {
11
+ 'knowledge-base/realtime-code/modules.md': ['module', 'current responsibility', 'key entry points', 'important constraints', 'last verified'],
12
+ 'knowledge-base/realtime-code/flows.md': ['flow name', 'trigger', 'path', 'output', 'failure points', 'notes'],
13
+ 'knowledge-base/realtime-code/runtime-notes.md': ['fact', 'evidence', 'affected area', 'date', 'notes'],
14
+ 'knowledge-base/requirements/decisions.md': ['decision', 'reason', 'date or context', 'affected artifact', 'notes'],
15
+ 'knowledge-base/requirements/acceptance.md': ['requirement', 'acceptance criteria', 'out of scope', 'open questions', 'confirmed by'],
16
+ 'knowledge-base/requirements/conflicts.md': ['conflict', 'source', 'impact', 'resolution', 'status'],
17
+ 'knowledge-base/codewiki/overview.md': ['one-line summary', 'what the system does', 'what changed', 'why it matters'],
18
+ 'knowledge-base/codewiki/architecture.md': ['layers', 'boundaries', 'dependencies', 'major integration points'],
19
+ 'knowledge-base/codewiki/modules.md': ['module name', 'responsibility', 'main interfaces', 'related runtime facts'],
20
+ 'knowledge-base/codewiki/flows.md': ['request flow', 'data flow', 'error flow', 'handoff flow'],
21
+ 'knowledge-base/codewiki/api.md': ['endpoint or contract', 'request shape', 'response shape', 'constraints'],
22
+ 'knowledge-base/codewiki/runbook.md': ['startup', 'verify', 'troubleshoot', 'recover'],
23
+ 'knowledge-base/codewiki/conventions.md': ['naming', 'layering', 'error handling', 'logging', 'data handling'],
24
+ 'knowledge-base/enterprise/decisions.md': ['decision', 'reason', 'scope', 'date', 'reusable lesson'],
25
+ 'knowledge-base/enterprise/pitfalls.md': ['pitfall', 'context', 'why it failed', 'how to avoid it'],
26
+ 'knowledge-base/enterprise/examples.md': ['example', 'context', 'lesson', 'reusable pattern'],
27
+ 'knowledge-base/enterprise/ai-coding-rules.md': ['rule', 'when it applies', 'why it matters', 'examples']
28
+ };
29
+
30
+ const SAMPLE_PACK = {
31
+ files: {
32
+ 'knowledge-base/realtime-code/modules.md': [
33
+ {
34
+ module: 'order-service',
35
+ 'current responsibility': 'creates orders and reserves inventory',
36
+ 'key entry points': 'createOrder(), reserveInventory()',
37
+ 'important constraints': 'stock must be checked before commit',
38
+ 'last verified': '2026-06-22'
39
+ }
40
+ ],
41
+ 'knowledge-base/requirements/decisions.md': [
42
+ {
43
+ decision: 'inventory must be reserved before order confirmation',
44
+ reason: 'avoid overselling',
45
+ 'date or context': '2026-06-22, order flow review',
46
+ 'affected artifact': 'checkout spec',
47
+ notes: 'failure should return a clear stock shortage message'
48
+ }
49
+ ],
50
+ 'knowledge-base/codewiki/flows.md': [
51
+ {
52
+ 'request flow': 'checkout -> validate stock -> reserve inventory -> create order',
53
+ 'data flow': 'cart snapshot -> reservation record -> order record',
54
+ 'error flow': 'stock shortage -> stop checkout -> return shortage reason',
55
+ 'handoff flow': 'checkout service hands off to inventory service and order repository'
56
+ }
57
+ ],
58
+ 'knowledge-base/enterprise/pitfalls.md': [
59
+ {
60
+ pitfall: 'reservation happens after order creation',
61
+ context: 'checkout path',
62
+ 'why it failed': 'allowed overselling under concurrent requests',
63
+ 'how to avoid it': 'reserve before committing the order'
64
+ }
65
+ ]
66
+ }
67
+ };
68
+
69
+ function parseArgs(argv) {
70
+ const args = {
71
+ input: null,
72
+ root: REPO_ROOT,
73
+ dryRun: false,
74
+ sample: false
75
+ };
76
+
77
+ for (let index = 0; index < argv.length; index += 1) {
78
+ const token = argv[index];
79
+ if (token === '--input' || token === '-i') {
80
+ args.input = argv[++index];
81
+ continue;
82
+ }
83
+ if (token.startsWith('--input=')) {
84
+ args.input = token.slice('--input='.length);
85
+ continue;
86
+ }
87
+ if (token === '--root' || token === '-r') {
88
+ args.root = path.resolve(argv[++index]);
89
+ continue;
90
+ }
91
+ if (token.startsWith('--root=')) {
92
+ args.root = path.resolve(token.slice('--root='.length));
93
+ continue;
94
+ }
95
+ if (token === '--dry-run') {
96
+ args.dryRun = true;
97
+ continue;
98
+ }
99
+ if (token === '--sample') {
100
+ args.sample = true;
101
+ continue;
102
+ }
103
+ }
104
+
105
+ return args;
106
+ }
107
+
108
+ function readInput(inputPath) {
109
+ if (!inputPath || inputPath === '-') {
110
+ return fs.readFileSync(0, 'utf8');
111
+ }
112
+ return fs.readFileSync(inputPath, 'utf8');
113
+ }
114
+
115
+ function loadPack(inputText) {
116
+ const parsed = JSON.parse(String(inputText).replace(/^\uFEFF/, ''));
117
+ if (parsed && typeof parsed === 'object' && parsed.files && typeof parsed.files === 'object') {
118
+ return parsed.files;
119
+ }
120
+ if (parsed && typeof parsed === 'object') {
121
+ return parsed;
122
+ }
123
+ throw new Error('Input must be a JSON object.');
124
+ }
125
+
126
+ function normalizeValue(value) {
127
+ if (value === null || value === undefined || value === '') return 'unknown';
128
+ if (Array.isArray(value)) return value.map(item => normalizeValue(item)).join(', ');
129
+ if (typeof value === 'object') return JSON.stringify(value);
130
+ return String(value).trim() || 'unknown';
131
+ }
132
+
133
+ function renderEntry(fields, entry) {
134
+ return fields.map(field => `- ${field}: ${normalizeValue(entry[field])}`).join('\n');
135
+ }
136
+
137
+ function renderFileSection(relativePath, entries) {
138
+ const fieldOrder = FILE_FIELD_ORDER[relativePath];
139
+ if (!fieldOrder) {
140
+ throw new Error(`Unsupported target file: ${relativePath}`);
141
+ }
142
+ if (!Array.isArray(entries) || entries.length === 0) {
143
+ throw new Error(`No entries provided for ${relativePath}`);
144
+ }
145
+
146
+ const blocks = entries.map(entry => renderEntry(fieldOrder, entry));
147
+ return [
148
+ '## Generated Entries',
149
+ START_MARKER,
150
+ blocks.join('\n\n'),
151
+ END_MARKER
152
+ ].join('\n');
153
+ }
154
+
155
+ function upsertGeneratedSection(existingContent, generatedSection) {
156
+ const startIndex = existingContent.indexOf(START_MARKER);
157
+ const endIndex = existingContent.indexOf(END_MARKER);
158
+
159
+ if (startIndex >= 0 && endIndex >= 0 && endIndex > startIndex) {
160
+ const before = existingContent.slice(0, startIndex).trimEnd();
161
+ const after = existingContent.slice(endIndex + END_MARKER.length).trimStart();
162
+ const middle = generatedSection;
163
+ const parts = [before, middle];
164
+ if (after) {
165
+ parts.push(after);
166
+ }
167
+ return `${parts.filter(Boolean).join('\n\n').trimEnd()}\n`;
168
+ }
169
+
170
+ const base = existingContent.trimEnd();
171
+ if (!base) {
172
+ return `${generatedSection}\n`;
173
+ }
174
+
175
+ return `${base}\n\n${generatedSection}\n`;
176
+ }
177
+
178
+ function collectTargets(filePack) {
179
+ const targets = [];
180
+ for (const [relativePath, entries] of Object.entries(filePack)) {
181
+ if (!relativePath.startsWith('knowledge-base/')) {
182
+ throw new Error(`Refusing to write outside knowledge-base: ${relativePath}`);
183
+ }
184
+ targets.push({ relativePath, entries });
185
+ }
186
+ return targets;
187
+ }
188
+
189
+ function ensureParentDir(filePath) {
190
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
191
+ }
192
+
193
+ function main() {
194
+ const args = parseArgs(process.argv.slice(2));
195
+
196
+ if (args.sample) {
197
+ process.stdout.write(`${JSON.stringify(SAMPLE_PACK, null, 2)}\n`);
198
+ return;
199
+ }
200
+
201
+ const inputText = readInput(args.input);
202
+ const filePack = loadPack(inputText);
203
+ const targets = collectTargets(filePack);
204
+
205
+ for (const { relativePath, entries } of targets) {
206
+ const absolutePath = path.join(args.root, relativePath);
207
+ const generatedSection = renderFileSection(relativePath, entries);
208
+ const existingContent = fs.existsSync(absolutePath) ? fs.readFileSync(absolutePath, 'utf8') : '';
209
+ const nextContent = upsertGeneratedSection(existingContent, generatedSection);
210
+
211
+ if (args.dryRun) {
212
+ process.stdout.write(`=== ${relativePath} ===\n${nextContent}\n`);
213
+ continue;
214
+ }
215
+
216
+ ensureParentDir(absolutePath);
217
+ fs.writeFileSync(absolutePath, nextContent, 'utf8');
218
+ process.stdout.write(`Wrote ${relativePath}\n`);
219
+ }
220
+ }
221
+
222
+ try {
223
+ main();
224
+ } catch (error) {
225
+ console.error(error.message);
226
+ process.exitCode = 1;
227
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: knowledge-capture
3
- description: 当下游工作需要可持续沉淀时,捕捉可复用的决策、需求知识、实时代码事实、CodeWiki 事实和交接说明
3
+ description: Capture reusable decisions, requirement knowledge, realtime code facts, CodeWiki facts, and handoff notes; use when an upstream task already produced evidence and you need to normalize it, persist it, or hand it off without redoing analysis.
4
4
  lifecycle_stage: capture
5
5
  rule_profile: capture
6
6
  dependencies: []
@@ -15,21 +15,26 @@ inputs:
15
15
  - approved artifacts
16
16
  - findings
17
17
  - decisions
18
+ - staged fact packs
18
19
  outputs:
19
20
  - reusable note
20
21
  - knowledge page
21
22
  - handoff summary
23
+ - knowledge-base write pack
22
24
  workflow:
23
25
  - collect the produced artifact
24
26
  - normalize it into a reusable note
25
27
  - separate requirement knowledge, realtime code facts, CodeWiki facts, and decision-log content
26
28
  - link it to the originating skill
29
+ - when persistence is needed, convert the note into a knowledge-base fact pack and write it with the capture writer
27
30
  - publish the handoff summary for downstream reuse
28
31
  gates:
29
32
  - stop at capture and organization
30
33
  - do not redo upstream analysis
31
34
  - do not generate new requirements or code
35
+ - do not rewrite the fact pack into a new analysis
32
36
  refs:
37
+ - skills/references/business-fact-extraction.md
33
38
  - skills/references/skill-reference-matrix.md
34
39
  - skills/references/rule-loading-map.md
35
40
  - skills/references/flow-test-cases.md
@@ -46,7 +51,7 @@ Store decisions, artifacts, and handoff notes so other skills can reuse them lat
46
51
 
47
52
  ## Suitable / Unsuitable
48
53
 
49
- - Suitable: summaries, decision logs, reusable knowledge, artifact handoff, CodeWiki facts, requirements knowledge, realtime code facts
54
+ - Suitable: summaries, decision logs, reusable knowledge, artifact handoff, CodeWiki facts, requirements knowledge, realtime code facts, staged fact packs
50
55
  - Unsuitable: requirement discovery, design, implementation, review, test authoring
51
56
 
52
57
  ## Workflow
@@ -55,12 +60,13 @@ Store decisions, artifacts, and handoff notes so other skills can reuse them lat
55
60
  2. Normalize it into a reusable note.
56
61
  3. Separate requirement knowledge, realtime code facts, CodeWiki facts, decision log entries, and pitfall notes.
57
62
  4. Link it back to the originating skill.
58
- 5. Publish the handoff summary for downstream reuse.
63
+ 5. If the note should persist, map it to the knowledge-base file targets and write the fact pack.
64
+ 6. Publish the handoff summary for downstream reuse.
59
65
 
60
66
  ## Replay Signals
61
67
 
62
- - Input signal: approved artifacts, findings, or decisions.
63
- - Output to verify: reusable note, knowledge page, handoff summary, decision log entry, codewiki update, enterprise knowledge note.
68
+ - Input signal: approved artifacts, findings, decisions, or staged fact packs.
69
+ - Output to verify: reusable note, knowledge page, handoff summary, decision log entry, codewiki update, enterprise knowledge note, knowledge-base write pack.
64
70
  - Stop signal: redoing upstream analysis or generating new requirements/code.
65
71
  - Handoff signal: the reusable note is ready for later reuse by other skills.
66
72
 
@@ -70,15 +76,18 @@ Store decisions, artifacts, and handoff notes so other skills can reuse them lat
70
76
  - Do not redo upstream analysis.
71
77
  - Do not generate new requirements or code.
72
78
  - Do not merge requirement knowledge, code facts, and decisions into one blob.
79
+ - Do not treat persistence as a new analysis pass.
80
+ - Do not rewrite the fact pack into a new analysis.
73
81
 
74
82
  ## Examples
75
83
 
76
84
  - Input: "Capture the decisions and pitfalls from this task."
77
- - Output: reusable note, knowledge page, handoff summary
85
+ - Output: reusable note, knowledge page, handoff summary, optional knowledge-base write pack
78
86
  - Stop: do not re-open the design or implementation debate
79
87
 
80
88
  ## References
81
89
 
90
+ - `skills/references/business-fact-extraction.md`
82
91
  - `skills/references/skill-reference-matrix.md`
83
92
  - `skills/references/rule-loading-map.md`
84
- - `skills/references/flow-test-cases.md`
93
+ - `docs/codewiki-knowledge-base.md`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: project-bootstrap
3
- description: 当项目需要初始化时,为新工作区装载合适的技能和规则包
3
+ description: 当项目需要初始化时,为新工作区装载合适的技能和规则包
4
4
  lifecycle_stage: scaffold
5
5
  rule_profile: scaffold
6
6
  dependencies: []
@@ -58,7 +58,7 @@ Create a new workspace with the right skills and rules layout.
58
58
  - Input signal: client type, workspace markers, desired rules bundle.
59
59
  - Output to verify: starter structure, installed bundle, setup notes.
60
60
  - Stop signal: product scope design or application code generation.
61
- - Handoff signal: the workspace is ready for `workflow-router` or `product-intake`.
61
+ - Handoff signal: the workspace is ready for `workflow-router` or `spec`.
62
62
 
63
63
  ## Examples
64
64