deepclause-sdk 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +83 -12
  2. package/dist/agent.d.ts +14 -1
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +117 -9
  5. package/dist/agent.js.map +1 -1
  6. package/dist/cli/config.d.ts +86 -26
  7. package/dist/cli/config.d.ts.map +1 -1
  8. package/dist/cli/config.js +15 -0
  9. package/dist/cli/config.js.map +1 -1
  10. package/dist/cli/index.js +38 -0
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/repl.d.ts +27 -0
  13. package/dist/cli/repl.d.ts.map +1 -1
  14. package/dist/cli/repl.js +191 -5
  15. package/dist/cli/repl.js.map +1 -1
  16. package/dist/cli/run.d.ts.map +1 -1
  17. package/dist/cli/run.js +16 -0
  18. package/dist/cli/run.js.map +1 -1
  19. package/dist/cli/visualize.d.ts +4 -0
  20. package/dist/cli/visualize.d.ts.map +1 -1
  21. package/dist/cli/visualize.js +29 -4
  22. package/dist/cli/visualize.js.map +1 -1
  23. package/dist/prolog/bridge.d.ts +3 -1
  24. package/dist/prolog/bridge.d.ts.map +1 -1
  25. package/dist/prolog/bridge.js +2 -0
  26. package/dist/prolog/bridge.js.map +1 -1
  27. package/dist/prolog/loader.d.ts +32 -0
  28. package/dist/prolog/loader.d.ts.map +1 -1
  29. package/dist/prolog/loader.js +87 -0
  30. package/dist/prolog/loader.js.map +1 -1
  31. package/dist/prolog-src/deepclause_mi.pl +1217 -120
  32. package/dist/repl/agent.d.ts +33 -1
  33. package/dist/repl/agent.d.ts.map +1 -1
  34. package/dist/repl/agent.js +91 -8
  35. package/dist/repl/agent.js.map +1 -1
  36. package/dist/repl/backend.d.ts +31 -0
  37. package/dist/repl/backend.d.ts.map +1 -1
  38. package/dist/repl/backend.js +122 -77
  39. package/dist/repl/backend.js.map +1 -1
  40. package/dist/repl/harness-tools.d.ts +49 -2
  41. package/dist/repl/harness-tools.d.ts.map +1 -1
  42. package/dist/repl/harness-tools.js +87 -7
  43. package/dist/repl/harness-tools.js.map +1 -1
  44. package/dist/repl/imagegen.d.ts +29 -0
  45. package/dist/repl/imagegen.d.ts.map +1 -0
  46. package/dist/repl/imagegen.js +84 -0
  47. package/dist/repl/imagegen.js.map +1 -0
  48. package/dist/repl/index.d.ts +20 -2
  49. package/dist/repl/index.d.ts.map +1 -1
  50. package/dist/repl/index.js +6 -0
  51. package/dist/repl/index.js.map +1 -1
  52. package/dist/repl/model-resolver.d.ts +59 -0
  53. package/dist/repl/model-resolver.d.ts.map +1 -0
  54. package/dist/repl/model-resolver.js +156 -0
  55. package/dist/repl/model-resolver.js.map +1 -0
  56. package/dist/repl/render.d.ts +36 -2
  57. package/dist/repl/render.d.ts.map +1 -1
  58. package/dist/repl/render.js +175 -17
  59. package/dist/repl/render.js.map +1 -1
  60. package/dist/repl/session.d.ts +129 -4
  61. package/dist/repl/session.d.ts.map +1 -1
  62. package/dist/repl/session.js +380 -17
  63. package/dist/repl/session.js.map +1 -1
  64. package/dist/repl/tool-arguments.d.ts +36 -0
  65. package/dist/repl/tool-arguments.d.ts.map +1 -0
  66. package/dist/repl/tool-arguments.js +123 -0
  67. package/dist/repl/tool-arguments.js.map +1 -0
  68. package/dist/repl/toolset.d.ts +28 -1
  69. package/dist/repl/toolset.d.ts.map +1 -1
  70. package/dist/repl/toolset.js +52 -4
  71. package/dist/repl/toolset.js.map +1 -1
  72. package/dist/repl/tui/transcript.d.ts +2 -0
  73. package/dist/repl/tui/transcript.d.ts.map +1 -1
  74. package/dist/repl/tui/transcript.js +16 -0
  75. package/dist/repl/tui/transcript.js.map +1 -1
  76. package/dist/runner.d.ts +44 -2
  77. package/dist/runner.d.ts.map +1 -1
  78. package/dist/runner.js +293 -33
  79. package/dist/runner.js.map +1 -1
  80. package/dist/system/assets/docs/AGENT_PROMPT.md +1000 -44
  81. package/dist/system/assets/docs/DML_AUTHORING.md +96 -17
  82. package/dist/system/assets/docs/DML_REFERENCE.md +652 -39
  83. package/dist/system/assets/docs/PROLOG_SNIPPETS.md +45 -1
  84. package/dist/system/assets/docs/TASK_PROMPT.md +2 -0
  85. package/dist/system/environment.d.ts +36 -0
  86. package/dist/system/environment.d.ts.map +1 -0
  87. package/dist/system/environment.js +81 -0
  88. package/dist/system/environment.js.map +1 -0
  89. package/dist/system/runtime/shell-manager.d.ts +40 -2
  90. package/dist/system/runtime/shell-manager.d.ts.map +1 -1
  91. package/dist/system/runtime/shell-manager.js +82 -16
  92. package/dist/system/runtime/shell-manager.js.map +1 -1
  93. package/dist/system/runtime/shell-tool-events.js +25 -1
  94. package/dist/system/runtime/shell-tool-events.js.map +1 -1
  95. package/dist/types.d.ts +76 -2
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/visualize/ascii.d.ts +55 -0
  98. package/dist/visualize/ascii.d.ts.map +1 -0
  99. package/dist/visualize/ascii.js +242 -0
  100. package/dist/visualize/ascii.js.map +1 -0
  101. package/dist/visualize/display.d.ts +24 -0
  102. package/dist/visualize/display.d.ts.map +1 -0
  103. package/dist/visualize/display.js +29 -0
  104. package/dist/visualize/display.js.map +1 -0
  105. package/dist/visualize/graphics.d.ts +35 -0
  106. package/dist/visualize/graphics.d.ts.map +1 -0
  107. package/dist/visualize/graphics.js +96 -0
  108. package/dist/visualize/graphics.js.map +1 -0
  109. package/dist/visualize/image.d.ts +38 -0
  110. package/dist/visualize/image.d.ts.map +1 -0
  111. package/dist/visualize/image.js +95 -0
  112. package/dist/visualize/image.js.map +1 -0
  113. package/dist/visualize/index.d.ts +7 -0
  114. package/dist/visualize/index.d.ts.map +1 -1
  115. package/dist/visualize/index.js +9 -0
  116. package/dist/visualize/index.js.map +1 -1
  117. package/dist/visualize/raster.d.ts +23 -0
  118. package/dist/visualize/raster.d.ts.map +1 -0
  119. package/dist/visualize/raster.js +47 -0
  120. package/dist/visualize/raster.js.map +1 -0
  121. package/dist/visualize/svg.d.ts +39 -0
  122. package/dist/visualize/svg.d.ts.map +1 -0
  123. package/dist/visualize/svg.js +148 -0
  124. package/dist/visualize/svg.js.map +1 -0
  125. package/dist/visualize/transcode.d.ts +13 -0
  126. package/dist/visualize/transcode.d.ts.map +1 -0
  127. package/dist/visualize/transcode.js +40 -0
  128. package/dist/visualize/transcode.js.map +1 -0
  129. package/docs/images/repl.png +0 -0
  130. package/package.json +10 -6
  131. package/src/prolog-src/deepclause_mi.pl +1217 -120
  132. package/dist/compaction.d.ts +0 -98
  133. package/dist/compaction.d.ts.map +0 -1
  134. package/dist/compaction.js +0 -471
  135. package/dist/compaction.js.map +0 -1
  136. package/dist/repl/tools.d.ts +0 -53
  137. package/dist/repl/tools.d.ts.map +0 -1
  138. package/dist/repl/tools.js +0 -307
  139. package/dist/repl/tools.js.map +0 -1
  140. package/dist/system/assets/compactors/default-loop-compactor.dml +0 -43
  141. package/dist/system/assets/compactors/default-session-compactor.dml +0 -30
  142. package/dist/system/assets/docs/META_PROMPT.md +0 -68
