@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.
@@ -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
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.1
8
+ CLI Target: es2022
9
+ ESM Build start
10
+ ESM dist/index.js 33.32 KB
11
+ ESM ⚡️ Build success in 216ms
12
+ DTS Build start
13
+ DTS ⚡️ Build success in 14890ms
14
+ DTS dist/index.d.ts 5.14 KB
@@ -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
+  RUN  v2.1.9 /home/runner/work/baseline/baseline/packages/lang
7
+
8
+ ✓ src/__tests__/validation.test.ts (5 tests) 184ms
9
+ ✓ src/__tests__/smoke.test.ts (2 tests) 28ms
10
+ ✓ src/__tests__/workflow.test.ts (1 test) 82ms
11
+
12
+  Test Files  3 passed (3)
13
+  Tests  8 passed (8)
14
+  Start at  14:02:30
15
+  Duration  6.28s (transform 1.37s, setup 0ms, collect 1.60s, tests 295ms, environment 1ms, prepare 1.81s)
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`
@@ -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 };