ptbk 0.119.0-21 → 0.119.0-26
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/README.md +16 -9
- package/dist/browser/browser.d.ts +50 -36
- package/dist/browser/browser.js +162 -118
- package/dist/browser/browser.js.map +1 -1
- package/dist/browser/fleet.d.ts +59 -0
- package/dist/browser/fleet.js +148 -0
- package/dist/browser/fleet.js.map +1 -0
- package/dist/browser/recording.js +2 -2
- package/dist/browser/recording.js.map +1 -1
- package/dist/chats/conversation.d.ts +1 -1
- package/dist/chats/conversation.js +8 -6
- package/dist/chats/conversation.js.map +1 -1
- package/dist/chats/local.js +5 -5
- package/dist/chats/local.js.map +1 -1
- package/dist/cli/commands/add.js +1 -1
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/boilerplates.js +1 -1
- package/dist/cli/commands/boilerplates.js.map +1 -1
- package/dist/cli/commands/find.js +1 -1
- package/dist/cli/commands/find.js.map +1 -1
- package/dist/cli/commands/fix.js +9 -4
- package/dist/cli/commands/fix.js.map +1 -1
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.js +279 -118
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/migrate.js +1 -1
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands/ping.js +20 -12
- package/dist/cli/commands/ping.js.map +1 -1
- package/dist/cli/commands/plan.js +20 -12
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/recover.js +1 -1
- package/dist/cli/commands/recover.js.map +1 -1
- package/dist/cli/commands/restart.js +6 -5
- package/dist/cli/commands/restart.js.map +1 -1
- package/dist/cli/commands/run.js +26 -15
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/start.js +11 -7
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/tool.d.ts +19 -0
- package/dist/cli/commands/tool.js +320 -0
- package/dist/cli/commands/tool.js.map +1 -0
- package/dist/cli/commands/verify.js +1 -1
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/common.d.ts +7 -1
- package/dist/cli/common.js +37 -20
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/compatibility.d.ts +8 -0
- package/dist/cli/compatibility.js +32 -0
- package/dist/cli/compatibility.js.map +1 -0
- package/dist/cli/parser.js +7 -3
- package/dist/cli/parser.js.map +1 -1
- package/dist/cli/registry.js +182 -7
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli/service-view.js +1 -1
- package/dist/cli/service-view.js.map +1 -1
- package/dist/cli/sources.js +2 -0
- package/dist/cli/sources.js.map +1 -1
- package/dist/cli/spec.js +8 -6
- package/dist/cli/spec.js.map +1 -1
- package/dist/common/naming.d.ts +53 -0
- package/dist/common/naming.js +90 -0
- package/dist/common/naming.js.map +1 -0
- package/dist/engine/agenda.d.ts +70 -9
- package/dist/engine/agenda.js +294 -61
- package/dist/engine/agenda.js.map +1 -1
- package/dist/engine/executor.d.ts +5 -0
- package/dist/engine/executor.js +24 -11
- package/dist/engine/executor.js.map +1 -1
- package/dist/engine/harnesses.d.ts +82 -18
- package/dist/engine/harnesses.js +191 -39
- package/dist/engine/harnesses.js.map +1 -1
- package/dist/engine/preview.js +2 -2
- package/dist/engine/preview.js.map +1 -1
- package/dist/engine/routing.d.ts +10 -0
- package/dist/engine/routing.js +67 -28
- package/dist/engine/routing.js.map +1 -1
- package/dist/engine/snapshot.d.ts +107 -7
- package/dist/engine/state.d.ts +4 -2
- package/dist/engine/state.js.map +1 -1
- package/dist/engine/sync.d.ts +96 -0
- package/dist/engine/sync.js +199 -0
- package/dist/engine/sync.js.map +1 -0
- package/dist/engine/team.d.ts +1 -0
- package/dist/engine/team.js +12 -8
- package/dist/engine/team.js.map +1 -1
- package/dist/expert/_main.md +96 -67
- package/dist/expert/agents/_index.md +10 -7
- package/dist/expert/agents/core-agents.md +4 -2
- package/dist/expert/agents/fixer.md +15 -12
- package/dist/expert/cli/acceptance.md +96 -78
- package/dist/expert/cli/api.md +26 -14
- package/dist/expert/cli/autonomous-operation.md +17 -19
- package/dist/expert/cli/browser.md +24 -24
- package/dist/expert/cli/checks.md +18 -10
- package/dist/expert/cli/cli.md +48 -41
- package/dist/expert/cli/configuration-migrations.md +43 -0
- package/dist/expert/cli/configuration.md +24 -14
- package/dist/expert/cli/controls.md +23 -11
- package/dist/expert/cli/dashboard-details.md +28 -10
- package/dist/expert/cli/dashboard-layout.md +15 -15
- package/dist/expert/cli/dashboard.md +8 -10
- package/dist/expert/cli/environment.md +33 -0
- package/dist/expert/cli/execution.md +10 -8
- package/dist/expert/cli/git-persistence.md +27 -21
- package/dist/expert/cli/git-preflight.md +8 -4
- package/dist/expert/cli/git-synchronization.md +32 -6
- package/dist/expert/cli/harness-plugins.md +12 -12
- package/dist/expert/cli/harnesses.md +22 -16
- package/dist/expert/cli/initialization-ui.md +14 -14
- package/dist/expert/cli/initialization.md +31 -21
- package/dist/expert/cli/installation.md +6 -0
- package/dist/expert/cli/isolation.md +5 -3
- package/dist/expert/cli/releasing.md +17 -3
- package/dist/expert/cli/retries.md +10 -8
- package/dist/expert/cli/run.md +7 -5
- package/dist/expert/cli/start.md +21 -15
- package/dist/expert/cli/status-view.md +15 -17
- package/dist/expert/cli/synchronization-setup.md +24 -0
- package/dist/expert/cli/terminal.md +14 -16
- package/dist/expert/cli/tool-management.md +60 -0
- package/dist/expert/cli/tool-runtime.md +35 -0
- package/dist/expert/cli/tools-migration.md +50 -0
- package/dist/expert/cli/tools.md +73 -0
- package/dist/expert/cli/trace-configuration.md +9 -11
- package/dist/expert/cli/updates.md +7 -7
- package/dist/expert/cli/windows-installer.md +67 -0
- package/dist/expert/cli/workspace.md +2 -0
- package/dist/expert/coding-standards/_index.md +11 -0
- package/dist/expert/coding-standards/naming.md +30 -0
- package/dist/expert/coding-standards/shared-logic.md +27 -0
- package/dist/expert/concepts/automatic-repair.md +33 -0
- package/dist/expert/concepts/engine-and-project.md +7 -5
- package/dist/expert/dictionary.md +18 -18
- package/dist/harness/plugins/claude-code/index.js +4 -2
- package/dist/harness/plugins/claude-code/index.js.map +1 -1
- package/dist/harness/plugins/cline/index.js +1 -0
- package/dist/harness/plugins/cline/index.js.map +1 -1
- package/dist/harness/plugins/gemini/index.js +2 -0
- package/dist/harness/plugins/gemini/index.js.map +1 -1
- package/dist/harness/plugins/github-copilot/index.js +1 -0
- package/dist/harness/plugins/github-copilot/index.js.map +1 -1
- package/dist/harness/plugins/openai-codex/index.js +13 -9
- package/dist/harness/plugins/openai-codex/index.js.map +1 -1
- package/dist/harness/plugins/opencode/index.js +1 -0
- package/dist/harness/plugins/opencode/index.js.map +1 -1
- package/dist/harness/plugins/qwen-code/index.js +1 -0
- package/dist/harness/plugins/qwen-code/index.js.map +1 -1
- package/dist/harness/types.d.ts +16 -5
- package/dist/project/config.d.ts +135 -48
- package/dist/project/config.js +331 -119
- package/dist/project/config.js.map +1 -1
- package/dist/project/configuration.d.ts +43 -0
- package/dist/project/configuration.js +165 -0
- package/dist/project/configuration.js.map +1 -0
- package/dist/project/defaults.d.ts +4 -2
- package/dist/project/defaults.js +10 -5
- package/dist/project/defaults.js.map +1 -1
- package/dist/project/git.d.ts +28 -0
- package/dist/project/git.js +81 -0
- package/dist/project/git.js.map +1 -1
- package/dist/project/migrations.d.ts +96 -0
- package/dist/project/migrations.js +301 -0
- package/dist/project/migrations.js.map +1 -0
- package/dist/project/publication.d.ts +57 -0
- package/dist/project/publication.js +117 -0
- package/dist/project/publication.js.map +1 -0
- package/dist/project/readiness.d.ts +14 -5
- package/dist/project/readiness.js +23 -22
- package/dist/project/readiness.js.map +1 -1
- package/dist/project/setup.js +2 -0
- package/dist/project/setup.js.map +1 -1
- package/dist/service/actions.d.ts +12 -4
- package/dist/service/actions.js +32 -2
- package/dist/service/actions.js.map +1 -1
- package/dist/service/control.d.ts +1 -1
- package/dist/service/control.js +1 -1
- package/dist/service/host.d.ts +5 -2
- package/dist/service/host.js +26 -16
- package/dist/service/host.js.map +1 -1
- package/dist/service/http.js +7 -2
- package/dist/service/http.js.map +1 -1
- package/dist/service/launcher.d.ts +2 -1
- package/dist/service/launcher.js +1 -0
- package/dist/service/launcher.js.map +1 -1
- package/dist/service/records.d.ts +3 -0
- package/dist/service/records.js +1 -1
- package/dist/service/records.js.map +1 -1
- package/dist/service/spa/app.css +39 -0
- package/dist/service/spa/app.js +242 -39
- package/dist/service/worker.js +1 -0
- package/dist/service/worker.js.map +1 -1
- package/dist/tools/environment.d.ts +122 -0
- package/dist/tools/environment.js +199 -0
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/model.d.ts +180 -0
- package/dist/tools/model.js +111 -0
- package/dist/tools/model.js.map +1 -0
- package/dist/tools/normalize.d.ts +51 -0
- package/dist/tools/normalize.js +321 -0
- package/dist/tools/normalize.js.map +1 -0
- package/dist/tools/operations.d.ts +198 -0
- package/dist/tools/operations.js +378 -0
- package/dist/tools/operations.js.map +1 -0
- package/dist/tools/readiness.d.ts +72 -0
- package/dist/tools/readiness.js +160 -0
- package/dist/tools/readiness.js.map +1 -0
- package/dist/ui/dashboard.d.ts +3 -0
- package/dist/ui/dashboard.js +173 -2
- package/dist/ui/dashboard.js.map +1 -1
- package/dist/ui/details.d.ts +35 -1
- package/dist/ui/details.js +103 -2
- package/dist/ui/details.js.map +1 -1
- package/dist/ui/secret.d.ts +8 -0
- package/dist/ui/secret.js +41 -0
- package/dist/ui/secret.js.map +1 -0
- package/dist/ui/status-view.d.ts +1 -0
- package/dist/ui/status-view.js +33 -8
- package/dist/ui/status-view.js.map +1 -1
- package/dist/ui/tool-forms.d.ts +24 -0
- package/dist/ui/tool-forms.js +133 -0
- package/dist/ui/tool-forms.js.map +1 -0
- package/package.json +1 -1
package/dist/project/config.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { formatDuration, parseDuration } from '../common/duration.js';
|
|
2
2
|
import { PtbkError } from '../common/errors.js';
|
|
3
3
|
import { readTextIfExists, writeFileAtomic } from '../common/fs.js';
|
|
4
|
+
import { canonicalEnumValue, matchEnum, matchProperty } from '../common/naming.js';
|
|
4
5
|
import { systemTimeZone } from '../common/time.js';
|
|
6
|
+
import { ENGINE_VERSION } from '../common/version.js';
|
|
7
|
+
import { HARNESS_VARIANTS, THINKING_LEVELS, enabledToolsOf, harnessPluginId, harnessVariantOf } from '../tools/model.js';
|
|
8
|
+
import { parseTools } from '../tools/normalize.js';
|
|
9
|
+
import { applyConfigurationMigration, planConfigurationMigration } from './migrations.js';
|
|
10
|
+
export { THINKING_LEVELS };
|
|
5
11
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @private project configuration
|
|
9
|
-
*/
|
|
10
|
-
export const THINKING_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
11
|
-
/**
|
|
12
|
-
* Every scalar setting (the per-harness map is handled separately).
|
|
12
|
+
* Every scalar setting (named tools live in `tools`, see the shared tool contract).
|
|
13
13
|
*
|
|
14
14
|
* @private project configuration
|
|
15
15
|
*/
|
|
16
16
|
export const SETTING_SPECS = [
|
|
17
|
+
{ key: 'isAutoSync', type: 'boolean', default: false, description: 'Automatic Git synchronization with the existing origin and current branch (pull every 60 s and at operation boundaries, push completed work).', application: 'live' },
|
|
17
18
|
{ key: 'paths.agents', type: 'string', default: 'agents', description: 'Directory of agent Books.', application: 'restart' },
|
|
18
19
|
{ key: 'paths.tasks', type: 'string', default: 'tasks', description: 'Task source directory.', application: 'restart' },
|
|
19
20
|
{ key: 'paths.context', type: 'nullable-string', default: 'AGENTS.md', description: 'Additional project context file (null disables).', application: 'next-task' },
|
|
20
21
|
{ key: 'routing.defaultAgent', type: 'string', default: 'Developer', description: 'Agent used by run/fix/plan when none is selected.', application: 'next-task' },
|
|
21
|
-
{
|
|
22
|
+
{
|
|
23
|
+
key: 'routing.harness',
|
|
24
|
+
type: 'enum',
|
|
25
|
+
values: HARNESS_VARIANTS.map(harnessPluginId),
|
|
26
|
+
default: undefined,
|
|
27
|
+
env: 'PTBK_HARNESS',
|
|
28
|
+
description: 'Default/bootstrap harness variant (used directly by Manager).',
|
|
29
|
+
application: 'next-task',
|
|
30
|
+
},
|
|
22
31
|
{ key: 'routing.model', type: 'string', default: undefined, env: 'PTBK_MODEL', description: 'Default model of the default harness.', application: 'next-task' },
|
|
23
32
|
{
|
|
24
33
|
key: 'routing.thinkingLevel',
|
|
@@ -52,15 +61,13 @@ export const SETTING_SPECS = [
|
|
|
52
61
|
description: 'Policy for unrelated uncommitted changes.',
|
|
53
62
|
application: 'next-task',
|
|
54
63
|
},
|
|
55
|
-
{ key: 'execution.
|
|
56
|
-
{ key: 'execution.
|
|
57
|
-
{ key: 'execution.
|
|
58
|
-
{ key: 'execution.
|
|
59
|
-
{ key: 'execution.
|
|
60
|
-
{ key: 'execution.
|
|
61
|
-
{ key: 'execution.
|
|
62
|
-
{ key: 'execution.preserveLogs', type: 'boolean', default: false, description: 'Keep all system logs in .ptbk/ without rotation (task traces are never rotated).', application: 'live' },
|
|
63
|
-
{ key: 'execution.autoMigrate', type: 'boolean', default: false, description: 'Run the configured migration hook after agent work.', application: 'next-task' },
|
|
64
|
+
{ key: 'execution.isCommitEnabled', type: 'boolean', default: true, description: 'Commit versioned changes automatically.', application: 'restart' },
|
|
65
|
+
{ key: 'execution.isIsolated', type: 'boolean', default: false, description: 'Execute tasks in a separate Git worktree.', application: 'next-task' },
|
|
66
|
+
{ key: 'execution.isLineEndingNormalizationEnabled', type: 'boolean', default: true, description: 'Normalize CRLF in changed files of LF projects.', application: 'next-task' },
|
|
67
|
+
{ key: 'execution.isCreditFallbackAllowed', type: 'boolean', default: false, description: 'Authorize explicit paid-credit fallback where supported.', application: 'next-task' },
|
|
68
|
+
{ key: 'execution.isQuestionsEnabled', type: 'boolean', default: true, description: 'Allow agents to ask the user.', application: 'next-task' },
|
|
69
|
+
{ key: 'execution.isLogPreservationEnabled', type: 'boolean', default: false, description: 'Keep all system logs in .ptbk/ without rotation (task traces are never rotated).', application: 'live' },
|
|
70
|
+
{ key: 'execution.isAutoMigrateEnabled', type: 'boolean', default: false, description: 'Run the configured migration hook after agent work.', application: 'next-task' },
|
|
64
71
|
{ key: 'execution.migrateCommand', type: 'string', default: undefined, description: 'Project migration hook command.', application: 'next-task' },
|
|
65
72
|
{
|
|
66
73
|
key: 'execution.stallTimeout',
|
|
@@ -69,15 +76,12 @@ export const SETTING_SPECS = [
|
|
|
69
76
|
description: 'A harness producing no output for this long is treated as stalled and retried (0 disables).',
|
|
70
77
|
application: 'next-task',
|
|
71
78
|
},
|
|
72
|
-
{ key: 'traces.
|
|
73
|
-
{ key: 'traces.
|
|
74
|
-
{ key: 'traces.
|
|
75
|
-
{ key: '
|
|
76
|
-
{ key: 'browser.mode', type: 'enum', values: ['headless', 'headful'], default: 'headless', description: 'Browser visibility.', application: 'next-task' },
|
|
77
|
-
{ key: 'browser.executable', type: 'string', default: undefined, description: 'Chrome-compatible browser executable.', application: 'next-task' },
|
|
78
|
-
{ key: 'server.enabled', type: 'boolean', default: true, description: 'Serve the local HTTP API and browser dashboard.', application: 'restart' },
|
|
79
|
+
{ key: 'traces.isCommitted', type: 'boolean', default: false, description: 'Include task traces (traces/<task-file-basename>/) in result commits; false ignores the whole traces/ tree.', application: 'next-task' },
|
|
80
|
+
{ key: 'traces.isVideoIgnored', type: 'boolean', default: true, description: 'Keep trace videos out of Git even when traces are committed.', application: 'next-task' },
|
|
81
|
+
{ key: 'traces.isVideoRecordingEnabled', type: 'boolean', default: true, description: 'Record attributable activity of browser tools used by tasks.', application: 'next-task' },
|
|
82
|
+
{ key: 'server.isEnabled', type: 'boolean', default: true, description: 'Serve the local HTTP API and browser dashboard.', application: 'restart' },
|
|
79
83
|
{ key: 'server.port', type: 'port', default: undefined, description: 'Local HTTP port (automatic from 3000 when omitted).', application: 'restart' },
|
|
80
|
-
{ key: 'server.tunnel.
|
|
84
|
+
{ key: 'server.tunnel.isEnabled', type: 'boolean', default: true, description: 'Protected remote tunnel when HTTP runs.', application: 'restart' },
|
|
81
85
|
{
|
|
82
86
|
key: 'server.tunnel.provider',
|
|
83
87
|
type: 'enum',
|
|
@@ -90,12 +94,12 @@ export const SETTING_SPECS = [
|
|
|
90
94
|
{ key: 'server.tunnel.name', type: 'string', default: undefined, description: 'Named tunnel name or UUID.', application: 'restart' },
|
|
91
95
|
{ key: 'server.tunnel.credentialsFile', type: 'string', default: undefined, description: 'Path to named-tunnel credentials (reference, not content).', application: 'restart' },
|
|
92
96
|
{ key: 'server.tunnel.tokenEnv', type: 'string', default: undefined, description: 'Environment variable holding a named-tunnel token.', application: 'restart' },
|
|
93
|
-
{ key: 'service.
|
|
97
|
+
{ key: 'service.isPersistent', type: 'boolean', default: true, description: 'Restart automatically after crashes and reboots.', application: 'restart' },
|
|
94
98
|
{ key: 'service.harnessUpdates', type: 'enum', values: ['auto', 'off'], default: 'auto', description: 'Automatic harness updates.', application: 'live' },
|
|
95
|
-
{ key: 'service.
|
|
96
|
-
{ key: 'discovery.
|
|
99
|
+
{ key: 'service.isQrShown', type: 'boolean', default: true, description: 'Show QR codes.', application: 'live' },
|
|
100
|
+
{ key: 'discovery.isEnabled', type: 'boolean', default: true, description: 'Goal discovery when the backlog is empty.', application: 'live' },
|
|
97
101
|
{ key: 'discovery.cooldown', type: 'duration', default: 6 * 3_600_000, description: 'Wait after a no-work enquiry.', application: 'live' },
|
|
98
|
-
{ key: 'learning.
|
|
102
|
+
{ key: 'learning.isEnabled', type: 'boolean', default: true, description: 'Teacher follow-ups for open agents.', application: 'next-task' },
|
|
99
103
|
{ key: 'team.timeout', type: 'duration', default: 300_000, description: 'Consultation timeout.', application: 'next-task' },
|
|
100
104
|
{ key: 'team.maxDepth', type: 'integer', default: 4, description: 'Maximal consultation depth.', application: 'next-task' },
|
|
101
105
|
{ key: 'team.maxCalls', type: 'integer', default: 24, description: 'Consultations per task.', application: 'next-task' },
|
|
@@ -108,6 +112,21 @@ export const SETTING_SPECS = [
|
|
|
108
112
|
* @private project configuration
|
|
109
113
|
*/
|
|
110
114
|
export const SETTING_SPEC_BY_KEY = new Map(SETTING_SPECS.map((spec) => [spec.key, spec]));
|
|
115
|
+
/**
|
|
116
|
+
* The explicit informational check saved when a project has no real validation. It always succeeds and means that
|
|
117
|
+
* real automated validation is **not** configured; it never counts as evidence of passing tests.
|
|
118
|
+
*
|
|
119
|
+
* @private project configuration
|
|
120
|
+
*/
|
|
121
|
+
export const CHECK_PLACEHOLDER = 'echo "Configure project checks in ptbk.json execution.check"';
|
|
122
|
+
/**
|
|
123
|
+
* Whether a check command is the informational placeholder rather than real validation.
|
|
124
|
+
*
|
|
125
|
+
* @private project configuration
|
|
126
|
+
*/
|
|
127
|
+
export function isCheckPlaceholder(check) {
|
|
128
|
+
return typeof check === 'string' && check.trim() === CHECK_PLACEHOLDER;
|
|
129
|
+
}
|
|
111
130
|
/**
|
|
112
131
|
* Reads a dot path from a nested object.
|
|
113
132
|
*
|
|
@@ -143,7 +162,7 @@ export function setPath(object, path, value) {
|
|
|
143
162
|
current[last] = value;
|
|
144
163
|
}
|
|
145
164
|
/**
|
|
146
|
-
* Parses a raw value according to a setting spec.
|
|
165
|
+
* Parses a raw value according to a setting spec (tolerant: `"true"`, canonical or kebab enum spellings).
|
|
147
166
|
*
|
|
148
167
|
* @private project configuration
|
|
149
168
|
*/
|
|
@@ -187,90 +206,228 @@ export function parseSettingValue(spec, raw) {
|
|
|
187
206
|
return { ok: false, message: parsed.reason };
|
|
188
207
|
return { ok: true, value: parsed.ms };
|
|
189
208
|
}
|
|
190
|
-
case 'enum':
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
209
|
+
case 'enum': {
|
|
210
|
+
const value = matchEnum(raw, spec.values);
|
|
211
|
+
if (value)
|
|
212
|
+
return { ok: true, value };
|
|
213
|
+
return { ok: false, message: `expected one of ${spec.values.map(canonicalEnumValue).join(', ')}` };
|
|
214
|
+
}
|
|
194
215
|
}
|
|
195
216
|
}
|
|
196
217
|
/**
|
|
197
|
-
* Serializes an effective value back to its `ptbk.json` representation.
|
|
218
|
+
* Serializes an effective value back to its canonical `ptbk.json` representation.
|
|
198
219
|
*
|
|
199
220
|
* @private project configuration
|
|
200
221
|
*/
|
|
201
222
|
export function serializeSettingValue(spec, value) {
|
|
202
223
|
if (spec.type === 'duration' && typeof value === 'number')
|
|
203
224
|
return value === 0 ? '0' : formatDuration(value).replace(/\s+/g, '');
|
|
225
|
+
if (spec.type === 'enum' && typeof value === 'string')
|
|
226
|
+
return canonicalEnumValue(value);
|
|
204
227
|
return value;
|
|
205
228
|
}
|
|
206
229
|
/**
|
|
207
|
-
*
|
|
230
|
+
* Parses `ptbk.json` text.
|
|
208
231
|
*
|
|
209
232
|
* @private project configuration
|
|
210
233
|
*/
|
|
211
|
-
export
|
|
212
|
-
const text = await readTextIfExists(project.configPath);
|
|
234
|
+
export function parseConfigText(text) {
|
|
213
235
|
if (text === undefined)
|
|
214
236
|
return { raw: {}, exists: false, diagnostics: [] };
|
|
215
237
|
try {
|
|
216
238
|
const raw = JSON.parse(text);
|
|
217
239
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
218
|
-
return { raw: {}, exists: true, diagnostics: [{ location: 'ptbk.json', message: 'The file must contain a JSON object.', severity: 'error' }] };
|
|
240
|
+
return { raw: {}, exists: true, text, diagnostics: [{ location: 'ptbk.json', message: 'The file must contain a JSON object.', severity: 'error' }] };
|
|
219
241
|
}
|
|
220
|
-
return { raw: raw, exists: true, diagnostics: [] };
|
|
242
|
+
return { raw: raw, exists: true, text, diagnostics: [] };
|
|
221
243
|
}
|
|
222
244
|
catch (error) {
|
|
223
|
-
return { raw: {}, exists: true, diagnostics: [{ location: 'ptbk.json', message: `Invalid JSON: ${error.message}`, severity: 'error' }] };
|
|
245
|
+
return { raw: {}, exists: true, text, diagnostics: [{ location: 'ptbk.json', message: `Invalid JSON: ${error.message}`, severity: 'error' }] };
|
|
224
246
|
}
|
|
225
247
|
}
|
|
226
248
|
/**
|
|
227
|
-
*
|
|
249
|
+
* Reads `ptbk.json` as raw JSON; returns an empty object when missing.
|
|
250
|
+
*
|
|
251
|
+
* @private project configuration
|
|
228
252
|
*/
|
|
229
|
-
|
|
253
|
+
export async function readProjectConfigFile(project) {
|
|
254
|
+
return parseConfigText(await readTextIfExists(project.configPath));
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Known top-level keys of `ptbk.json` (canonical spellings).
|
|
258
|
+
*/
|
|
259
|
+
const KNOWN_TOP_LEVEL_KEYS = ['$schema', 'promptbookVersion', 'isAutoSync', 'tools', 'paths', 'routing', 'execution', 'traces', 'server', 'service', 'discovery', 'learning', 'team', 'timezone', 'initialized'];
|
|
230
260
|
/**
|
|
231
|
-
*
|
|
261
|
+
* Known property names per configuration object path (for tolerant key canonicalization).
|
|
232
262
|
*/
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
263
|
+
function knownKeysByPath() {
|
|
264
|
+
const map = new Map([['', [...KNOWN_TOP_LEVEL_KEYS]]]);
|
|
265
|
+
for (const spec of SETTING_SPECS) {
|
|
266
|
+
const parts = spec.key.split('.');
|
|
267
|
+
for (let index = 0; index < parts.length; index++) {
|
|
268
|
+
const parent = parts.slice(0, index).join('.');
|
|
269
|
+
const list = map.get(parent) ?? [];
|
|
270
|
+
if (!list.includes(parts[index]))
|
|
271
|
+
list.push(parts[index]);
|
|
272
|
+
map.set(parent, list);
|
|
273
|
+
}
|
|
240
274
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
275
|
+
return map;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Canonicalizes known Promptbook-owned configuration: lower camelCase keys, `is`-prefixed booleans, kebab-case tool
|
|
279
|
+
* names and SCREAMING_SNAKE_CASE enum values. Tolerant input (case/separator differences) is corrected; ambiguous or
|
|
280
|
+
* colliding input is reported as a problem and preserved unchanged. Canonical input is returned unchanged.
|
|
281
|
+
*
|
|
282
|
+
* @private project configuration
|
|
283
|
+
*/
|
|
284
|
+
export function canonicalizeConfig(input) {
|
|
285
|
+
const raw = structuredClone(input);
|
|
286
|
+
const corrections = [];
|
|
287
|
+
const problems = [];
|
|
288
|
+
const known = knownKeysByPath();
|
|
289
|
+
const walk = (object, path) => {
|
|
290
|
+
const names = known.get(path);
|
|
291
|
+
if (!names)
|
|
292
|
+
return;
|
|
293
|
+
const groups = new Map();
|
|
294
|
+
for (const key of Object.keys(object)) {
|
|
295
|
+
const canonical = matchProperty(key, names) ?? key;
|
|
296
|
+
groups.set(canonical, [...(groups.get(canonical) ?? []), key]);
|
|
246
297
|
}
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
298
|
+
const rebuilt = {};
|
|
299
|
+
for (const [canonical, spellings] of groups) {
|
|
300
|
+
if (spellings.length > 1) {
|
|
301
|
+
problems.push({ location: `ptbk.json › ${path ? `${path}.` : ''}${canonical}`, message: `conflicting spellings ${spellings.map((spelling) => `"${spelling}"`).join(', ')} of the same setting (repair needed)`, severity: 'error' });
|
|
302
|
+
for (const spelling of spellings)
|
|
303
|
+
rebuilt[spelling] = object[spelling];
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const spelling = spellings[0];
|
|
307
|
+
if (spelling !== canonical)
|
|
308
|
+
corrections.push({ location: `${path ? `${path}.` : ''}${spelling}`, from: spelling, to: canonical });
|
|
309
|
+
rebuilt[canonical] = object[spelling];
|
|
254
310
|
}
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
311
|
+
for (const key of Object.keys(object))
|
|
312
|
+
delete object[key];
|
|
313
|
+
Object.assign(object, rebuilt);
|
|
314
|
+
for (const [key, value] of Object.entries(object)) {
|
|
315
|
+
const childPath = path ? `${path}.${key}` : key;
|
|
316
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value) && known.has(childPath))
|
|
317
|
+
walk(value, childPath);
|
|
258
318
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
319
|
+
};
|
|
320
|
+
walk(raw, '');
|
|
321
|
+
for (const spec of SETTING_SPECS) {
|
|
322
|
+
const value = getPath(raw, spec.key);
|
|
323
|
+
if (value === undefined)
|
|
324
|
+
continue;
|
|
325
|
+
if (spec.type === 'enum') {
|
|
326
|
+
const parsed = matchEnum(value, spec.values);
|
|
327
|
+
if (parsed && value !== canonicalEnumValue(parsed)) {
|
|
328
|
+
corrections.push({ location: spec.key, from: String(value), to: canonicalEnumValue(parsed) });
|
|
329
|
+
setPath(raw, spec.key, canonicalEnumValue(parsed));
|
|
262
330
|
}
|
|
263
331
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
332
|
+
else if (spec.type === 'boolean' && (value === 'true' || value === 'false')) {
|
|
333
|
+
corrections.push({ location: spec.key, from: value, to: value });
|
|
334
|
+
setPath(raw, spec.key, value === 'true');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (raw.tools !== undefined) {
|
|
338
|
+
const parsed = parseTools(raw.tools);
|
|
339
|
+
corrections.push(...parsed.corrections.map((correction) => ({ ...correction, location: correction.location.replace(/^ptbk\.json › /, '') })));
|
|
340
|
+
problems.push(...parsed.problems);
|
|
341
|
+
if (parsed.corrections.length)
|
|
342
|
+
raw.tools = parsed.canonical;
|
|
343
|
+
}
|
|
344
|
+
return { raw, corrections, problems };
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Maps a legacy/temporary profile spelling to a typed profile.
|
|
348
|
+
*
|
|
349
|
+
* @private project configuration
|
|
350
|
+
*/
|
|
351
|
+
export function profileFromSpelling(value) {
|
|
352
|
+
const legacy = { global: 'MANAGED_GLOBAL', isolated: 'PROJECT', user: 'USER_EXISTING' };
|
|
353
|
+
if (legacy[value])
|
|
354
|
+
return { source: legacy[value] };
|
|
355
|
+
const canonical = matchEnum(value, ['MANAGED_GLOBAL', 'PROJECT', 'USER_EXISTING']);
|
|
356
|
+
if (canonical)
|
|
357
|
+
return { source: canonical };
|
|
358
|
+
return { source: 'CUSTOM', path: value };
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Applies `--harness` restrictions: variants keep their ordered same-variant instances; a named instance stays an
|
|
362
|
+
* explicit restriction; a selected variant without a configured instance gets a temporary native instance.
|
|
363
|
+
*/
|
|
364
|
+
function restrictHarnesses(tools, selectors, diagnostics, overridden) {
|
|
365
|
+
const variants = new Set();
|
|
366
|
+
const names = new Set();
|
|
367
|
+
for (const selector of selectors) {
|
|
368
|
+
const variant = matchEnum(selector, HARNESS_VARIANTS) ?? harnessVariantOf(selector);
|
|
369
|
+
if (variant)
|
|
370
|
+
variants.add(variant);
|
|
371
|
+
else if (tools.some((tool) => tool.type === 'HARNESS' && tool.name === selector))
|
|
372
|
+
names.add(selector);
|
|
373
|
+
else
|
|
374
|
+
diagnostics.push({ location: `--harness ${selector}`, message: 'not a harness variant or configured harness tool name', severity: 'error' });
|
|
375
|
+
}
|
|
376
|
+
const result = tools.map((tool) => {
|
|
377
|
+
if (tool.type !== 'HARNESS')
|
|
378
|
+
return tool;
|
|
379
|
+
const selected = names.has(tool.name) || variants.has(tool.variant);
|
|
380
|
+
if (selected === tool.isEnabled)
|
|
381
|
+
return tool;
|
|
382
|
+
overridden.add(tool.name);
|
|
383
|
+
return { ...tool, isEnabled: selected };
|
|
384
|
+
});
|
|
385
|
+
for (const variant of variants) {
|
|
386
|
+
if (result.some((tool) => tool.type === 'HARNESS' && tool.variant === variant))
|
|
387
|
+
continue;
|
|
388
|
+
const name = harnessPluginId(variant);
|
|
389
|
+
if (result.some((tool) => tool.name === name))
|
|
390
|
+
continue;
|
|
391
|
+
overridden.add(name);
|
|
392
|
+
result.push({ type: 'HARNESS', variant: variant, name, isEnabled: true, authentication: 'NATIVE' });
|
|
271
393
|
}
|
|
272
394
|
return result;
|
|
273
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Applies temporary browser overrides to exactly one unambiguous browser tool.
|
|
398
|
+
*/
|
|
399
|
+
function overrideBrowser(tools, overrides, diagnostics, overridden) {
|
|
400
|
+
if (!overrides.mode && !overrides.profile)
|
|
401
|
+
return tools;
|
|
402
|
+
const browsers = tools.filter((tool) => tool.type === 'BROWSER');
|
|
403
|
+
let target;
|
|
404
|
+
if (overrides.tool) {
|
|
405
|
+
target = browsers.find((tool) => tool.name === overrides.tool);
|
|
406
|
+
if (!target) {
|
|
407
|
+
diagnostics.push({ location: `--browser-tool ${overrides.tool}`, message: 'no browser tool has this name', severity: 'error' });
|
|
408
|
+
return tools;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
const enabled = browsers.filter((tool) => tool.isEnabled);
|
|
413
|
+
if (enabled.length > 1) {
|
|
414
|
+
diagnostics.push({ location: '--browser-mode/--browser-profile', message: `several browsers are enabled (${enabled.map((tool) => tool.name).join(', ')}); select one with --browser-tool <name>`, severity: 'error' });
|
|
415
|
+
return tools;
|
|
416
|
+
}
|
|
417
|
+
target = enabled[0] ?? browsers[0];
|
|
418
|
+
}
|
|
419
|
+
if (!target) {
|
|
420
|
+
diagnostics.push({ location: '--browser-mode/--browser-profile', message: 'no browser tool is configured (add one with `ptbk tool add BROWSER …`)', severity: 'error' });
|
|
421
|
+
return tools;
|
|
422
|
+
}
|
|
423
|
+
overridden.add(target.name);
|
|
424
|
+
const changed = {
|
|
425
|
+
...target,
|
|
426
|
+
...(overrides.mode ? { isHeadless: overrides.mode !== 'headful' } : {}),
|
|
427
|
+
...(overrides.profile ? { profile: profileFromSpelling(overrides.profile) } : {}),
|
|
428
|
+
};
|
|
429
|
+
return tools.map((tool) => (tool === target ? changed : tool));
|
|
430
|
+
}
|
|
274
431
|
/**
|
|
275
432
|
* Resolves effective settings: engine defaults < legacy environment < `ptbk.json` < CLI flags < live runtime changes.
|
|
276
433
|
*
|
|
@@ -284,7 +441,7 @@ export function resolveSettings(layers) {
|
|
|
284
441
|
const sources = {};
|
|
285
442
|
const env = layers.env ?? process.env;
|
|
286
443
|
for (const key of Object.keys(layers.file)) {
|
|
287
|
-
if (!KNOWN_TOP_LEVEL_KEYS.
|
|
444
|
+
if (!KNOWN_TOP_LEVEL_KEYS.includes(key))
|
|
288
445
|
diagnostics.push({ location: `ptbk.json › ${key}`, message: 'unknown setting (preserved, ignored)', severity: 'warning' });
|
|
289
446
|
}
|
|
290
447
|
for (const spec of SETTING_SPECS) {
|
|
@@ -331,28 +488,65 @@ export function resolveSettings(layers) {
|
|
|
331
488
|
values.timezone = systemTimeZone();
|
|
332
489
|
}
|
|
333
490
|
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return { values, sources, harnesses, diagnostics };
|
|
491
|
+
const parsedTools = parseTools(layers.file.tools);
|
|
492
|
+
diagnostics.push(...parsedTools.problems);
|
|
493
|
+
const overridden = new Set();
|
|
494
|
+
let tools = [...parsedTools.tools];
|
|
495
|
+
if (layers.cliHarnesses?.length)
|
|
496
|
+
tools = restrictHarnesses(tools, layers.cliHarnesses, diagnostics, overridden);
|
|
497
|
+
if (layers.cliBrowser)
|
|
498
|
+
tools = overrideBrowser(tools, layers.cliBrowser, diagnostics, overridden);
|
|
499
|
+
if (values['server.isEnabled'] === false && sources['server.tunnel.isEnabled'] !== 'cli')
|
|
500
|
+
values['server.tunnel.isEnabled'] = false;
|
|
501
|
+
return { values, sources, tools, overriddenTools: overridden, diagnostics };
|
|
346
502
|
}
|
|
347
503
|
/**
|
|
348
|
-
* Loads and resolves the project's settings
|
|
504
|
+
* Loads and resolves the project's settings without writing anything: a pending configuration migration and
|
|
505
|
+
* deterministic spelling corrections are applied in memory and reported; persisting them is the job of the mutating
|
|
506
|
+
* entry points (see the configuration coordinator).
|
|
349
507
|
*
|
|
350
508
|
* @private project configuration
|
|
351
509
|
*/
|
|
352
510
|
export async function loadSettings(project, layers = {}) {
|
|
353
511
|
const file = await readProjectConfigFile(project);
|
|
354
|
-
|
|
355
|
-
|
|
512
|
+
return interpretConfig(file, layers);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Interprets a read configuration file for this engine (pure; see {@link loadSettings}).
|
|
516
|
+
*
|
|
517
|
+
* @private project configuration
|
|
518
|
+
*/
|
|
519
|
+
export function interpretConfig(file, layers = {}, engineVersion = ENGINE_VERSION) {
|
|
520
|
+
const diagnostics = [...file.diagnostics];
|
|
521
|
+
const migration = file.exists && !file.diagnostics.length ? planConfigurationMigration(file.raw, engineVersion) : { kind: 'current', version: engineVersion };
|
|
522
|
+
let interpreted = file.raw;
|
|
523
|
+
if (migration.kind === 'migrate') {
|
|
524
|
+
const migrated = applyConfigurationMigration(file.raw, migration);
|
|
525
|
+
interpreted = migrated.raw;
|
|
526
|
+
diagnostics.push(...migrated.problems);
|
|
527
|
+
diagnostics.push({ location: 'ptbk.json › promptbookVersion', message: `configuration migration ${migration.from} → ${migration.to} is pending (it is applied and committed before new work)`, severity: 'warning' });
|
|
528
|
+
}
|
|
529
|
+
else if (migration.kind === 'older-engine') {
|
|
530
|
+
diagnostics.push({
|
|
531
|
+
location: 'ptbk.json › promptbookVersion',
|
|
532
|
+
message: `this project was configured by ptbk ${migration.saved}, which is newer than the running ptbk ${migration.engine}; update ptbk (npm install -g ptbk@latest, or the project's local dependency) and rerun — the project is never downgraded`,
|
|
533
|
+
severity: 'error',
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
else if (migration.kind === 'invalid') {
|
|
537
|
+
diagnostics.push({ location: 'ptbk.json › promptbookVersion', message: migration.reason, severity: 'error' });
|
|
538
|
+
}
|
|
539
|
+
const canonical = canonicalizeConfig(interpreted);
|
|
540
|
+
const resolved = resolveSettings({ ...layers, file: canonical.raw });
|
|
541
|
+
const seen = new Set();
|
|
542
|
+
const merged = [...diagnostics, ...canonical.problems.filter((problem) => !problem.location.includes('tools')), ...resolved.diagnostics].filter((diagnostic) => {
|
|
543
|
+
const key = `${diagnostic.location}\u0000${diagnostic.message}`;
|
|
544
|
+
if (seen.has(key))
|
|
545
|
+
return false;
|
|
546
|
+
seen.add(key);
|
|
547
|
+
return true;
|
|
548
|
+
});
|
|
549
|
+
return { ...resolved, diagnostics: merged, fileExists: file.exists, raw: file.raw, interpreted: canonical.raw, migration, corrections: migration.kind === 'migrate' ? [] : canonical.corrections };
|
|
356
550
|
}
|
|
357
551
|
/**
|
|
358
552
|
* Throws a configuration error when settings contain errors (used before affected work).
|
|
@@ -382,19 +576,43 @@ export function setting(settings, key) {
|
|
|
382
576
|
return settings.values[key];
|
|
383
577
|
}
|
|
384
578
|
/**
|
|
385
|
-
* Enabled harness
|
|
579
|
+
* Enabled harness instances in configuration order.
|
|
580
|
+
*
|
|
581
|
+
* @private project configuration
|
|
582
|
+
*/
|
|
583
|
+
export function enabledHarnessTools(settings) {
|
|
584
|
+
return enabledToolsOf(settings.tools, 'HARNESS');
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Enabled browser instances in configuration order.
|
|
588
|
+
*
|
|
589
|
+
* @private project configuration
|
|
590
|
+
*/
|
|
591
|
+
export function enabledBrowserTools(settings) {
|
|
592
|
+
return enabledToolsOf(settings.tools, 'BROWSER');
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Harness plugin identifiers that have at least one enabled instance, in first-instance order.
|
|
386
596
|
*
|
|
387
597
|
* @private project configuration
|
|
388
598
|
*/
|
|
389
599
|
export function enabledHarnesses(settings) {
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
600
|
+
return [...new Set(enabledHarnessTools(settings).map((tool) => harnessPluginId(tool.variant)))];
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Serializes `ptbk.json` text (stable 4-space JSON).
|
|
604
|
+
*
|
|
605
|
+
* @private project configuration
|
|
606
|
+
*/
|
|
607
|
+
export function configText(raw) {
|
|
608
|
+
return `${JSON.stringify(raw, null, 4)}\n`;
|
|
393
609
|
}
|
|
394
610
|
/**
|
|
395
|
-
* Applies changes to `ptbk.json`, preserving unknown keys, and returns whether the file content changed.
|
|
611
|
+
* Applies scalar setting changes to `ptbk.json`, preserving unknown keys, and returns whether the file content changed.
|
|
396
612
|
*
|
|
397
|
-
* Values are effective values (durations in ms); `undefined` removes a key.
|
|
613
|
+
* Values are effective values (durations in ms, internal enum spellings); `undefined` removes a key. A new file is
|
|
614
|
+
* stamped with the running engine's `promptbookVersion`. An existing file must already be current for this engine
|
|
615
|
+
* (the configuration coordinator migrates it first).
|
|
398
616
|
*
|
|
399
617
|
* @private project configuration
|
|
400
618
|
*/
|
|
@@ -409,33 +627,27 @@ export async function updateProjectConfig(project, changes) {
|
|
|
409
627
|
});
|
|
410
628
|
}
|
|
411
629
|
const raw = structuredClone(file.raw);
|
|
412
|
-
if (
|
|
413
|
-
raw.
|
|
630
|
+
if (!file.exists)
|
|
631
|
+
raw.promptbookVersion = ENGINE_VERSION;
|
|
632
|
+
else {
|
|
633
|
+
const plan = planConfigurationMigration(raw);
|
|
634
|
+
if (plan.kind !== 'current') {
|
|
635
|
+
throw new PtbkError('ptbk.json must be migrated before it can be changed.', {
|
|
636
|
+
kind: 'configuration',
|
|
637
|
+
project: project.root,
|
|
638
|
+
reason: plan.kind === 'migrate' ? `The configuration is at ${plan.from}; this engine is ${plan.to}.` : plan.kind === 'older-engine' ? `The configuration was written by the newer ptbk ${plan.saved}.` : plan.reason,
|
|
639
|
+
next: ['Run `ptbk start` (or `ptbk init`) to apply the committed configuration migration first.'],
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
414
643
|
for (const [key, value] of Object.entries(changes.settings ?? {})) {
|
|
415
644
|
const spec = SETTING_SPEC_BY_KEY.get(key);
|
|
416
645
|
if (!spec)
|
|
417
646
|
throw new Error(`Unknown setting ${key}`);
|
|
418
647
|
setPath(raw, key, value === undefined ? undefined : serializeSettingValue(spec, value));
|
|
419
648
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
if (harness === undefined) {
|
|
423
|
-
delete map[id];
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
const current = (map[id] && typeof map[id] === 'object' ? map[id] : {});
|
|
427
|
-
const next = { ...current };
|
|
428
|
-
for (const [field, value] of Object.entries(harness)) {
|
|
429
|
-
if (value === undefined)
|
|
430
|
-
delete next[field];
|
|
431
|
-
else
|
|
432
|
-
next[field] = value;
|
|
433
|
-
}
|
|
434
|
-
map[id] = next;
|
|
435
|
-
}
|
|
436
|
-
const text = `${JSON.stringify(raw, null, 4)}\n`;
|
|
437
|
-
const before = await readTextIfExists(project.configPath);
|
|
438
|
-
if (before === text)
|
|
649
|
+
const text = configText(raw);
|
|
650
|
+
if (file.text === text)
|
|
439
651
|
return false;
|
|
440
652
|
await writeFileAtomic(project.configPath, text);
|
|
441
653
|
return true;
|