@pantion/dialogs 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dialogs/dialog-builder/convergence-rules.md +64 -0
- package/dialogs/dialog-builder/dialog.json +10 -0
- package/dialogs/dialog-builder/prompts/convergence-intro.md +21 -0
- package/dialogs/dialog-builder/prompts/translate-intro.md +17 -0
- package/dialogs/dialog-builder/translate.md +46 -0
- package/dialogs/image/convergence-rules.md +55 -0
- package/dialogs/image/dialog.json +12 -0
- package/dialogs/image/prompts/convergence-intro.md +25 -0
- package/dialogs/image/prompts/translate-intro.md +37 -0
- package/dialogs/image/translate.md +67 -0
- package/dialogs/software/convergence-rules.md +29 -0
- package/dialogs/software/dialog.json +12 -0
- package/dialogs/software/prompts/convergence-intro.md +22 -0
- package/dialogs/software/prompts/translate-intro.md +19 -0
- package/dialogs/software/translate.md +74 -0
- package/dialogs/software-brownfield/convergence-rules.md +109 -0
- package/dialogs/software-brownfield/dialog.json +12 -0
- package/dialogs/software-brownfield/prompts/convergence-intro.md +26 -0
- package/dialogs/software-brownfield/prompts/translate-intro.md +13 -0
- package/dialogs/software-brownfield/translate.md +56 -0
- package/dialogs/video/convergence-rules.md +96 -0
- package/dialogs/video/dialog.json +12 -0
- package/dialogs/video/prompts/convergence-intro.md +28 -0
- package/dialogs/video/prompts/translate-intro.md +41 -0
- package/dialogs/video/translate.md +81 -0
- package/dist/core/canon/index-manager.d.ts +27 -0
- package/dist/core/canon/index-manager.d.ts.map +1 -0
- package/dist/core/canon/index-manager.js +127 -0
- package/dist/core/canon/index-manager.js.map +1 -0
- package/dist/core/canon/manifest.d.ts +21 -0
- package/dist/core/canon/manifest.d.ts.map +1 -0
- package/dist/core/canon/manifest.js +56 -0
- package/dist/core/canon/manifest.js.map +1 -0
- package/dist/core/canon/validator.d.ts +12 -0
- package/dist/core/canon/validator.d.ts.map +1 -0
- package/dist/core/canon/validator.js +320 -0
- package/dist/core/canon/validator.js.map +1 -0
- package/dist/core/dialog/canon-writer.d.ts +22 -0
- package/dist/core/dialog/canon-writer.d.ts.map +1 -0
- package/dist/core/dialog/canon-writer.js +96 -0
- package/dist/core/dialog/canon-writer.js.map +1 -0
- package/dist/core/dialog/registry.d.ts +10 -0
- package/dist/core/dialog/registry.d.ts.map +1 -0
- package/dist/core/dialog/registry.js +102 -0
- package/dist/core/dialog/registry.js.map +1 -0
- package/dist/core/dialog/selector.d.ts +11 -0
- package/dist/core/dialog/selector.d.ts.map +1 -0
- package/dist/core/dialog/selector.js +32 -0
- package/dist/core/dialog/selector.js.map +1 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +30 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/protocol/convergence.d.ts +11 -0
- package/dist/core/protocol/convergence.d.ts.map +1 -0
- package/dist/core/protocol/convergence.js +30 -0
- package/dist/core/protocol/convergence.js.map +1 -0
- package/dist/core/protocol/loader.d.ts +6 -0
- package/dist/core/protocol/loader.d.ts.map +1 -0
- package/dist/core/protocol/loader.js +31 -0
- package/dist/core/protocol/loader.js.map +1 -0
- package/dist/core/protocol/stamp-parser.d.ts +46 -0
- package/dist/core/protocol/stamp-parser.d.ts.map +1 -0
- package/dist/core/protocol/stamp-parser.js +333 -0
- package/dist/core/protocol/stamp-parser.js.map +1 -0
- package/dist/core/protocol/system-prompt.d.ts +16 -0
- package/dist/core/protocol/system-prompt.d.ts.map +1 -0
- package/dist/core/protocol/system-prompt.js +68 -0
- package/dist/core/protocol/system-prompt.js.map +1 -0
- package/dist/core/session/canon-writer.d.ts +33 -0
- package/dist/core/session/canon-writer.d.ts.map +1 -0
- package/dist/core/session/canon-writer.js +152 -0
- package/dist/core/session/canon-writer.js.map +1 -0
- package/dist/core/session/manager.d.ts +10 -0
- package/dist/core/session/manager.d.ts.map +1 -0
- package/dist/core/session/manager.js +105 -0
- package/dist/core/session/manager.js.map +1 -0
- package/dist/core/skill/canon-writer.d.ts +22 -0
- package/dist/core/skill/canon-writer.d.ts.map +1 -0
- package/dist/core/skill/canon-writer.js +96 -0
- package/dist/core/skill/canon-writer.js.map +1 -0
- package/dist/core/skill/registry.d.ts +10 -0
- package/dist/core/skill/registry.d.ts.map +1 -0
- package/dist/core/skill/registry.js +102 -0
- package/dist/core/skill/registry.js.map +1 -0
- package/dist/core/skill/selector.d.ts +11 -0
- package/dist/core/skill/selector.d.ts.map +1 -0
- package/dist/core/skill/selector.js +32 -0
- package/dist/core/skill/selector.js.map +1 -0
- package/dist/core/soul/registry.d.ts +10 -0
- package/dist/core/soul/registry.d.ts.map +1 -0
- package/dist/core/soul/registry.js +73 -0
- package/dist/core/soul/registry.js.map +1 -0
- package/dist/core/types.d.ts +154 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/utils/fs.d.ts +14 -0
- package/dist/core/utils/fs.d.ts.map +1 -0
- package/dist/core/utils/fs.js +44 -0
- package/dist/core/utils/fs.js.map +1 -0
- package/dist/core/utils/project-detect.d.ts +3 -0
- package/dist/core/utils/project-detect.d.ts.map +1 -0
- package/dist/core/utils/project-detect.js +38 -0
- package/dist/core/utils/project-detect.js.map +1 -0
- package/dist/feature-set.d.ts +14 -0
- package/dist/feature-set.d.ts.map +1 -0
- package/dist/feature-set.js +38 -0
- package/dist/feature-set.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/convergence-prompts.d.ts +4 -0
- package/dist/prompts/convergence-prompts.d.ts.map +1 -0
- package/dist/prompts/convergence-prompts.js +76 -0
- package/dist/prompts/convergence-prompts.js.map +1 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +7 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/workflow-prompts.d.ts +9 -0
- package/dist/prompts/workflow-prompts.d.ts.map +1 -0
- package/dist/prompts/workflow-prompts.js +265 -0
- package/dist/prompts/workflow-prompts.js.map +1 -0
- package/dist/resources/canon-resources.d.ts +4 -0
- package/dist/resources/canon-resources.d.ts.map +1 -0
- package/dist/resources/canon-resources.js +164 -0
- package/dist/resources/canon-resources.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +47 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/amend.d.ts +4 -0
- package/dist/tools/amend.d.ts.map +1 -0
- package/dist/tools/amend.js +106 -0
- package/dist/tools/amend.js.map +1 -0
- package/dist/tools/approve.d.ts +4 -0
- package/dist/tools/approve.d.ts.map +1 -0
- package/dist/tools/approve.js +60 -0
- package/dist/tools/approve.js.map +1 -0
- package/dist/tools/check-convergence.d.ts +4 -0
- package/dist/tools/check-convergence.d.ts.map +1 -0
- package/dist/tools/check-convergence.js +50 -0
- package/dist/tools/check-convergence.js.map +1 -0
- package/dist/tools/check.d.ts +4 -0
- package/dist/tools/check.d.ts.map +1 -0
- package/dist/tools/check.js +190 -0
- package/dist/tools/check.js.map +1 -0
- package/dist/tools/create-dialog.d.ts +4 -0
- package/dist/tools/create-dialog.d.ts.map +1 -0
- package/dist/tools/create-dialog.js +58 -0
- package/dist/tools/create-dialog.js.map +1 -0
- package/dist/tools/create-skill.d.ts +4 -0
- package/dist/tools/create-skill.d.ts.map +1 -0
- package/dist/tools/create-skill.js +58 -0
- package/dist/tools/create-skill.js.map +1 -0
- package/dist/tools/decompose.d.ts +4 -0
- package/dist/tools/decompose.d.ts.map +1 -0
- package/dist/tools/decompose.js +56 -0
- package/dist/tools/decompose.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +49 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-canons.d.ts +4 -0
- package/dist/tools/list-canons.d.ts.map +1 -0
- package/dist/tools/list-canons.js +28 -0
- package/dist/tools/list-canons.js.map +1 -0
- package/dist/tools/migrate.d.ts +4 -0
- package/dist/tools/migrate.d.ts.map +1 -0
- package/dist/tools/migrate.js +38 -0
- package/dist/tools/migrate.js.map +1 -0
- package/dist/tools/onboard.d.ts +4 -0
- package/dist/tools/onboard.d.ts.map +1 -0
- package/dist/tools/onboard.js +27 -0
- package/dist/tools/onboard.js.map +1 -0
- package/dist/tools/reconverge.d.ts +4 -0
- package/dist/tools/reconverge.d.ts.map +1 -0
- package/dist/tools/reconverge.js +68 -0
- package/dist/tools/reconverge.js.map +1 -0
- package/dist/tools/redialog.d.ts +4 -0
- package/dist/tools/redialog.d.ts.map +1 -0
- package/dist/tools/redialog.js +63 -0
- package/dist/tools/redialog.js.map +1 -0
- package/dist/tools/reflect.d.ts +4 -0
- package/dist/tools/reflect.d.ts.map +1 -0
- package/dist/tools/reflect.js +86 -0
- package/dist/tools/reflect.js.map +1 -0
- package/dist/tools/reject.d.ts +4 -0
- package/dist/tools/reject.d.ts.map +1 -0
- package/dist/tools/reject.js +57 -0
- package/dist/tools/reject.js.map +1 -0
- package/dist/tools/reskill.d.ts +4 -0
- package/dist/tools/reskill.d.ts.map +1 -0
- package/dist/tools/reskill.js +63 -0
- package/dist/tools/reskill.js.map +1 -0
- package/dist/tools/resume.d.ts +4 -0
- package/dist/tools/resume.d.ts.map +1 -0
- package/dist/tools/resume.js +56 -0
- package/dist/tools/resume.js.map +1 -0
- package/dist/tools/reverse.d.ts +4 -0
- package/dist/tools/reverse.d.ts.map +1 -0
- package/dist/tools/reverse.js +32 -0
- package/dist/tools/reverse.js.map +1 -0
- package/dist/tools/save-canon.d.ts +4 -0
- package/dist/tools/save-canon.d.ts.map +1 -0
- package/dist/tools/save-canon.js +97 -0
- package/dist/tools/save-canon.js.map +1 -0
- package/dist/tools/start.d.ts +4 -0
- package/dist/tools/start.d.ts.map +1 -0
- package/dist/tools/start.js +83 -0
- package/dist/tools/start.js.map +1 -0
- package/dist/tools/translate.d.ts +4 -0
- package/dist/tools/translate.d.ts.map +1 -0
- package/dist/tools/translate.js +102 -0
- package/dist/tools/translate.js.map +1 -0
- package/dist/tools/update.d.ts +4 -0
- package/dist/tools/update.d.ts.map +1 -0
- package/dist/tools/update.js +42 -0
- package/dist/tools/update.js.map +1 -0
- package/dist/tools/validate.d.ts +4 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +86 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/utils/response.d.ts +12 -0
- package/dist/utils/response.d.ts.map +1 -0
- package/dist/utils/response.js +18 -0
- package/dist/utils/response.js.map +1 -0
- package/package.json +37 -0
- package/protocol/commands/amend.md +188 -0
- package/protocol/commands/build.md +90 -0
- package/protocol/commands/check.md +255 -0
- package/protocol/commands/create-dialog.md +81 -0
- package/protocol/commands/decompose.md +230 -0
- package/protocol/commands/dialog.md +173 -0
- package/protocol/commands/help.md +121 -0
- package/protocol/commands/migrate.md +173 -0
- package/protocol/commands/onboard.md +210 -0
- package/protocol/commands/quick.md +170 -0
- package/protocol/commands/redialog.md +73 -0
- package/protocol/commands/reflect.md +136 -0
- package/protocol/commands/resume.md +148 -0
- package/protocol/commands/reverse.md +312 -0
- package/protocol/commands/start.md +220 -0
- package/protocol/commands/translate.md +157 -0
- package/protocol/commands/update.md +205 -0
- package/protocol/core-advanced.md +188 -0
- package/protocol/core.md +274 -0
- package/protocol/pantion-future-prompt.md +88 -0
- package/protocol/pantion-intent.md +78 -0
- package/protocol/templates/acceptance-tests.md +116 -0
- package/protocol/templates/behavior-map.md +135 -0
- package/protocol/templates/traceability-map.md +56 -0
- package/souls/beginner/rules.md +34 -0
- package/souls/beginner/soul.json +6 -0
- package/souls/default/rules.md +25 -0
- package/souls/default/soul.json +6 -0
- package/souls/young/rules.md +67 -0
- package/souls/young/soul.json +6 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { appendRealityConvergence, readFileSafe, canonDir, readCanonIndex, } from '../core/index.js';
|
|
4
|
+
import { success, error } from '../utils/response.js';
|
|
5
|
+
const messageSchema = z.object({
|
|
6
|
+
role: z.enum(['user', 'assistant']),
|
|
7
|
+
content: z.string(),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Analyze impact: which other canons and derived files may be affected.
|
|
11
|
+
*/
|
|
12
|
+
function analyzeImpact(canonName, projectPath) {
|
|
13
|
+
const dir = canonDir(projectPath);
|
|
14
|
+
const allCanons = readCanonIndex(projectPath);
|
|
15
|
+
const affectedCanons = [];
|
|
16
|
+
const filesToRegenerate = [];
|
|
17
|
+
// Check if any other canons reference this one as parent
|
|
18
|
+
for (const canon of allCanons) {
|
|
19
|
+
if (canon.name === canonName)
|
|
20
|
+
continue;
|
|
21
|
+
const dialogPath = resolve(dir, canon.name, 'dialog.md');
|
|
22
|
+
const dialog = readFileSafe(dialogPath);
|
|
23
|
+
if (!dialog)
|
|
24
|
+
continue;
|
|
25
|
+
const parentMatch = dialog.match(/PARENT:\s*(.+)/i);
|
|
26
|
+
if (parentMatch) {
|
|
27
|
+
const parent = parentMatch[1].trim().toLowerCase();
|
|
28
|
+
if (parent.includes(canonName.toLowerCase()) || parent.includes(`${canonName}-dialog`) || parent.includes(`${canonName}/dialog`)) {
|
|
29
|
+
affectedCanons.push(canon.name);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Check traceability for files that may need review
|
|
34
|
+
const traceabilityPath = resolve(dir, canonName, 'traceability.md');
|
|
35
|
+
const traceability = readFileSafe(traceabilityPath);
|
|
36
|
+
if (traceability) {
|
|
37
|
+
const fileRefs = traceability.match(/(?:spec\/|canon\/)[^\s|)]+\.md/g) ?? [];
|
|
38
|
+
for (const ref of fileRefs) {
|
|
39
|
+
filesToRegenerate.push(ref);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let consistencyWarning;
|
|
43
|
+
if (affectedCanons.length > 0) {
|
|
44
|
+
consistencyWarning = `This canon is referenced as parent by ${affectedCanons.length} other canon(s): ${affectedCanons.join(', ')}. Consider reviewing child canons for consistency.`;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
affected_canons: affectedCanons,
|
|
48
|
+
files_to_regenerate: [...new Set(filesToRegenerate)],
|
|
49
|
+
consistency_warning: consistencyWarning,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function registerReflect(server, context) {
|
|
53
|
+
server.tool('pantion_reflect', 'Append a Reality Convergence block to an existing canon. Captures empirical observations from a built implementation. Observational only — records, classifies, and creates open questions but does NOT modify intent. Intent changes require a separate pantion_amend.', {
|
|
54
|
+
canon_name: z.string().describe('Name of the canon to reflect on'),
|
|
55
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
56
|
+
reflection_dialog: z.array(messageSchema).describe('The reality convergence dialog to append'),
|
|
57
|
+
stamp: z.string().describe('Raw reality convergence stamp (REALITY STAMP block)'),
|
|
58
|
+
}, async ({ canon_name, project_path, reflection_dialog, stamp }) => {
|
|
59
|
+
try {
|
|
60
|
+
const projectPath = project_path ?? context.projectPath;
|
|
61
|
+
// Analyze impact before appending
|
|
62
|
+
const impact = analyzeImpact(canon_name, projectPath);
|
|
63
|
+
// Append the Reality Convergence block (observational — does not change intent)
|
|
64
|
+
const canonPath = appendRealityConvergence(canon_name, projectPath, reflection_dialog, stamp);
|
|
65
|
+
// NOTE: Reality Convergence does NOT reset the HUMAN STAMP.
|
|
66
|
+
// It is observational only — it records, classifies, and creates open questions.
|
|
67
|
+
// Intent changes require a separate pantion_amend with HUMAN STAMP approval.
|
|
68
|
+
// NOTE: Reality Convergence does NOT change the canon lifecycle status.
|
|
69
|
+
// The canon remains CONVERGED/AMENDED/etc. The REALITY STAMP is an overlay.
|
|
70
|
+
return success({
|
|
71
|
+
appended: true,
|
|
72
|
+
canon_path: canonPath,
|
|
73
|
+
impact_analysis: {
|
|
74
|
+
affected_canons: impact.affected_canons.length > 0 ? impact.affected_canons : undefined,
|
|
75
|
+
files_to_regenerate: impact.files_to_regenerate.length > 0 ? impact.files_to_regenerate : undefined,
|
|
76
|
+
consistency_warning: impact.consistency_warning,
|
|
77
|
+
},
|
|
78
|
+
next_steps: 'Review observations and open questions. Use pantion_amend to apply intent changes where needed (requires HUMAN STAMP approval).',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=reflect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflect.js","sourceRoot":"","sources":["../../src/tools/reflect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,aAAa,CACpB,SAAiB,EACjB,WAAmB;IAEnB,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,yDAAyD;IACzD,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC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C,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;oBACvF,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS;oBACnG,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;iBAChD;gBACD,UAAU,EAAE,iIAAiI;aAC9I,CAAC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reject.d.ts","sourceRoot":"","sources":["../../src/tools/reject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAclD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CA6D9E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { readFileSafe, canonDir, extractConvergenceStamp, extractHumanStamp, formatHumanStamp, replaceHumanStamp, writeFile, assertSafeName, } from '../core/index.js';
|
|
4
|
+
import { success, error } from '../utils/response.js';
|
|
5
|
+
export function registerReject(server, context) {
|
|
6
|
+
server.tool('pantion_reject', 'Reject a converged canon. Fills in the HUMAN STAMP with REJECTED status. A rejected canon can be approved later after changes (amend/redialog).', {
|
|
7
|
+
canon_name: z.string().describe('Name of the canon to reject'),
|
|
8
|
+
role: z.string().describe('Role of the reviewer (e.g. "Product Owner", "Opdrachtgever")'),
|
|
9
|
+
note: z.string().optional().describe('Optional note explaining the rejection'),
|
|
10
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
11
|
+
}, async ({ canon_name, role, note, project_path }) => {
|
|
12
|
+
try {
|
|
13
|
+
const projectPath = project_path ?? context.projectPath;
|
|
14
|
+
assertSafeName(canon_name);
|
|
15
|
+
const dir = canonDir(projectPath);
|
|
16
|
+
const dialogPath = resolve(dir, canon_name, 'dialog.md');
|
|
17
|
+
const content = readFileSafe(dialogPath);
|
|
18
|
+
if (!content) {
|
|
19
|
+
return error(`Canon dialog not found: ${canon_name}`);
|
|
20
|
+
}
|
|
21
|
+
const stamp = extractConvergenceStamp(content);
|
|
22
|
+
if (!stamp || stamp.type === 'draft') {
|
|
23
|
+
return error('Canon is not converged. Only converged canons can be rejected.');
|
|
24
|
+
}
|
|
25
|
+
const date = new Date().toISOString().split('T')[0];
|
|
26
|
+
const newStamp = formatHumanStamp({
|
|
27
|
+
status: 'REJECTED',
|
|
28
|
+
date,
|
|
29
|
+
role,
|
|
30
|
+
note: note ?? '[not set]',
|
|
31
|
+
});
|
|
32
|
+
let updated;
|
|
33
|
+
const humanStamp = extractHumanStamp(content);
|
|
34
|
+
if (humanStamp) {
|
|
35
|
+
updated = replaceHumanStamp(content, newStamp);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
updated = content + '\n\n' + newStamp + '\n';
|
|
39
|
+
}
|
|
40
|
+
if (!updated) {
|
|
41
|
+
return error('Failed to update HUMAN STAMP in dialog file.');
|
|
42
|
+
}
|
|
43
|
+
writeFile(dialogPath, updated);
|
|
44
|
+
return success({
|
|
45
|
+
rejected: true,
|
|
46
|
+
canon_name,
|
|
47
|
+
date,
|
|
48
|
+
role,
|
|
49
|
+
note: note ?? undefined,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=reject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reject.js","sourceRoot":"","sources":["../../src/tools/reject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,OAAsB;IACtE,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,iJAAiJ,EACjJ;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QAC9D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;QACzF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QAC9E,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;KACpG,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;YACxD,cAAc,CAAC,UAAU,CAAC,CAAC;YAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,OA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AAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reskill.d.ts","sourceRoot":"","sources":["../../src/tools/reskill.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAalD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAuE/E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { readSkillCanonDialog, skillHasCanon, extractConvergenceStamp, assembleSystemPrompt, createSession, saveSession, getSkill, assertSafeName, } from '../core/index.js';
|
|
3
|
+
import { success, error } from '../utils/response.js';
|
|
4
|
+
export function registerReskill(server, context) {
|
|
5
|
+
server.tool('pantion_reskill', 'Re-evaluate an existing dynamic skill canon with a better model. Reads the skill-canon, provides gap analysis instructions, and creates a session for supplementary convergence.', {
|
|
6
|
+
skill_name: z.string().describe('Name of the skill to reskill'),
|
|
7
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
8
|
+
}, async ({ skill_name, project_path }) => {
|
|
9
|
+
try {
|
|
10
|
+
assertSafeName(skill_name);
|
|
11
|
+
const projectPath = project_path ?? context.projectPath;
|
|
12
|
+
// Verify skill exists and has a canon
|
|
13
|
+
if (!skillHasCanon(projectPath, skill_name)) {
|
|
14
|
+
const skill = getSkill(skill_name, projectPath, context.skillsDir);
|
|
15
|
+
if (skill) {
|
|
16
|
+
return error(`Skill "${skill_name}" exists but has no canon (it is a hand-crafted skill). Use pantion_create-skill to create a dynamic version.`);
|
|
17
|
+
}
|
|
18
|
+
return error(`Skill "${skill_name}" not found or has no canon.`);
|
|
19
|
+
}
|
|
20
|
+
const dialog = readSkillCanonDialog(projectPath, skill_name);
|
|
21
|
+
if (!dialog) {
|
|
22
|
+
return error(`Could not read skill canon dialog for "${skill_name}".`);
|
|
23
|
+
}
|
|
24
|
+
const stamp = extractConvergenceStamp(dialog);
|
|
25
|
+
if (!stamp) {
|
|
26
|
+
return error('No convergence stamp found in skill canon. This skill may be a DRAFT — use pantion_resume instead.');
|
|
27
|
+
}
|
|
28
|
+
if (stamp.type === 'draft') {
|
|
29
|
+
return error('Skill canon is still a DRAFT. Resume the skill creation dialog first.');
|
|
30
|
+
}
|
|
31
|
+
const statusMatch = stamp.raw.match(/STATUS:\s*(.+)/);
|
|
32
|
+
const displayStatus = statusMatch ? statusMatch[1].trim() : stamp.type;
|
|
33
|
+
// Load skill-builder rules for the reconverge prompt
|
|
34
|
+
const skillBuilder = getSkill('skill-builder', projectPath, context.skillsDir);
|
|
35
|
+
// Assemble reconverge system prompt with skill-builder context
|
|
36
|
+
const convergenceInstructions = assembleSystemPrompt({
|
|
37
|
+
mode: 'reconverge',
|
|
38
|
+
existingDialog: dialog,
|
|
39
|
+
canonName: `skill:${skill_name}`,
|
|
40
|
+
skillRules: skillBuilder?.convergenceRules,
|
|
41
|
+
protocolDir: context.protocolDir,
|
|
42
|
+
});
|
|
43
|
+
// Create session for the reskill work
|
|
44
|
+
const session = createSession(projectPath, `reskill-${skill_name}`, convergenceInstructions);
|
|
45
|
+
session.canonType = 'skill';
|
|
46
|
+
session.targetSkillName = skill_name;
|
|
47
|
+
session.skill = 'skill-builder';
|
|
48
|
+
saveSession(projectPath, session);
|
|
49
|
+
return success({
|
|
50
|
+
dialog,
|
|
51
|
+
current_status: displayStatus,
|
|
52
|
+
skill_name,
|
|
53
|
+
session_id: session.id,
|
|
54
|
+
convergence_instructions: convergenceInstructions,
|
|
55
|
+
message: `Skill canon "${skill_name}" loaded for reconvergence. Status: ${displayStatus}. Analyze the skill dialog for gaps in domain knowledge before conducting supplementary convergence.`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=reskill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reskill.js","sourceRoot":"","sources":["../../src/tools/reskill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,OAAsB;IACvE,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,kLAAkL,EAClL;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QAC/D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;KACpG,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,cAAc,CAAC,UAAU,CAAC,CAAC;YAC3B,MAAM,WAAW,GAAG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;YAExD,sCAAsC;YACtC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC;gBAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,C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E,WAAW,UAAU,EAAE,EAAE,uBAAuB,CAAC,CAAC;YAC7F,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;YAC5B,OAAO,CAAC,eAAe,GAAG,UAAU,CAAC;YACrC,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC;YAChC,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAElC,OAAO,OAAO,CAAC;gBACb,MAAM;gBACN,cAAc,EAAE,aAAa;gBAC7B,UAAU;gBACV,UAAU,EAAE,OAAO,CAAC,EAAE;gBACtB,wBAAwB,EAAE,uBAAuB;gBACjD,OAAO,EAAE,gBAAgB,UAAU,uCAAuC,aAAa,sGAAsG;aAC9L,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../src/tools/resume.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAelD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CA2D9E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { readFileSafe, canonDir, extractConvergenceStamp, extractProgressStamp, assembleSystemPrompt, createSession, saveSession, assertSafeName, } from '../core/index.js';
|
|
4
|
+
import { success, error } from '../utils/response.js';
|
|
5
|
+
export function registerResume(server, context) {
|
|
6
|
+
server.tool('pantion_resume', 'Resume a DRAFT canon for continued convergence. Returns the existing dialog and convergence instructions.', {
|
|
7
|
+
canon_name: z.string().describe('Name of the canon to resume'),
|
|
8
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
9
|
+
}, async ({ canon_name, project_path }) => {
|
|
10
|
+
try {
|
|
11
|
+
const projectPath = project_path ?? context.projectPath;
|
|
12
|
+
assertSafeName(canon_name);
|
|
13
|
+
const dir = canonDir(projectPath);
|
|
14
|
+
const dialogPath = resolve(dir, canon_name, 'dialog.md');
|
|
15
|
+
const dialog = readFileSafe(dialogPath);
|
|
16
|
+
if (!dialog) {
|
|
17
|
+
return error(`Canon dialog not found: ${dialogPath}`);
|
|
18
|
+
}
|
|
19
|
+
// Extract open questions from stamp
|
|
20
|
+
let openQuestions = [];
|
|
21
|
+
const convergenceStamp = extractConvergenceStamp(dialog);
|
|
22
|
+
if (convergenceStamp) {
|
|
23
|
+
openQuestions = convergenceStamp.openQuestions;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const progressStamp = extractProgressStamp(dialog);
|
|
27
|
+
if (progressStamp) {
|
|
28
|
+
openQuestions = progressStamp.openQuestions;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Extract inference policy from stamp (if available)
|
|
32
|
+
const inferencePolicy = convergenceStamp?.inferencePolicy;
|
|
33
|
+
// Assemble resume system prompt
|
|
34
|
+
const convergenceInstructions = assembleSystemPrompt({
|
|
35
|
+
mode: 'resume',
|
|
36
|
+
existingDialog: dialog,
|
|
37
|
+
protocolDir: context.protocolDir,
|
|
38
|
+
inferencePolicy: inferencePolicy === 'strict' ? 'strict' : undefined,
|
|
39
|
+
});
|
|
40
|
+
// Create a new session for the resumed work
|
|
41
|
+
const session = createSession(projectPath, `resume-${canon_name}`, convergenceInstructions);
|
|
42
|
+
session.canonName = canon_name;
|
|
43
|
+
saveSession(projectPath, session);
|
|
44
|
+
return success({
|
|
45
|
+
dialog,
|
|
46
|
+
open_questions: openQuestions,
|
|
47
|
+
session_id: session.id,
|
|
48
|
+
convergence_instructions: convergenceInstructions,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","sourceRoot":"","sources":["../../src/tools/resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,WAAW,EAEX,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,OAAsB;IACtE,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,2GAA2G,EAC3G;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QAC9D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;KACpG,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC;YACL,MAAM,WAAW,GAAG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;YACxD,cAAc,CAAC,UAAU,CAAC,CAAC;YAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;YAEzD,MAAM,MA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K,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/tools/reverse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQlD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAkC/E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { assembleSystemPrompt, createSession, saveSession, } from '../core/index.js';
|
|
3
|
+
import { success, error } from '../utils/response.js';
|
|
4
|
+
export function registerReverse(server, context) {
|
|
5
|
+
server.tool('pantion_reverse', 'Start a reverse Pantion session: extract intent from an existing codebase and reconstruct it as a DialogSpec Canon. The client LLM scans the code and produces a synthetic dialog.', {
|
|
6
|
+
canon_name: z.string().optional().describe('Name for the resulting canon (default: "reverse")'),
|
|
7
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
8
|
+
}, async ({ canon_name, project_path }) => {
|
|
9
|
+
try {
|
|
10
|
+
const projectPath = project_path ?? context.projectPath;
|
|
11
|
+
const name = canon_name ?? 'reverse';
|
|
12
|
+
const convergenceInstructions = assembleSystemPrompt({
|
|
13
|
+
mode: 'reverse',
|
|
14
|
+
canonName: name,
|
|
15
|
+
protocolDir: context.protocolDir,
|
|
16
|
+
});
|
|
17
|
+
const session = createSession(projectPath, `reverse-${name}`, convergenceInstructions);
|
|
18
|
+
session.canonName = name;
|
|
19
|
+
saveSession(projectPath, session);
|
|
20
|
+
return success({
|
|
21
|
+
session_id: session.id,
|
|
22
|
+
canon_name: name,
|
|
23
|
+
convergence_instructions: convergenceInstructions,
|
|
24
|
+
message: `Reverse Pantion session started. Follow the reverse protocol: scan the codebase, extract intent, classify HARD/FLEX, and produce a synthetic DialogSpec Canon.`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=reverse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/tools/reverse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,OAAsB;IACvE,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,oLAAoL,EACpL;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;QAC/F,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;KACpG,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC;YACL,MAAM,WAAW,GAAG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;YACxD,MAAM,IAAI,GAAG,UAAU,IAAI,SAAS,CAAC;YAErC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;gBACnD,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,IAAI;gBACf,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,uBAAuB,CAAC,CAAC;YACvF,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;YACzB,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAElC,OAAO,OAAO,CAAC;gBACb,UAAU,EAAE,OAAO,CAAC,EAAE;gBACtB,UAAU,EAAE,IAAI;gBAChB,wBAAwB,EAAE,uBAAuB;gBACjD,OAAO,EAAE,gKAAgK;aAC1K,CAAC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-canon.d.ts","sourceRoot":"","sources":["../../src/tools/save-canon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmBlD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CA+FjF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadSession, saveSession, writeDialogFile, writeSummaryFile, updateCanonIndex, writeDialogCanonFile, writeDialogSummaryFile, extractConvergenceStamp, } from '../core/index.js';
|
|
3
|
+
import { success, error } from '../utils/response.js';
|
|
4
|
+
const messageSchema = z.object({
|
|
5
|
+
role: z.enum(['user', 'assistant']),
|
|
6
|
+
content: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export function registerSaveCanon(server, context) {
|
|
9
|
+
server.tool('pantion_save-canon', 'Write canon files to disk after convergence. Writes the dialog file (THE CANON) and optionally a summary.', {
|
|
10
|
+
session_id: z.string().describe('Session ID from pantion_start'),
|
|
11
|
+
dialog: z.array(messageSchema).describe('The full converged dialog'),
|
|
12
|
+
name: z.string().describe('Canon name (e.g. "my-project")'),
|
|
13
|
+
summary: z.string().optional().describe('Client-generated summary content'),
|
|
14
|
+
dialog_name: z.string().optional().describe('Target dialog name — writes to dialogs/{name}/canon/ instead of canon/'),
|
|
15
|
+
mode: z.enum(['dialog', 'full']).optional().describe('Convergence mode used. Dialog mode auto-approves the canon.'),
|
|
16
|
+
check_result: z.string().optional().describe('Last pantion_check result summary (e.g. "PASS (12/13)")'),
|
|
17
|
+
}, async ({ session_id, dialog, name, summary, dialog_name, mode, check_result }) => {
|
|
18
|
+
try {
|
|
19
|
+
const projectPath = context.projectPath;
|
|
20
|
+
const date = new Date().toISOString().split('T')[0];
|
|
21
|
+
const messages = dialog.map((m) => ({ role: m.role, content: m.content }));
|
|
22
|
+
// Check for convergence stamp (blocking error if missing)
|
|
23
|
+
const fullText = dialog.map((m) => m.content).join('\n');
|
|
24
|
+
const stamp = extractConvergenceStamp(fullText);
|
|
25
|
+
if (!stamp) {
|
|
26
|
+
return error('Dialog does not contain a DIALOGSPEC STAMP. A converged stamp is required to save a canon.');
|
|
27
|
+
}
|
|
28
|
+
if (stamp.type === 'draft') {
|
|
29
|
+
return error('Dialog contains a DRAFT stamp. Only converged dialogs can be saved as canon. Use pantion_resume to continue convergence.');
|
|
30
|
+
}
|
|
31
|
+
// Update session
|
|
32
|
+
const session = loadSession(projectPath, session_id);
|
|
33
|
+
if (session) {
|
|
34
|
+
session.messages = messages;
|
|
35
|
+
session.canonName = name;
|
|
36
|
+
session.status = 'converged';
|
|
37
|
+
if (dialog_name) {
|
|
38
|
+
session.canonType = 'dialog';
|
|
39
|
+
session.targetDialogName = dialog_name;
|
|
40
|
+
}
|
|
41
|
+
saveSession(projectPath, session);
|
|
42
|
+
}
|
|
43
|
+
// Build a session-like object for the canon writer
|
|
44
|
+
const sessionForWriter = session ?? {
|
|
45
|
+
id: session_id,
|
|
46
|
+
name,
|
|
47
|
+
status: 'converged',
|
|
48
|
+
messages,
|
|
49
|
+
systemPrompt: '',
|
|
50
|
+
createdAt: new Date().toISOString(),
|
|
51
|
+
updatedAt: new Date().toISOString(),
|
|
52
|
+
canonName: name,
|
|
53
|
+
};
|
|
54
|
+
// Build canon metadata from session state + parameters
|
|
55
|
+
const metadata = {};
|
|
56
|
+
if (session?.dialog)
|
|
57
|
+
metadata.dialog = session.dialog;
|
|
58
|
+
if (session?.soul)
|
|
59
|
+
metadata.soul = session.soul;
|
|
60
|
+
if (mode)
|
|
61
|
+
metadata.mode = mode;
|
|
62
|
+
if (check_result)
|
|
63
|
+
metadata.checkResult = check_result;
|
|
64
|
+
const hasMetadata = Object.keys(metadata).length > 0;
|
|
65
|
+
let canonPath;
|
|
66
|
+
let summaryPath;
|
|
67
|
+
if (dialog_name) {
|
|
68
|
+
// Dialog canon → dialogs/{dialog_name}/canon/
|
|
69
|
+
canonPath = writeDialogCanonFile(sessionForWriter, dialog_name, date, projectPath, mode, hasMetadata ? metadata : undefined);
|
|
70
|
+
if (summary) {
|
|
71
|
+
summaryPath = writeDialogSummaryFile(dialog_name, date, summary, projectPath);
|
|
72
|
+
}
|
|
73
|
+
// Dialog canons do NOT go in the project canon index
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Project canon → canon/ (existing behavior)
|
|
77
|
+
canonPath = writeDialogFile(sessionForWriter, name, date, projectPath, mode, hasMetadata ? metadata : undefined);
|
|
78
|
+
if (summary) {
|
|
79
|
+
summaryPath = writeSummaryFile(name, date, summary, projectPath);
|
|
80
|
+
}
|
|
81
|
+
updateCanonIndex(name, 'converged', date, projectPath);
|
|
82
|
+
}
|
|
83
|
+
return success({
|
|
84
|
+
canon_path: canonPath,
|
|
85
|
+
summary_path: summaryPath,
|
|
86
|
+
index_updated: !dialog_name,
|
|
87
|
+
dialog_name: dialog_name ?? undefined,
|
|
88
|
+
stamp_type: stamp.type,
|
|
89
|
+
stamp_model: stamp.model,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=save-canon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-canon.js","sourceRoot":"","sources":["../../src/tools/save-canon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,OAAsB;IACzE,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,2GAA2G,EAC3G;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QAChE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QACpE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,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CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/tools/start.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAYlD,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAwF7E"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { autoSelectDialog, listDialogs, getDialog, assembleSystemPrompt, createSession, saveSession, getSoul, } from '../core/index.js';
|
|
3
|
+
import { success, error } from '../utils/response.js';
|
|
4
|
+
export function registerStart(server, context) {
|
|
5
|
+
server.tool('pantion_start', 'Start a new Pantion dialog session. Returns convergence instructions for the client LLM.', {
|
|
6
|
+
project_path: z.string().optional().describe('Project directory (defaults to server project path)'),
|
|
7
|
+
dialog: z.string().optional().describe('Explicit dialog name to use (e.g. "dating-profile", "software")'),
|
|
8
|
+
domain: z.string().optional().describe('Domain hint for dialog auto-selection (e.g. "software", "image")'),
|
|
9
|
+
user_message: z.string().optional().describe('The user\'s original message — used for dialog auto-selection via keyword matching'),
|
|
10
|
+
soul: z.string().optional().describe('Interaction style (e.g. "default", "beginner", "young")'),
|
|
11
|
+
mode: z.enum(['dialog', 'full']).default('full').describe('Convergence mode: "full" (default, complete protocol) or "dialog" (fast, conservative assumptions)'),
|
|
12
|
+
}, async ({ project_path, dialog: dialogName, domain, user_message, soul, mode }) => {
|
|
13
|
+
try {
|
|
14
|
+
const projectPath = project_path ?? context.projectPath;
|
|
15
|
+
// Select dialog: explicit name > domain hint > user message keywords
|
|
16
|
+
let selection = dialogName
|
|
17
|
+
? (() => {
|
|
18
|
+
const s = getDialog(dialogName, projectPath, context.dialogsDir);
|
|
19
|
+
return s ? { dialog: s, matchedKeywords: [dialogName] } : null;
|
|
20
|
+
})()
|
|
21
|
+
: null;
|
|
22
|
+
if (!selection) {
|
|
23
|
+
const selectionInput = domain ?? user_message;
|
|
24
|
+
selection = selectionInput
|
|
25
|
+
? autoSelectDialog(selectionInput, projectPath, context.dialogsDir)
|
|
26
|
+
: null;
|
|
27
|
+
}
|
|
28
|
+
// If no dialog matched, list available dialogs for the client to present
|
|
29
|
+
const availableDialogs = !selection
|
|
30
|
+
? listDialogs(projectPath, context.dialogsDir)
|
|
31
|
+
.filter((s) => s.manifest.name !== 'dialog-builder')
|
|
32
|
+
.map((s) => ({ name: s.manifest.name, displayName: s.manifest.displayName, description: s.manifest.description }))
|
|
33
|
+
: undefined;
|
|
34
|
+
// Load soul (default if not specified)
|
|
35
|
+
const soulObj = soul
|
|
36
|
+
? getSoul(soul, projectPath, context.soulsDir)
|
|
37
|
+
: getSoul('default', projectPath, context.soulsDir);
|
|
38
|
+
// Assemble convergence instructions (system prompt for client LLM)
|
|
39
|
+
const promptMode = mode === 'full' ? 'start' : 'dialog';
|
|
40
|
+
const convergenceInstructions = assembleSystemPrompt({
|
|
41
|
+
mode: promptMode,
|
|
42
|
+
dialogRules: selection?.dialog.convergenceRules,
|
|
43
|
+
soulRules: soulObj?.rules,
|
|
44
|
+
protocolDir: context.protocolDir,
|
|
45
|
+
});
|
|
46
|
+
// Create a session
|
|
47
|
+
const sessionName = `session-${Date.now()}`;
|
|
48
|
+
const session = createSession(projectPath, sessionName, convergenceInstructions);
|
|
49
|
+
if (selection || soulObj) {
|
|
50
|
+
if (selection)
|
|
51
|
+
session.dialog = selection.dialog.manifest.name;
|
|
52
|
+
if (soulObj)
|
|
53
|
+
session.soul = soulObj.manifest.name;
|
|
54
|
+
saveSession(projectPath, session);
|
|
55
|
+
}
|
|
56
|
+
const firstQuestion = selection
|
|
57
|
+
? `I've selected the **${selection.dialog.manifest.displayName}** dialog (matched: ${selection.matchedKeywords.join(', ')}). What would you like to build?`
|
|
58
|
+
: availableDialogs && availableDialogs.length > 0
|
|
59
|
+
? `Welcome to Pantion. I couldn't determine the domain from your description. Available domains: ${availableDialogs.map((s) => `**${s.displayName}**`).join(', ')}. Which fits best, or shall I proceed with a general convergence?`
|
|
60
|
+
: 'Welcome to Pantion. Describe in your own words what you want to build. Be as free as you like — I will ask the right questions to turn your idea into an unambiguous intent description.';
|
|
61
|
+
return success({
|
|
62
|
+
session_id: session.id,
|
|
63
|
+
mode,
|
|
64
|
+
dialog: selection ? {
|
|
65
|
+
name: selection.dialog.manifest.name,
|
|
66
|
+
displayName: selection.dialog.manifest.displayName,
|
|
67
|
+
matchedKeywords: selection.matchedKeywords,
|
|
68
|
+
} : null,
|
|
69
|
+
available_dialogs: availableDialogs?.length ? availableDialogs : undefined,
|
|
70
|
+
soul: soulObj ? {
|
|
71
|
+
name: soulObj.manifest.name,
|
|
72
|
+
displayName: soulObj.manifest.displayName,
|
|
73
|
+
} : null,
|
|
74
|
+
convergence_instructions: convergenceInstructions,
|
|
75
|
+
first_question: firstQuestion,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
return error(err instanceof Error ? err.message : String(err));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/tools/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,aAAa,CAAC,MAAiB,EAAE,OAAsB;IACrE,MAAM,CAAC,IAAI,CACT,eAAe,EACf,0FAA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