principles-disciple 1.11.0 → 1.13.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/CHANGELOG.md +26 -0
- package/README.md +66 -0
- package/esbuild.config.js +1 -1
- package/openclaw.plugin.json +4 -4
- package/package.json +2 -3
- package/run-nocturnal.mjs +30 -0
- package/scripts/db-migrate.mjs +170 -0
- package/scripts/sync-plugin.mjs +250 -6
- package/src/commands/archive-impl.ts +136 -0
- package/src/commands/capabilities.ts +4 -2
- package/src/commands/context.ts +5 -1
- package/src/commands/disable-impl.ts +151 -0
- package/src/commands/evolution-status.ts +64 -19
- package/src/commands/export.ts +8 -6
- package/src/commands/focus.ts +8 -20
- package/src/commands/nocturnal-review.ts +5 -7
- package/src/commands/nocturnal-rollout.ts +1 -12
- package/src/commands/nocturnal-train.ts +21 -47
- package/src/commands/pain.ts +10 -5
- package/src/commands/principle-rollback.ts +4 -2
- package/src/commands/promote-impl.ts +274 -0
- package/src/commands/rollback-impl.ts +234 -0
- package/src/commands/rollback.ts +6 -3
- package/src/commands/samples.ts +2 -0
- package/src/commands/thinking-os.ts +3 -4
- package/src/commands/workflow-debug.ts +2 -1
- package/src/config/errors.ts +1 -0
- package/src/core/AGENTS.md +34 -0
- package/src/core/adaptive-thresholds.ts +4 -3
- package/src/core/code-implementation-storage.ts +241 -0
- package/src/core/config.ts +5 -2
- package/src/core/control-ui-db.ts +29 -10
- package/src/core/detection-funnel.ts +12 -7
- package/src/core/diagnostician-task-store.ts +156 -0
- package/src/core/dictionary.ts +4 -4
- package/src/core/empathy-keyword-matcher.ts +7 -3
- package/src/core/empathy-types.ts +13 -2
- package/src/core/event-log.ts +14 -6
- package/src/core/evolution-engine.ts +27 -31
- package/src/core/evolution-logger.ts +3 -2
- package/src/core/evolution-reducer.ts +110 -31
- package/src/core/evolution-types.ts +10 -0
- package/src/core/external-training-contract.ts +1 -0
- package/src/core/focus-history.ts +38 -24
- package/src/core/hygiene/tracker.ts +10 -6
- package/src/core/init.ts +5 -2
- package/src/core/migration.ts +3 -3
- package/src/core/model-deployment-registry.ts +6 -4
- package/src/core/model-training-registry.ts +5 -3
- package/src/core/nocturnal-arbiter.ts +13 -14
- package/src/core/nocturnal-artifact-lineage.ts +117 -0
- package/src/core/nocturnal-artificer.ts +257 -0
- package/src/core/nocturnal-candidate-scoring.ts +4 -2
- package/src/core/nocturnal-compliance.ts +67 -19
- package/src/core/nocturnal-dataset.ts +95 -2
- package/src/core/nocturnal-executability.ts +2 -3
- package/src/core/nocturnal-export.ts +6 -3
- package/src/core/nocturnal-rule-implementation-validator.ts +245 -0
- package/src/core/nocturnal-trajectory-extractor.ts +10 -3
- package/src/core/nocturnal-trinity.ts +319 -61
- package/src/core/pain-context-extractor.ts +29 -15
- package/src/core/pain.ts +7 -5
- package/src/core/path-resolver.ts +16 -15
- package/src/core/paths.ts +2 -1
- package/src/core/pd-task-reconciler.ts +463 -0
- package/src/core/pd-task-service.ts +42 -0
- package/src/core/pd-task-store.ts +77 -0
- package/src/core/pd-task-types.ts +128 -0
- package/src/core/principle-internalization/deprecated-readiness.ts +91 -0
- package/src/core/principle-internalization/internalization-routing-policy.ts +208 -0
- package/src/core/principle-internalization/lifecycle-metrics.ts +149 -0
- package/src/core/principle-internalization/lifecycle-read-model.ts +243 -0
- package/src/core/principle-internalization/lifecycle-refresh.ts +11 -0
- package/src/core/principle-internalization/principle-lifecycle-service.ts +167 -0
- package/src/core/principle-training-state.ts +95 -370
- package/src/core/principle-tree-ledger.ts +733 -0
- package/src/core/principle-tree-migration.ts +195 -0
- package/src/core/profile.ts +3 -1
- package/src/core/promotion-gate.ts +14 -18
- package/src/core/replay-engine.ts +562 -0
- package/src/core/risk-calculator.ts +6 -4
- package/src/core/rule-host-helpers.ts +39 -0
- package/src/core/rule-host-types.ts +82 -0
- package/src/core/rule-host.ts +245 -0
- package/src/core/rule-implementation-runtime.ts +38 -0
- package/src/core/schema/db-types.ts +16 -0
- package/src/core/schema/index.ts +26 -0
- package/src/core/schema/migration-runner.ts +207 -0
- package/src/core/schema/migrations/001-init-trajectory.ts +211 -0
- package/src/core/schema/migrations/002-init-central.ts +122 -0
- package/src/core/schema/migrations/003-init-workflow.ts +55 -0
- package/src/core/schema/migrations/004-add-thinking-and-gfi.ts +74 -0
- package/src/core/schema/migrations/index.ts +31 -0
- package/src/core/schema/schema-definitions.ts +650 -0
- package/src/core/session-tracker.ts +6 -4
- package/src/core/shadow-observation-registry.ts +6 -3
- package/src/core/system-logger.ts +2 -2
- package/src/core/thinking-models.ts +182 -46
- package/src/core/thinking-os-parser.ts +156 -0
- package/src/core/training-program.ts +7 -7
- package/src/core/trajectory.ts +42 -36
- package/src/core/workspace-context.ts +77 -11
- package/src/core/workspace-dir-validation.ts +152 -0
- package/src/hooks/AGENTS.md +31 -0
- package/src/hooks/bash-risk.ts +3 -1
- package/src/hooks/edit-verification.ts +9 -5
- package/src/hooks/gate-block-helper.ts +5 -1
- package/src/hooks/gate.ts +152 -5
- package/src/hooks/gfi-gate.ts +9 -2
- package/src/hooks/lifecycle-routing.ts +124 -0
- package/src/hooks/lifecycle.ts +12 -12
- package/src/hooks/llm.ts +17 -109
- package/src/hooks/message-sanitize.ts +5 -3
- package/src/hooks/pain.ts +19 -15
- package/src/hooks/progressive-trust-gate.ts +7 -1
- package/src/hooks/prompt.ts +169 -60
- package/src/hooks/subagent.ts +5 -4
- package/src/hooks/thinking-checkpoint.ts +2 -0
- package/src/hooks/trajectory-collector.ts +15 -12
- package/src/http/principles-console-route.ts +31 -68
- package/src/i18n/commands.ts +2 -2
- package/src/index.ts +130 -40
- package/src/service/central-database.ts +131 -43
- package/src/service/central-health-service.ts +47 -0
- package/src/service/central-overview-service.ts +135 -0
- package/src/service/central-sync-service.ts +87 -0
- package/src/service/control-ui-query-service.ts +46 -36
- package/src/service/event-log-auditor.ts +261 -0
- package/src/service/evolution-query-service.ts +23 -22
- package/src/service/evolution-worker.ts +565 -261
- package/src/service/health-query-service.ts +213 -36
- package/src/service/nocturnal-runtime.ts +8 -4
- package/src/service/nocturnal-service.ts +503 -59
- package/src/service/nocturnal-target-selector.ts +5 -7
- package/src/service/runtime-summary-service.ts +2 -1
- package/src/service/subagent-workflow/deep-reflect-workflow-manager.ts +25 -336
- package/src/service/subagent-workflow/dynamic-timeout.ts +30 -0
- package/src/service/subagent-workflow/empathy-observer-workflow-manager.ts +48 -386
- package/src/service/subagent-workflow/index.ts +2 -0
- package/src/service/subagent-workflow/nocturnal-workflow-manager.ts +169 -284
- package/src/service/subagent-workflow/runtime-direct-driver.ts +114 -16
- package/src/service/subagent-workflow/subagent-error-utils.ts +25 -0
- package/src/service/subagent-workflow/types.ts +9 -4
- package/src/service/subagent-workflow/workflow-manager-base.ts +573 -0
- package/src/service/subagent-workflow/workflow-store.ts +71 -11
- package/src/service/trajectory-service.ts +2 -1
- package/src/tools/critique-prompt.ts +1 -1
- package/src/tools/deep-reflect.ts +175 -209
- package/src/tools/model-index.ts +2 -1
- package/src/types/event-types.ts +2 -2
- package/src/types/principle-tree-schema.ts +29 -23
- package/src/utils/file-lock.ts +5 -3
- package/src/utils/io.ts +5 -2
- package/src/utils/nlp.ts +5 -46
- package/src/utils/node-vm-polyfill.ts +11 -0
- package/src/utils/plugin-logger.ts +2 -0
- package/src/utils/retry.ts +572 -0
- package/src/utils/subagent-probe.ts +1 -1
- package/templates/langs/en/core/AGENTS.md +0 -13
- package/templates/langs/en/core/SOUL.md +1 -31
- package/templates/langs/en/core/TOOLS.md +0 -4
- package/templates/langs/en/principles/THINKING_OS.md +77 -0
- package/templates/langs/en/skills/admin/SKILL.md +0 -1
- package/templates/langs/en/skills/evolution-framework-update/SKILL.md +1 -1
- package/templates/langs/en/skills/pd-diagnostician/SKILL.md +18 -5
- package/templates/langs/zh/core/AGENTS.md +0 -22
- package/templates/langs/zh/core/SOUL.md +1 -31
- package/templates/langs/zh/core/TOOLS.md +0 -4
- package/templates/langs/zh/principles/THINKING_OS.md +77 -0
- package/templates/langs/zh/skills/admin/SKILL.md +0 -1
- package/templates/langs/zh/skills/evolution-framework-update/SKILL.md +1 -1
- package/templates/langs/zh/skills/pd-diagnostician/SKILL.md +25 -4
- package/tests/commands/evolution-status.test.ts +119 -0
- package/tests/commands/implementation-lifecycle.test.ts +362 -0
- package/tests/core/code-implementation-storage.test.ts +398 -0
- package/tests/core/evolution-reducer.detector-metadata.test.ts +28 -28
- package/tests/core/nocturnal-artifact-lineage.test.ts +53 -0
- package/tests/core/nocturnal-artificer.test.ts +241 -0
- package/tests/core/nocturnal-compliance-p-principles.test.ts +133 -0
- package/tests/core/nocturnal-rule-implementation-validator.test.ts +127 -0
- package/tests/core/pd-task-store.test.ts +126 -0
- package/tests/core/principle-internalization/deprecated-readiness.test.ts +193 -0
- package/tests/core/principle-internalization/internalization-routing-policy.test.ts +212 -0
- package/tests/core/principle-internalization/lifecycle-metrics.test.ts +350 -0
- package/tests/core/principle-internalization/principle-lifecycle-service.test.ts +211 -0
- package/tests/core/principle-training-state.test.ts +228 -1
- package/tests/core/principle-tree-ledger.test.ts +423 -0
- package/tests/core/regression-v1-9-1.test.ts +265 -0
- package/tests/core/replay-engine.test.ts +234 -0
- package/tests/core/rule-host-helpers.test.ts +120 -0
- package/tests/core/rule-host.test.ts +389 -0
- package/tests/core/rule-implementation-runtime.test.ts +64 -0
- package/tests/core/workspace-context.test.ts +53 -0
- package/tests/core/workspace-dir-validation.test.ts +272 -0
- package/tests/hooks/gate-rule-host-pipeline.test.ts +385 -0
- package/tests/hooks/pain.test.ts +74 -10
- package/tests/hooks/prompt.test.ts +63 -1
- package/tests/integration/principle-lifecycle.e2e.test.ts +197 -0
- package/tests/integration/tool-hooks-workspace-dir.e2e.test.ts +211 -0
- package/tests/service/data-endpoints-regression.test.ts +834 -0
- package/tests/service/evolution-worker.test.ts +0 -123
- package/tests/service/nocturnal-service-code-candidate.test.ts +330 -0
- package/tests/utils/nlp.test.ts +1 -19
- package/tests/utils/retry.test.ts +327 -0
- package/ui/src/App.tsx +1 -1
- package/ui/src/api.ts +4 -0
- package/ui/src/charts.tsx +366 -0
- package/ui/src/components/WorkspaceConfig.tsx +107 -75
- package/ui/src/i18n/ui.ts +89 -31
- package/ui/src/pages/EvolutionPage.tsx +1 -1
- package/ui/src/pages/OverviewPage.tsx +441 -81
- package/ui/src/pages/ThinkingModelsPage.tsx +287 -69
- package/ui/src/styles.css +43 -0
- package/ui/src/types.ts +17 -1
- package/src/agents/nocturnal-dreamer.md +0 -152
- package/src/agents/nocturnal-philosopher.md +0 -138
- package/src/agents/nocturnal-reflector.md +0 -126
- package/src/agents/nocturnal-scribe.md +0 -164
- package/templates/workspace/.principles/00-kernel.md +0 -51
- package/templates/workspace/.principles/DECISION_POLICY.json +0 -44
- package/templates/workspace/.principles/PRINCIPLES.md +0 -20
- package/templates/workspace/.principles/PROFILE.json +0 -54
- package/templates/workspace/.principles/PROFILE.schema.json +0 -56
- package/templates/workspace/.principles/THINKING_OS.md +0 -64
- package/templates/workspace/.principles/THINKING_OS_ARCHIVE.md +0 -7
- package/templates/workspace/.principles/THINKING_OS_CANDIDATES.md +0 -9
- package/templates/workspace/.principles/models/_INDEX.md +0 -27
- package/templates/workspace/.principles/models/first_principles.md +0 -62
- package/templates/workspace/.principles/models/marketing_4p.md +0 -52
- package/templates/workspace/.principles/models/porter_five.md +0 -63
- package/templates/workspace/.principles/models/swot.md +0 -60
- package/templates/workspace/.principles/models/user_story_map.md +0 -63
- package/templates/workspace/.state/WORKBOARD.json +0 -4
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* - All errors caught silently — return empty string on failure
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import * as fs from 'fs';
|
|
22
|
+
import type * as fs from 'fs';
|
|
23
|
+
import * as fsPromises from 'fs/promises';
|
|
23
24
|
import * as path from 'path';
|
|
24
25
|
import * as os from 'os';
|
|
25
26
|
|
|
@@ -46,27 +47,38 @@ function getAgentsDir(): string {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// =========================================================================
|
|
49
|
-
// Safe File Reading
|
|
50
|
+
// Safe File Reading (Async)
|
|
50
51
|
// =========================================================================
|
|
51
52
|
|
|
52
|
-
function safeTail(filePath: string): string[] {
|
|
53
|
+
async function safeTail(filePath: string): Promise<string[]> {
|
|
53
54
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
// Check existence and stats asynchronously
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/init-declarations -- assigned in try, catch has early return
|
|
57
|
+
let stat: fs.Stats;
|
|
58
|
+
try {
|
|
59
|
+
stat = await fsPromises.stat(filePath);
|
|
60
|
+
} catch {
|
|
61
|
+
return []; // File doesn't exist or can't be accessed
|
|
62
|
+
}
|
|
56
63
|
if (stat.size === 0) return [];
|
|
57
64
|
|
|
58
65
|
const isTruncated = stat.size > TAIL_READ_SIZE;
|
|
59
66
|
const readSize = Math.min(stat.size, TAIL_READ_SIZE);
|
|
60
67
|
const buffer = Buffer.alloc(readSize);
|
|
61
|
-
|
|
68
|
+
|
|
69
|
+
// Use async file read
|
|
70
|
+
const fileHandle = await fsPromises.open(filePath, 'r');
|
|
62
71
|
try {
|
|
63
|
-
|
|
72
|
+
await fileHandle.read(buffer, 0, readSize, stat.size - readSize);
|
|
73
|
+
await fileHandle.close();
|
|
64
74
|
const content = buffer.toString('utf8');
|
|
65
75
|
// Only strip first line if file was actually truncated (started mid-line)
|
|
66
76
|
const validContent = isTruncated ? content.slice(content.indexOf('\n') + 1) : content;
|
|
67
77
|
return validContent.split('\n').filter(l => l.trim().length > 0);
|
|
68
|
-
}
|
|
69
|
-
|
|
78
|
+
} catch (err) {
|
|
79
|
+
// Ensure file handle is closed even on error
|
|
80
|
+
try { await fileHandle.close(); } catch { /* ignore close error */ }
|
|
81
|
+
throw err;
|
|
70
82
|
}
|
|
71
83
|
} catch (err) {
|
|
72
84
|
console.debug(`[pain-context-extractor] safeTail failed: ${String(err)}`);
|
|
@@ -81,7 +93,7 @@ function safeTail(filePath: string): string[] {
|
|
|
81
93
|
interface ParsedMessage {
|
|
82
94
|
role: string;
|
|
83
95
|
textParts: string[];
|
|
84
|
-
toolCalls:
|
|
96
|
+
toolCalls: { id?: string; name?: string; arguments?: Record<string, unknown> }[];
|
|
85
97
|
toolCallId?: string;
|
|
86
98
|
toolName?: string;
|
|
87
99
|
details?: { exitCode?: number; isError?: boolean; aggregated?: string };
|
|
@@ -193,14 +205,14 @@ function extractTurn(msg: ParsedMessage): string | null {
|
|
|
193
205
|
*/
|
|
194
206
|
export async function extractRecentConversation(
|
|
195
207
|
sessionId: string,
|
|
196
|
-
agentId
|
|
208
|
+
agentId = 'main',
|
|
197
209
|
maxTurns: number = MAX_TURNS,
|
|
198
210
|
): Promise<string> {
|
|
199
211
|
if (!sessionId || sessionId.length < 5 || !SAFE_ID_REGEX.test(sessionId)) return '';
|
|
200
212
|
if (agentId && !SAFE_ID_REGEX.test(agentId)) return '';
|
|
201
213
|
try {
|
|
202
214
|
const jsonlPath = path.join(getAgentsDir(), agentId, 'sessions', `${sessionId}.jsonl`);
|
|
203
|
-
const lines = safeTail(jsonlPath);
|
|
215
|
+
const lines = await safeTail(jsonlPath);
|
|
204
216
|
const messages = parseSafeMessages(lines);
|
|
205
217
|
if (messages.length === 0) return '';
|
|
206
218
|
|
|
@@ -223,9 +235,11 @@ export async function extractRecentConversation(
|
|
|
223
235
|
/**
|
|
224
236
|
* Extracts failed tool call context with argument correlation.
|
|
225
237
|
*/
|
|
238
|
+
/* eslint-disable @typescript-eslint/default-param-last */ // Reason: breaking API change - default param must precede required params for type inference compatibility
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/max-params -- Reason: context extraction requires session + agent + tool + path - refactoring would break API
|
|
226
240
|
export async function extractFailedToolContext(
|
|
227
241
|
sessionId: string,
|
|
228
|
-
agentId
|
|
242
|
+
agentId = 'main',
|
|
229
243
|
toolName: string,
|
|
230
244
|
filePath?: string,
|
|
231
245
|
): Promise<string> {
|
|
@@ -233,7 +247,7 @@ export async function extractFailedToolContext(
|
|
|
233
247
|
if (agentId && !SAFE_ID_REGEX.test(agentId)) return '';
|
|
234
248
|
try {
|
|
235
249
|
const jsonlPath = path.join(getAgentsDir(), agentId, 'sessions', `${sessionId}.jsonl`);
|
|
236
|
-
const lines = safeTail(jsonlPath);
|
|
250
|
+
const lines = await safeTail(jsonlPath);
|
|
237
251
|
const messages = parseSafeMessages(lines);
|
|
238
252
|
if (messages.length === 0) return '';
|
|
239
253
|
|
|
@@ -266,7 +280,7 @@ export async function extractFailedToolContext(
|
|
|
266
280
|
const isError = msg.details?.isError || (exitCode !== undefined && exitCode !== 0);
|
|
267
281
|
if (!isError) continue;
|
|
268
282
|
|
|
269
|
-
const toolCallId = msg
|
|
283
|
+
const {toolCallId} = msg;
|
|
270
284
|
const correlated = toolCallId ? toolArgsById.get(toolCallId) : null;
|
|
271
285
|
if (filePath && correlated && !correlated.fullArgs.includes(filePath)) continue;
|
|
272
286
|
|
package/src/core/pain.ts
CHANGED
|
@@ -86,6 +86,7 @@ export function validatePainFlag(data: Record<string, string>): string[] {
|
|
|
86
86
|
return missing;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/max-params -- Reason: Score computation requires all 5 parameters - refactoring to options object would be breaking API change
|
|
89
90
|
export function computePainScore(rc: number, isSpiral: boolean, missingTestCommand: boolean, softScore: number, projectDir?: string): number {
|
|
90
91
|
let score = Math.max(0, softScore || 0);
|
|
91
92
|
|
|
@@ -112,7 +113,7 @@ export function computePainScore(rc: number, isSpiral: boolean, missingTestComma
|
|
|
112
113
|
return Math.min(100, score);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
export function painSeverityLabel(painScore: number, isSpiral
|
|
116
|
+
export function painSeverityLabel(painScore: number, isSpiral = false, projectDir?: string): string {
|
|
116
117
|
if (isSpiral) {
|
|
117
118
|
return "critical";
|
|
118
119
|
}
|
|
@@ -153,7 +154,7 @@ export function readPainFlagData(projectDir: string): Record<string, string> {
|
|
|
153
154
|
}
|
|
154
155
|
const content = fs.readFileSync(painFlagPath, "utf-8");
|
|
155
156
|
return parseKvLines(content);
|
|
156
|
-
} catch (e) {
|
|
157
|
+
} catch (e) { // eslint-disable-line @typescript-eslint/no-unused-vars, no-unused-vars -- Reason: intentionally unused - returning empty object on error
|
|
157
158
|
return {};
|
|
158
159
|
}
|
|
159
160
|
}
|
|
@@ -164,15 +165,16 @@ export function readPainFlagData(projectDir: string): Record<string, string> {
|
|
|
164
165
|
* If any principle matches the pain signal, its painPreventedCount is incremented.
|
|
165
166
|
* Errors are silently ignored to avoid disrupting the pain pipeline.
|
|
166
167
|
*/
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/max-params -- Reason: principle value tracking requires workspace + data + getters + updaters - refactoring would break API
|
|
167
169
|
export function trackPrincipleValue(
|
|
168
170
|
workspaceDir: string,
|
|
169
171
|
painData: { reason?: string; source?: string; score?: string },
|
|
170
|
-
getActivePrinciples: () =>
|
|
172
|
+
getActivePrinciples: () => {
|
|
171
173
|
id: string;
|
|
172
174
|
trigger: string;
|
|
173
175
|
valueMetrics?: { painPreventedCount: number; lastPainPreventedAt?: string; calculatedAt: string };
|
|
174
|
-
}
|
|
175
|
-
updatePrincipleMetrics: (
|
|
176
|
+
}[],
|
|
177
|
+
updatePrincipleMetrics: (_id: string, _metrics: { painPreventedCount: number; lastPainPreventedAt: string; calculatedAt: string }) => void, // eslint-disable-line no-unused-vars -- Reason: callback params required by interface, actual values accessed via principle.id and principle.valueMetrics
|
|
176
178
|
): void {
|
|
177
179
|
try {
|
|
178
180
|
const activePrinciples = getActivePrinciples();
|
|
@@ -8,10 +8,12 @@ export interface PathResolverOptions {
|
|
|
8
8
|
workspaceDir?: string;
|
|
9
9
|
normalizeWorkspace?: boolean;
|
|
10
10
|
logger?: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/* eslint-disable no-unused-vars -- Reason: logger callback param names intentionally unused - callbacks only invoked for side effects */
|
|
12
|
+
debug?: (_msg: string) => void;
|
|
13
|
+
info?: (_msg: string) => void;
|
|
14
|
+
warn?: (_msg: string) => void;
|
|
15
|
+
error?: (_msg: string) => void;
|
|
16
|
+
/* eslint-enable no-unused-vars */
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -96,7 +98,6 @@ function findConfigFile(): string | null {
|
|
|
96
98
|
return null;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
/* eslint-disable no-console */
|
|
100
101
|
function loadConfigFromFile(): PDConfig | null {
|
|
101
102
|
const configPath = findConfigFile();
|
|
102
103
|
if (!configPath) {
|
|
@@ -113,7 +114,6 @@ function loadConfigFromFile(): PDConfig | null {
|
|
|
113
114
|
return null;
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
|
-
/* eslint-enable no-console */
|
|
117
117
|
|
|
118
118
|
export class PathResolver {
|
|
119
119
|
private static extensionRoot: string | null = null;
|
|
@@ -302,7 +302,6 @@ export class PathResolver {
|
|
|
302
302
|
'PROFILE': workspacePath.join(workspace, '.principles', 'PROFILE.json'),
|
|
303
303
|
'PRINCIPLES': workspacePath.join(workspace, '.principles', 'PRINCIPLES.md'),
|
|
304
304
|
'THINKING_OS': workspacePath.join(workspace, '.principles', 'THINKING_OS.md'),
|
|
305
|
-
'KERNEL': workspacePath.join(workspace, '.principles', '00-kernel.md'),
|
|
306
305
|
'DECISION_POLICY': workspacePath.join(workspace, '.principles', 'DECISION_POLICY.json'),
|
|
307
306
|
'MODELS_DIR': workspacePath.join(workspace, '.principles', 'models'),
|
|
308
307
|
'PLAN': workspacePath.join(workspace, 'PLAN.md'),
|
|
@@ -355,25 +354,25 @@ export class PathResolver {
|
|
|
355
354
|
}
|
|
356
355
|
}
|
|
357
356
|
|
|
358
|
-
static createFromHookContext(ctx:
|
|
357
|
+
static createFromHookContext(ctx: Record<string, unknown>): PathResolver {
|
|
359
358
|
const resolver = new PathResolver();
|
|
360
|
-
|
|
359
|
+
|
|
361
360
|
if (ctx?.workspaceDir) {
|
|
362
|
-
let workspaceDir = ctx.workspaceDir;
|
|
363
|
-
|
|
361
|
+
let workspaceDir = String(ctx.workspaceDir);
|
|
362
|
+
|
|
364
363
|
if (resolver.normalizeWorkspace) {
|
|
365
364
|
workspaceDir = resolver.normalizePath(workspaceDir);
|
|
366
365
|
}
|
|
367
|
-
|
|
366
|
+
|
|
368
367
|
resolver.workspaceDir = workspaceDir;
|
|
369
368
|
resolver.initialized = true;
|
|
370
369
|
resolver.log('info', `Created from hook context with workspace: ${workspaceDir}`);
|
|
371
370
|
}
|
|
372
|
-
|
|
371
|
+
|
|
373
372
|
if (ctx?.stateDir) {
|
|
374
|
-
resolver.stateDir = ctx.stateDir;
|
|
373
|
+
resolver.stateDir = String(ctx.stateDir);
|
|
375
374
|
}
|
|
376
|
-
|
|
375
|
+
|
|
377
376
|
return resolver;
|
|
378
377
|
}
|
|
379
378
|
}
|
|
@@ -421,7 +420,9 @@ export function resolveWorkspaceDirFromApi(
|
|
|
421
420
|
if (!api) return undefined;
|
|
422
421
|
|
|
423
422
|
// 1. Official API: api.runtime.agent.resolveAgentWorkspaceDir
|
|
423
|
+
/* eslint-disable no-unused-vars -- Reason: type callback params cfg/id unused - actual values passed are api.config and agentId */
|
|
424
424
|
const officialAgent = (api.runtime as { agent?: { resolveAgentWorkspaceDir?: (cfg: unknown, id: string) => string } }).agent;
|
|
425
|
+
/* eslint-enable no-unused-vars */
|
|
425
426
|
if (officialAgent?.resolveAgentWorkspaceDir) {
|
|
426
427
|
try {
|
|
427
428
|
return officialAgent.resolveAgentWorkspaceDir(api.config, agentId ?? 'main');
|
package/src/core/paths.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const PD_DIRS = {
|
|
|
33
33
|
NOCTURNAL_SAMPLES: posixJoin('.state', 'nocturnal', 'samples'),
|
|
34
34
|
NOCTURNAL_MEMORY: posixJoin('.state', 'nocturnal', 'memory'),
|
|
35
35
|
NOCTURNAL_EXPORTS: posixJoin('.state', 'exports', 'orpo'),
|
|
36
|
+
IMPL_CODE_DIR: posixJoin('.state', 'principles', 'implementations'),
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -42,7 +43,6 @@ export const PD_FILES = {
|
|
|
42
43
|
PROFILE: posixJoin(PD_DIRS.IDENTITY, 'PROFILE.json'),
|
|
43
44
|
PRINCIPLES: posixJoin(PD_DIRS.IDENTITY, 'PRINCIPLES.md'),
|
|
44
45
|
THINKING_OS: posixJoin(PD_DIRS.IDENTITY, 'THINKING_OS.md'),
|
|
45
|
-
KERNEL: posixJoin(PD_DIRS.IDENTITY, '00-kernel.md'),
|
|
46
46
|
DECISION_POLICY: posixJoin(PD_DIRS.IDENTITY, 'DECISION_POLICY.json'),
|
|
47
47
|
MODELS_DIR: PD_DIRS.MODELS,
|
|
48
48
|
|
|
@@ -65,6 +65,7 @@ export const PD_FILES = {
|
|
|
65
65
|
NOCTURNAL_SAMPLES_DIR: PD_DIRS.NOCTURNAL_SAMPLES,
|
|
66
66
|
NOCTURNAL_MEMORY_DIR: PD_DIRS.NOCTURNAL_MEMORY,
|
|
67
67
|
NOCTURNAL_EXPORTS_DIR: PD_DIRS.NOCTURNAL_EXPORTS,
|
|
68
|
+
IMPL_CODE_DIR: PD_DIRS.IMPL_CODE_DIR,
|
|
68
69
|
|
|
69
70
|
PLAN: 'PLAN.md',
|
|
70
71
|
MEMORY_MD: 'MEMORY.md',
|