@wooojin/forgen 0.6.8 → 0.6.9
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/plugin.json +1 -1
- package/CHANGELOG.md +17 -0
- package/README.ja.md +15 -10
- package/README.ko.md +15 -10
- package/README.md +19 -14
- package/README.zh.md +13 -8
- package/dist/checks/dangerous-response-pattern.d.ts +2 -1
- package/dist/checks/dangerous-response-pattern.js +27 -3
- package/dist/cli.js +133 -17
- package/dist/core/auto-compound-runner.js +502 -397
- package/dist/core/block-cli.js +7 -3
- package/dist/core/compound-consent.d.ts +18 -0
- package/dist/core/compound-consent.js +101 -6
- package/dist/core/compound-sweep-cli.d.ts +16 -0
- package/dist/core/compound-sweep-cli.js +67 -5
- package/dist/core/config-hooks.js +28 -10
- package/dist/core/correction-signals.d.ts +9 -0
- package/dist/core/correction-signals.js +37 -0
- package/dist/core/dev-cli.d.ts +1 -2
- package/dist/core/dev-cli.js +9 -28
- package/dist/core/doctor-verify.d.ts +35 -0
- package/dist/core/doctor-verify.js +502 -0
- package/dist/core/doctor.d.ts +4 -6
- package/dist/core/doctor.js +103 -184
- package/dist/core/explain-cli.js +8 -0
- package/dist/core/extraction-haiku.d.ts +64 -0
- package/dist/core/extraction-haiku.js +208 -0
- package/dist/core/extraction-queue.d.ts +68 -0
- package/dist/core/extraction-queue.js +300 -0
- package/dist/core/flow-status.d.ts +93 -0
- package/dist/core/flow-status.js +368 -0
- package/dist/core/harness.js +14 -42
- package/dist/core/inspect-cli.js +37 -13
- package/dist/core/lifecycle-classifier.d.ts +5 -1
- package/dist/core/lifecycle-classifier.js +13 -2
- package/dist/core/migrate-cli.d.ts +1 -1
- package/dist/core/migrate-cli.js +11 -11
- package/dist/core/migrate-tenetx.d.ts +1 -1
- package/dist/core/migrate-tenetx.js +2 -2
- package/dist/core/node-engine.d.ts +3 -0
- package/dist/core/node-engine.js +8 -0
- package/dist/core/observability-store.d.ts +15 -0
- package/dist/core/observability-store.js +73 -0
- package/dist/core/paths.d.ts +2 -0
- package/dist/core/paths.js +2 -0
- package/dist/core/rendered-rules-manifest.d.ts +7 -1
- package/dist/core/rendered-rules-manifest.js +45 -1
- package/dist/core/session-store.d.ts +13 -11
- package/dist/core/session-store.js +103 -119
- package/dist/core/settings-injector.d.ts +5 -2
- package/dist/core/settings-injector.js +21 -88
- package/dist/core/spawn.d.ts +9 -1
- package/dist/core/spawn.js +33 -33
- package/dist/core/stats-cli.d.ts +7 -0
- package/dist/core/stats-cli.js +66 -93
- package/dist/core/status-cli.d.ts +1 -1
- package/dist/core/status-cli.js +23 -4
- package/dist/core/statusline-cli.js +5 -0
- package/dist/core/statusline-install.d.ts +10 -2
- package/dist/core/statusline-install.js +27 -4
- package/dist/core/transcript-summary.d.ts +84 -9
- package/dist/core/transcript-summary.js +283 -49
- package/dist/core/uninstall.d.ts +4 -0
- package/dist/core/uninstall.js +68 -36
- package/dist/core/v1-bootstrap.d.ts +1 -1
- package/dist/core/v1-bootstrap.js +38 -9
- package/dist/engine/acted-on-evidence.d.ts +8 -0
- package/dist/engine/acted-on-evidence.js +38 -0
- package/dist/engine/block-judge.d.ts +3 -1
- package/dist/engine/block-judge.js +4 -3
- package/dist/engine/compound-cli.d.ts +26 -2
- package/dist/engine/compound-cli.js +143 -19
- package/dist/engine/compound-lifecycle.d.ts +36 -2
- package/dist/engine/compound-lifecycle.js +131 -11
- package/dist/engine/compound-loop.d.ts +4 -0
- package/dist/engine/compound-loop.js +93 -18
- package/dist/engine/correction-cluster-runner.d.ts +11 -1
- package/dist/engine/correction-cluster-runner.js +39 -15
- package/dist/engine/correction-clustering.d.ts +11 -0
- package/dist/engine/correction-clustering.js +20 -3
- package/dist/engine/lifecycle/lifecycle-cli.js +10 -3
- package/dist/engine/lifecycle/meta-reclassifier.d.ts +9 -0
- package/dist/engine/lifecycle/meta-reclassifier.js +15 -3
- package/dist/engine/lifecycle/orchestrator.js +3 -2
- package/dist/engine/lifecycle/signals.d.ts +19 -1
- package/dist/engine/lifecycle/signals.js +61 -2
- package/dist/engine/lifecycle/trigger-t1-correction.d.ts +1 -1
- package/dist/engine/lifecycle/trigger-t1-correction.js +9 -28
- package/dist/engine/lifecycle/trigger-t5-conflict.d.ts +8 -0
- package/dist/engine/lifecycle/trigger-t5-conflict.js +60 -2
- package/dist/engine/roi-demotion.d.ts +11 -0
- package/dist/engine/roi-demotion.js +50 -8
- package/dist/engine/rule-detectability.d.ts +39 -0
- package/dist/engine/rule-detectability.js +66 -0
- package/dist/engine/rule-project-cli.d.ts +25 -0
- package/dist/engine/rule-project-cli.js +148 -0
- package/dist/engine/rule-recovery-cli.d.ts +21 -0
- package/dist/engine/rule-recovery-cli.js +265 -0
- package/dist/engine/rule-toggle-cli.d.ts +14 -2
- package/dist/engine/rule-toggle-cli.js +94 -6
- package/dist/engine/skill-promoter.d.ts +14 -8
- package/dist/engine/skill-promoter.js +57 -85
- package/dist/engine/solution-format.d.ts +26 -1
- package/dist/engine/solution-format.js +65 -3
- package/dist/engine/solution-habit.d.ts +1 -0
- package/dist/engine/solution-habit.js +22 -0
- package/dist/engine/solution-index.d.ts +5 -0
- package/dist/engine/solution-index.js +32 -0
- package/dist/engine/solution-matcher-eval.js +4 -4
- package/dist/engine/solution-matcher.js +15 -13
- package/dist/engine/solution-scope.d.ts +11 -0
- package/dist/engine/solution-scope.js +19 -0
- package/dist/engine/solution-writer.d.ts +3 -1
- package/dist/engine/solution-writer.js +3 -2
- package/dist/engine/term-normalizer.js +49 -0
- package/dist/fgx.js +1 -1
- package/dist/forge/cli.js +51 -8
- package/dist/forge/evidence-processor.js +6 -0
- package/dist/hooks/context-guard.d.ts +0 -22
- package/dist/hooks/context-guard.js +22 -55
- package/dist/hooks/context-usage.d.ts +21 -0
- package/dist/hooks/context-usage.js +103 -0
- package/dist/hooks/dangerous-patterns.json +1 -16
- package/dist/hooks/db-guard.d.ts +1 -1
- package/dist/hooks/db-guard.js +21 -30
- package/dist/hooks/hook-config.d.ts +2 -0
- package/dist/hooks/hook-config.js +5 -1
- package/dist/hooks/hooks-generator.d.ts +4 -0
- package/dist/hooks/hooks-generator.js +10 -4
- package/dist/hooks/permission-handler.js +23 -3
- package/dist/hooks/post-tool-use.js +14 -10
- package/dist/hooks/pre-tool-use.d.ts +17 -3
- package/dist/hooks/pre-tool-use.js +143 -30
- package/dist/hooks/rate-limiter.js +12 -7
- package/dist/hooks/secret-filter.js +15 -4
- package/dist/hooks/session-end.d.ts +2 -2
- package/dist/hooks/session-end.js +13 -7
- package/dist/hooks/session-recovery.js +79 -50
- package/dist/hooks/shared/command-analyzer.d.ts +45 -0
- package/dist/hooks/shared/command-analyzer.js +972 -0
- package/dist/hooks/shared/command-parser.d.ts +5 -29
- package/dist/hooks/shared/command-parser.js +65 -35
- package/dist/hooks/shared/commit-guard.d.ts +15 -0
- package/dist/hooks/shared/commit-guard.js +176 -0
- package/dist/hooks/shared/hook-response.d.ts +6 -0
- package/dist/hooks/shared/hook-response.js +12 -0
- package/dist/hooks/shared/hook-timing.js +9 -3
- package/dist/hooks/shared/injection-caps.d.ts +32 -2
- package/dist/hooks/shared/injection-caps.js +73 -2
- package/dist/hooks/shared/is-main.d.ts +8 -0
- package/dist/hooks/shared/is-main.js +20 -0
- package/dist/hooks/shared/tool-response.d.ts +6 -0
- package/dist/hooks/shared/tool-response.js +30 -0
- package/dist/hooks/slop-detector.js +6 -3
- package/dist/hooks/solution-injector.d.ts +23 -0
- package/dist/hooks/solution-injector.js +102 -101
- package/dist/hooks/stop-guard.d.ts +11 -1
- package/dist/hooks/stop-guard.js +28 -11
- package/dist/hooks/subagent-stop-guard.js +2 -1
- package/dist/hooks/subagent-tracker.js +2 -1
- package/dist/host/capabilities-codex.js +1 -0
- package/dist/host/claude-shim.d.ts +24 -0
- package/dist/host/claude-shim.js +68 -0
- package/dist/host/codex-hook-shim.d.ts +3 -1
- package/dist/host/codex-hook-shim.js +7 -5
- package/dist/host/codex-notify.js +1 -1
- package/dist/host/codex-rules-context.d.ts +6 -4
- package/dist/host/codex-rules-context.js +11 -24
- package/dist/host/exec-host.d.ts +5 -1
- package/dist/host/exec-host.js +15 -4
- package/dist/host/install-claude.d.ts +47 -14
- package/dist/host/install-claude.js +302 -155
- package/dist/host/install-codex.d.ts +20 -0
- package/dist/host/install-codex.js +32 -1
- package/dist/host/install-opencode.d.ts +3 -1
- package/dist/host/install-opencode.js +6 -3
- package/dist/host/install-orchestrator.js +14 -1
- package/dist/host/opencode/translate.d.ts +1 -1
- package/dist/host/opencode/translate.js +5 -3
- package/dist/host/projection.d.ts +9 -1
- package/dist/host/projection.js +19 -2
- package/dist/mcp/server.js +5 -0
- package/dist/mcp/solution-reader.d.ts +5 -5
- package/dist/mcp/solution-reader.js +13 -35
- package/dist/mcp/tools.js +18 -1
- package/dist/renderer/inspect-renderer.js +4 -2
- package/dist/renderer/render-report.d.ts +22 -0
- package/dist/renderer/render-report.js +29 -0
- package/dist/renderer/rule-renderer.d.ts +28 -2
- package/dist/renderer/rule-renderer.js +91 -76
- package/dist/store/evidence-store.js +34 -6
- package/dist/store/rule-lifecycle.d.ts +3 -1
- package/dist/store/rule-lifecycle.js +10 -0
- package/dist/store/rule-scope.d.ts +7 -0
- package/dist/store/rule-scope.js +54 -0
- package/dist/store/rule-store.d.ts +29 -3
- package/dist/store/rule-store.js +110 -26
- package/dist/store/types.d.ts +22 -2
- package/dist/way/cli.d.ts +1 -0
- package/dist/way/cli.js +313 -0
- package/dist/way/compile.d.ts +22 -0
- package/dist/way/compile.js +408 -0
- package/dist/way/conflict.d.ts +2 -0
- package/dist/way/conflict.js +18 -0
- package/dist/way/draft.d.ts +43 -0
- package/dist/way/draft.js +335 -0
- package/dist/way/extract.d.ts +17 -0
- package/dist/way/extract.js +172 -0
- package/dist/way/io.d.ts +79 -0
- package/dist/way/io.js +425 -0
- package/dist/way/similar.d.ts +2 -0
- package/dist/way/similar.js +30 -0
- package/dist/way/types.d.ts +98 -0
- package/dist/way/types.js +2 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/postinstall.js +76 -899
- package/dist/core/health-cli.d.ts +0 -25
- package/dist/core/health-cli.js +0 -90
- package/dist/host/parity-harness.d.ts +0 -70
- package/dist/host/parity-harness.js +0 -287
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Way 컴파일러 — 순수 함수. 파일을 쓰지 않는다.
|
|
3
|
+
* compile(way, target, { project, budget }) → { files, omitted, degraded }
|
|
4
|
+
* 예산을 넘으면 자르지 않고 우선순위로 항목을 고르며, 빠진 항목은 omitted 로 보고한다.
|
|
5
|
+
* 어떤 대상도 룰을 강제하지 못하므로, 강제 가능한 룰은 degraded 에 "자문으로 전환" 으로 적는다.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { NEGATION_RE } from '../engine/lifecycle/trigger-t5-conflict.js';
|
|
9
|
+
import { compareRank, STRENGTH_RANK } from '../renderer/rule-renderer.js';
|
|
10
|
+
const MARK = '<!-- forgen-way: generated by `forgen way export`. Edits are overwritten; change the source rules instead. -->';
|
|
11
|
+
const SKILL_MARK = '<!-- forgen-way -->';
|
|
12
|
+
/** forgen way 가 쓴 파일인가. 이 표식이 없는 파일은 덮어쓰지 않는다. */
|
|
13
|
+
export function isWayManaged(content) {
|
|
14
|
+
const head = content.split('\n', 16);
|
|
15
|
+
if (head.some((l) => /^<!-- forgen-way(: [^<>]*)? -->$/.test(l.trim())))
|
|
16
|
+
return true;
|
|
17
|
+
// json 산출물은 주석을 쓸 수 없으니 최상위 필드로 본다.
|
|
18
|
+
if (head[0]?.trim() === '{') {
|
|
19
|
+
try {
|
|
20
|
+
const j = JSON.parse(content);
|
|
21
|
+
return j.schema === 'forgen-way/1' && j.generator === 'forgen-way';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
export const DEFAULT_BUDGET = {
|
|
30
|
+
'agents-md': 8000, 'claude-rules': 8000, gemini: 8000, cursor: 8000, 'system-prompt': 8000, workflow: 8000,
|
|
31
|
+
};
|
|
32
|
+
const KIND_ORDER = { rule: 0, solution: 1, habit: 2 };
|
|
33
|
+
const rankOf = (i) => ({ strength: i.strength, source: i.source ?? 'behavior_inference', updated_at: i.updated_at ?? '', id: i.id });
|
|
34
|
+
/** 예산이 모자랄 때 먼저 지키는 순서. 룰끼리는 렌더러(byPriority)와 같은 비교를 쓴다: 강도 → 출처 → 최신. 다른 종류는 강도 다음에 룰 > 솔루션 > 습관. */
|
|
35
|
+
export function comparePriority(a, b) {
|
|
36
|
+
return (STRENGTH_RANK[a.strength] - STRENGTH_RANK[b.strength]) || (KIND_ORDER[a.kind] - KIND_ORDER[b.kind]) || compareRank(rankOf(a), rankOf(b));
|
|
37
|
+
}
|
|
38
|
+
const KO = {
|
|
39
|
+
must: '반드시', general: '일반', procedures: '검증된 절차', habits: '습관 (참고)', when: '적용', trig: '계기', said: '사용자 발언', mined: '추론', imported: '가져옴',
|
|
40
|
+
intro: '사용자의 작업 방식이다. 지금 작업 범위와 무관한 항목은 무시한다. 사용자의 직접 지시가 충돌하면 그 지시가 우선한다.',
|
|
41
|
+
inferredNote: '[추론] 표시는 사용자가 직접 말한 것이 아니라 행동에서 추론한 항목이다. 참고로만 따른다.',
|
|
42
|
+
project: '프로젝트', title: '작업 방식', skillUse: '다음 상황에서 사용', skillWhen: '적용 조건', skillDo: '절차', skillWhy: '근거', skillCare: '주의',
|
|
43
|
+
skillRule: '지침', skillBan: '금지', skillSituation: '계기', strength: '강도', advisory: '자문이다. 이 파일은 강제 수단이 없다.', enforcedNote: 'forgen 훅이 설치된 환경에서는 차단되지만, 이 파일만으로는 자문이다.',
|
|
44
|
+
scope: '범위', global: '전역', unknownWhy: '근거 원문 없음', check: '점검 목록',
|
|
45
|
+
};
|
|
46
|
+
const EN = {
|
|
47
|
+
must: 'Always', general: 'General', procedures: 'Verified procedures', habits: 'Habits (reference)', when: 'applies', trig: 'prompted by', said: 'user said', mined: 'inferred', imported: 'imported',
|
|
48
|
+
intro: "These are the user's working preferences. Ignore any item unrelated to the current task. A direct instruction from the user wins over any rule here.",
|
|
49
|
+
inferredNote: 'Items tagged [inferred] were not stated by the user; they were inferred from behavior. Treat them as hints.',
|
|
50
|
+
project: 'Project', title: 'Working rules', skillUse: 'Use when', skillWhen: 'When it applies', skillDo: 'Procedure', skillWhy: 'Why', skillCare: 'Cautions',
|
|
51
|
+
skillRule: 'Guideline', skillBan: 'Prohibited', skillSituation: 'Prompted by', strength: 'Strength', advisory: 'Advisory. This file cannot enforce anything.', enforcedNote: 'Blocked where forgen hooks are installed; advisory from this file alone.',
|
|
52
|
+
scope: 'Scope', global: 'global', unknownWhy: 'no original quote', check: 'Checklist',
|
|
53
|
+
};
|
|
54
|
+
function pickLang(items) {
|
|
55
|
+
const text = items.map((i) => i.statement).join('');
|
|
56
|
+
const han = (text.match(/[ㄱ-힝]/g) ?? []).length;
|
|
57
|
+
return han > text.length * 0.1 ? KO : EN;
|
|
58
|
+
}
|
|
59
|
+
const oneLine = (s) => s.replace(/\s+/g, ' ').trim();
|
|
60
|
+
function firstSentence(s, max = 200) {
|
|
61
|
+
const t = oneLine(s);
|
|
62
|
+
const m = /^.{12,}?[.!?。](?=\s|$)/.exec(t);
|
|
63
|
+
const cand = m ? m[0] : t;
|
|
64
|
+
if (cand.length <= max)
|
|
65
|
+
return cand;
|
|
66
|
+
const cut = cand.slice(0, max);
|
|
67
|
+
return `${cut.slice(0, Math.max(cut.lastIndexOf(' '), max - 40))}…`;
|
|
68
|
+
}
|
|
69
|
+
function tag(i, L) {
|
|
70
|
+
const p = i.provenance;
|
|
71
|
+
if (p.kind === 'you-said' && p.quote)
|
|
72
|
+
return ` — ${L.said}${p.date ? ` ${p.date}` : ''}: "${p.quote}"`;
|
|
73
|
+
if (p.kind === 'mined')
|
|
74
|
+
return ` [${L.mined}]`;
|
|
75
|
+
if (p.kind === 'imported')
|
|
76
|
+
return ` [${L.imported}]`;
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
// ── 대상별 취급 ──
|
|
80
|
+
/** Claude 쪽 산출물(호스트 용어가 그대로 통한다). 나머지는 다른 모델이 읽는다. */
|
|
81
|
+
const CLAUDE_TARGETS = new Set(['claude-rules', 'skill', 'json']);
|
|
82
|
+
/** 룰의 `trigger`(교정이 필요했던 계기)를 싣는 대상: 교정 맥락을 같이 보여 주는 쪽만. 그 밖에서는 잡음이다. */
|
|
83
|
+
const TRIGGER_TARGETS = new Set(['claude-rules', 'skill', 'json']);
|
|
84
|
+
const HOST_TERM = /secret-filter|db-guard|slop-detector|\bhooks?\b|훅|\bmcp\b|claude\s*code|claude\s*(?:가|는|를|의|도|에게|한테)?(?![a-z])|클로드|\bforgen\b|\.claude\b/i;
|
|
85
|
+
const CLAUSE_SEP = /(?<=[.!?。])\s+|\s+[—–]\s+|;\s+|\s+\/\/\s+/;
|
|
86
|
+
/** 문장 끝에 붙은 호스트 전용 절(문장·대시·세미콜론·괄호 단위)만 떼어 낸다. 앞부분은 한 글자도 바꾸지 않는다. 남는 호스트 용어는 residual. */
|
|
87
|
+
export function scrubHostTail(statement) {
|
|
88
|
+
let text = statement.trimEnd();
|
|
89
|
+
let removed = false;
|
|
90
|
+
for (let guard = 0; guard < 4; guard++) {
|
|
91
|
+
// 끝 괄호절
|
|
92
|
+
const paren = /\s*[((][^()()]*[))]\s*[.。]?$/.exec(text);
|
|
93
|
+
if (paren && HOST_TERM.test(paren[0]) && text.slice(0, paren.index).trim().length >= 12) {
|
|
94
|
+
text = text.slice(0, paren.index).trimEnd();
|
|
95
|
+
removed = true;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// 끝 절
|
|
99
|
+
const seps = [...text.matchAll(new RegExp(CLAUSE_SEP.source, 'g'))];
|
|
100
|
+
const last = seps.at(-1);
|
|
101
|
+
if (!last || last.index === undefined)
|
|
102
|
+
break;
|
|
103
|
+
const tail = text.slice(last.index + last[0].length);
|
|
104
|
+
const head = text.slice(0, last.index).replace(/[\s;—–]+$/, '');
|
|
105
|
+
if (HOST_TERM.test(tail) && head.length >= 12) {
|
|
106
|
+
text = head;
|
|
107
|
+
removed = true;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return { text, removed, residual: HOST_TERM.test(text) };
|
|
113
|
+
}
|
|
114
|
+
const PRODUCT_NOT = new Set(['Always', 'Never', 'Prefer', 'Avoid', 'Keep', 'Before', 'After', 'When', 'Make', 'Write', 'Check', 'Ensure', 'Only', 'Every', 'Each', 'Please', 'Don', 'Run', 'Read', 'Test', 'Tests', 'Commit', 'Ask']);
|
|
115
|
+
const PRODUCT_RE = /^(?:\[[^\]]*\]\s*)?([A-Z][A-Za-z0-9_]{3,})(?=[\s(,:은는이가의]|$)/;
|
|
116
|
+
function projectKeysIn(text, keys) {
|
|
117
|
+
const lower = text.toLowerCase();
|
|
118
|
+
return [...keys].filter((k) => k.length >= 3 && lower.includes(k));
|
|
119
|
+
}
|
|
120
|
+
/** 프로젝트가 지정되지 않은 전역 항목 중 프로젝트 전용일 수 있는 것: 알려진 프로젝트 키가 문장에 나오거나, 문장이 제품 이름으로 시작한다. */
|
|
121
|
+
export function projectSpecificSuspects(items) {
|
|
122
|
+
const keys = new Set(items.flatMap((i) => i.projects));
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const i of items) {
|
|
125
|
+
if (i.kind !== 'rule' || i.projects.length)
|
|
126
|
+
continue;
|
|
127
|
+
const hit = projectKeysIn(`${i.statement} ${i.applies_when}`, keys)[0];
|
|
128
|
+
if (hit) {
|
|
129
|
+
out.push({ id: i.id, why: `프로젝트 "${hit}" 언급` });
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const m = PRODUCT_RE.exec(i.statement.trim());
|
|
133
|
+
if (m && !PRODUCT_NOT.has(m[1]))
|
|
134
|
+
out.push({ id: i.id, why: `"${m[1]}" 로 시작(제품·프로젝트 이름일 수 있음)` });
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
/** 사람이 읽을 상황 문구인가. 공백 없는 식별자(`secret-leak`)나 프로필 표지는 아니다. */
|
|
139
|
+
function readableWhen(i) {
|
|
140
|
+
const w = oneLine(i.applies_when);
|
|
141
|
+
if (!w || w === 'profile' || i.statement.includes(w) || (!/\s/.test(w) && /^[\w.:-]+$/.test(w)))
|
|
142
|
+
return '';
|
|
143
|
+
return w;
|
|
144
|
+
}
|
|
145
|
+
function whenNote(i, L, target) {
|
|
146
|
+
if (i.kind === 'rule' && !TRIGGER_TARGETS.has(target))
|
|
147
|
+
return '';
|
|
148
|
+
const w = readableWhen(i);
|
|
149
|
+
return w ? ` (${i.kind === 'rule' ? L.trig : L.when}: ${w})` : '';
|
|
150
|
+
}
|
|
151
|
+
function line(i, L, target) {
|
|
152
|
+
const when = whenNote(i, L, target);
|
|
153
|
+
const body = i.statement.trim().replace(/\n/g, '\n ');
|
|
154
|
+
return `- ${body}${when}${tag(i, L)}`;
|
|
155
|
+
}
|
|
156
|
+
function groups(items) {
|
|
157
|
+
return {
|
|
158
|
+
must: items.filter((i) => i.kind === 'rule' && (i.strength === 'hard' || i.strength === 'strong')),
|
|
159
|
+
general: items.filter((i) => i.kind === 'rule' && (i.strength === 'default' || i.strength === 'soft')),
|
|
160
|
+
procedures: items.filter((i) => i.kind === 'solution'),
|
|
161
|
+
habits: items.filter((i) => i.kind === 'habit'),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function markdownBody(items, L, target, project) {
|
|
165
|
+
const g = groups(items);
|
|
166
|
+
const out = [`# ${L.title}`, ''];
|
|
167
|
+
if (project)
|
|
168
|
+
out.push(`${L.project}: ${project}`, '');
|
|
169
|
+
out.push(L.intro);
|
|
170
|
+
if (items.some((i) => i.provenance.kind !== 'you-said'))
|
|
171
|
+
out.push(L.inferredNote);
|
|
172
|
+
for (const [key, label] of [['must', L.must], ['general', L.general], ['procedures', L.procedures], ['habits', L.habits]]) {
|
|
173
|
+
if (!g[key].length)
|
|
174
|
+
continue;
|
|
175
|
+
out.push('', `## ${label}`, ...g[key].map((i) => line(i, L, target)));
|
|
176
|
+
}
|
|
177
|
+
return `${out.join('\n')}\n`;
|
|
178
|
+
}
|
|
179
|
+
// ── skill ──
|
|
180
|
+
function asciiSlug(s) {
|
|
181
|
+
return s.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
182
|
+
}
|
|
183
|
+
const CHO = ['g', 'kk', 'n', 'd', 'tt', 'r', 'm', 'b', 'pp', 's', 'ss', '', 'j', 'jj', 'ch', 'k', 't', 'p', 'h'];
|
|
184
|
+
const JUNG = ['a', 'ae', 'ya', 'yae', 'eo', 'e', 'yeo', 'ye', 'o', 'wa', 'wae', 'oe', 'yo', 'u', 'wo', 'we', 'wi', 'yu', 'eu', 'ui', 'i'];
|
|
185
|
+
const JONG = ['', 'k', 'kk', 'ks', 'n', 'nj', 'nh', 't', 'l', 'lk', 'lm', 'lb', 'ls', 'lt', 'lp', 'lh', 'm', 'p', 'ps', 't', 'tt', 'ng', 't', 't', 'k', 't', 'p', 'h'];
|
|
186
|
+
/** 국어의 로마자 표기(음운 변동 없이 글자 단위)로 슬러그용 ASCII 를 만든다. 의미는 못 살려도 사람이 구분할 수 있는 이름이 된다. */
|
|
187
|
+
export function romanize(s) {
|
|
188
|
+
let out = '';
|
|
189
|
+
for (const ch of s) {
|
|
190
|
+
const c = ch.codePointAt(0) ?? 0;
|
|
191
|
+
if (c >= 0xac00 && c <= 0xd7a3) {
|
|
192
|
+
const n = c - 0xac00;
|
|
193
|
+
out += `${CHO[Math.floor(n / 588)]}${JUNG[Math.floor((n % 588) / 28)]}${JONG[n % 28]}`;
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
out += /[A-Za-z0-9]/.test(ch) ? ch : ' ';
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
const shortId = (id) => createHash('sha256').update(id).digest('hex').slice(0, 4);
|
|
201
|
+
/** 슬러그 길이 제한을 단어 경계에서 지킨다. */
|
|
202
|
+
function clipSlug(slug, max) {
|
|
203
|
+
if (slug.length <= max)
|
|
204
|
+
return slug;
|
|
205
|
+
const cut = slug.slice(0, max);
|
|
206
|
+
const k = cut.lastIndexOf('-');
|
|
207
|
+
return (k >= 8 ? cut.slice(0, k) : cut).replace(/-+$/g, '');
|
|
208
|
+
}
|
|
209
|
+
function skillName(i, used) {
|
|
210
|
+
const src = i.kind === 'solution' ? i.id.replace(/^solution:/, '') : i.statement.slice(0, 80);
|
|
211
|
+
let base = asciiSlug(src);
|
|
212
|
+
if (base.length < 3)
|
|
213
|
+
base = asciiSlug(romanize(src));
|
|
214
|
+
if (base.length < 3)
|
|
215
|
+
base = `${asciiSlug(i.category ?? i.kind) || i.kind}-${shortId(i.id)}`;
|
|
216
|
+
base = clipSlug(base, 48);
|
|
217
|
+
let name = base;
|
|
218
|
+
if (used.has(name))
|
|
219
|
+
name = `${clipSlug(base, 43)}-${shortId(i.id)}`;
|
|
220
|
+
for (let n = 2; used.has(name); n++)
|
|
221
|
+
name = `${clipSlug(base, 40)}-${shortId(i.id)}${n}`;
|
|
222
|
+
used.add(name);
|
|
223
|
+
return name;
|
|
224
|
+
}
|
|
225
|
+
/** 스킬로 낼 만한가: 솔루션이고 실제 상황 문장(공백이 있는 Context)이 있어야 한다. 룰의 trigger 는 사용 시점이 아니다. */
|
|
226
|
+
export function isSkillable(i) {
|
|
227
|
+
return i.kind === 'solution' && /\s/.test(i.applies_when.trim());
|
|
228
|
+
}
|
|
229
|
+
function yamlStr(s) {
|
|
230
|
+
return JSON.stringify(s); // JSON 문자열은 유효한 YAML 큰따옴표 스칼라다.
|
|
231
|
+
}
|
|
232
|
+
const hasUseTime = (i) => i.kind === 'solution' && /\s/.test(oneLine(i.applies_when));
|
|
233
|
+
function skillFile(i, name, L, degradedNote) {
|
|
234
|
+
let desc = hasUseTime(i) ? `${L.skillUse}: ${oneLine(i.applies_when)}. ${firstSentence(i.statement)}` : firstSentence(i.statement, 300);
|
|
235
|
+
if (!hasUseTime(i))
|
|
236
|
+
degradedNote.push(`${i.id}: 낮은 품질: 사용 시점이 없어 description 이 호출 조건이 아니다. forgen way draft skill "<주제>" 로 초안을 쓰라`);
|
|
237
|
+
if (desc.length > 1024) {
|
|
238
|
+
desc = `${desc.slice(0, 1023)}…`;
|
|
239
|
+
degradedNote.push(`${i.id}: description 1024자 제한으로 줄임`);
|
|
240
|
+
}
|
|
241
|
+
const p = i.provenance;
|
|
242
|
+
const why = i.why || (p.kind === 'you-said' ? `${L.said}${p.date ? ` ${p.date}` : ''}` : p.kind === 'imported' ? `${L.imported}: ${p.from}` : p.kind === 'mined' ? `${L.mined}` : '') || L.unknownWhy;
|
|
243
|
+
const care = [
|
|
244
|
+
`${L.strength}: ${i.strength}`,
|
|
245
|
+
`${L.scope}: ${i.projects.length ? i.projects.join(', ') : L.global}`,
|
|
246
|
+
i.enforceable ? L.enforcedNote : L.advisory,
|
|
247
|
+
];
|
|
248
|
+
const title = i.kind === 'solution' ? name : firstSentence(i.statement, 70);
|
|
249
|
+
const prohibition = i.kind === 'rule' && NEGATION_RE.test(i.statement);
|
|
250
|
+
const bodyHead = i.kind === 'solution'
|
|
251
|
+
? [`## ${L.skillWhen}`, i.applies_when || L.global, '', `## ${L.skillDo}`, i.statement.trim()]
|
|
252
|
+
: [`## ${prohibition ? L.skillBan : L.skillRule}`, i.statement.trim(), ...(readableWhen(i) ? ['', `## ${L.skillSituation}`, readableWhen(i)] : [])];
|
|
253
|
+
const body = [
|
|
254
|
+
'---', `name: ${name}`, `description: ${yamlStr(desc)}`, 'metadata:', ` forgen-way-id: ${yamlStr(i.id)}`, ` generated-by: "forgen-way"`, '---',
|
|
255
|
+
SKILL_MARK, '', `# ${title}`, '', ...bodyHead, '', `## ${L.skillWhy}`, why, '', `## ${L.skillCare}`, ...care.map((c) => `- ${c}`), '',
|
|
256
|
+
].join('\n');
|
|
257
|
+
return { path: `.claude/skills/${name}/SKILL.md`, content: body };
|
|
258
|
+
}
|
|
259
|
+
// ── 대상별 렌더 ──
|
|
260
|
+
function renderFiles(target, items, L, o, notes, genAt = '') {
|
|
261
|
+
switch (target) {
|
|
262
|
+
case 'agents-md': return [{ path: 'AGENTS.md', content: `${MARK}\n${markdownBody(items, L, target, o.project)}` }];
|
|
263
|
+
case 'claude-rules': return [{ path: '.claude/rules/forgen-way.md', content: `${MARK}\n${markdownBody(items, L, target, o.project)}` }];
|
|
264
|
+
case 'gemini': return [{ path: 'GEMINI.md', content: `${MARK}\n${markdownBody(items, L, target, o.project)}` }];
|
|
265
|
+
case 'system-prompt': {
|
|
266
|
+
const g = groups(items);
|
|
267
|
+
const out = [MARK, L.intro];
|
|
268
|
+
if (items.some((i) => i.provenance.kind !== 'you-said'))
|
|
269
|
+
out.push(L.inferredNote);
|
|
270
|
+
for (const [key, label] of [['must', L.must], ['general', L.general], ['procedures', L.procedures], ['habits', L.habits]]) {
|
|
271
|
+
if (g[key].length)
|
|
272
|
+
out.push('', `${label}:`, ...g[key].map((i) => line(i, L, target)));
|
|
273
|
+
}
|
|
274
|
+
return [{ path: 'system-prompt.txt', content: `${out.join('\n')}\n` }];
|
|
275
|
+
}
|
|
276
|
+
case 'cursor': {
|
|
277
|
+
const g = groups(items);
|
|
278
|
+
const files = [];
|
|
279
|
+
const always = [...g.must];
|
|
280
|
+
const rest = [...g.general, ...g.procedures, ...g.habits];
|
|
281
|
+
if (always.length)
|
|
282
|
+
files.push({ path: '.cursor/rules/forgen-way.mdc', content: `---\ndescription: ${yamlStr(L.title)}\nalwaysApply: true\n---\n${MARK}\n${markdownBody(always, L, target, o.project)}` });
|
|
283
|
+
if (rest.length)
|
|
284
|
+
files.push({ path: '.cursor/rules/forgen-way-situational.mdc', content: `---\ndescription: ${yamlStr(`${L.title}: ${L.general}, ${L.procedures}`)}\nalwaysApply: false\n---\n${MARK}\n${markdownBody(rest, L, target, o.project)}` });
|
|
285
|
+
return files;
|
|
286
|
+
}
|
|
287
|
+
case 'workflow': {
|
|
288
|
+
const byCat = new Map();
|
|
289
|
+
for (const i of items)
|
|
290
|
+
byCat.set(i.category ?? i.kind, [...(byCat.get(i.category ?? i.kind) ?? []), i]);
|
|
291
|
+
const out = [MARK, `# ${L.check}`, ''];
|
|
292
|
+
for (const [cat, list] of [...byCat].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
293
|
+
out.push(`## ${cat}`, ...list.map((i) => `- [ ] ${oneLine(i.statement)}${whenNote(i, L, target)}${tag(i, L)}`), '');
|
|
294
|
+
}
|
|
295
|
+
return [{ path: 'forgen-way-checklist.md', content: `${out.join('\n')}` }];
|
|
296
|
+
}
|
|
297
|
+
case 'skill': {
|
|
298
|
+
const used = new Set();
|
|
299
|
+
return items.map((i) => skillFile(i, skillName(i, used), L, notes));
|
|
300
|
+
}
|
|
301
|
+
case 'json':
|
|
302
|
+
return [{ path: 'forgen-way.json', content: `${JSON.stringify({ schema: 'forgen-way/1', generator: 'forgen-way', generated_at: genAt, project: o.project ?? null, items }, null, 2)}\n` }];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
export function compile(way, target, o = {}) {
|
|
306
|
+
const omitted = [];
|
|
307
|
+
const degraded = [];
|
|
308
|
+
const warnings = [];
|
|
309
|
+
const knownProjects = new Set(way.items.flatMap((i) => i.projects));
|
|
310
|
+
let pool = [];
|
|
311
|
+
for (const i of way.items) {
|
|
312
|
+
if (o.only && !o.only.includes(i.id)) {
|
|
313
|
+
omitted.push({ id: i.id, reason: 'not-selected' });
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (i.kind === 'rule' && i.status && i.status !== 'active') {
|
|
317
|
+
omitted.push({ id: i.id, reason: 'not-selected', detail: i.status });
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (i.projects.length && !(o.project && i.projects.includes(o.project))) {
|
|
321
|
+
omitted.push({ id: i.id, reason: 'project-scope', detail: i.projects.join(',') });
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (i.kind === 'habit' && !o.habits && !o.only) {
|
|
325
|
+
omitted.push({ id: i.id, reason: 'habit-excluded' });
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (i.conflicts_with) {
|
|
329
|
+
omitted.push({ id: i.id, reason: 'conflict', detail: `활성 룰 ${i.conflicts_with.slice(0, 8)} 과 상반` });
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (target === 'skill' && !isSkillable(i) && !o.only) {
|
|
333
|
+
omitted.push({ id: i.id, reason: 'not-a-procedure', detail: i.kind === 'solution' ? '사용 시점(Context) 없음: forgen way draft skill "<주제>"' : '룰은 사용 시점이 없다: forgen way draft skill "<주제>"' });
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
pool.push(i);
|
|
337
|
+
}
|
|
338
|
+
// 렌더러와 같은 render_key 중복 제거 (같은 키면 순위가 높은 하나만)
|
|
339
|
+
const best = new Map();
|
|
340
|
+
for (const i of pool) {
|
|
341
|
+
if (i.kind !== 'rule' || !i.render_key)
|
|
342
|
+
continue;
|
|
343
|
+
const cur = best.get(i.render_key);
|
|
344
|
+
if (!cur || comparePriority(i, cur) < 0)
|
|
345
|
+
best.set(i.render_key, i);
|
|
346
|
+
}
|
|
347
|
+
pool = pool.filter((i) => {
|
|
348
|
+
const w = i.kind === 'rule' && i.render_key ? best.get(i.render_key) : undefined;
|
|
349
|
+
if (w && w !== i) {
|
|
350
|
+
omitted.push({ id: i.id, reason: 'duplicate', detail: `render_key ${i.render_key} → ${w.id.slice(0, 8)}` });
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
return true;
|
|
354
|
+
});
|
|
355
|
+
// 다른 프로젝트 전용 계기는 숨긴다 (전역 항목의 trigger 가 프로젝트 이름을 말하는 경우)
|
|
356
|
+
const foreign = [...knownProjects].filter((k) => k !== o.project);
|
|
357
|
+
pool = pool.map((i) => (i.applies_when && projectKeysIn(i.applies_when, foreign).length ? { ...i, applies_when: '' } : i));
|
|
358
|
+
// 다른 모델이 읽는 산출물: 호스트 전용 꼬리 절 제거, 남으면 degraded
|
|
359
|
+
const hostNotes = [];
|
|
360
|
+
if (!CLAUDE_TARGETS.has(target)) {
|
|
361
|
+
pool = pool.map((i) => {
|
|
362
|
+
if (!HOST_TERM.test(i.statement))
|
|
363
|
+
return i;
|
|
364
|
+
const r = scrubHostTail(i.statement);
|
|
365
|
+
if (r.removed)
|
|
366
|
+
hostNotes.push({ id: i.id, reason: '호스트 전용 꼬리 절 제거 (다른 모델 대상)' });
|
|
367
|
+
if (r.residual)
|
|
368
|
+
hostNotes.push({ id: i.id, reason: '호스트 전용 표현이 문장 안에 남음 (다른 모델에서는 뜻이 안 통할 수 있다)' });
|
|
369
|
+
return r.removed ? { ...i, statement: r.text } : i;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
pool.sort((a, b) => comparePriority(a, b));
|
|
373
|
+
const L = pickLang(pool.length ? pool : way.items);
|
|
374
|
+
const budget = target === 'json' ? undefined : (o.budget ?? DEFAULT_BUDGET[target]);
|
|
375
|
+
const notes = [];
|
|
376
|
+
const chosen = [];
|
|
377
|
+
for (const i of pool) {
|
|
378
|
+
if (budget !== undefined) {
|
|
379
|
+
const size = renderFiles(target, [...chosen, i], L, o, []).reduce((n, f) => n + f.content.length, 0);
|
|
380
|
+
if (size > budget) {
|
|
381
|
+
omitted.push({ id: i.id, reason: 'budget', detail: `${budget}자 예산 초과` });
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
chosen.push(i);
|
|
386
|
+
}
|
|
387
|
+
const files = chosen.length ? renderFiles(target, chosen, L, o, notes, way.generated_at) : [];
|
|
388
|
+
const chosenIds = new Set(chosen.map((i) => i.id));
|
|
389
|
+
if (target !== 'json') {
|
|
390
|
+
for (const i of chosen)
|
|
391
|
+
if (i.enforceable)
|
|
392
|
+
degraded.push({ id: i.id, reason: `자문으로 전환: ${target} 산출물은 룰을 강제하지 못한다` });
|
|
393
|
+
degraded.push(...hostNotes.filter((h) => chosenIds.has(h.id)));
|
|
394
|
+
}
|
|
395
|
+
for (const n of notes)
|
|
396
|
+
degraded.push({ id: n.split(':')[0], reason: n.slice(n.indexOf(':') + 2) });
|
|
397
|
+
if (!o.project) {
|
|
398
|
+
const suspects = projectSpecificSuspects(chosen);
|
|
399
|
+
const globalRules = chosen.filter((i) => i.kind === 'rule' && !i.projects.length).length;
|
|
400
|
+
if (globalRules > 0) {
|
|
401
|
+
warnings.push(`프로젝트 미지정 전역 산출물: 룰 ${globalRules}개 중 ${suspects.length}개가 프로젝트 전용일 수 있음. 분류: forgen rule classify-projects --project <키> --keywords a,b (또는 forgen rule set-project <id> <키>)`);
|
|
402
|
+
if (target !== 'json')
|
|
403
|
+
for (const s of suspects)
|
|
404
|
+
degraded.push({ id: s.id, reason: `프로젝트 전용일 수 있음: ${s.why}` });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return { files, omitted, degraded, warnings };
|
|
408
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 문장이 활성 룰과 상반되는가. 라이프사이클 T5(한글 부정 표지 + 부정된 동작이 반대편에 긍정으로 등장)를 그대로 재사용한다.
|
|
3
|
+
* T5 는 같은 category·scope 인 쌍만 보므로, 후보를 각 룰의 category·scope 로 복제해 비교한다.
|
|
4
|
+
*/
|
|
5
|
+
import { detect, NEGATION_RE } from '../engine/lifecycle/trigger-t5-conflict.js';
|
|
6
|
+
/** T5 의 부정 표지에 "말고·거부·없이" 같은 변형을 더한 극성 판정. 같은 극성이면 상반이 아니다(같은 입장의 다른 표현). */
|
|
7
|
+
const EXT_NEG = /말고|거부|없이|막지|않고|않는|않음|아니|못하/;
|
|
8
|
+
const isNeg = (t) => NEGATION_RE.test(t) || EXT_NEG.test(t);
|
|
9
|
+
export function conflictingRule(text, rules) {
|
|
10
|
+
for (const r of rules) {
|
|
11
|
+
if (r.status !== 'active' || isNeg(r.policy) === isNeg(text))
|
|
12
|
+
continue;
|
|
13
|
+
const cand = { ...r, rule_id: '__candidate__', policy: text };
|
|
14
|
+
if (detect({ rules: [r, cand], ts: 0 }).length)
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CompiledFile } from './types.js';
|
|
2
|
+
export type DraftKind = 'skill' | 'workflow';
|
|
3
|
+
export interface DraftSource {
|
|
4
|
+
/** `rule:<id>` · `solution:<name>` · `correction:<evidence_id>` */
|
|
5
|
+
id: string;
|
|
6
|
+
kind: 'rule' | 'solution' | 'correction';
|
|
7
|
+
/** 보내도 되는 텍스트 (비밀 마스킹·private 제거 후) */
|
|
8
|
+
text: string;
|
|
9
|
+
/** 룰: 발화 원문 (있을 때) */
|
|
10
|
+
quote?: string;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GatherResult {
|
|
14
|
+
sources: DraftSource[];
|
|
15
|
+
excludedPrivate: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function topicScore(topic: string, text: string): number;
|
|
18
|
+
/** 주제와 관련된 룰(rule-relevance + 주제어), 솔루션(매처 + 주제어), 교정 원문(같은 기준)을 모은다. */
|
|
19
|
+
export declare function gatherSources(topic: string, opts?: {
|
|
20
|
+
project?: string;
|
|
21
|
+
cwd?: string;
|
|
22
|
+
}): GatherResult;
|
|
23
|
+
export declare function buildDraftPrompt(kind: DraftKind, topic: string, sources: DraftSource[]): string;
|
|
24
|
+
export interface DraftOutcome {
|
|
25
|
+
mode: 'haiku' | 'deterministic';
|
|
26
|
+
text: string;
|
|
27
|
+
/** 결정론 출력일 때 Haiku 를 쓰지 못한 사유 */
|
|
28
|
+
reason?: string;
|
|
29
|
+
ms?: number;
|
|
30
|
+
}
|
|
31
|
+
/** 모델이 감싼 코드펜스·앞말을 걷어낸다. */
|
|
32
|
+
export declare function stripWrapper(out: string): string;
|
|
33
|
+
/** 결정론 출력: 관련 항목 묶음. 초안이 아니라 재료다. */
|
|
34
|
+
export declare function deterministicBundle(kind: DraftKind, topic: string, sources: DraftSource[], reason: string): string;
|
|
35
|
+
export declare function writeDraft(kind: DraftKind, topic: string, sources: DraftSource[], opts?: {
|
|
36
|
+
cwd?: string;
|
|
37
|
+
noLlm?: boolean;
|
|
38
|
+
}): DraftOutcome;
|
|
39
|
+
/** 초안 텍스트에서 SKILL.md 이름을 안전한 ASCII 로 뽑는다 (없거나 이상하면 주제에서 만든다). */
|
|
40
|
+
export declare function skillNameFor(text: string, topic: string): string;
|
|
41
|
+
/** 초안을 파일 묶음으로 만든다. 스킬은 `.claude/skills/<name>/`, 워크플로우는 `workflows/<slug>.md`. 근거는 옆 파일. */
|
|
42
|
+
export declare function draftFiles(kind: DraftKind, topic: string, outcome: DraftOutcome, sources: DraftSource[], excludedPrivate: number): CompiledFile[];
|
|
43
|
+
export declare function readTopic(args: string[]): string | undefined;
|