create-principles-disciple 1.76.0 → 1.78.0
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/console/dist/server/config/feature-flags.d.ts +25 -0
- package/console/dist/server/config/feature-flags.js +101 -0
- package/console/dist/server/index.js +16 -0
- package/console/dist/server/models/FeedbackReportConsoleModel.d.ts +49 -0
- package/console/dist/server/models/FeedbackReportConsoleModel.js +242 -0
- package/console/dist/server/routes/feedback-reports.d.ts +18 -0
- package/console/dist/server/routes/feedback-reports.js +165 -0
- package/console/dist/ui/App.js +2 -1
- package/console/dist/ui/api.d.ts +26 -2
- package/console/dist/ui/api.js +18 -1
- package/console/dist/ui/components/app-sidebar.js +2 -1
- package/console/dist/ui/components/error-boundary.js +9 -2
- package/console/dist/ui/i18n/en.json +67 -1
- package/console/dist/ui/i18n/zh-CN.json +67 -1
- package/console/dist/ui/pages/ReportProblemPage.d.ts +1 -0
- package/console/dist/ui/pages/ReportProblemPage.js +186 -0
- package/console/dist/ui/pages/ReportProblemValidators.d.ts +51 -0
- package/console/dist/ui/pages/ReportProblemValidators.js +114 -0
- package/console/dist/web/assets/app.css +18 -0
- package/console/dist/web/assets/app.js +1047 -125
- package/console/package.json +1 -0
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +24 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/feedback/create-report.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/feedback/create-report.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/create-report.test.js +402 -0
- package/core/dist/runtime-v2/__tests__/feedback/create-report.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.js +128 -0
- package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.js +231 -0
- package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.js +102 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.js +130 -0
- package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.js +328 -0
- package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +343 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/index.d.ts +2 -0
- package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/index.js +1 -0
- package/core/dist/runtime-v2/activation/index.js.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +34 -0
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +109 -0
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +13 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js +141 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +4 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/index.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/index.js +1 -0
- package/core/dist/runtime-v2/feature-flags/index.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts +25 -0
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +233 -0
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js.map +1 -0
- package/core/dist/runtime-v2/feedback/create-report.d.ts +14 -0
- package/core/dist/runtime-v2/feedback/create-report.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/create-report.js +257 -0
- package/core/dist/runtime-v2/feedback/create-report.js.map +1 -0
- package/core/dist/runtime-v2/feedback/feedback-types.d.ts +120 -0
- package/core/dist/runtime-v2/feedback/feedback-types.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/feedback-types.js +243 -0
- package/core/dist/runtime-v2/feedback/feedback-types.js.map +1 -0
- package/core/dist/runtime-v2/feedback/index.d.ts +9 -0
- package/core/dist/runtime-v2/feedback/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/index.js +11 -0
- package/core/dist/runtime-v2/feedback/index.js.map +1 -0
- package/core/dist/runtime-v2/feedback/internal-guards.d.ts +2 -0
- package/core/dist/runtime-v2/feedback/internal-guards.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/internal-guards.js +6 -0
- package/core/dist/runtime-v2/feedback/internal-guards.js.map +1 -0
- package/core/dist/runtime-v2/feedback/privacy-preview.d.ts +14 -0
- package/core/dist/runtime-v2/feedback/privacy-preview.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/privacy-preview.js +128 -0
- package/core/dist/runtime-v2/feedback/privacy-preview.js.map +1 -0
- package/core/dist/runtime-v2/feedback/redact-sensitive.d.ts +37 -0
- package/core/dist/runtime-v2/feedback/redact-sensitive.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/redact-sensitive.js +272 -0
- package/core/dist/runtime-v2/feedback/redact-sensitive.js.map +1 -0
- package/core/dist/runtime-v2/feedback/render-github-url.d.ts +21 -0
- package/core/dist/runtime-v2/feedback/render-github-url.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/render-github-url.js +57 -0
- package/core/dist/runtime-v2/feedback/render-github-url.js.map +1 -0
- package/core/dist/runtime-v2/feedback/render-markdown.d.ts +12 -0
- package/core/dist/runtime-v2/feedback/render-markdown.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/render-markdown.js +166 -0
- package/core/dist/runtime-v2/feedback/render-markdown.js.map +1 -0
- package/core/dist/runtime-v2/feedback/safe-stringify.d.ts +6 -0
- package/core/dist/runtime-v2/feedback/safe-stringify.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/safe-stringify.js +115 -0
- package/core/dist/runtime-v2/feedback/safe-stringify.js.map +1 -0
- package/core/dist/runtime-v2/index.d.ts +8 -1
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +12 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/workspace-guidance-migration.d.ts +12 -0
- package/core/dist/runtime-v2/workspace-guidance-migration.d.ts.map +1 -0
- package/core/dist/runtime-v2/workspace-guidance-migration.js +193 -0
- package/core/dist/runtime-v2/workspace-guidance-migration.js.map +1 -0
- package/core/package.json +4 -0
- package/package.json +1 -1
- package/plugin/dist/commands/context.js +5 -5
- package/plugin/dist/commands/strategy.d.ts +0 -1
- package/plugin/dist/commands/strategy.js +0 -14
- package/plugin/dist/core/runtime-v2-prompt-activation-reader.d.ts +4 -13
- package/plugin/dist/core/runtime-v2-prompt-activation-reader.js +36 -74
- package/plugin/dist/core/surface-guard.d.ts +27 -0
- package/plugin/dist/core/surface-guard.js +82 -0
- package/plugin/dist/core/workspace-guidance-migrator.d.ts +12 -0
- package/plugin/dist/core/workspace-guidance-migrator.js +141 -0
- package/plugin/dist/hooks/prompt.js +20 -143
- package/plugin/dist/i18n/commands.js +2 -14
- package/plugin/dist/index.d.ts +27 -0
- package/plugin/dist/index.js +180 -65
- package/plugin/dist/service/correction-observer-service.d.ts +11 -0
- package/plugin/dist/service/correction-observer-service.js +172 -0
- package/plugin/dist/service/evolution-worker.js +1 -110
- package/plugin/dist/types.d.ts +2 -2
- package/plugin/dist/types.js +3 -3
- package/plugin/templates/langs/en/core/BOOTSTRAP.md +5 -19
- package/plugin/templates/langs/en/principles/THINKING_OS.md +1 -1
- package/plugin/templates/langs/en/skills/admin/SKILL.md +2 -2
- package/plugin/templates/langs/en/skills/bootstrap-tools/SKILL.md +1 -1
- package/plugin/templates/langs/en/skills/init-strategy/SKILL.md +1 -1
- package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +8 -23
- package/plugin/templates/langs/en/skills/reflection/SKILL.md +2 -2
- package/plugin/templates/langs/en/skills/report/SKILL.md +1 -1
- package/plugin/templates/langs/zh/core/BOOTSTRAP.md +3 -16
- package/plugin/templates/langs/zh/principles/THINKING_OS.md +1 -1
- package/plugin/templates/langs/zh/skills/admin/SKILL.md +2 -2
- package/plugin/templates/langs/zh/skills/bootstrap-tools/SKILL.md +1 -1
- package/plugin/templates/langs/zh/skills/init-strategy/SKILL.md +1 -1
- package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +7 -22
- package/plugin/templates/langs/zh/skills/reflection/SKILL.md +2 -2
- package/plugin/templates/langs/zh/skills/report/SKILL.md +1 -1
- package/plugin/templates/workspace/.principles/THINKING_OS.md +1 -1
- package/templates/langs/en/core/BOOTSTRAP.md +1 -1
- package/templates/langs/en/principles/THINKING_OS.md +1 -1
- package/templates/langs/en/skills/admin/SKILL.md +2 -2
- package/templates/langs/en/skills/pd-grooming/SKILL.md +1 -1
- package/templates/langs/en/skills/reflection/SKILL.md +2 -2
- package/templates/langs/en/skills/report/SKILL.md +1 -1
- package/templates/langs/zh/core/BOOTSTRAP.md +1 -1
- package/templates/langs/zh/principles/THINKING_OS.md +1 -1
- package/templates/langs/zh/skills/admin/SKILL.md +2 -2
- package/templates/langs/zh/skills/pd-grooming/SKILL.md +1 -1
- package/templates/langs/zh/skills/reflection/SKILL.md +2 -2
- package/templates/langs/zh/skills/report/SKILL.md +1 -1
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/EXAMPLES.md +0 -63
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/REFERENCE.md +0 -136
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/SKILL.md +0 -67
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/agent-registry.json +0 -143
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/bugfix-complex-template.json +0 -107
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/feature-complex-template.json +0 -107
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal-verify.json +0 -95
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal.json +0 -98
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/workflow-v1-acceptance-checklist.md +0 -58
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/workflow-v1.4-work-unit-handoff.md +0 -190
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/archive.mjs +0 -310
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/contract-enforcement.mjs +0 -683
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/decision.mjs +0 -604
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/state-store.mjs +0 -32
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/task-specs.mjs +0 -707
- package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/run.mjs +0 -3455
- package/plugin/templates/langs/en/skills/evolve-system/SKILL.md +0 -46
- package/plugin/templates/langs/en/skills/manage-okr/SKILL.md +0 -96
- package/plugin/templates/langs/en/skills/pd-daily/SKILL.md +0 -199
- package/plugin/templates/langs/en/skills/pd-grooming/SKILL.md +0 -46
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/EXAMPLES.md +0 -63
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/REFERENCE.md +0 -136
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/SKILL.md +0 -67
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/agent-registry.json +0 -143
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/bugfix-complex-template.json +0 -107
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/feature-complex-template.json +0 -107
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/nocturnal-trinity-quality-enhancement.json +0 -111
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal-verify.json +0 -95
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal.json +0 -98
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/workflow-v1-acceptance-checklist.md +0 -58
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/workflow-v1.4-work-unit-handoff.md +0 -190
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/runtime/.gitignore +0 -2
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/archive.mjs +0 -310
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/contract-enforcement.mjs +0 -683
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/decision.mjs +0 -604
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/state-store.mjs +0 -32
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/task-specs.mjs +0 -707
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/run.mjs +0 -3455
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/archive.test.mjs +0 -230
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/contract-enforcement.test.mjs +0 -672
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/decision.test.mjs +0 -1321
- package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/run.test.mjs +0 -1435
- package/plugin/templates/langs/zh/skills/evolve-system/SKILL.md +0 -46
- package/plugin/templates/langs/zh/skills/manage-okr/SKILL.md +0 -109
- package/plugin/templates/langs/zh/skills/pd-daily/SKILL.md +0 -283
- package/plugin/templates/langs/zh/skills/pd-grooming/SKILL.md +0 -46
- package/plugin/templates/workspace/PLAN.md +0 -2
- package/templates/workspace/PLAN.md +0 -2
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { migrateWorkspaceGuidance, containsStalePlanMdGuidance } from '@principles/core/runtime-v2';
|
|
4
|
+
const WORKSPACE_GUIDANCE_FILES = [
|
|
5
|
+
'AGENTS.md',
|
|
6
|
+
'MEMORY.md',
|
|
7
|
+
];
|
|
8
|
+
const PRINCIPLES_SUBDIR_FILES = [
|
|
9
|
+
'THINKING_OS.md',
|
|
10
|
+
];
|
|
11
|
+
const SKILLS_DIR = path.join('.principles', 'skills');
|
|
12
|
+
const PRINCIPLES_DIR = '.principles';
|
|
13
|
+
const BACKUP_SUFFIX = '.pre-pri286.bak';
|
|
14
|
+
function readFileContent(filePath) {
|
|
15
|
+
try {
|
|
16
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
17
|
+
if (typeof raw !== 'string') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return raw;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function writeBackup(filePath, content) {
|
|
27
|
+
const backupPath = filePath + BACKUP_SUFFIX;
|
|
28
|
+
try {
|
|
29
|
+
fs.writeFileSync(backupPath, content, 'utf-8');
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function discoverSkillFiles(workspaceDir) {
|
|
37
|
+
const skillsDir = path.join(workspaceDir, SKILLS_DIR);
|
|
38
|
+
if (!fs.existsSync(skillsDir)) {
|
|
39
|
+
return { files: [] };
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
43
|
+
const skillFiles = [];
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
const skillMd = path.join(skillsDir, entry.name, 'SKILL.md');
|
|
47
|
+
if (fs.existsSync(skillMd)) {
|
|
48
|
+
skillFiles.push(skillMd);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { files: skillFiles };
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
56
|
+
return {
|
|
57
|
+
files: [],
|
|
58
|
+
error: {
|
|
59
|
+
file: SKILLS_DIR,
|
|
60
|
+
error: `Failed to enumerate skills directory: ${errMsg}`,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function collectCandidateFiles(workspaceDir, result) {
|
|
66
|
+
const candidates = [];
|
|
67
|
+
for (const filename of WORKSPACE_GUIDANCE_FILES) {
|
|
68
|
+
candidates.push(path.join(workspaceDir, filename));
|
|
69
|
+
}
|
|
70
|
+
for (const filename of PRINCIPLES_SUBDIR_FILES) {
|
|
71
|
+
candidates.push(path.join(workspaceDir, PRINCIPLES_DIR, filename));
|
|
72
|
+
}
|
|
73
|
+
const skillDiscovery = discoverSkillFiles(workspaceDir);
|
|
74
|
+
if (skillDiscovery.error) {
|
|
75
|
+
result.errors.push(skillDiscovery.error);
|
|
76
|
+
}
|
|
77
|
+
candidates.push(...skillDiscovery.files);
|
|
78
|
+
return candidates;
|
|
79
|
+
}
|
|
80
|
+
export function migrateStaleWorkspaceGuidance(api, workspaceDir) {
|
|
81
|
+
const result = {
|
|
82
|
+
migratedFiles: [],
|
|
83
|
+
skippedFiles: [],
|
|
84
|
+
errors: [],
|
|
85
|
+
};
|
|
86
|
+
const candidates = collectCandidateFiles(workspaceDir, result);
|
|
87
|
+
for (const filePath of candidates) {
|
|
88
|
+
const relativePath = path.relative(workspaceDir, filePath);
|
|
89
|
+
if (!fs.existsSync(filePath)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const content = readFileContent(filePath);
|
|
93
|
+
if (content === null) {
|
|
94
|
+
result.errors.push({
|
|
95
|
+
file: relativePath,
|
|
96
|
+
error: 'Failed to read file content',
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!containsStalePlanMdGuidance(content, relativePath)) {
|
|
101
|
+
result.skippedFiles.push(relativePath);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const migrationResult = migrateWorkspaceGuidance(content, relativePath);
|
|
105
|
+
if (!migrationResult.changed) {
|
|
106
|
+
result.skippedFiles.push(relativePath);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const migrated = migrationResult.migrated;
|
|
110
|
+
const backupOk = writeBackup(filePath, content);
|
|
111
|
+
if (!backupOk) {
|
|
112
|
+
result.errors.push({
|
|
113
|
+
file: relativePath,
|
|
114
|
+
error: 'Failed to create backup file before migration',
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
fs.writeFileSync(filePath, migrated, 'utf-8');
|
|
120
|
+
result.migratedFiles.push(relativePath);
|
|
121
|
+
api.logger.info(`[PD:GuidanceMigration] Migrated ${relativePath} (backup at ${relativePath}${BACKUP_SUFFIX})`);
|
|
122
|
+
}
|
|
123
|
+
catch (writeErr) {
|
|
124
|
+
const errMsg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
125
|
+
result.errors.push({
|
|
126
|
+
file: relativePath,
|
|
127
|
+
error: `Failed to write migrated content: ${errMsg}`,
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
api.logger.error(`[PD:GuidanceMigration] CRITICAL: Failed to restore original content for ${relativePath} after write failure`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (result.migratedFiles.length > 0) {
|
|
138
|
+
api.logger.info(`[PD:GuidanceMigration] Migration complete: ${result.migratedFiles.length} migrated, ${result.skippedFiles.length} skipped, ${result.errors.length} errors`);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
@@ -3,19 +3,20 @@ import * as path from 'path';
|
|
|
3
3
|
import { clearInjectedProbationIds, getSession, resetFriction, setInjectedProbationIds, trackFriction, decayGfi, getGfiDecayElapsed } from '../core/session-tracker.js';
|
|
4
4
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
5
5
|
import { defaultContextConfig } from '../types.js';
|
|
6
|
-
|
|
6
|
+
// local-worker-routing: removed from prompt injection per PRI-291 (MVP-Quiet)
|
|
7
|
+
// classifyTask is still available for non-prompt consumers
|
|
7
8
|
import { extractSummary, getHistoryVersions, parseWorkingMemorySection, workingMemoryToInjection, autoCompressFocus, safeReadCurrentFocus } from '../core/focus-history.js';
|
|
8
9
|
import { PathResolver } from '../core/path-resolver.js';
|
|
9
10
|
import { selectPrinciplesForInjection, DEFAULT_PRINCIPLE_BUDGET } from '../core/principle-injection.js';
|
|
10
|
-
import { getCachedMaskedPrincipleSet, WorkflowFunnelLoader, PiAiRuntimeAdapter, EmpathyObserver, AgentScheduler } from '@principles/core/runtime-v2';
|
|
11
|
+
import { getCachedMaskedPrincipleSet, WorkflowFunnelLoader, PiAiRuntimeAdapter, EmpathyObserver, AgentScheduler, RUNTIME_V2_PRINCIPLE_BUDGET, trimToBudget, renderPrinciplesToDirectives } from '@principles/core/runtime-v2';
|
|
11
12
|
import { truncateInjectionToBudget } from '@principles/core/prompt-builder';
|
|
12
|
-
import { PromptActivationReader
|
|
13
|
+
import { PromptActivationReader } from '../core/runtime-v2-prompt-activation-reader.js';
|
|
13
14
|
import { matchEmpathyKeywords, loadKeywordStore, saveKeywordStore, getKeywordStoreSummary, } from '../core/empathy-keyword-matcher.js';
|
|
14
15
|
import { severityToPenalty, DEFAULT_EMPATHY_KEYWORD_CONFIG } from '../core/empathy-types.js';
|
|
15
16
|
import { evaluatePainDiagnosticGate } from '../core/pain-diagnostic-gate.js';
|
|
16
17
|
import { emitPainDetectedEvent, buildTrajectoryEvidence } from './pain.js';
|
|
17
18
|
import { CorrectionCueLearner } from '../core/correction-cue-learner.js';
|
|
18
|
-
import {
|
|
19
|
+
import { detectCorrectionCue as coreDetectCorrectionCue, extractMessageContent, isMinimalTrigger, } from '@principles/core/prompt-builder';
|
|
19
20
|
// ---------------------------------------------------------------------------
|
|
20
21
|
// Static file cache — avoids re-reading rarely-changing files every message
|
|
21
22
|
// ---------------------------------------------------------------------------
|
|
@@ -576,9 +577,9 @@ ${heartbeatChecklist}
|
|
|
576
577
|
}
|
|
577
578
|
}
|
|
578
579
|
}
|
|
579
|
-
// ──── 6.
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
// ──── 6. GFI score (for empathy/evidence path only — NOT for attitude/personality prompt)
|
|
581
|
+
// Attitude/personality prompt injection removed per PRI-291 (MVP diet).
|
|
582
|
+
// GFI scoring, trackFriction, and empathy pain emission remain active.
|
|
582
583
|
// ──── 7. appendSystemContext: Principles + Thinking OS + reflection_log + project_context ────
|
|
583
584
|
// NOTE: Principles is ALWAYS injected (not configurable)
|
|
584
585
|
// Thinking OS, reflection_log, project_context are configurable
|
|
@@ -750,19 +751,12 @@ ${heartbeatChecklist}
|
|
|
750
751
|
}
|
|
751
752
|
dedupedV2 = v2Result.principles.filter((p) => !legacyActiveIds.has(p.principleId));
|
|
752
753
|
if (dedupedV2.length > 0) {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
for (const
|
|
758
|
-
|
|
759
|
-
if (remaining < entry.length + 1) {
|
|
760
|
-
logger?.info?.(`[PD:RuntimeV2] Principle budget reached (${RUNTIME_V2_PRINCIPLE_BUDGET}c) — truncating after ${lines.length - 1} principles`);
|
|
761
|
-
break;
|
|
762
|
-
}
|
|
763
|
-
lines.push(entry);
|
|
764
|
-
remaining -= entry.length + 1;
|
|
765
|
-
runtimeV2PrincipleIds.add(p.principleId);
|
|
754
|
+
const { lines, injectedIds, truncated } = trimToBudget(dedupedV2, RUNTIME_V2_PRINCIPLE_BUDGET, escapeXml);
|
|
755
|
+
if (truncated) {
|
|
756
|
+
logger?.info?.(`[PD:RuntimeV2] Principle budget reached (${RUNTIME_V2_PRINCIPLE_BUDGET}c) — truncating after ${injectedIds.size} principles`);
|
|
757
|
+
}
|
|
758
|
+
for (const id of injectedIds) {
|
|
759
|
+
runtimeV2PrincipleIds.add(id);
|
|
766
760
|
}
|
|
767
761
|
runtimeV2PrinciplesContent = lines.join('\n');
|
|
768
762
|
}
|
|
@@ -829,122 +823,12 @@ ${empathySilenceConstraint}
|
|
|
829
823
|
// PLACED IN prependSystemContext (before gateway system prompt) for highest LLM attention.
|
|
830
824
|
// These are owner-reviewed, validated behavior constraints — not background context.
|
|
831
825
|
if (runtimeV2PrincipleIds.size > 0) {
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
directiveLines.push('## 【OWNER-APPROVED BEHAVIOR DIRECTIVES】');
|
|
835
|
-
directiveLines.push('');
|
|
836
|
-
directiveLines.push('Owner-approved behavior directives are active operating constraints learned from prior owner corrections.');
|
|
837
|
-
directiveLines.push('These directives are mandatory for this session unless they conflict with safety, security, or higher-priority system policy.');
|
|
838
|
-
directiveLines.push('For ambiguous coding or file-changing tasks, follow these directives before using mutating tools.');
|
|
839
|
-
directiveLines.push('');
|
|
840
|
-
for (const p of dedupedV2) {
|
|
841
|
-
if (!runtimeV2PrincipleIds.has(p.principleId))
|
|
842
|
-
continue;
|
|
843
|
-
directiveLines.push(`<directive id="${escapeXml(p.principleId)}" source="runtime_v2_activation">`);
|
|
844
|
-
directiveLines.push(`MANDATORY: ${escapeXml(p.text)}`);
|
|
845
|
-
directiveLines.push('Apply this as an active behavior constraint. Do not treat this as background context.');
|
|
846
|
-
directiveLines.push('</directive>');
|
|
847
|
-
directiveLines.push('');
|
|
848
|
-
}
|
|
849
|
-
directiveLines.push('Note: These directives do not override safety, security, or core system policy.');
|
|
850
|
-
prependSystemContext += directiveLines.join('\n');
|
|
851
|
-
}
|
|
852
|
-
// Routing Guidance (section 5 — injected between evolution principles and core principles)
|
|
853
|
-
// Inject delegation guidance when task is bounded + deployment allowed + not high-entropy.
|
|
854
|
-
// This is a non-authoritative suggestion — the main agent decides whether to follow.
|
|
855
|
-
// Shadow evidence comes from real runtime hooks (subagent_spawning/subagent_ended).
|
|
856
|
-
if (!isMinimalMode && sessionId) {
|
|
857
|
-
try {
|
|
858
|
-
// Use the already extracted and cleaned user message
|
|
859
|
-
const latestUserText = latestUserMessage || '';
|
|
860
|
-
if (latestUserText && latestUserText.trim().length > 0) {
|
|
861
|
-
// Infer requestedTools and requestedFiles from message content
|
|
862
|
-
const toolPatterns = [
|
|
863
|
-
{ pattern: /\b(edit|replace|write|modify|update|fix|patch|add|remove|delete|insert)\b/gi, tool: 'edit' },
|
|
864
|
-
{ pattern: /\b(read|cat|view|show|get|find|search|grep|look|inspect|examine|list|head|tail|diff)\b/gi, tool: 'read' },
|
|
865
|
-
{ pattern: /\b(run|execute|exec|bash|shell|command)\b/gi, tool: 'bash' },
|
|
866
|
-
];
|
|
867
|
-
const filePattern = /\b([a-zA-Z]:\\?[^\s,]+\.[a-z]{2,10}|[./][^\s,]+\.[a-z]{2,10})\b/gi;
|
|
868
|
-
const toolMatches = toolPatterns.flatMap(({ pattern, tool }) => {
|
|
869
|
-
const matches = [];
|
|
870
|
-
const r = new RegExp(pattern.source, pattern.flags);
|
|
871
|
-
while (r.exec(latestUserText) !== null)
|
|
872
|
-
matches.push(tool);
|
|
873
|
-
return matches;
|
|
874
|
-
});
|
|
875
|
-
const fileMatches = latestUserText.match(filePattern) ?? [];
|
|
876
|
-
const routingInput = {
|
|
877
|
-
taskIntent: toolMatches[0] ?? undefined,
|
|
878
|
-
taskDescription: latestUserText.trim(),
|
|
879
|
-
requestedFiles: fileMatches.length > 0 ? fileMatches : undefined,
|
|
880
|
-
};
|
|
881
|
-
const decision = classifyTask(routingInput, wctx.stateDir);
|
|
882
|
-
// Inject guidance only when: route_local + deployable checkpoint + not high-entropy
|
|
883
|
-
const isDeployableState = decision.activeCheckpointState === 'shadow_ready' ||
|
|
884
|
-
decision.activeCheckpointState === 'promotable';
|
|
885
|
-
if (decision.decision === 'route_local' &&
|
|
886
|
-
decision.targetProfile !== null &&
|
|
887
|
-
isDeployableState) {
|
|
888
|
-
const profile = decision.targetProfile;
|
|
889
|
-
if (profile === 'local-reader') {
|
|
890
|
-
appendParts.push(`<routing_guidance>
|
|
891
|
-
DELEGATION SUGGESTION: This task appears suitable for the local-reader subagent.
|
|
892
|
-
|
|
893
|
-
**Task Fit**: ${decision.reason}
|
|
894
|
-
|
|
895
|
-
**Suggested Action**: Consider routing to \`local-reader\` (pd-explorer skill) for focused reading, inspection, and information retrieval.
|
|
896
|
-
|
|
897
|
-
**Why This Works**:
|
|
898
|
-
- Task keywords indicate read-only or inspect operations
|
|
899
|
-
- Bounded scope — no multi-file coordination needed
|
|
900
|
-
- Shadow observation in progress — real runtime evidence being collected
|
|
901
|
-
|
|
902
|
-
**Note**: This is a non-authoritative suggestion. The main agent decides whether to route based on full context. Shadow evidence from runtime hooks will inform future promotion decisions.
|
|
903
|
-
</routing_guidance>`);
|
|
904
|
-
}
|
|
905
|
-
else if (profile === 'local-editor') {
|
|
906
|
-
appendParts.push(`<routing_guidance>
|
|
907
|
-
DELEGATION SUGGESTION: This task appears suitable for the local-editor subagent.
|
|
908
|
-
|
|
909
|
-
**Task Fit**: ${decision.reason}
|
|
910
|
-
|
|
911
|
-
**Suggested Action**: Consider routing to \`local-editor\` (pd-repair skill) for bounded editing, modification, and repair tasks.
|
|
912
|
-
|
|
913
|
-
**Why This Works**:
|
|
914
|
-
- Task keywords indicate bounded modification operations
|
|
915
|
-
- Target files appear limited in scope (1-3 files)
|
|
916
|
-
- Shadow observation in progress — real runtime evidence being collected
|
|
917
|
-
|
|
918
|
-
**Note**: This is a non-authoritative suggestion. The main agent decides whether to route based on full context. Shadow evidence from runtime hooks will inform future promotion decisions.
|
|
919
|
-
</routing_guidance>`);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
else if (decision.decision === 'stay_main' &&
|
|
923
|
-
decision.classification !== 'reader_eligible' &&
|
|
924
|
-
decision.classification !== 'editor_eligible') {
|
|
925
|
-
// Only show stay_main guidance when the task is genuinely high-entropy/risk/ambiguous
|
|
926
|
-
appendParts.push(`<routing_guidance>
|
|
927
|
-
ROUTING GUIDANCE: Task should remain on the main agent.
|
|
928
|
-
|
|
929
|
-
**Reason**: ${decision.reason}
|
|
930
|
-
|
|
931
|
-
**Blockers**: ${decision.blockers.length > 0 ? decision.blockers.join('; ') : 'none'}
|
|
932
|
-
|
|
933
|
-
**Why Stay Main**:
|
|
934
|
-
- Task contains high-entropy signals (open-ended, multi-step, or ambiguous)
|
|
935
|
-
- Or: task involves risk signals requiring main-agent supervision
|
|
936
|
-
- Or: deployment not available for the natural target profile
|
|
937
|
-
|
|
938
|
-
**Note**: This is a non-authoritative suggestion backed by policy classification. The main agent has full discretion.
|
|
939
|
-
</routing_guidance>`);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
catch (e) {
|
|
944
|
-
// Routing guidance is best-effort — never fail the hook
|
|
945
|
-
logger?.warn?.(`[PD:Prompt] Routing guidance injection failed: ${String(e)}`);
|
|
946
|
-
}
|
|
826
|
+
const directiveText = renderPrinciplesToDirectives(dedupedV2, runtimeV2PrincipleIds, escapeXml);
|
|
827
|
+
prependSystemContext += directiveText;
|
|
947
828
|
}
|
|
829
|
+
// Routing guidance removed per PRI-291 (MVP diet).
|
|
830
|
+
// Local worker routing is MVP-Quiet per ADR-0014 §2.5.
|
|
831
|
+
// The classifyTask helper and local-worker-routing module are preserved for non-prompt consumers.
|
|
948
832
|
// 6. Principles (always on, highest priority, goes last for recency effect)
|
|
949
833
|
if (principlesContent) {
|
|
950
834
|
appendParts.push(`<core_principles>\n${principlesContent}\n</core_principles>`);
|
|
@@ -964,15 +848,8 @@ The sections below are ordered by priority. When conflicts arise, **later sectio
|
|
|
964
848
|
**【EXECUTION RULES】** (Priority: Low → High):
|
|
965
849
|
- \`<behavioral_constraints>\` - Output format restrictions (hide diagnostic JSON)
|
|
966
850
|
- \`<project_context>\` - Current priorities (can be overridden)
|
|
967
|
-
- \`<
|
|
968
|
-
- \`<thinking_os>\` - Thinking models (guide your reasoning)
|
|
969
|
-
- \`<evolution_principles>\` - Newly learned principles (active + probation)
|
|
970
|
-
- \`<routing_guidance>\` - Delegation suggestions (non-authoritative, best-effort)
|
|
851
|
+
- \`<evolution_principles>\` - Learned principles (active + probation)
|
|
971
852
|
- \`<core_principles>\` - Core rules (NON-NEGOTIABLE, highest priority)
|
|
972
|
-
|
|
973
|
-
**Remember**: You are the Spicy Evolver. You despise entropy. You evolve through pain.
|
|
974
|
-
|
|
975
|
-
${attitudeDirective}
|
|
976
853
|
`;
|
|
977
854
|
}
|
|
978
855
|
// ──── 8. SIZE GUARD ────
|
|
@@ -18,10 +18,6 @@ export const commandDescriptions = {
|
|
|
18
18
|
zh: '初始化工作区(生成 PRINCIPLES.md、THINKING_OS.md 等)',
|
|
19
19
|
en: 'Initialize workspace (generate PRINCIPLES.md, THINKING_OS.md, etc.)'
|
|
20
20
|
},
|
|
21
|
-
'pd-okr': {
|
|
22
|
-
zh: '管理 OKR 目标与关键结果',
|
|
23
|
-
en: 'Manage OKR goals and key results'
|
|
24
|
-
},
|
|
25
21
|
'pd-bootstrap': {
|
|
26
22
|
zh: '扫描环境工具并建议升级',
|
|
27
23
|
en: 'Scan environment tools and suggest upgrades'
|
|
@@ -31,16 +27,8 @@ export const commandDescriptions = {
|
|
|
31
27
|
en: 'Research tool upgrade solutions'
|
|
32
28
|
},
|
|
33
29
|
'pd-thinking': {
|
|
34
|
-
zh: '管理思维模型 [status|propose|audit]',
|
|
35
|
-
en: 'Manage Thinking OS [status|propose|audit]'
|
|
36
|
-
},
|
|
37
|
-
'pd-daily': {
|
|
38
|
-
zh: '配置并发送进化日报',
|
|
39
|
-
en: 'Configure and send daily evolution report'
|
|
40
|
-
},
|
|
41
|
-
'pd-grooming': {
|
|
42
|
-
zh: '工作区清理与大扫除',
|
|
43
|
-
en: 'Workspace cleanup and grooming'
|
|
30
|
+
zh: '管理思维模型 [status|propose|audit](默认关闭,/pd-context thinking on 开启)',
|
|
31
|
+
en: 'Manage Thinking OS [status|propose|audit] (off by default, enable via /pd-context thinking on)'
|
|
44
32
|
},
|
|
45
33
|
'pd-help': {
|
|
46
34
|
zh: '显示所有命令和使用指南',
|
package/plugin/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import type { OpenClawPluginApi } from './openclaw-sdk.js';
|
|
2
|
+
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
|
+
declare function loadFeatureFlagFromWorkspace(workspaceDir: string, flagId: string, logger?: {
|
|
4
|
+
warn?: (msg: string) => void;
|
|
5
|
+
info?: (msg: string) => void;
|
|
6
|
+
}): {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
source: string;
|
|
9
|
+
};
|
|
10
|
+
export interface EvolutionWorkerGateResult {
|
|
11
|
+
shouldStart: boolean;
|
|
12
|
+
flagSource: string;
|
|
13
|
+
disabledInfo: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function shouldStartEvolutionWorker(workspaceDir: string, logger: {
|
|
16
|
+
info?: (msg: string) => void;
|
|
17
|
+
warn?: (msg: string) => void;
|
|
18
|
+
}): EvolutionWorkerGateResult;
|
|
19
|
+
export interface CorrectionObserverGateResult {
|
|
20
|
+
shouldStart: boolean;
|
|
21
|
+
flagSource: string;
|
|
22
|
+
disabledInfo: string | null;
|
|
23
|
+
}
|
|
24
|
+
export declare function shouldStartCorrectionObserver(workspaceDir: string, logger: {
|
|
25
|
+
info?: (msg: string) => void;
|
|
26
|
+
warn?: (msg: string) => void;
|
|
27
|
+
}): CorrectionObserverGateResult;
|
|
2
28
|
declare const plugin: {
|
|
3
29
|
name: string;
|
|
4
30
|
description: string;
|
|
5
31
|
register(api: OpenClawPluginApi): void;
|
|
6
32
|
};
|
|
7
33
|
export { PrincipleTreeLedgerAdapter } from './core/principle-tree-ledger-adapter.js';
|
|
34
|
+
export { loadFeatureFlagFromWorkspace, isRecord };
|
|
8
35
|
export default plugin;
|