@baselineos/lang 0.1.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/.turbo/turbo-build.log +14 -0
- package/.turbo/turbo-test.log +16 -0
- package/LICENSE +17 -0
- package/README.md +19 -0
- package/dist/index.d.ts +176 -0
- package/dist/index.js +1082 -0
- package/package.json +34 -0
- package/src/__tests__/smoke.test.ts +14 -0
- package/src/__tests__/validation.test.ts +83 -0
- package/src/__tests__/workflow.test.ts +11 -0
- package/src/config/lang-system-config.json +346 -0
- package/src/index.ts +25 -0
- package/src/system.ts +1025 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
> @baselineos/lang@0.1.0 build /home/runner/work/baseline/baseline/packages/lang
|
|
3
|
+
> tsup src/index.ts --format esm --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Target: es2022
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m33.32 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 216ms
|
|
12
|
+
[34mDTS[39m Build start
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 14890ms
|
|
14
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.14 KB[39m
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
> @baselineos/lang@0.1.0 test /home/runner/work/baseline/baseline/packages/lang
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[7m[36m RUN [39m[27m[22m [36mv2.1.9 [39m[90m/home/runner/work/baseline/baseline/packages/lang[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m src/__tests__/validation.test.ts [2m([22m[2m5 tests[22m[2m)[22m[90m 184[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/__tests__/smoke.test.ts [2m([22m[2m2 tests[22m[2m)[22m[90m 28[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/__tests__/workflow.test.ts [2m([22m[2m1 test[22m[2m)[22m[90m 82[2mms[22m[39m
|
|
11
|
+
|
|
12
|
+
[2m Test Files [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
13
|
+
[2m Tests [22m [1m[32m8 passed[39m[22m[90m (8)[39m
|
|
14
|
+
[2m Start at [22m 14:02:30
|
|
15
|
+
[2m Duration [22m 6.28s[2m (transform 1.37s, setup 0ms, collect 1.60s, tests 295ms, environment 1ms, prepare 1.81s)[22m
|
|
16
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Baseline Protocol Foundation
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @baselineos/lang
|
|
2
|
+
|
|
3
|
+
Lang layer package for Baseline.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Implements language parsing/normalization and baseline terminology handling for workflow input interpretation.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm --filter @baselineos/lang build
|
|
13
|
+
pnpm --filter @baselineos/lang test
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Integration
|
|
17
|
+
|
|
18
|
+
- Depends on: `@baselineos/protocol-core`
|
|
19
|
+
- Consumed by: `@baselineos/cli`, `baselineos`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline Lang System
|
|
3
|
+
*
|
|
4
|
+
* The foundation layer of the Baseline Protocol that handles natural language
|
|
5
|
+
* processing, command interpretation, and language syntax management.
|
|
6
|
+
*
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
interface LangSystemConfig {
|
|
10
|
+
language: string;
|
|
11
|
+
syntax: SyntaxConfig;
|
|
12
|
+
patterns: PatternConfig;
|
|
13
|
+
commands: Record<string, CommandConfig>;
|
|
14
|
+
lexicon?: Record<string, LexiconEntry>;
|
|
15
|
+
validation?: LangValidationConfig;
|
|
16
|
+
}
|
|
17
|
+
interface SyntaxConfig {
|
|
18
|
+
commandPrefix: string;
|
|
19
|
+
optionPrefix: string;
|
|
20
|
+
separator: string;
|
|
21
|
+
quoteChar: string;
|
|
22
|
+
}
|
|
23
|
+
interface PatternConfig {
|
|
24
|
+
intent: RegExp;
|
|
25
|
+
command: RegExp;
|
|
26
|
+
option: RegExp;
|
|
27
|
+
value: RegExp;
|
|
28
|
+
}
|
|
29
|
+
interface LangValidationConfig {
|
|
30
|
+
allowUnknownOptions?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface CommandOptionSpec {
|
|
33
|
+
type?: 'string' | 'number' | 'boolean';
|
|
34
|
+
description?: string;
|
|
35
|
+
required?: boolean;
|
|
36
|
+
default?: unknown;
|
|
37
|
+
values?: string[];
|
|
38
|
+
}
|
|
39
|
+
interface CommandValidationSpec {
|
|
40
|
+
minArgs?: number;
|
|
41
|
+
maxArgs?: number;
|
|
42
|
+
allowUnknownOptions?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface LexiconEntry {
|
|
45
|
+
description: string;
|
|
46
|
+
aliases?: string[];
|
|
47
|
+
tags?: string[];
|
|
48
|
+
examples?: string[];
|
|
49
|
+
source?: string;
|
|
50
|
+
}
|
|
51
|
+
interface CommandConfig {
|
|
52
|
+
aliases: string[];
|
|
53
|
+
description: string;
|
|
54
|
+
usage: string;
|
|
55
|
+
examples: string[];
|
|
56
|
+
handler?: CommandHandler;
|
|
57
|
+
options?: Record<string, CommandOptionSpec>;
|
|
58
|
+
validation?: CommandValidationSpec;
|
|
59
|
+
}
|
|
60
|
+
interface RegisteredCommand {
|
|
61
|
+
name: string;
|
|
62
|
+
aliases: string[];
|
|
63
|
+
description: string;
|
|
64
|
+
usage: string;
|
|
65
|
+
examples: string[];
|
|
66
|
+
handler: CommandHandler;
|
|
67
|
+
options: Record<string, CommandOptionSpec>;
|
|
68
|
+
validation: CommandValidationSpec;
|
|
69
|
+
}
|
|
70
|
+
type CommandHandler = (command: string, options: Map<string, unknown>, args: string[]) => CommandResult;
|
|
71
|
+
interface CommandResult {
|
|
72
|
+
success: boolean;
|
|
73
|
+
message?: string;
|
|
74
|
+
error?: string;
|
|
75
|
+
options?: Map<string, unknown>;
|
|
76
|
+
arguments?: string[];
|
|
77
|
+
suggestions?: string[];
|
|
78
|
+
timestamp?: string;
|
|
79
|
+
}
|
|
80
|
+
interface ParsedInput {
|
|
81
|
+
original: string;
|
|
82
|
+
tokens: string[];
|
|
83
|
+
command: string | null;
|
|
84
|
+
options: Map<string, unknown>;
|
|
85
|
+
arguments: string[];
|
|
86
|
+
intent: string | null;
|
|
87
|
+
}
|
|
88
|
+
interface IntentResult {
|
|
89
|
+
type: string;
|
|
90
|
+
confidence: number;
|
|
91
|
+
patterns: RegExp[];
|
|
92
|
+
}
|
|
93
|
+
interface ProcessResult {
|
|
94
|
+
success: boolean;
|
|
95
|
+
input?: string;
|
|
96
|
+
parsed?: ParsedInput;
|
|
97
|
+
intent?: IntentResult;
|
|
98
|
+
result?: CommandResult;
|
|
99
|
+
error?: string;
|
|
100
|
+
details?: string | string[];
|
|
101
|
+
suggestions?: string[];
|
|
102
|
+
timestamp?: string;
|
|
103
|
+
}
|
|
104
|
+
interface ParsedOption {
|
|
105
|
+
name: string;
|
|
106
|
+
value: string | null;
|
|
107
|
+
type: 'long' | 'short' | 'unknown';
|
|
108
|
+
}
|
|
109
|
+
interface BaselineLangOptions {
|
|
110
|
+
projectRoot?: string;
|
|
111
|
+
projectLexicon?: Record<string, LexiconEntry>;
|
|
112
|
+
}
|
|
113
|
+
declare class IntentRecognizer {
|
|
114
|
+
private patterns;
|
|
115
|
+
initialize(patterns: Record<string, unknown>): void;
|
|
116
|
+
recognize(parsed: ParsedInput): IntentResult;
|
|
117
|
+
private analyzeCommand;
|
|
118
|
+
private analyzeArguments;
|
|
119
|
+
}
|
|
120
|
+
declare class CommandProcessor {
|
|
121
|
+
commandRegistry: Map<string, RegisteredCommand> | null;
|
|
122
|
+
process(parsed: ParsedInput, _intent: IntentResult): CommandResult;
|
|
123
|
+
private findCommand;
|
|
124
|
+
}
|
|
125
|
+
declare class SyntaxValidator {
|
|
126
|
+
validate(parsed: ParsedInput): {
|
|
127
|
+
valid: boolean;
|
|
128
|
+
errors: string[];
|
|
129
|
+
};
|
|
130
|
+
private isValidOption;
|
|
131
|
+
}
|
|
132
|
+
declare class BaselineLangSystem {
|
|
133
|
+
private config;
|
|
134
|
+
private commandRegistry;
|
|
135
|
+
private languagePatterns;
|
|
136
|
+
private intentRecognizer;
|
|
137
|
+
private commandProcessor;
|
|
138
|
+
private syntaxValidator;
|
|
139
|
+
private lexicon;
|
|
140
|
+
private validationDefaults;
|
|
141
|
+
constructor(options?: BaselineLangOptions);
|
|
142
|
+
private loadConfiguration;
|
|
143
|
+
private initializeSystem;
|
|
144
|
+
private registerBuiltInCommands;
|
|
145
|
+
registerCommand(name: string, config: CommandConfig): void;
|
|
146
|
+
private loadLanguagePatterns;
|
|
147
|
+
private resolveCommand;
|
|
148
|
+
private validateCommand;
|
|
149
|
+
private normalizeOptions;
|
|
150
|
+
private listCommands;
|
|
151
|
+
private helpCommandHandler;
|
|
152
|
+
private formatHelpPayload;
|
|
153
|
+
private coerceOptionValue;
|
|
154
|
+
private loadLexicon;
|
|
155
|
+
private loadProjectLexicon;
|
|
156
|
+
private extractLexicon;
|
|
157
|
+
private sanitizeLexicon;
|
|
158
|
+
mergeLexicon(entries: Record<string, LexiconEntry>, source?: string): void;
|
|
159
|
+
private mergeStringArrays;
|
|
160
|
+
processInput(input: string): ProcessResult;
|
|
161
|
+
parseInput(input: string): ParsedInput;
|
|
162
|
+
tokenize(input: string): string[];
|
|
163
|
+
private isCommand;
|
|
164
|
+
private isOption;
|
|
165
|
+
private parseOption;
|
|
166
|
+
generateSuggestions(input: string): string[];
|
|
167
|
+
private getSuggestionTerms;
|
|
168
|
+
findSimilarCommands(input: string, maxResults?: number): string[];
|
|
169
|
+
private levenshteinDistance;
|
|
170
|
+
private defaultCommandHandler;
|
|
171
|
+
getCommandRegistry(): Map<string, RegisteredCommand>;
|
|
172
|
+
getLanguagePatterns(): Map<string, Record<string, RegExp>>;
|
|
173
|
+
getLexicon(): Map<string, LexiconEntry>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { type BaselineLangOptions, BaselineLangSystem, type CommandConfig, type CommandHandler, type CommandOptionSpec, CommandProcessor, type CommandResult, type CommandValidationSpec, IntentRecognizer, type IntentResult, type LangSystemConfig, type LangValidationConfig, type LexiconEntry, type ParsedInput, type ParsedOption, type PatternConfig, type ProcessResult, type RegisteredCommand, type SyntaxConfig, SyntaxValidator };
|