@promptbook/components 0.114.0-10 → 0.114.0-12
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/esm/index.es.js +180 -62
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +180 -62
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ParsedCommitment } from '../../commitments/_base/ParsedCommitment';
|
|
2
2
|
import type { string_agent_name } from '../../types/string_agent_name';
|
|
3
|
+
import type { ParsedUnknownCommitment } from './ParsedUnknownCommitment';
|
|
3
4
|
/**
|
|
4
5
|
* Result of parsing agent source for commitments
|
|
5
6
|
*
|
|
@@ -18,6 +19,10 @@ export type AgentSourceParseResult = {
|
|
|
18
19
|
* All parsed commitments
|
|
19
20
|
*/
|
|
20
21
|
commitments: ParsedCommitment[];
|
|
22
|
+
/**
|
|
23
|
+
* Uppercase commitment blocks whose types are not registered by Promptbook.
|
|
24
|
+
*/
|
|
25
|
+
unknownCommitments: ParsedUnknownCommitment[];
|
|
21
26
|
/**
|
|
22
27
|
* Lines that are not commitments (for system message)
|
|
23
28
|
*/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An uppercase Book commitment block whose keyword is not registered by Promptbook.
|
|
3
|
+
*
|
|
4
|
+
* Unknown commitments are retained as system-message context instead of being applied
|
|
5
|
+
* as executable commitments.
|
|
6
|
+
*
|
|
7
|
+
* @private internal type of `parseAgentSourceWithCommitments`
|
|
8
|
+
*/
|
|
9
|
+
export type ParsedUnknownCommitment = {
|
|
10
|
+
/**
|
|
11
|
+
* Uppercase unknown commitment type, for example `FOO` or `BAR BZZ`.
|
|
12
|
+
*/
|
|
13
|
+
readonly type: string;
|
|
14
|
+
/**
|
|
15
|
+
* Original first line, retained for precise editor diagnostics.
|
|
16
|
+
*/
|
|
17
|
+
readonly originalLine: string;
|
|
18
|
+
/**
|
|
19
|
+
* Line number in the agent source (1-based).
|
|
20
|
+
*/
|
|
21
|
+
readonly lineNumber: number;
|
|
22
|
+
/**
|
|
23
|
+
* Complete unknown commitment block, including its keyword and continuation lines.
|
|
24
|
+
*/
|
|
25
|
+
readonly source: string;
|
|
26
|
+
};
|
package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the regex used to recognize the uppercase commitment type at the beginning of a Book line.
|
|
3
|
+
*
|
|
4
|
+
* A fresh regular expression keeps Monaco tokenizer state isolated from parser calls.
|
|
5
|
+
*
|
|
6
|
+
* @returns Regular expression matching one Book commitment-like line.
|
|
7
|
+
*
|
|
8
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBookCommitmentLineTypeRegex(): RegExp;
|
|
11
|
+
/**
|
|
12
|
+
* Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
|
|
13
|
+
*
|
|
14
|
+
* @param line - One raw Book source line.
|
|
15
|
+
* @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
|
|
16
|
+
*
|
|
17
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
18
|
+
*/
|
|
19
|
+
export declare function getBookCommitmentLineType(line: string): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
2
|
+
/**
|
|
3
|
+
* Monaco diagnostic shown when a Book source uses an uppercase commitment not registered by Promptbook.
|
|
4
|
+
*
|
|
5
|
+
* @private internal type of `BookEditorMonaco`
|
|
6
|
+
*/
|
|
7
|
+
type UnknownCommitmentDiagnostic = {
|
|
8
|
+
readonly startLineNumber: number;
|
|
9
|
+
readonly startColumn: number;
|
|
10
|
+
readonly endLineNumber: number;
|
|
11
|
+
readonly endColumn: number;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly source: string;
|
|
14
|
+
readonly severity: 'error';
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates Book editor diagnostics for uppercase commitments not registered by Promptbook.
|
|
18
|
+
*
|
|
19
|
+
* Unknown commitment blocks remain valid extra context in the generated system message,
|
|
20
|
+
* but the editor marks their keywords so authors can spot likely typos immediately.
|
|
21
|
+
*
|
|
22
|
+
* @param agentSource - Current editor content.
|
|
23
|
+
* @returns Error markers for all unknown commitment keywords.
|
|
24
|
+
*
|
|
25
|
+
* @private internal utility of `BookEditorMonaco`
|
|
26
|
+
*/
|
|
27
|
+
export declare function createUnknownCommitmentDiagnostics(agentSource?: string_book): ReadonlyArray<UnknownCommitmentDiagnostic>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { HarnessDefinition } from './HarnessDefinition';
|
|
2
2
|
import type { HarnessInstallationStatus } from './HarnessInstallationStatus';
|
|
3
3
|
/**
|
|
4
|
-
* Detects whether one CLI coding harness is installed globally and whether it is up to date.
|
|
4
|
+
* Detects whether one CLI coding harness is installed globally and, when enabled, whether it is up to date.
|
|
5
5
|
*
|
|
6
|
-
* Note: `$` is used to indicate that this function is not a pure function - it runs the harness command and
|
|
6
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs the harness command and may query npm
|
|
7
7
|
*
|
|
8
8
|
* @private internal utility of `promptbookCli`
|
|
9
9
|
*/
|
|
10
|
-
export declare function $checkHarnessInstallation(definition: HarnessDefinition): Promise<HarnessInstallationStatus>;
|
|
10
|
+
export declare function $checkHarnessInstallation(definition: HarnessDefinition, isHarnessUpdateCheckEnabled?: boolean): Promise<HarnessInstallationStatus>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PromptRunnerHarnessName } from '../promptRunnerCliOptions';
|
|
2
2
|
/**
|
|
3
|
-
* Checks that every given CLI coding harness is installed globally and up to date
|
|
4
|
-
* install
|
|
3
|
+
* Checks that every given CLI coding harness is installed globally and, when enabled, up to date.
|
|
4
|
+
* Offers to install missing harnesses and update outdated ones.
|
|
5
5
|
*
|
|
6
6
|
* Harness names which are `undefined`, for example when no `--harness` is selected in a dry run,
|
|
7
7
|
* are ignored so that every call site can pass its raw selection.
|
|
@@ -10,4 +10,4 @@ import type { PromptRunnerHarnessName } from '../promptRunnerCliOptions';
|
|
|
10
10
|
*
|
|
11
11
|
* @private internal utility of `promptbookCli`
|
|
12
12
|
*/
|
|
13
|
-
export declare function $ensureHarnessInstallations(harnessNames: ReadonlyArray<PromptRunnerHarnessName | undefined
|
|
13
|
+
export declare function $ensureHarnessInstallations(harnessNames: ReadonlyArray<PromptRunnerHarnessName | undefined>, isHarnessUpdateCheckEnabled?: boolean): Promise<void>;
|
|
@@ -5,11 +5,12 @@ import type { HarnessDefinition } from './HarnessDefinition';
|
|
|
5
5
|
* - `up-to-date` the newest published version is installed
|
|
6
6
|
* - `outdated` an older version is installed
|
|
7
7
|
* - `not-installed` the harness command is not available globally
|
|
8
|
+
* - `installed` the harness is installed and automatic update checking was disabled
|
|
8
9
|
* - `unknown` the harness is installed but the newest published version could not be resolved, for example when offline
|
|
9
10
|
*
|
|
10
11
|
* @private internal utility of `promptbookCli`
|
|
11
12
|
*/
|
|
12
|
-
export type HarnessInstallationState = 'up-to-date' | 'outdated' | 'not-installed' | 'unknown';
|
|
13
|
+
export type HarnessInstallationState = 'up-to-date' | 'outdated' | 'not-installed' | 'installed' | 'unknown';
|
|
13
14
|
/**
|
|
14
15
|
* Installation state of one CLI coding harness on the current machine.
|
|
15
16
|
*
|
|
@@ -21,7 +22,7 @@ export type HarnessInstallationStatus = {
|
|
|
21
22
|
*/
|
|
22
23
|
readonly definition: HarnessDefinition;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* Installation state, including whether the newest published version was checked.
|
|
25
26
|
*/
|
|
26
27
|
readonly installationState: HarnessInstallationState;
|
|
27
28
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Command as Program } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Commander option bag for opting out of automatic coding-harness update checks.
|
|
4
|
+
*
|
|
5
|
+
* @private internal utility of `promptbookCli`
|
|
6
|
+
*/
|
|
7
|
+
export type HarnessUpdateCliOptions = {
|
|
8
|
+
readonly harnessUpdate: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Normalized automatic coding-harness update-check option.
|
|
12
|
+
*
|
|
13
|
+
* @private internal utility of `promptbookCli`
|
|
14
|
+
*/
|
|
15
|
+
export type NormalizedHarnessUpdateCliOptions = {
|
|
16
|
+
readonly isHarnessUpdateCheckEnabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Registers the shared `--no-harness-update` option on a `ptbk coder` command that uses a coding harness.
|
|
20
|
+
*
|
|
21
|
+
* @private internal utility of `promptbookCli`
|
|
22
|
+
*/
|
|
23
|
+
export declare function addHarnessUpdateOption(command: Program): void;
|
|
24
|
+
/**
|
|
25
|
+
* Converts the Commander harness-update flag into the normalized harness-check option.
|
|
26
|
+
*
|
|
27
|
+
* @private internal utility of `promptbookCli`
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeHarnessUpdateCliOptions(cliOptions: HarnessUpdateCliOptions): NormalizedHarnessUpdateCliOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { string_executable_path } from '../../types/string_filename';
|
|
2
2
|
import type { LocateAppOptions } from '../locateApp';
|
|
3
3
|
/**
|
|
4
|
-
* Attempts to locate the specified application on a Windows system by searching common installation directories.
|
|
4
|
+
* Attempts to locate the specified application on a Windows system by searching PATH and common installation directories.
|
|
5
5
|
* Returns the path to the executable if found, or null otherwise.
|
|
6
6
|
*
|
|
7
7
|
* @private within the repository
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.114.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.114.0-10`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -18316,6 +18316,42 @@
|
|
|
18316
18316
|
// TODO: [🧠] Maybe create through standardized $register
|
|
18317
18317
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
18318
18318
|
|
|
18319
|
+
/**
|
|
18320
|
+
* Pattern shared by Book parsing and editor highlighting for a commitment-like line.
|
|
18321
|
+
*
|
|
18322
|
+
* A Book commitment keyword consists of one or more all-uppercase words with at least
|
|
18323
|
+
* two characters each. This deliberately mirrors the Book editor syntax rule so an
|
|
18324
|
+
* unknown keyword starts a new source block everywhere it is interpreted.
|
|
18325
|
+
*
|
|
18326
|
+
* @private internal constant of `getBookCommitmentLineType`
|
|
18327
|
+
*/
|
|
18328
|
+
const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
|
|
18329
|
+
/**
|
|
18330
|
+
* Creates the regex used to recognize the uppercase commitment type at the beginning of a Book line.
|
|
18331
|
+
*
|
|
18332
|
+
* A fresh regular expression keeps Monaco tokenizer state isolated from parser calls.
|
|
18333
|
+
*
|
|
18334
|
+
* @returns Regular expression matching one Book commitment-like line.
|
|
18335
|
+
*
|
|
18336
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
18337
|
+
*/
|
|
18338
|
+
function createBookCommitmentLineTypeRegex() {
|
|
18339
|
+
return new RegExp(BOOK_COMMITMENT_LINE_TYPE_REGEX.source);
|
|
18340
|
+
}
|
|
18341
|
+
/**
|
|
18342
|
+
* Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
|
|
18343
|
+
*
|
|
18344
|
+
* @param line - One raw Book source line.
|
|
18345
|
+
* @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
|
|
18346
|
+
*
|
|
18347
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
18348
|
+
*/
|
|
18349
|
+
function getBookCommitmentLineType(line) {
|
|
18350
|
+
var _a;
|
|
18351
|
+
const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
|
|
18352
|
+
return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
|
|
18353
|
+
}
|
|
18354
|
+
|
|
18319
18355
|
/**
|
|
18320
18356
|
* Consumes the agent-name prelude from raw source.
|
|
18321
18357
|
*
|
|
@@ -18373,13 +18409,15 @@
|
|
|
18373
18409
|
return {
|
|
18374
18410
|
agentName: null,
|
|
18375
18411
|
commitments: [],
|
|
18412
|
+
unknownCommitments: [],
|
|
18376
18413
|
nonCommitmentLines: [],
|
|
18377
18414
|
};
|
|
18378
18415
|
}
|
|
18379
18416
|
const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
|
|
18380
18417
|
const commitments = [];
|
|
18418
|
+
const unknownCommitments = [];
|
|
18381
18419
|
const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
|
|
18382
|
-
// Parse commitments with multiline support
|
|
18420
|
+
// Parse commitments with multiline support.
|
|
18383
18421
|
let currentCommitment = null;
|
|
18384
18422
|
// Process lines starting from after the agent name line
|
|
18385
18423
|
const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
|
|
@@ -18393,25 +18431,11 @@
|
|
|
18393
18431
|
// Check if this line starts or ends a code block
|
|
18394
18432
|
if (trimmedLine.startsWith('```')) {
|
|
18395
18433
|
isInsideCodeBlock = !isInsideCodeBlock;
|
|
18396
|
-
|
|
18397
|
-
// If we are inside a commitment, the code block is part of it
|
|
18398
|
-
currentCommitment.contentLines.push(line);
|
|
18399
|
-
}
|
|
18400
|
-
else {
|
|
18401
|
-
// If we are not inside a commitment, the code block is non-commitment
|
|
18402
|
-
nonCommitmentLines.push(line);
|
|
18403
|
-
}
|
|
18434
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18404
18435
|
continue;
|
|
18405
18436
|
}
|
|
18406
18437
|
if (isInsideCodeBlock) {
|
|
18407
|
-
|
|
18408
|
-
// If we are inside a commitment and a code block, the line is part of the commitment
|
|
18409
|
-
currentCommitment.contentLines.push(line);
|
|
18410
|
-
}
|
|
18411
|
-
else {
|
|
18412
|
-
// If we are inside a code block but not a commitment, the line is non-commitment
|
|
18413
|
-
nonCommitmentLines.push(line);
|
|
18414
|
-
}
|
|
18438
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18415
18439
|
continue;
|
|
18416
18440
|
}
|
|
18417
18441
|
// Check if this line starts a new commitment
|
|
@@ -18420,22 +18444,14 @@
|
|
|
18420
18444
|
const typeRegex = definition.createTypeRegex();
|
|
18421
18445
|
const match = typeRegex.exec(line.trim());
|
|
18422
18446
|
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
18423
|
-
|
|
18424
|
-
if (currentCommitment) {
|
|
18425
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18426
|
-
commitments.push({
|
|
18427
|
-
type: currentCommitment.type,
|
|
18428
|
-
content: spacetrim.spaceTrim(fullContent),
|
|
18429
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18430
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18431
|
-
});
|
|
18432
|
-
}
|
|
18447
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18433
18448
|
// Extract the initial content from the commitment line
|
|
18434
18449
|
const fullRegex = definition.createRegex();
|
|
18435
18450
|
const fullMatch = fullRegex.exec(line.trim());
|
|
18436
18451
|
const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
|
|
18437
18452
|
// Start a new commitment
|
|
18438
18453
|
currentCommitment = {
|
|
18454
|
+
kind: 'known',
|
|
18439
18455
|
type: definition.type,
|
|
18440
18456
|
startLineNumber: i + 1,
|
|
18441
18457
|
originalStartLine: line,
|
|
@@ -18445,52 +18461,90 @@
|
|
|
18445
18461
|
break;
|
|
18446
18462
|
}
|
|
18447
18463
|
}
|
|
18464
|
+
if (foundNewCommitment) {
|
|
18465
|
+
continue;
|
|
18466
|
+
}
|
|
18467
|
+
const unknownCommitmentType = getBookCommitmentLineType(line);
|
|
18468
|
+
if (unknownCommitmentType) {
|
|
18469
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18470
|
+
currentCommitment = {
|
|
18471
|
+
kind: 'unknown',
|
|
18472
|
+
type: unknownCommitmentType,
|
|
18473
|
+
startLineNumber: i + 1,
|
|
18474
|
+
originalStartLine: line,
|
|
18475
|
+
sourceLines: [line],
|
|
18476
|
+
};
|
|
18477
|
+
continue;
|
|
18478
|
+
}
|
|
18448
18479
|
// Check if this is a horizontal line (ends any current commitment)
|
|
18449
18480
|
const isHorizontalLine = HORIZONTAL_LINE_PATTERN$2.test(line);
|
|
18450
18481
|
if (isHorizontalLine) {
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18454
|
-
commitments.push({
|
|
18455
|
-
type: currentCommitment.type,
|
|
18456
|
-
content: spacetrim.spaceTrim(fullContent),
|
|
18457
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18458
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18459
|
-
});
|
|
18460
|
-
currentCommitment = null;
|
|
18461
|
-
}
|
|
18482
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18483
|
+
currentCommitment = null;
|
|
18462
18484
|
// Add horizontal line to non-commitment lines
|
|
18463
18485
|
nonCommitmentLines.push(line);
|
|
18464
18486
|
continue;
|
|
18465
18487
|
}
|
|
18466
|
-
|
|
18467
|
-
if (currentCommitment) {
|
|
18468
|
-
// This line belongs to the current commitment
|
|
18469
|
-
currentCommitment.contentLines.push(line);
|
|
18470
|
-
}
|
|
18471
|
-
else {
|
|
18472
|
-
// This line is not part of any commitment
|
|
18473
|
-
nonCommitmentLines.push(line);
|
|
18474
|
-
}
|
|
18475
|
-
}
|
|
18476
|
-
}
|
|
18477
|
-
// Don't forget to save the last commitment if it exists
|
|
18478
|
-
if (currentCommitment) {
|
|
18479
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18480
|
-
commitments.push({
|
|
18481
|
-
type: currentCommitment.type,
|
|
18482
|
-
content: spacetrim.spaceTrim(fullContent),
|
|
18483
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18484
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18485
|
-
});
|
|
18488
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18486
18489
|
}
|
|
18490
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18487
18491
|
return {
|
|
18488
18492
|
agentName,
|
|
18489
18493
|
agentNameLineNumber,
|
|
18490
18494
|
commitments,
|
|
18495
|
+
unknownCommitments,
|
|
18491
18496
|
nonCommitmentLines,
|
|
18492
18497
|
};
|
|
18493
18498
|
}
|
|
18499
|
+
/**
|
|
18500
|
+
* Stores the current known or unknown commitment in its appropriate parsed collection.
|
|
18501
|
+
*
|
|
18502
|
+
* @param currentCommitment - Commitment-like block collected so far.
|
|
18503
|
+
* @param commitments - Parsed registered commitments to append to.
|
|
18504
|
+
* @param unknownCommitments - Parsed unregistered commitments to append to.
|
|
18505
|
+
*
|
|
18506
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
18507
|
+
*/
|
|
18508
|
+
function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
|
|
18509
|
+
if (!currentCommitment) {
|
|
18510
|
+
return;
|
|
18511
|
+
}
|
|
18512
|
+
if (currentCommitment.kind === 'unknown') {
|
|
18513
|
+
unknownCommitments.push({
|
|
18514
|
+
type: currentCommitment.type,
|
|
18515
|
+
originalLine: currentCommitment.originalStartLine,
|
|
18516
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
18517
|
+
source: spacetrim.spaceTrim(currentCommitment.sourceLines.join('\n')),
|
|
18518
|
+
});
|
|
18519
|
+
return;
|
|
18520
|
+
}
|
|
18521
|
+
commitments.push({
|
|
18522
|
+
type: currentCommitment.type,
|
|
18523
|
+
content: spacetrim.spaceTrim(currentCommitment.contentLines.join('\n')),
|
|
18524
|
+
originalLine: currentCommitment.originalStartLine,
|
|
18525
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
18526
|
+
});
|
|
18527
|
+
}
|
|
18528
|
+
/**
|
|
18529
|
+
* Adds one source line to the active commitment-like block, or to plain source content when none is active.
|
|
18530
|
+
*
|
|
18531
|
+
* @param currentCommitment - Commitment-like block currently being collected.
|
|
18532
|
+
* @param line - Source line to append.
|
|
18533
|
+
* @param nonCommitmentLines - Plain source lines to append to when no block is active.
|
|
18534
|
+
*
|
|
18535
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
18536
|
+
*/
|
|
18537
|
+
function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
|
|
18538
|
+
if (!currentCommitment) {
|
|
18539
|
+
nonCommitmentLines.push(line);
|
|
18540
|
+
return;
|
|
18541
|
+
}
|
|
18542
|
+
if (currentCommitment.kind === 'unknown') {
|
|
18543
|
+
currentCommitment.sourceLines.push(line);
|
|
18544
|
+
return;
|
|
18545
|
+
}
|
|
18546
|
+
currentCommitment.contentLines.push(line);
|
|
18547
|
+
}
|
|
18494
18548
|
|
|
18495
18549
|
/**
|
|
18496
18550
|
* Parses parameters from text using both supported notations:
|
|
@@ -19995,6 +20049,35 @@
|
|
|
19995
20049
|
return [];
|
|
19996
20050
|
}
|
|
19997
20051
|
|
|
20052
|
+
/**
|
|
20053
|
+
* Creates Book editor diagnostics for uppercase commitments not registered by Promptbook.
|
|
20054
|
+
*
|
|
20055
|
+
* Unknown commitment blocks remain valid extra context in the generated system message,
|
|
20056
|
+
* but the editor marks their keywords so authors can spot likely typos immediately.
|
|
20057
|
+
*
|
|
20058
|
+
* @param agentSource - Current editor content.
|
|
20059
|
+
* @returns Error markers for all unknown commitment keywords.
|
|
20060
|
+
*
|
|
20061
|
+
* @private internal utility of `BookEditorMonaco`
|
|
20062
|
+
*/
|
|
20063
|
+
function createUnknownCommitmentDiagnostics(agentSource) {
|
|
20064
|
+
if (!(agentSource === null || agentSource === void 0 ? void 0 : agentSource.trim())) {
|
|
20065
|
+
return [];
|
|
20066
|
+
}
|
|
20067
|
+
return parseAgentSourceWithCommitments(agentSource).unknownCommitments.map((commitment) => {
|
|
20068
|
+
const startColumn = commitment.originalLine.indexOf(commitment.type) + 1;
|
|
20069
|
+
return {
|
|
20070
|
+
startLineNumber: commitment.lineNumber,
|
|
20071
|
+
startColumn,
|
|
20072
|
+
endLineNumber: commitment.lineNumber,
|
|
20073
|
+
endColumn: startColumn + commitment.type.length,
|
|
20074
|
+
message: `Unknown commitment \`${commitment.type}\` is added to the system message as extra context.`,
|
|
20075
|
+
source: 'Promptbook',
|
|
20076
|
+
severity: 'error',
|
|
20077
|
+
};
|
|
20078
|
+
});
|
|
20079
|
+
}
|
|
20080
|
+
|
|
19998
20081
|
/**
|
|
19999
20082
|
* Adds visual decorations for separators and code blocks inside `BookEditorMonaco`.
|
|
20000
20083
|
*
|
|
@@ -20441,7 +20524,7 @@
|
|
|
20441
20524
|
*
|
|
20442
20525
|
* @private function of BookEditorMonaco
|
|
20443
20526
|
*/
|
|
20444
|
-
const DYNAMIC_COMMITMENT_REGEX =
|
|
20527
|
+
const DYNAMIC_COMMITMENT_REGEX = createBookCommitmentLineTypeRegex();
|
|
20445
20528
|
/**
|
|
20446
20529
|
* Regex pattern to match horizontal lines.
|
|
20447
20530
|
*
|
|
@@ -22144,7 +22227,11 @@
|
|
|
22144
22227
|
editor,
|
|
22145
22228
|
handleFiles,
|
|
22146
22229
|
});
|
|
22147
|
-
const combinedDiagnostics = [
|
|
22230
|
+
const combinedDiagnostics = [
|
|
22231
|
+
...(diagnostics || []),
|
|
22232
|
+
...createDeprecatedCommitmentDiagnostics(),
|
|
22233
|
+
...createUnknownCommitmentDiagnostics(value),
|
|
22234
|
+
];
|
|
22148
22235
|
const isActionBarVisible = isBookEditorMonacoActionbarVisible({
|
|
22149
22236
|
hoistedMenuItems,
|
|
22150
22237
|
isUploadButtonShown,
|
|
@@ -49293,7 +49380,8 @@
|
|
|
49293
49380
|
requirements = await importReferencedFiles(requirements);
|
|
49294
49381
|
requirements = appendMcpServers(requirements, agentSource);
|
|
49295
49382
|
requirements = appendNonCommitmentContent(requirements, parseResult);
|
|
49296
|
-
|
|
49383
|
+
requirements = appendExampleInteractions(requirements, parseResult);
|
|
49384
|
+
return appendUnknownCommitmentContent(requirements, parseResult);
|
|
49297
49385
|
}
|
|
49298
49386
|
/**
|
|
49299
49387
|
* Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
|
|
@@ -49415,6 +49503,36 @@
|
|
|
49415
49503
|
}
|
|
49416
49504
|
return appendSystemMessageSection(requirements, nonCommitmentContent);
|
|
49417
49505
|
}
|
|
49506
|
+
/**
|
|
49507
|
+
* Appends unknown commitment blocks as final extra context without applying commitment side effects.
|
|
49508
|
+
*
|
|
49509
|
+
* @param requirements - Current requirements snapshot.
|
|
49510
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
49511
|
+
* @returns Requirements with unknown commitment context appended at the end of the system message.
|
|
49512
|
+
*
|
|
49513
|
+
* @private internal utility of `augmentAgentModelRequirementsFromSource`
|
|
49514
|
+
*/
|
|
49515
|
+
function appendUnknownCommitmentContent(requirements, parseResult) {
|
|
49516
|
+
const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
|
|
49517
|
+
if (!unknownCommitmentContent) {
|
|
49518
|
+
return requirements;
|
|
49519
|
+
}
|
|
49520
|
+
return appendSystemMessageSection(requirements, unknownCommitmentContent);
|
|
49521
|
+
}
|
|
49522
|
+
/**
|
|
49523
|
+
* Joins unknown commitment blocks into their final extra-context representation.
|
|
49524
|
+
*
|
|
49525
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
49526
|
+
* @returns Unknown commitment source blocks in their original order.
|
|
49527
|
+
*
|
|
49528
|
+
* @private internal utility of `appendUnknownCommitmentContent`
|
|
49529
|
+
*/
|
|
49530
|
+
function getUnknownCommitmentContent(parseResult) {
|
|
49531
|
+
return parseResult.unknownCommitments
|
|
49532
|
+
.map((commitment) => commitment.source)
|
|
49533
|
+
.filter(Boolean)
|
|
49534
|
+
.join('\n\n');
|
|
49535
|
+
}
|
|
49418
49536
|
/**
|
|
49419
49537
|
* Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
|
|
49420
49538
|
*
|