@gobing-ai/knowledge-kit 0.0.12 → 0.0.14
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/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +120 -26
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +22187 -0
- package/plugins/generations/content-gen/plugin.json +1 -1
- package/plugins/generations/core-facts-gen/dist/index.js +22068 -0
- package/plugins/generations/core-facts-gen/plugin.json +1 -1
- package/plugins/generations/daily-article-gen/dist/index.js +22050 -0
- package/plugins/generations/daily-article-gen/plugin.json +1 -1
- package/plugins/generations/daily-article-gen/src/index.ts +13 -1
- package/plugins/generations/dailynews-gen/dist/index.js +22344 -0
- package/plugins/generations/dailynews-gen/plugin.json +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +22503 -0
- package/plugins/generations/episode-plan-gen/plugin.json +1 -1
- package/plugins/generations/episode-plan-gen/src/index.ts +11 -0
- package/plugins/generations/image-gen/config.example.yaml +75 -0
- package/plugins/generations/image-gen/dist/index.js +24862 -0
- package/plugins/generations/image-gen/package.json +17 -0
- package/plugins/generations/image-gen/plugin.json +7 -0
- package/plugins/generations/image-gen/presets/formats/cover.yaml +57 -0
- package/plugins/generations/image-gen/presets/formats/free.yaml +46 -0
- package/plugins/generations/image-gen/presets/formats/illustration.yaml +48 -0
- package/plugins/generations/image-gen/presets/styles/clean-webapp-ui.yaml +28 -0
- package/plugins/generations/image-gen/presets/styles/cute.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/editorial.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/fresh.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/minimalist.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/photorealistic.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/sketch.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/technical-diagram.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/vibrant.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/warm.yaml +3 -0
- package/plugins/generations/image-gen/src/bytes.ts +19 -0
- package/plugins/generations/image-gen/src/index.ts +319 -0
- package/plugins/generations/image-gen/src/job.ts +143 -0
- package/plugins/generations/image-gen/src/paths.ts +31 -0
- package/plugins/generations/image-gen/src/presets.ts +344 -0
- package/plugins/generations/image-gen/src/providers/agnes.ts +110 -0
- package/plugins/generations/image-gen/src/providers/azure.ts +153 -0
- package/plugins/generations/image-gen/src/providers/codex-cli.ts +170 -0
- package/plugins/generations/image-gen/src/providers/dashscope.ts +485 -0
- package/plugins/generations/image-gen/src/providers/google.ts +268 -0
- package/plugins/generations/image-gen/src/providers/huggingface.ts +59 -0
- package/plugins/generations/image-gen/src/providers/jimeng.ts +259 -0
- package/plugins/generations/image-gen/src/providers/minimax.ts +171 -0
- package/plugins/generations/image-gen/src/providers/openai.ts +319 -0
- package/plugins/generations/image-gen/src/providers/openrouter.ts +257 -0
- package/plugins/generations/image-gen/src/providers/refs.ts +24 -0
- package/plugins/generations/image-gen/src/providers/replicate.ts +279 -0
- package/plugins/generations/image-gen/src/providers/seedream.ts +128 -0
- package/plugins/generations/image-gen/src/providers/types.ts +286 -0
- package/plugins/generations/image-gen/src/providers/zai.ts +237 -0
- package/plugins/generations/image-gen/tsconfig.json +8 -0
- package/plugins/generations/news-report-gen/dist/index.js +22193 -0
- package/plugins/generations/news-report-gen/package.json +17 -0
- package/plugins/generations/news-report-gen/plugin.json +7 -0
- package/plugins/generations/news-report-gen/src/index.ts +308 -0
- package/plugins/generations/news-report-gen/tsconfig.json +4 -0
- package/plugins/generations/omni-voice-gen/Makefile +14 -0
- package/plugins/generations/omni-voice-gen/README.md +112 -0
- package/plugins/generations/omni-voice-gen/bin/omni-voice-gen +2 -0
- package/plugins/generations/omni-voice-gen/dist/omni-voice-gen-prr8skpb. +2 -0
- package/plugins/generations/omni-voice-gen/dist/omni-voice-gen.js +6 -0
- package/plugins/generations/omni-voice-gen/plugin.json +6 -0
- package/plugins/generations/omni-voice-gen/profiles.json +12 -0
- package/plugins/generations/omni-voice-gen/pyproject.toml +25 -0
- package/plugins/generations/omni-voice-gen/scripts/coverage_gate.py +74 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/__init__.py +1 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/__main__.py +39 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/audio.py +190 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/backend.py +150 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/contract.py +76 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/mp3.py +60 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/pipeline.py +289 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/profiles.py +100 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/qc.py +234 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/voicescript.py +352 -0
- package/plugins/generations/omni-voice-gen/uv.lock +3510 -0
- package/plugins/generations/voice-gen/dist/index.js +23055 -0
- package/plugins/generations/voice-gen/plugin.json +1 -1
- package/plugins/generations/voice-gen/src/index.ts +16 -1
- package/plugins/generations/voice-gen/src/voicebox-client.ts +3 -1
- package/plugins/ingestions/aihot-ingest/dist/index.js +22378 -0
- package/plugins/ingestions/aihot-ingest/plugin.json +1 -1
- package/plugins/ingestions/horizon-ingest/dist/index.js +22125 -0
- package/plugins/ingestions/horizon-ingest/plugin.json +1 -1
- package/plugins/ingestions/karakeep-local/dist/index.js +24204 -0
- package/plugins/ingestions/karakeep-local/plugin.json +1 -1
- package/plugins/ingestions/last30days-ingest/dist/index.js +22070 -0
- package/plugins/ingestions/last30days-ingest/plugin.json +1 -1
- package/plugins/ingestions/web-search/dist/index.js +24399 -0
- package/plugins/ingestions/web-search/plugin.json +1 -1
- package/plugins/kk/commands/image-extract.md +40 -0
- package/plugins/kk/commands/image-generate.md +32 -0
- package/plugins/kk/config.example.yaml +80 -0
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/skills/image-authoring/SKILL.md +257 -0
- package/plugins/kk/skills/image-authoring/references/format-drafting.md +57 -0
- package/plugins/kk/skills/image-authoring/references/illustration-positions.md +87 -0
- package/plugins/kk/skills/image-authoring/references/migrating-from-wt.md +31 -0
- package/plugins/kk/skills/image-authoring/references/providers.md +52 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +139 -0
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +130 -30
- package/plugins/publishings/emdash-pub/dist/index.js +22263 -0
- package/plugins/publishings/emdash-pub/plugin.json +1 -1
- package/plugins/publishings/podcast-pub/dist/index.js +22650 -0
- package/plugins/publishings/podcast-pub/plugin.json +8 -2
- package/plugins/publishings/podcast-pub/src/index.ts +18 -2
- package/plugins/publishings/podcast-pub/src/show-notes.ts +56 -9
- package/plugins/publishings/qiita-pub/dist/index.js +22101 -0
- package/plugins/publishings/qiita-pub/plugin.json +1 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +22323 -0
- package/plugins/publishings/surfdash-pub/plugin.json +1 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +109 -9
- package/plugins/publishings/zenn-pub/dist/index.js +22142 -0
- package/plugins/publishings/zenn-pub/plugin.json +1 -1
- package/plugins/sp/scripts/batch-preflight.mjs +346 -0
- package/plugins/sp/scripts/batch-preflight.ts +459 -0
- package/plugins/sp/scripts/daily-summary/daily-summary.mjs +615 -0
- package/plugins/sp/scripts/daily-summary/daily-summary.ts +846 -0
- package/plugins/sp/scripts/daily-summary/logger.ts +28 -0
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +223 -0
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +367 -0
- package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +132 -0
- package/plugins/sp/scripts/dogfood-testing/validate-report.ts +169 -0
- package/plugins/sp/scripts/feature-dev-precheck.mjs +171 -0
- package/plugins/sp/scripts/feature-dev-precheck.ts +238 -0
- package/plugins/sp/scripts/feature-sync-bounded.mjs +285 -0
- package/plugins/sp/scripts/feature-sync-bounded.ts +478 -0
- package/plugins/sp/scripts/history-anatomy-cache.mjs +902 -0
- package/plugins/sp/scripts/history-anatomy-cache.ts +1028 -0
- package/plugins/sp/scripts/idea-handoff.mjs +22 -0
- package/plugins/sp/scripts/idea-handoff.ts +44 -0
- package/plugins/sp/scripts/inline-pipeline-parity-check.ts +185 -0
- package/plugins/sp/scripts/inline-run-setup.ts +198 -0
- package/plugins/sp/scripts/pr-reviewing.mjs +769 -0
- package/plugins/sp/scripts/pr-reviewing.ts +925 -0
- package/plugins/sp/scripts/quality-gate.mjs +179 -0
- package/plugins/sp/scripts/quality-gate.ts +217 -0
- package/plugins/sp/scripts/script-contract-check.ts +319 -0
- package/plugins/sp/scripts/stage-registry-adapter.ts +1533 -0
- package/plugins/sp/scripts/surface-drift-inventory.ts +929 -0
- package/plugins/sp/scripts/task-evidence-precheck.ts +181 -0
- package/plugins/sp/scripts/task-size-precheck.ts +175 -0
- package/plugins/sp/scripts/transition-shim-check.ts +238 -0
- package/plugins/sp/scripts/validate-commands.ts +689 -0
- package/plugins/sp/scripts/validate-flag-contracts.ts +878 -0
- package/plugins/sp/scripts/verify-answer-lint.ts +530 -0
- package/plugins/sp/scripts/workflow-step-profile.mjs +316 -0
- package/plugins/sp/scripts/workflow-step-profile.ts +456 -0
- package/plugins/sp/scripts/wrapup-steps.mjs +373 -0
- package/plugins/sp/scripts/wrapup-steps.ts +466 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal self-contained logger for the embedded daily-summary script.
|
|
3
|
+
*
|
|
4
|
+
* The skill script stays self-contained (no CLI extraction, no monorepo coupling), so it carries its
|
|
5
|
+
* own tiny logger rather than importing the host plugin's. API mirrors the logger subset the script
|
|
6
|
+
* and test use: `logger.{info,warn,error}` and `enableLogger(console, file)`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type Channels = { console: boolean; file: boolean };
|
|
10
|
+
|
|
11
|
+
const state: Channels = { console: true, file: false };
|
|
12
|
+
|
|
13
|
+
/** Toggle output channels. Only the console channel is honoured here (no file appender by design). */
|
|
14
|
+
export function enableLogger(consoleOn: boolean, fileOn: boolean): void {
|
|
15
|
+
state.console = consoleOn;
|
|
16
|
+
state.file = fileOn;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function emit(stream: 'log' | 'warn' | 'error', message: string): void {
|
|
20
|
+
if (!state.console) return;
|
|
21
|
+
console[stream](message);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const logger = {
|
|
25
|
+
info: (message: string): void => emit('log', message),
|
|
26
|
+
warn: (message: string): void => emit('warn', message),
|
|
27
|
+
error: (message: string): void => emit('error', message),
|
|
28
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
|
|
4
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
5
|
+
|
|
6
|
+
// plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts
|
|
7
|
+
var PIPELINE_TOKENS = [
|
|
8
|
+
'--next',
|
|
9
|
+
'dev-runall',
|
|
10
|
+
'dev-wrapall',
|
|
11
|
+
'dev-refineall',
|
|
12
|
+
'dev-verifyall',
|
|
13
|
+
'dev-run',
|
|
14
|
+
'dev-wrap',
|
|
15
|
+
'dev-idea',
|
|
16
|
+
'refineall',
|
|
17
|
+
'verifyall',
|
|
18
|
+
'runall',
|
|
19
|
+
'wrapall',
|
|
20
|
+
'run',
|
|
21
|
+
'wrap',
|
|
22
|
+
'idea',
|
|
23
|
+
];
|
|
24
|
+
var PIPELINE_DRIVING_REFUSE_MESSAGE =
|
|
25
|
+
'⚠ pipeline-driving testee detected; pass --max-retry 0 (observe-only) or --max-retry N (fix mode, tree mutation acknowledged)';
|
|
26
|
+
var MUTATING_FIX_REFUSE_MESSAGE =
|
|
27
|
+
'⚠ mutating --fix mode detected (--fix all | --fix blockers-first); pass --max-retry 0 (observe-only for the driver; the testee still mutates the tree) or --max-retry N (fix mode, driver + testee both mutate)';
|
|
28
|
+
var IMPLEMENT_HEAVY_ADVISORY_MESSAGE =
|
|
29
|
+
'⚠ implement-heavy pipeline dogfood: prefer --max-retry 0 (observe-only) or step-split; operator --max-retry N overrides';
|
|
30
|
+
var IMPLEMENT_HEAVY_TOKENS = [
|
|
31
|
+
'dev-runall',
|
|
32
|
+
'dev-wrapall',
|
|
33
|
+
'dev-run',
|
|
34
|
+
'dev-wrap',
|
|
35
|
+
'dev-idea',
|
|
36
|
+
'runall',
|
|
37
|
+
'wrapall',
|
|
38
|
+
'run',
|
|
39
|
+
'wrap',
|
|
40
|
+
'idea',
|
|
41
|
+
'implement',
|
|
42
|
+
];
|
|
43
|
+
function hasMutatingFixMode(step) {
|
|
44
|
+
return /(?<![\w-])--fix[=\s]+(all|blockers-first)(?![\w-])/i.test(step);
|
|
45
|
+
}
|
|
46
|
+
function tokenMatches(testee, token) {
|
|
47
|
+
const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
48
|
+
const re = new RegExp(`(?<![\\w-])${escaped}(?![\\w-])`, 'i');
|
|
49
|
+
return re.test(testee);
|
|
50
|
+
}
|
|
51
|
+
function detectPipelineDriving(testee) {
|
|
52
|
+
if (typeof testee !== 'string' || testee.length === 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return PIPELINE_TOKENS.some((token) => tokenMatches(testee, token));
|
|
56
|
+
}
|
|
57
|
+
function isImplementHeavyStep(step) {
|
|
58
|
+
if (typeof step !== 'string' || step.length === 0) return false;
|
|
59
|
+
const nonMutatingOnly =
|
|
60
|
+
tokenMatches(step, 'dev-verify') || tokenMatches(step, 'dev-review') || tokenMatches(step, 'dev-unit');
|
|
61
|
+
const hasMutating = IMPLEMENT_HEAVY_TOKENS.some((token) => tokenMatches(step, token)) || hasMutatingFixMode(step);
|
|
62
|
+
if (nonMutatingOnly && !hasMutating) return false;
|
|
63
|
+
if (tokenMatches(step, 'dev-refine') && !hasMutating && !tokenMatches(step, '--next')) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (tokenMatches(step, 'dev-refine') && tokenMatches(step, '--next')) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return hasMutating;
|
|
70
|
+
}
|
|
71
|
+
function detectImplementHeavy(testee, derivedSteps = []) {
|
|
72
|
+
if (isImplementHeavyStep(testee)) return true;
|
|
73
|
+
if (!detectPipelineDriving(testee)) return false;
|
|
74
|
+
return derivedSteps.some((step) => isImplementHeavyStep(step));
|
|
75
|
+
}
|
|
76
|
+
function evaluateDogfoodGate(testee, options = {}) {
|
|
77
|
+
const maxRetryPresent = options.maxRetryPresent === true;
|
|
78
|
+
const steps = options.steps ?? [];
|
|
79
|
+
const pipelineDriving = detectPipelineDriving(testee);
|
|
80
|
+
const mutatingFix = hasMutatingFixMode(testee);
|
|
81
|
+
const implementHeavy = detectImplementHeavy(testee, steps);
|
|
82
|
+
if (pipelineDriving && !maxRetryPresent) {
|
|
83
|
+
return {
|
|
84
|
+
pipelineDriving,
|
|
85
|
+
mutatingFix,
|
|
86
|
+
maxRetryPresent,
|
|
87
|
+
implementHeavy,
|
|
88
|
+
refuse: true,
|
|
89
|
+
advisory: false,
|
|
90
|
+
message: PIPELINE_DRIVING_REFUSE_MESSAGE,
|
|
91
|
+
exitCode: 2,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (mutatingFix && !maxRetryPresent) {
|
|
95
|
+
return {
|
|
96
|
+
pipelineDriving,
|
|
97
|
+
mutatingFix,
|
|
98
|
+
maxRetryPresent,
|
|
99
|
+
implementHeavy,
|
|
100
|
+
refuse: true,
|
|
101
|
+
advisory: false,
|
|
102
|
+
message: MUTATING_FIX_REFUSE_MESSAGE,
|
|
103
|
+
exitCode: 2,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (implementHeavy) {
|
|
107
|
+
return {
|
|
108
|
+
pipelineDriving,
|
|
109
|
+
mutatingFix,
|
|
110
|
+
maxRetryPresent,
|
|
111
|
+
implementHeavy,
|
|
112
|
+
refuse: false,
|
|
113
|
+
advisory: true,
|
|
114
|
+
message: IMPLEMENT_HEAVY_ADVISORY_MESSAGE,
|
|
115
|
+
exitCode: 0,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
pipelineDriving,
|
|
120
|
+
mutatingFix,
|
|
121
|
+
maxRetryPresent,
|
|
122
|
+
implementHeavy,
|
|
123
|
+
refuse: false,
|
|
124
|
+
advisory: false,
|
|
125
|
+
message: null,
|
|
126
|
+
exitCode: 0,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function parseCliArgs(argv) {
|
|
130
|
+
let testee = null;
|
|
131
|
+
let maxRetryPresent = false;
|
|
132
|
+
let steps = [];
|
|
133
|
+
let json = false;
|
|
134
|
+
let help = false;
|
|
135
|
+
for (let i = 0; i < argv.length; i++) {
|
|
136
|
+
const a = argv[i];
|
|
137
|
+
if (a === '--help' || a === '-h') {
|
|
138
|
+
help = true;
|
|
139
|
+
} else if (a === '--json') {
|
|
140
|
+
json = true;
|
|
141
|
+
} else if (a === '--max-retry-present') {
|
|
142
|
+
maxRetryPresent = true;
|
|
143
|
+
} else if (a === '--testee') {
|
|
144
|
+
testee = argv[++i] ?? null;
|
|
145
|
+
} else if (a === '--steps') {
|
|
146
|
+
const raw = argv[++i] ?? '';
|
|
147
|
+
steps =
|
|
148
|
+
raw.length === 0
|
|
149
|
+
? []
|
|
150
|
+
: raw
|
|
151
|
+
.split('||')
|
|
152
|
+
.map((s) => s.trim())
|
|
153
|
+
.filter(Boolean);
|
|
154
|
+
} else if (a === '--') {
|
|
155
|
+
testee = argv.slice(i + 1).join(' ');
|
|
156
|
+
break;
|
|
157
|
+
} else if (!a.startsWith('-') && testee === null) {
|
|
158
|
+
testee = a;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { testee, maxRetryPresent, steps, json, help };
|
|
162
|
+
}
|
|
163
|
+
var CLI_USAGE = `Usage:
|
|
164
|
+
bun plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts \\
|
|
165
|
+
--testee "<testee string>" [--max-retry-present] [--steps "s1||s2"] [--json]
|
|
166
|
+
|
|
167
|
+
Exit codes:
|
|
168
|
+
0 proceed (stdout may carry implement-heavy advisory)
|
|
169
|
+
2 refuse — pipeline-driving OR mutating --fix mode without --max-retry
|
|
170
|
+
1 usage error
|
|
171
|
+
|
|
172
|
+
Phase 1.0: run BEFORE deriving steps (omit --steps).
|
|
173
|
+
Phase 1 W8: re-run AFTER step derivation with --steps "label1||label2".`;
|
|
174
|
+
function runCli(argv) {
|
|
175
|
+
const { testee, maxRetryPresent, steps, json, help } = parseCliArgs(argv);
|
|
176
|
+
if (help) {
|
|
177
|
+
return { exitCode: 0, stdout: '', stderr: CLI_USAGE };
|
|
178
|
+
}
|
|
179
|
+
if (testee === null || testee.length === 0) {
|
|
180
|
+
return { exitCode: 1, stdout: '', stderr: CLI_USAGE };
|
|
181
|
+
}
|
|
182
|
+
const result = evaluateDogfoodGate(testee, { maxRetryPresent, steps });
|
|
183
|
+
if (json) {
|
|
184
|
+
return {
|
|
185
|
+
exitCode: result.exitCode,
|
|
186
|
+
stdout: `${JSON.stringify(result, null, 2)}
|
|
187
|
+
`,
|
|
188
|
+
stderr: '',
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (result.message) {
|
|
192
|
+
return {
|
|
193
|
+
exitCode: result.exitCode,
|
|
194
|
+
stdout: `${result.message}
|
|
195
|
+
`,
|
|
196
|
+
stderr: '',
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return { exitCode: result.exitCode, stdout: '', stderr: '' };
|
|
200
|
+
}
|
|
201
|
+
{
|
|
202
|
+
const { exitCode, stdout, stderr } = runCli(process.argv.slice(2));
|
|
203
|
+
if (stdout) process.stdout.write(stdout);
|
|
204
|
+
if (stderr)
|
|
205
|
+
process.stderr.write(`${stderr}
|
|
206
|
+
`);
|
|
207
|
+
process.exit(exitCode);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
CLI_USAGE,
|
|
212
|
+
detectImplementHeavy,
|
|
213
|
+
detectPipelineDriving,
|
|
214
|
+
evaluateDogfoodGate,
|
|
215
|
+
hasMutatingFixMode,
|
|
216
|
+
IMPLEMENT_HEAVY_ADVISORY_MESSAGE,
|
|
217
|
+
isImplementHeavyStep,
|
|
218
|
+
MUTATING_FIX_REFUSE_MESSAGE,
|
|
219
|
+
PIPELINE_DRIVING_REFUSE_MESSAGE,
|
|
220
|
+
PIPELINE_TOKENS,
|
|
221
|
+
parseCliArgs,
|
|
222
|
+
runCli,
|
|
223
|
+
};
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* detect-pipeline-driving — @1.2 pipeline-driving testee detector (task 0277, W7).
|
|
3
|
+
*
|
|
4
|
+
* Pure function over the raw testee string → boolean. Used by the dogfood driver
|
|
5
|
+
* (Phase 1.0 refuse-ambiguous gate) and by unit tests so the matcher contract is
|
|
6
|
+
* machine-checked rather than agent-interpreted.
|
|
7
|
+
*
|
|
8
|
+
* Also ships a **CLI gate** (import.meta.main) so Phase 1.0 is a live shell call,
|
|
9
|
+
* not agent-only prose interpretation:
|
|
10
|
+
*
|
|
11
|
+
* bun plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts \
|
|
12
|
+
* --testee "/sp:dev-run 0125 --auto --next" [--max-retry-present] \
|
|
13
|
+
* [--steps "step1||step2"] [--json]
|
|
14
|
+
*
|
|
15
|
+
* Exit codes:
|
|
16
|
+
* 0 — proceed (may print implement-heavy advisory on stderr)
|
|
17
|
+
* 2 — refuse: pipeline-driving without explicit --max-retry
|
|
18
|
+
* 1 — usage / argument error
|
|
19
|
+
*
|
|
20
|
+
* Contract (0274 §3 dogfood-pipeline-detect, 0277 R1):
|
|
21
|
+
* - Word-boundary matchers with `-` treated as a word char (NOT a boundary).
|
|
22
|
+
* A token counts only when it is a distinct hyphen-word, not when it is a
|
|
23
|
+
* substring of a longer alphanumeric or hyphen run. This removes the
|
|
24
|
+
* leading-space dependency of the @1.1 prose detector.
|
|
25
|
+
* - Two token shapes, both with strict `[^\w-]` boundaries:
|
|
26
|
+
* (a) complete tokens — `--next`, `dev-run`, `dev-runall`, `dev-wrap`,
|
|
27
|
+
* `dev-wrapall`, `dev-idea` — matched as whole hyphen-words so the
|
|
28
|
+
* slash form `/sp:dev-run` matches on its `dev-run` tail whether or
|
|
29
|
+
* not it is preceded by a space, but `--next` does NOT match inside
|
|
30
|
+
* `--next-gen` (the trailing `-gen` breaks the boundary).
|
|
31
|
+
* (b) bare nouns — `run`, `runall`, `wrap`, `wrapall`, `idea` — matched
|
|
32
|
+
* only as standalone words, so `run` matches in
|
|
33
|
+
* `bun ... task run 0042` but NOT inside `runaway`/`prerun`, and
|
|
34
|
+
* `idea` does NOT match inside `idealist`/`ideal`.
|
|
35
|
+
* - Listing both shapes is what makes the detector leading-space invariant
|
|
36
|
+
* (the slash form is caught by its `dev-*` tail; the bare noun is caught
|
|
37
|
+
* when it appears as its own word) without letting `run` leak into every
|
|
38
|
+
* `-run-` identifier.
|
|
39
|
+
*
|
|
40
|
+
* Non-goals of detectPipelineDriving: decides ambiguity only. It does NOT decide
|
|
41
|
+
* observe vs fix — any explicit `--max-retry` value proceeds regardless.
|
|
42
|
+
* Implement-heavy advisory is a separate helper (detectImplementHeavy).
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Tokens whose presence makes a testee pipeline-driving. Ordered for stable
|
|
47
|
+
* diagnostics. Two shapes per the contract above: complete `dev-*` / `--next`
|
|
48
|
+
* tokens first, then bare nouns.
|
|
49
|
+
*/
|
|
50
|
+
const PIPELINE_TOKENS = [
|
|
51
|
+
'--next',
|
|
52
|
+
'dev-runall',
|
|
53
|
+
'dev-wrapall',
|
|
54
|
+
'dev-refineall',
|
|
55
|
+
'dev-verifyall',
|
|
56
|
+
'dev-run',
|
|
57
|
+
'dev-wrap',
|
|
58
|
+
'dev-idea',
|
|
59
|
+
'refineall',
|
|
60
|
+
'verifyall',
|
|
61
|
+
'runall',
|
|
62
|
+
'wrapall',
|
|
63
|
+
'run',
|
|
64
|
+
'wrap',
|
|
65
|
+
'idea',
|
|
66
|
+
] as const;
|
|
67
|
+
|
|
68
|
+
/** Refuse message when pipeline-driving and `--max-retry` was not passed (exact string). */
|
|
69
|
+
export const PIPELINE_DRIVING_REFUSE_MESSAGE =
|
|
70
|
+
'⚠ pipeline-driving testee detected; pass --max-retry 0 (observe-only) or --max-retry N (fix mode, tree mutation acknowledged)';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Refuse message when the testee carries a mutating `--fix` mode (`--fix all` /
|
|
74
|
+
* `--fix blockers-first`) and `--max-retry` was not passed. A mutating fix mode
|
|
75
|
+
* mutates the working tree independent of pipeline-driving (task 0293 R1/R2):
|
|
76
|
+
* `--max-retry 0` bounds the **driver** only — the testee's own `--fix` pass
|
|
77
|
+
* still mutates the tree — so the message must not imply otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export const MUTATING_FIX_REFUSE_MESSAGE =
|
|
80
|
+
'⚠ mutating --fix mode detected (--fix all | --fix blockers-first); pass --max-retry 0 (observe-only for the driver; the testee still mutates the tree) or --max-retry N (fix mode, driver + testee both mutate)';
|
|
81
|
+
|
|
82
|
+
/** Advisory when pipeline-driving + implement-heavy derived steps (exact string). */
|
|
83
|
+
export const IMPLEMENT_HEAVY_ADVISORY_MESSAGE =
|
|
84
|
+
'⚠ implement-heavy pipeline dogfood: prefer --max-retry 0 (observe-only) or step-split; operator --max-retry N overrides';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Tokens that mark a derived step as implement-heavy (mutates product/code or
|
|
88
|
+
* drives a mutating pipeline leg). Deliberately excludes verify/review/unit-only
|
|
89
|
+
* surfaces even when they carry `--next`.
|
|
90
|
+
*/
|
|
91
|
+
const IMPLEMENT_HEAVY_TOKENS = [
|
|
92
|
+
'dev-runall',
|
|
93
|
+
'dev-wrapall',
|
|
94
|
+
'dev-run',
|
|
95
|
+
'dev-wrap',
|
|
96
|
+
'dev-idea',
|
|
97
|
+
'runall',
|
|
98
|
+
'wrapall',
|
|
99
|
+
// bare `run` / `wrap` / `idea` — only when not clearly a non-mutating surface
|
|
100
|
+
'run',
|
|
101
|
+
'wrap',
|
|
102
|
+
'idea',
|
|
103
|
+
'implement',
|
|
104
|
+
] as const;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A verify/review surface stops being non-mutating the moment it carries a
|
|
108
|
+
* repair mode: `--fix all` / `--fix blockers-first` applies Edit/Write repairs
|
|
109
|
+
* to the working tree (0280 dogfood, finding P2). `--fix none` stays
|
|
110
|
+
* observational. Boundary-guarded so `--prefix all` / `--focus all` never match.
|
|
111
|
+
* Exported so the Phase 1.0 gate and tests share one matcher (task 0293 R1/R4).
|
|
112
|
+
*/
|
|
113
|
+
export function hasMutatingFixMode(step: string): boolean {
|
|
114
|
+
return /(?<![\w-])--fix[=\s]+(all|blockers-first)(?![\w-])/i.test(step);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Match a token at a word boundary. A "word boundary" here is the position
|
|
119
|
+
* between a non-`[\w-]` char (or string start) and the token, and between the
|
|
120
|
+
* token and a non-`[\w-]` char (or string end). Treating `-` as a word char
|
|
121
|
+
* is what makes `--next` reject `--next-gen` and `dev-run` reject `dev-runner`.
|
|
122
|
+
*/
|
|
123
|
+
function tokenMatches(testee: string, token: string): boolean {
|
|
124
|
+
const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
// (?<![\w-]) — not preceded by a word char or hyphen.
|
|
126
|
+
// (?![\w-]) — not followed by a word char or hyphen.
|
|
127
|
+
const re = new RegExp(`(?<![\\w-])${escaped}(?![\\w-])`, 'i');
|
|
128
|
+
return re.test(testee);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Returns whether the testee string is pipeline-driving (contains any of the
|
|
133
|
+
* pipeline-driving tokens as a distinct hyphen-word). Machine-checked
|
|
134
|
+
* counterpart of the prose list in SKILL.md §Pipeline-driving detection and
|
|
135
|
+
* dev-dogfood.md.
|
|
136
|
+
*/
|
|
137
|
+
export function detectPipelineDriving(testee: string): boolean {
|
|
138
|
+
if (typeof testee !== 'string' || testee.length === 0) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return PIPELINE_TOKENS.some((token) => tokenMatches(testee, token));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* True when a single step label (or the whole testee) is implement-heavy —
|
|
146
|
+
* it chains into real implementation / wrap / idea work, not verify-only.
|
|
147
|
+
*
|
|
148
|
+
* Non-mutating surfaces (`dev-verify`, `dev-review`, `dev-unit`, plain
|
|
149
|
+
* `dev-refine` without a further run) are never implement-heavy even if
|
|
150
|
+
* pipeline-driving via `--next` — UNLESS they carry a mutating repair mode
|
|
151
|
+
* (`--fix all` / `--fix blockers-first`), which turns the verify/review leg
|
|
152
|
+
* into a tree-mutating fix pass (0280 dogfood, finding P2).
|
|
153
|
+
*/
|
|
154
|
+
export function isImplementHeavyStep(step: string): boolean {
|
|
155
|
+
if (typeof step !== 'string' || step.length === 0) return false;
|
|
156
|
+
// Explicit non-mutating surfaces win unless a mutating token co-occurs.
|
|
157
|
+
const nonMutatingOnly =
|
|
158
|
+
tokenMatches(step, 'dev-verify') || tokenMatches(step, 'dev-review') || tokenMatches(step, 'dev-unit');
|
|
159
|
+
const hasMutating = IMPLEMENT_HEAVY_TOKENS.some((token) => tokenMatches(step, token)) || hasMutatingFixMode(step);
|
|
160
|
+
if (nonMutatingOnly && !hasMutating) return false;
|
|
161
|
+
// refine alone is planning, not implement-heavy; refine+run/--next chain is.
|
|
162
|
+
if (tokenMatches(step, 'dev-refine') && !hasMutating && !tokenMatches(step, '--next')) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (tokenMatches(step, 'dev-refine') && tokenMatches(step, '--next')) {
|
|
166
|
+
// refine --next chains into run → implement-heavy
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return hasMutating;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* True when the testee is implement-heavy: it carries a pipeline-driving token,
|
|
174
|
+
* a mutating `--fix` mode, OR at least one derived step (or the testee itself
|
|
175
|
+
* when no steps given) is implement-heavy. Used for the W8 Phase 1 advisory
|
|
176
|
+
* after step derivation.
|
|
177
|
+
*
|
|
178
|
+
* Task 0293 R3: a mutating `--fix` mode alone is implement-heavy even with no
|
|
179
|
+
* pipeline token — the verify/review leg itself becomes a tree-mutating fix
|
|
180
|
+
* pass.
|
|
181
|
+
*/
|
|
182
|
+
export function detectImplementHeavy(testee: string, derivedSteps: string[] = []): boolean {
|
|
183
|
+
if (isImplementHeavyStep(testee)) return true;
|
|
184
|
+
if (!detectPipelineDriving(testee)) return false;
|
|
185
|
+
return derivedSteps.some((step) => isImplementHeavyStep(step));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface GateResult {
|
|
189
|
+
pipelineDriving: boolean;
|
|
190
|
+
mutatingFix: boolean;
|
|
191
|
+
maxRetryPresent: boolean;
|
|
192
|
+
implementHeavy: boolean;
|
|
193
|
+
refuse: boolean;
|
|
194
|
+
advisory: boolean;
|
|
195
|
+
message: string | null;
|
|
196
|
+
exitCode: 0 | 1 | 2;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Phase 1.0 + W8 gate decision. Pure — no I/O. The CLI wrapper prints and exits.
|
|
201
|
+
*
|
|
202
|
+
* Refuse condition (task 0293 R1) is the union of two **independent** mutation
|
|
203
|
+
* sources, each gated on `!maxRetryPresent`:
|
|
204
|
+
*
|
|
205
|
+
* 1. pipeline-driving testee (`--next`, `dev-run`, …) — refuses because the
|
|
206
|
+
* testee chains lifecycle legs whose cumulative blast radius the driver
|
|
207
|
+
* cannot pre-attribute.
|
|
208
|
+
* 2. mutating `--fix` mode (`--fix all` / `--fix blockers-first`) — refuses
|
|
209
|
+
* because the testee itself applies Edit/Write repairs even with no
|
|
210
|
+
* pipeline token. `--max-retry 0` bounds the **driver** only; the testee
|
|
211
|
+
* still mutates (honesty note in MUTATING_FIX_REFUSE_MESSAGE).
|
|
212
|
+
*
|
|
213
|
+
* Pipeline-driving is reported first when both co-occur (its refuse message is
|
|
214
|
+
* the superset — chain + tree mutation).
|
|
215
|
+
*/
|
|
216
|
+
export function evaluateDogfoodGate(
|
|
217
|
+
testee: string,
|
|
218
|
+
options: { maxRetryPresent?: boolean; steps?: string[] } = {},
|
|
219
|
+
): GateResult {
|
|
220
|
+
const maxRetryPresent = options.maxRetryPresent === true;
|
|
221
|
+
const steps = options.steps ?? [];
|
|
222
|
+
const pipelineDriving = detectPipelineDriving(testee);
|
|
223
|
+
const mutatingFix = hasMutatingFixMode(testee);
|
|
224
|
+
const implementHeavy = detectImplementHeavy(testee, steps);
|
|
225
|
+
|
|
226
|
+
if (pipelineDriving && !maxRetryPresent) {
|
|
227
|
+
return {
|
|
228
|
+
pipelineDriving,
|
|
229
|
+
mutatingFix,
|
|
230
|
+
maxRetryPresent,
|
|
231
|
+
implementHeavy,
|
|
232
|
+
refuse: true,
|
|
233
|
+
advisory: false,
|
|
234
|
+
message: PIPELINE_DRIVING_REFUSE_MESSAGE,
|
|
235
|
+
exitCode: 2,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (mutatingFix && !maxRetryPresent) {
|
|
240
|
+
return {
|
|
241
|
+
pipelineDriving,
|
|
242
|
+
mutatingFix,
|
|
243
|
+
maxRetryPresent,
|
|
244
|
+
implementHeavy,
|
|
245
|
+
refuse: true,
|
|
246
|
+
advisory: false,
|
|
247
|
+
message: MUTATING_FIX_REFUSE_MESSAGE,
|
|
248
|
+
exitCode: 2,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (implementHeavy) {
|
|
253
|
+
return {
|
|
254
|
+
pipelineDriving,
|
|
255
|
+
mutatingFix,
|
|
256
|
+
maxRetryPresent,
|
|
257
|
+
implementHeavy,
|
|
258
|
+
refuse: false,
|
|
259
|
+
advisory: true,
|
|
260
|
+
message: IMPLEMENT_HEAVY_ADVISORY_MESSAGE,
|
|
261
|
+
exitCode: 0,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
pipelineDriving,
|
|
267
|
+
mutatingFix,
|
|
268
|
+
maxRetryPresent,
|
|
269
|
+
implementHeavy,
|
|
270
|
+
refuse: false,
|
|
271
|
+
advisory: false,
|
|
272
|
+
message: null,
|
|
273
|
+
exitCode: 0,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export { PIPELINE_TOKENS };
|
|
278
|
+
|
|
279
|
+
// ── CLI entry (live Phase 1.0 gate) ──────────────────────────────────────────
|
|
280
|
+
|
|
281
|
+
export interface CliArgs {
|
|
282
|
+
testee: string | null;
|
|
283
|
+
maxRetryPresent: boolean;
|
|
284
|
+
steps: string[];
|
|
285
|
+
json: boolean;
|
|
286
|
+
help: boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Parse CLI argv (everything after the script name). Exported for unit tests. */
|
|
290
|
+
export function parseCliArgs(argv: string[]): CliArgs {
|
|
291
|
+
let testee: string | null = null;
|
|
292
|
+
let maxRetryPresent = false;
|
|
293
|
+
let steps: string[] = [];
|
|
294
|
+
let json = false;
|
|
295
|
+
let help = false;
|
|
296
|
+
|
|
297
|
+
for (let i = 0; i < argv.length; i++) {
|
|
298
|
+
const a = argv[i];
|
|
299
|
+
if (a === '--help' || a === '-h') {
|
|
300
|
+
help = true;
|
|
301
|
+
} else if (a === '--json') {
|
|
302
|
+
json = true;
|
|
303
|
+
} else if (a === '--max-retry-present') {
|
|
304
|
+
maxRetryPresent = true;
|
|
305
|
+
} else if (a === '--testee') {
|
|
306
|
+
testee = argv[++i] ?? null;
|
|
307
|
+
} else if (a === '--steps') {
|
|
308
|
+
const raw = argv[++i] ?? '';
|
|
309
|
+
steps =
|
|
310
|
+
raw.length === 0
|
|
311
|
+
? []
|
|
312
|
+
: raw
|
|
313
|
+
.split('||')
|
|
314
|
+
.map((s) => s.trim())
|
|
315
|
+
.filter(Boolean);
|
|
316
|
+
} else if (a === '--') {
|
|
317
|
+
testee = argv.slice(i + 1).join(' ');
|
|
318
|
+
break;
|
|
319
|
+
} else if (!a.startsWith('-') && testee === null) {
|
|
320
|
+
testee = a;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return { testee, maxRetryPresent, steps, json, help };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export const CLI_USAGE = `Usage:
|
|
328
|
+
bun plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts \\
|
|
329
|
+
--testee "<testee string>" [--max-retry-present] [--steps "s1||s2"] [--json]
|
|
330
|
+
|
|
331
|
+
Exit codes:
|
|
332
|
+
0 proceed (stdout may carry implement-heavy advisory)
|
|
333
|
+
2 refuse — pipeline-driving OR mutating --fix mode without --max-retry
|
|
334
|
+
1 usage error
|
|
335
|
+
|
|
336
|
+
Phase 1.0: run BEFORE deriving steps (omit --steps).
|
|
337
|
+
Phase 1 W8: re-run AFTER step derivation with --steps "label1||label2".`;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Pure CLI runner for tests: returns { exitCode, stdout, stderr } without
|
|
341
|
+
* process.exit / console I/O side effects.
|
|
342
|
+
*/
|
|
343
|
+
export function runCli(argv: string[]): { exitCode: number; stdout: string; stderr: string } {
|
|
344
|
+
const { testee, maxRetryPresent, steps, json, help } = parseCliArgs(argv);
|
|
345
|
+
if (help) {
|
|
346
|
+
return { exitCode: 0, stdout: '', stderr: CLI_USAGE };
|
|
347
|
+
}
|
|
348
|
+
if (testee === null || testee.length === 0) {
|
|
349
|
+
return { exitCode: 1, stdout: '', stderr: CLI_USAGE };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const result = evaluateDogfoodGate(testee, { maxRetryPresent, steps });
|
|
353
|
+
if (json) {
|
|
354
|
+
return { exitCode: result.exitCode, stdout: `${JSON.stringify(result, null, 2)}\n`, stderr: '' };
|
|
355
|
+
}
|
|
356
|
+
if (result.message) {
|
|
357
|
+
return { exitCode: result.exitCode, stdout: `${result.message}\n`, stderr: '' };
|
|
358
|
+
}
|
|
359
|
+
return { exitCode: result.exitCode, stdout: '', stderr: '' };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (import.meta.main) {
|
|
363
|
+
const { exitCode, stdout, stderr } = runCli(process.argv.slice(2));
|
|
364
|
+
if (stdout) process.stdout.write(stdout);
|
|
365
|
+
if (stderr) process.stderr.write(`${stderr}\n`);
|
|
366
|
+
process.exit(exitCode);
|
|
367
|
+
}
|