@@ -1,307 +0,0 @@
1
- /**
2
- * Host-backed meta tools (M3).
3
- *
4
- * A `meta` frame's agent tool set is *replaced* with exactly these tools; the
5
- * harness's own DML tools are hidden from the code-writing model. The tools act
6
- * on the live scratch module (snapshot/restored by the prompt transaction).
7
- *
8
- * M3 ships listing/assert/retract/execute; M6 adds ask_user.
9
- */
10
- import { plainValue } from './frames.js';
11
- function quoteString(value) {
12
- return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
13
- }
14
- function listingFilterTerm(filter) {
15
- if (/^[a-z][a-zA-Z0-9_]*\/\d+$/.test(filter) || /^[a-z][a-zA-Z0-9_]*$/.test(filter)) {
16
- return filter;
17
- }
18
- return `'${filter.replace(/'/g, "''")}'`;
19
- }
20
- function textResult(message) {
21
- return { text: message };
22
- }
23
- export function createMetaTools(ctx) {
24
- const tools = new Map();
25
- // The AI SDK may issue several tool calls from one assistant message and run
26
- // them concurrently. Meta tools mutate the shared session and create child
27
- // frames, so serialize them: a child frame must run to completion before the
28
- // meta frame resumes (proposal §10.3).
29
- let queue = Promise.resolve();
30
- const serialized = (fn) => {
31
- const run = queue.then(fn, fn);
32
- queue = run.then(() => undefined, () => undefined);
33
- return run;
34
- };
35
- const notify = (toolName, toolArgs, state, toolSummary) => {
36
- ctx.onEvent?.({ type: 'tool_call', toolName, toolArgs, toolState: state, toolSummary });
37
- };
38
- tools.set('listing', {
39
- description: 'Read-only listing of the living harness: predicates, a Name/Arity, tools, or scripts.',
40
- parameters: {
41
- type: 'object',
42
- properties: {
43
- filter: {
44
- type: 'string',
45
- description: "One of: all (default), a Name/Arity, tools, scripts, or a name prefix.",
46
- },
47
- },
48
- required: [],
49
- },
50
- execute: (args) => serialized(async () => {
51
- const filter = String(args.filter ?? 'all').trim() || 'all';
52
- if (filter === 'tools' && ctx.hostToolsCatalog) {
53
- return textResult(ctx.hostToolsCatalog);
54
- }
55
- const result = ctx.prologQuery(`deepclause_mi:repl_listing('${ctx.sessionId}', ${listingFilterTerm(filter)}, Text)`);
56
- const text = plainValue(result?.Text);
57
- const output = typeof text === 'string' ? text : '';
58
- notify('listing', { filter }, 'completed', `${output.trim() ? output.trim().split('\n').length : 0} line(s)`);
59
- return textResult(output);
60
- }),
61
- });
62
- tools.set('assert', {
63
- description: 'Parse and assert a clause, tool/2, or script_body/2 fact into the scratch harness.',
64
- parameters: {
65
- type: 'object',
66
- properties: {
67
- clause: { type: 'string', description: 'The DML clause/fact text to assert (no trailing period required).' },
68
- },
69
- required: ['clause'],
70
- },
71
- execute: (args) => serialized(async () => {
72
- if (ctx.isFrozen()) {
73
- return { ok: false, error: 'harness is frozen; assert is disabled' };
74
- }
75
- const clause = String(args.clause ?? '');
76
- const result = ctx.prologQuery(`deepclause_mi:repl_assert('${ctx.sessionId}', ${quoteString(clause)}, Result)`);
77
- const outcome = plainValue(result?.Result);
78
- if (outcome === 'ok') {
79
- notify('assert', { clause }, 'completed', 'ok');
80
- return { ok: true };
81
- }
82
- notify('assert', { clause }, 'failed', String(outcome));
83
- return { ok: false, error: String(outcome) };
84
- }),
85
- });
86
- tools.set('assert_many', {
87
- description: 'Parse a block of clauses and assert them in the order written. Use this to define a whole predicate so clause order (base case before recursive rule) is preserved.',
88
- parameters: {
89
- type: 'object',
90
- properties: {
91
- clauses: { type: 'string', description: 'The DML clauses/facts, in order, each ending with a period.' },
92
- },
93
- required: ['clauses'],
94
- },
95
- execute: (args) => serialized(async () => {
96
- if (ctx.isFrozen()) {
97
- return { ok: false, error: 'harness is frozen; assert is disabled' };
98
- }
99
- const clauses = String(args.clauses ?? '');
100
- const result = ctx.prologQuery(`deepclause_mi:repl_assert_many('${ctx.sessionId}', ${quoteString(clauses)}, Result)`);
101
- const outcome = plainValue(result?.Result);
102
- if (outcome === 'ok') {
103
- notify('assert_many', { clauses }, 'completed', 'ok');
104
- return { ok: true };
105
- }
106
- notify('assert_many', { clauses }, 'failed', String(outcome));
107
- return { ok: false, error: String(outcome) };
108
- }),
109
- });
110
- tools.set('retract', {
111
- description: 'Remove matching clauses from the scratch harness (reserved names are protected).',
112
- parameters: {
113
- type: 'object',
114
- properties: {
115
- clause: { type: 'string', description: 'The clause pattern to retract (no trailing period required).' },
116
- },
117
- required: ['clause'],
118
- },
119
- execute: (args) => serialized(async () => {
120
- if (ctx.isFrozen()) {
121
- return { ok: false, error: 'harness is frozen; retract is disabled' };
122
- }
123
- const clause = String(args.clause ?? '');
124
- const result = ctx.prologQuery(`deepclause_mi:repl_retract('${ctx.sessionId}', ${quoteString(clause)}, Result)`);
125
- const outcome = plainValue(result?.Result);
126
- if (outcome === 'ok') {
127
- notify('retract', { clause }, 'completed', 'ok');
128
- return { ok: true };
129
- }
130
- notify('retract', { clause }, 'failed', String(outcome));
131
- return { ok: false, error: String(outcome) };
132
- }),
133
- });
134
- tools.set('define', {
135
- description: 'Replace the predicate(s) defined by a clause block: remove every predicate the block defines (plus the head pattern), then assert the block in order. A block may define several predicates. Prefer this over assert when changing existing predicates.',
136
- parameters: {
137
- type: 'object',
138
- properties: {
139
- head: { type: 'string', description: 'A head pattern for the predicate, e.g. "describe_image(Path, Text)" or "doc(describe_image/2, _)".' },
140
- clauses: { type: 'string', description: 'The complete clause block for the predicate, in order, each ending with a period.' },
141
- },
142
- required: ['head', 'clauses'],
143
- },
144
- execute: (args) => serialized(async () => {
145
- if (ctx.isFrozen()) {
146
- return { ok: false, error: 'harness is frozen; define is disabled' };
147
- }
148
- const head = String(args.head ?? '');
149
- const clauses = String(args.clauses ?? '');
150
- const result = ctx.prologQuery(`deepclause_mi:repl_define('${ctx.sessionId}', ${quoteString(head)}, ${quoteString(clauses)}, Result)`);
151
- const outcome = plainValue(result?.Result);
152
- if (outcome === 'ok') {
153
- notify('define', { head }, 'completed', 'ok');
154
- return { ok: true };
155
- }
156
- notify('define', { head }, 'failed', String(outcome));
157
- return { ok: false, error: String(outcome) };
158
- }),
159
- });
160
- tools.set('execute', {
161
- description: 'Run a DML goal against the scratch harness and return its bindings/output.',
162
- parameters: {
163
- type: 'object',
164
- properties: {
165
- goal: { type: 'string', description: 'The DML goal to run, e.g. "fact(5, F)".' },
166
- limit: { type: 'integer', description: 'Maximum solutions to collect (default 5).' },
167
- },
168
- required: ['goal'],
169
- },
170
- execute: (args, context) => serialized(async () => {
171
- const goal = String(args.goal ?? '');
172
- const limit = typeof args.limit === 'number' ? args.limit : undefined;
173
- const result = await ctx.executeGoal(goal, limit, context?.signal);
174
- notify('execute', { goal }, result.error ? 'failed' : 'completed', result.error ?? `${result.solutions.length} solution(s)`);
175
- return result;
176
- }),
177
- });
178
- if (ctx.fileTools) {
179
- const fileTools = ctx.fileTools;
180
- tools.set('read_file', {
181
- description: 'Read a workspace file. Paths are workspace-relative. Use this to inspect generated scripts.',
182
- parameters: {
183
- type: 'object',
184
- properties: { path: { type: 'string', description: 'Workspace-relative file path.' } },
185
- required: ['path'],
186
- },
187
- execute: (args) => serialized(async () => {
188
- const filePath = String(args.path ?? '');
189
- try {
190
- const content = await fileTools.read(filePath);
191
- if (content === null) {
192
- notify('read_file', { path: filePath }, 'failed', 'not found');
193
- return { error: `not found: ${filePath}` };
194
- }
195
- notify('read_file', { path: filePath }, 'completed', `${content.length} chars`);
196
- return { path: filePath, content };
197
- }
198
- catch (error) {
199
- notify('read_file', { path: filePath }, 'failed', String(error));
200
- return { error: String(error) };
201
- }
202
- }),
203
- });
204
- tools.set('write_file', {
205
- description: 'Write a workspace file. Paths are workspace-relative; the write lands on disk immediately, so bash can run it in the same turn. Use this to author script files; link them with a script_file/2 fact and run them with exec(bash(...)).',
206
- parameters: {
207
- type: 'object',
208
- properties: {
209
- path: { type: 'string', description: 'Workspace-relative file path.' },
210
- content: { type: 'string', description: 'The full file content.' },
211
- },
212
- required: ['path', 'content'],
213
- },
214
- execute: (args) => serialized(async () => {
215
- const filePath = String(args.path ?? '');
216
- const content = String(args.content ?? '');
217
- try {
218
- await fileTools.write(filePath, content);
219
- notify('write_file', { path: filePath }, 'completed', `${content.length} chars`);
220
- return { ok: true, path: filePath };
221
- }
222
- catch (error) {
223
- notify('write_file', { path: filePath }, 'failed', String(error));
224
- return { ok: false, error: String(error) };
225
- }
226
- }),
227
- });
228
- tools.set('list_files', {
229
- description: 'List a workspace directory.',
230
- parameters: {
231
- type: 'object',
232
- properties: { path: { type: 'string', description: 'Workspace-relative directory (default ".").' } },
233
- required: [],
234
- },
235
- execute: (args) => serialized(async () => {
236
- const dir = args.path ? String(args.path) : '.';
237
- try {
238
- const entries = await fileTools.list(dir);
239
- notify('list_files', { path: dir }, 'completed', `${entries.length} entries`);
240
- return { path: dir, entries };
241
- }
242
- catch (error) {
243
- notify('list_files', { path: dir }, 'failed', String(error));
244
- return { error: String(error) };
245
- }
246
- }),
247
- });
248
- tools.set('delete_file', {
249
- description: 'Delete a workspace file.',
250
- parameters: {
251
- type: 'object',
252
- properties: { path: { type: 'string', description: 'Workspace-relative file path.' } },
253
- required: ['path'],
254
- },
255
- execute: (args) => serialized(async () => {
256
- const filePath = String(args.path ?? '');
257
- try {
258
- await fileTools.remove(filePath);
259
- notify('delete_file', { path: filePath }, 'completed', 'deleted');
260
- return { ok: true };
261
- }
262
- catch (error) {
263
- notify('delete_file', { path: filePath }, 'failed', String(error));
264
- return { ok: false, error: String(error) };
265
- }
266
- }),
267
- });
268
- }
269
- if (ctx.askUser) {
270
- tools.set('ask_user', {
271
- description: 'Ask the human a clarifying question before writing the harness.',
272
- parameters: {
273
- type: 'object',
274
- properties: {
275
- prompt: { type: 'string', description: 'The question to ask.' },
276
- options: { type: 'array', description: 'Optional menu of answers.' },
277
- },
278
- required: ['prompt'],
279
- },
280
- execute: (args) => serialized(async () => {
281
- const prompt = String(args.prompt ?? '');
282
- const options = Array.isArray(args.options) ? args.options.map(String) : undefined;
283
- const result = await ctx.askUser(prompt, options);
284
- notify('ask_user', { prompt }, 'completed', 'cancelled' in result ? 'cancelled' : result.answer);
285
- return result;
286
- }),
287
- });
288
- }
289
- return tools;
290
- }
291
- /**
292
- * Compact catalog injected into the meta prompt. The full schemas are always
293
- * available through the `listing(tools)` / `listing` tool.
294
- */
295
- export function describeMetaTools() {
296
- return [
297
- '- listing(filter) — read-only list of predicates (all), Name/Arity, tools, or scripts.',
298
- '- assert(clause) / assert_many(clauses) — write DML clauses into the scratch harness.',
299
- '- define(head, clauses) — replace a predicate (clear Name/Arity, then assert the clauses).',
300
- '- retract(clause) — remove a predicate from the scratch harness.',
301
- '- execute(goal, limit?) — run a DML goal against the scratch harness; returns bindings/output.',
302
- '- read_file / write_file / list_files / delete_file — workspace-scoped file I/O (writes land immediately).',
303
- '- ask_user(prompt, options?) — ask the human a clarifying question.',
304
- '- bash — the capability host tool, available to probe the environment and run commands.',
305
- ].join('\n');
306
- }
307
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/repl/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAE,MAA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M,CAAC,MAAM,CACpD,CAAC;gBACF,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,wFAAwF;QACxF,uFAAuF;QACvF,4FAA4F;QAC5F,kEAAkE;QAClE,gGAAgG;QAChG,4GAA4G;QAC5G,qEAAqE;QACrE,yFAAyF;KAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -1,43 +0,0 @@
1
- should_skip_loop_compaction(MessageCount, _EstimatedTokens, MaxCtx) :-
2
- MaxCtx > 0,
3
- Threshold is MaxCtx * 3 // 4,
4
- _EstimatedTokens < Threshold,
5
- MessageCount < 12.
6
-
7
- should_skip_loop_compaction(MessageCount, EstimatedTokens, 0) :-
8
- MessageCount < 12.
9
-
10
- should_skip_loop_compaction(_MessageCount, EstimatedTokens, 0) :-
11
- EstimatedTokens < 50000.
12
-
13
- agent_main :-
14
- param(message_count, MessageCount),
15
- param(estimated_tokens, EstimatedTokens),
16
- ( param(max_context_tokens, MaxCtx) -> true ; MaxCtx = 0 ),
17
- should_skip_loop_compaction(MessageCount, EstimatedTokens, MaxCtx),
18
- answer("{\"apply\":false}").
19
-
20
- agent_main :-
21
- param(message_count, MessageCount),
22
- param(estimated_tokens, EstimatedTokens),
23
- ( param(max_context_tokens, MaxCtx) -> true ; MaxCtx = 0 ),
24
- get_memory(HistoryMessages),
25
- ( MaxCtx > 0
26
- -> Threshold is MaxCtx * 3 // 4,
27
- format(string(ThresholdNote), "Context threshold: ~w tokens (75% of ~w).", [Threshold, MaxCtx])
28
- ; format(string(ThresholdNote), "Context threshold: 50000 tokens (default).", [])
29
- ),
30
- format(string(ReviewPrompt), "You compact the live prompt history of a long-running DeepClause task loop before the next model call.\n\nReturn exactly one of these:\n- SKIP\n- A concise plain-text working-memory summary only\n\nRules:\n- If compaction is unnecessary, return exactly SKIP.\n- If compaction is needed, preserve the active objective, latest state, important tool findings, unresolved blockers, and the next action.\n- The runtime will keep all system messages plus the last 3 raw non-system messages itself, so do not restate them verbatim.\n- Return readable prose only, not JSON, YAML, XML, code fences, or schema-like dumps.\n\nLoop stats:\n- Message count: ~w\n- Estimated tokens: ~w\n- ~w", [MessageCount, EstimatedTokens, ThresholdNote]),
31
- PromptMessage = message{role: system, content: ReviewPrompt},
32
- append([PromptMessage], HistoryMessages, LlmMessages),
33
- ( llm(LlmMessages, Summary)
34
- -> normalize_space(string(NormalizedSummary), Summary),
35
- ( NormalizedSummary == "SKIP"
36
- -> answer("{\"apply\":false}")
37
- ; Summary \= ""
38
- -> format(string(ResultSpec), "DC_COMPACTOR_REWRITE_V1\napply=true\nkeep_last_messages=3\nsummary:\n~w", [Summary]),
39
- answer(ResultSpec)
40
- ; answer("{\"apply\":false}")
41
- )
42
- ; answer("{\"apply\":false}")
43
- ).
@@ -1,30 +0,0 @@
1
- should_skip_session_compaction(MessageCount, _EstimatedTokens) :-
2
- MessageCount < 8.
3
-
4
- should_skip_session_compaction(_MessageCount, EstimatedTokens) :-
5
- EstimatedTokens < 50000.
6
-
7
- agent_main :-
8
- param(message_count, MessageCount),
9
- param(estimated_tokens, EstimatedTokens),
10
- should_skip_session_compaction(MessageCount, EstimatedTokens),
11
- answer("{\"apply\":false}").
12
-
13
- agent_main :-
14
- param(message_count, MessageCount),
15
- param(estimated_tokens, EstimatedTokens),
16
- get_memory(HistoryMessages),
17
- format(string(ReviewPrompt), "You compact DeepClause conductor session history before the next user turn.\n\nReturn exactly one of these:\n- SKIP\n- A concise plain-text summary only\n\nRules:\n- If compaction is unnecessary, return exactly SKIP.\n- If compaction is needed, preserve durable user goals, constraints, decisions, open questions, and next steps.\n- The runtime will keep the last 2 raw trailing messages itself, so do not restate them verbatim.\n- Return readable prose only, not JSON, YAML, XML, code fences, or schema-like dumps.\n\nSession stats:\n- Message count: ~w\n- Estimated tokens: ~w", [MessageCount, EstimatedTokens]),
18
- PromptMessage = message{role: system, content: ReviewPrompt},
19
- append([PromptMessage], HistoryMessages, LlmMessages),
20
- ( llm(LlmMessages, Summary)
21
- -> normalize_space(string(NormalizedSummary), Summary),
22
- ( NormalizedSummary == "SKIP"
23
- -> answer("{\"apply\":false}")
24
- ; Summary \= ""
25
- -> format(string(ResultSpec), "DC_COMPACTOR_REWRITE_V1\napply=true\nkeep_last_messages=2\nsummary:\n~w", [Summary]),
26
- answer(ResultSpec)
27
- ; answer("{\"apply\":false}")
28
- )
29
- ; answer("{\"apply\":false}")
30
- ).
@@ -1,68 +0,0 @@
1
- You are the DeepClause REPL harness author. Maintain a living library of DML skills.
2
-
3
- WHAT A HARNESS IS
4
- - A harness is a living library of reusable DML SKILLS for this workspace, not a single script. A skill is a predicate; name skills descriptively and run them with execute or goal:.
5
- - Skills compose: model calls via task/N (a bounded agentic turn that may itself call other skills), fresh-context calls via prompt/N, semantic judgments (choose/rate/verify/probability), and host tools via exec/2 (almost always bash). Keep the Prolog around them thin.
6
- - KEEP SKILLS ABSTRACT: a skill is a short, readable sequence of steps, not a Prolog program. Express each step as a task/N or prompt/N and let the model do the extraction, classification, summarisation, or decision; use Prolog only as glue — simple guards (->, ;, once/1, ==, \==), member/2, between/3, format/2-3, and small arithmetic. Avoid heavy recursion, hand-rolled list algorithms, CLP, and assert/retract inside skills. If the logic starts to look like an algorithm, that is the signal to describe the step in a task/prompt (or run it once with execute) instead of committing it. The harness is an orchestration layer over model calls, not a logic library.
7
- - DATA = CODE: the harness is a live Prolog module, so structured data belongs in it as facts (for example country(Name, Code).) and is inspected and queried exactly like code (listing, goal:, execute). Add data as facts when it is small enough to reason over; keep large datasets in a file or a linked script instead of bloating the module.
8
- - TESTS: a harness may carry test predicates that pin the intended behavior of a skill (for example test_<name>, or a small check/2 runner). When you change a skill, update or add its test and run it (execute or goal:) so the change is verified, not assumed.
9
- - HISTORY: the harness remembers. Query the harness_* facts (harness_change/5, harness_changed/4, harness_turn/5, harness_session/5, harness_session_end/2, harness_head/4, harness_trace/3) to see what happened in previous sessions; listing(history) shows a tail.
10
- - EVOLVE ONLY WHEN ASKED: create or change the harness only for an explicit create/change/run request. On a fresh workspace create what the user asked for; afterwards change only what the request requires, reuse existing skills instead of duplicating them, and never refactor or extend the harness on your own initiative.
11
- - SKILLS VS ONE-SHOT WORK: the harness is a library of reusable CAPABILITIES, not a record of what you did. Most requests mix both: a capability worth naming, and a one-off action for this request. Do the one-off part NOW (an execute goal, or bash) and commit only the capability. Example — "find the latest image in ~/Downloads and tell me what's on it": run the find/copy-the-latest-file step once in the turn, and add only describe_image(Path, Text) as the skill. Finding a latest file, copying files around, moving data, or any single concrete invocation is a task, not a skill.
12
- - NO HARDCODED ENVIRONMENT: a skill takes its inputs as arguments. Never bake a host path (/home/...), a machine-specific directory, a fixed filename, or a specific URL into a predicate or script; the copied /home/andreas/Downloads is exactly the failure mode. A predicate that exists only to be called once, with literals frozen in, is a script in disguise — do not commit it.
13
- - GENERALIZE, DON'T SPECIALIZE: prefer a few small, composable primitives over a predicate per request, and express one-off requests by composing them (or a direct goal:) instead of naming something for every phrasing. Even find_latest(Dir, Pattern, Path) is fairly narrow — the reusable parts (list a directory, filter, pick a best/latest element) are shared by many tasks. Ask whether another caller would plausibly reuse a predicate with different arguments; if only this request would, do not add it. Do not create a predicate for a one-off: run the shell command (ls, grep, jq, curl, ffmpeg) or a direct execute goal now, and keep the harness for capabilities worth reusing. When a script genuinely is the capability, parameterize and document it like any other skill.
14
-
15
- AUTHORING CONTRACT
16
- - Emit only valid DML. There is no Markdown->DML compiler; the code you return is loaded directly.
17
- - Reserve the repl_* and meta_* namespaces. Never define repl_delete as logic; repl_delete(Name/Arity) deletes a predicate.
18
- - For every predicate you change, return its COMPLETE definition. The commit replaces by predicate, so partial definitions lose clauses.
19
- - Define facts with head. and rules with 'head :- body.'.
20
- - Use task(Desc, ...Vars) for model calls, exec(Tool(Args), Result) for host tools, output/1 and answer/1 for results.
21
- - Numbers and transformations: prefer a task/prompt when they are open-ended, and keep arithmetic to plain is/2 comparisons. Use CLP(FD)/CLP(Q) only for a genuine constraint problem (scheduling, puzzles, exact search), never as a shortcut for ordinary arithmetic. If you do: bound every domain (`X ins 0..N`) before `label/1`, prefer `once/1`, and keep the model small — an under-specified or unsatisfiable model can search forever, and there is no per-goal timeout.
22
- - FILE I/O: prefer the shell — `exec(bash(...))` — and the host file tools (read_file, write_file, list_files, delete_file) for reading, writing, copying, and converting files. Use the DML file predicates (read_file/2, open/3, close/1, read_string/3, write/2, write_file/2, append_file/2, directory_files/2, size_file/2, time_file/2) only when the content must be bound and reasoned over inside Prolog; do not read a file into DML just to move or transform it. Paths are workspace-relative.
23
- - PATHS: every path in DML is workspace-relative and can only reach inside the workspace (read_file("images/a.png"), directory_files("images"), size_file("images/a.png"), read_media("images/a.png")). Never write /workspace/... or any absolute path in DML; they are rejected. directory_files/2 returns bare names, so build relative paths (atom_concat('images/', Name, Path)), and convert any tool or bash result to a workspace-relative path before DML uses it. bash can see more of the sandbox than DML can — keep that in bash. Prefer bash or the host file tools for file operations; reserve the DML file predicates for content you must reason over in Prolog.
24
- - Conversation memory: system(Text) sets persistent context and user(Text) adds a user turn; both survive across task/2..4 in the same frame. Use prompt/1..4 for a fresh context.
25
- - MEDIA (images): images are workspace files referenced, never embedded. read_media(Path, Img) yields media(Path, Mime); attach_media(Img) adds it to conversation memory so the next task/N sends it to the model as an image block. Only PNG/JPEG/GIF/WebP; never inline bytes in clauses or memory, and semantic judgments stay text-only.
26
- - Semantic judgments (not generative): judge(State, [choose(...) - X, rate(...) - R, verify(...) - V, probability(...) - P]) or the one-off choose/4, rate/4, verify/3, probability/3, holds/2,3. They never read or write memory. Backends: llm (default) and jev; require_judgment(Capability, Goal) gates a goal on capabilities (calibrated, probability, confidence, independentQuestions).
27
- - DETERMINISM: a skill that calls task/N, prompt/N, exec/2, read_media/2, attach_media/1, or writes a file must be deterministic — exactly one solution, with no choicepoint left across the side effect (use once/1, ->, or a cut). Otherwise execute, and any caller, re-runs the model call on backtracking: slow, costly, and it returns a different answer each time.
28
- - SELF-CONTAINMENT: the harness is the .dml PLUS the files it links. Write each program to a file with write_file (it lands on disk immediately, so bash can run it in the same turn), link it with script_file(Name, Path) (path is workspace-relative), and run it with exec(bash(...)). export bundles the linked files into a .zip, so they travel with the harness. Link a script only when the work genuinely needs the shell or an external tool — not for glue that Prolog handles — and make it a general component, not a one-off.
29
- - Naming: there is no agent_main requirement in the REPL. Name predicates descriptively. To delete a predicate, emit repl_delete(Name/Arity) as a directive fact.
30
- - ANNOTATE (the harness is self-describing): for every skill, helper, and tool you add or change, include a `doc(Name/Arity, Text)` fact describing how to use it — one or two terse sentences: what it does, its arguments (+in / -out), and an example goal. Keep them accurate; the next turn and people read them. Optionally include one `module_doc(Text)` fact summarising the whole harness. They appear in the manifest and in `listing`.
31
- - READ FIRST: call the listing tool before writing so you build on the current harness.
32
- - You have workspace file tools (read_file, write_file, list_files, delete_file) and the bash host tool. The host provides bash access to a sandbox: explore it freely (python3 --version, which curl, pip list, ...) and install a dependency when a skill genuinely needs one (network and user approval may apply). Installs live in the sandbox/session, not the exported harness, so prefer the standard library and keep dependencies deliberate.
33
- - CLAUSE ORDER MATTERS: a predicate's clauses are tried in order, so a base case must come before a recursive rule. Define a predicate with assert_many (clauses are asserted in the order written) rather than several one-at-a-time asserts.
34
- - REDEFINE A PREDICATE WHOLE: use define(head, clauses) (or retract then assert_many) to change a predicate. assert appends, so asserting a clause twice duplicates it and execute then yields several solutions; never patch a predicate clause by clause.
35
- - After changing a predicate, call listing(Name/Arity) to confirm the clauses are present and in the right order.
36
- - BOUNDED ITERATION: do not loop, assert, or execute unboundedly. Use finite recursion, CLP(FD)/CLP(Q), or plain iteration with a known bound; execute is gas-limited and the turn has a model-call budget. Stop when the task is done.
37
- - If the request is ambiguous, call the ask_user tool to ask a clarifying question before writing code.
38
- - DIRECT QUESTIONS: if the request is only a question you can answer directly (for example "what did we just do?", "what can you do?", "how do I ...?"), do NOT write or change harness code. Set DMLCode to the empty string and set the Answer output variable to your reply. Build DML only when the user asks you to create, change, or run logic.
39
-
40
- HOST TOOL CATALOG (only these names may be called through exec/2; listing(tools) has full schemas)
41
- {{CATALOG}}
42
-
43
- DML LANGUAGE REFERENCE
44
- {{REFERENCE}}
45
-
46
- DML AUTHORING GUIDE
47
- {{AUTHORING}}
48
-
49
- IDIOMATIC HARNESS EXAMPLES
50
- {{EXAMPLES}}
51
-
52
- COMMON PROLOG SNIPPETS (tested)
53
- {{SNIPPETS}}
54
-
55
- CURRENT HARNESS MANIFEST
56
- {{MANIFEST}}
57
-
58
- META MEMORY (your previous requests and outcomes; also in the conversation history)
59
- {{MEMORY}}
60
-
61
- USER REQUEST
62
- {{REQUEST}}
63
-
64
- OUTPUT CONTRACT
65
- Return the complete DML definitions for every predicate this turn touches.
66
- Set the DMLCode output variable to the DML source (optionally wrapped in a fenced dml block).
67
- Use the execute tool to run and verify a goal during the turn; the commit only changes the module.
68
- Set every requested output variable before calling finish: for a direct question set DMLCode to the empty string and Answer to your reply; otherwise set DMLCode and set Answer to the empty string.