agentic-api 1.0.5 → 2.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.
Files changed (104) hide show
  1. package/README.md +118 -22
  2. package/dist/src/agents/agents.example.d.ts +3 -0
  3. package/dist/src/agents/agents.example.js +38 -0
  4. package/dist/src/agents/authentication.js +2 -0
  5. package/dist/src/agents/digestor.js +25 -16
  6. package/dist/src/agents/prompts.d.ts +2 -2
  7. package/dist/src/agents/prompts.js +112 -49
  8. package/dist/src/agents/reducer.core.d.ts +12 -0
  9. package/dist/src/agents/reducer.core.js +207 -0
  10. package/dist/src/agents/reducer.d.ts +3 -0
  11. package/dist/src/agents/reducer.example.d.ts +28 -0
  12. package/dist/src/agents/reducer.example.js +118 -0
  13. package/dist/src/agents/reducer.js +19 -0
  14. package/dist/src/agents/reducer.loaders.d.ts +34 -0
  15. package/dist/src/agents/reducer.loaders.js +122 -0
  16. package/dist/src/agents/reducer.process.d.ts +16 -0
  17. package/dist/src/agents/reducer.process.js +143 -0
  18. package/dist/src/agents/reducer.tools.d.ts +29 -0
  19. package/dist/src/agents/reducer.tools.js +157 -0
  20. package/dist/src/agents/reducer.types.d.ts +50 -0
  21. package/dist/src/agents/reducer.types.js +5 -0
  22. package/dist/src/agents/simulator.d.ts +47 -0
  23. package/dist/src/agents/simulator.executor.d.ts +26 -0
  24. package/dist/src/agents/simulator.executor.js +132 -0
  25. package/dist/src/agents/simulator.js +205 -0
  26. package/dist/src/agents/simulator.prompts.d.ts +16 -0
  27. package/dist/src/agents/simulator.prompts.js +108 -0
  28. package/dist/src/agents/simulator.types.d.ts +42 -0
  29. package/dist/src/agents/simulator.types.js +2 -0
  30. package/dist/src/agents/simulator.utils.d.ts +20 -0
  31. package/dist/src/agents/simulator.utils.js +87 -0
  32. package/dist/src/execute.d.ts +14 -7
  33. package/dist/src/execute.js +359 -84
  34. package/dist/src/index.d.ts +9 -0
  35. package/dist/src/index.js +14 -0
  36. package/dist/src/princing.openai.d.ts +9 -2
  37. package/dist/src/princing.openai.js +16 -11
  38. package/dist/src/prompts.d.ts +3 -2
  39. package/dist/src/prompts.js +207 -72
  40. package/dist/src/rag/embeddings.d.ts +103 -0
  41. package/dist/src/rag/embeddings.js +466 -0
  42. package/dist/src/rag/index.d.ts +12 -0
  43. package/dist/src/rag/index.js +40 -0
  44. package/dist/src/rag/lucene.d.ts +45 -0
  45. package/dist/src/rag/lucene.js +227 -0
  46. package/dist/src/rag/parser.d.ts +68 -0
  47. package/dist/src/rag/parser.js +192 -0
  48. package/dist/src/rag/tools.d.ts +76 -0
  49. package/dist/src/rag/tools.js +196 -0
  50. package/dist/src/rag/types.d.ts +178 -0
  51. package/dist/src/rag/types.js +21 -0
  52. package/dist/src/rag/usecase.d.ts +16 -0
  53. package/dist/src/rag/usecase.js +79 -0
  54. package/dist/src/rules/errors.d.ts +60 -0
  55. package/dist/src/rules/errors.js +97 -0
  56. package/dist/src/rules/git/git.e2e.helper.d.ts +104 -0
  57. package/dist/src/rules/git/git.e2e.helper.js +488 -0
  58. package/dist/src/rules/git/git.health.d.ts +66 -0
  59. package/dist/src/rules/git/git.health.js +354 -0
  60. package/dist/src/rules/git/git.helper.d.ts +129 -0
  61. package/dist/src/rules/git/git.helper.js +53 -0
  62. package/dist/src/rules/git/index.d.ts +6 -0
  63. package/dist/src/rules/git/index.js +76 -0
  64. package/dist/src/rules/git/repo.d.ts +128 -0
  65. package/dist/src/rules/git/repo.js +900 -0
  66. package/dist/src/rules/git/repo.pr.d.ts +137 -0
  67. package/dist/src/rules/git/repo.pr.js +589 -0
  68. package/dist/src/rules/git/repo.tools.d.ts +134 -0
  69. package/dist/src/rules/git/repo.tools.js +730 -0
  70. package/dist/src/rules/index.d.ts +8 -0
  71. package/dist/src/rules/index.js +25 -0
  72. package/dist/src/rules/messages.d.ts +17 -0
  73. package/dist/src/rules/messages.js +21 -0
  74. package/dist/src/rules/types.ctrl.d.ts +28 -0
  75. package/dist/src/rules/types.ctrl.js +2 -0
  76. package/dist/src/rules/types.d.ts +510 -0
  77. package/dist/src/rules/types.helpers.d.ts +132 -0
  78. package/dist/src/rules/types.helpers.js +2 -0
  79. package/dist/src/rules/types.js +33 -0
  80. package/dist/src/rules/user.mapper.d.ts +61 -0
  81. package/dist/src/rules/user.mapper.js +160 -0
  82. package/dist/src/rules/utils/slug.d.ts +22 -0
  83. package/dist/src/rules/utils/slug.js +35 -0
  84. package/dist/src/rules/utils.matter.d.ts +66 -0
  85. package/dist/src/rules/utils.matter.js +208 -0
  86. package/dist/src/rules/utils.slug.d.ts +22 -0
  87. package/dist/src/rules/utils.slug.js +35 -0
  88. package/dist/src/scrapper.d.ts +3 -2
  89. package/dist/src/scrapper.js +33 -37
  90. package/dist/src/stategraph/index.d.ts +8 -0
  91. package/dist/src/stategraph/index.js +21 -0
  92. package/dist/src/stategraph/stategraph.d.ts +91 -0
  93. package/dist/src/stategraph/stategraph.js +241 -0
  94. package/dist/src/stategraph/stategraph.storage.d.ts +41 -0
  95. package/dist/src/stategraph/stategraph.storage.js +166 -0
  96. package/dist/src/stategraph/types.d.ts +139 -0
  97. package/dist/src/stategraph/types.js +19 -0
  98. package/dist/src/types.d.ts +68 -39
  99. package/dist/src/types.js +53 -89
  100. package/dist/src/usecase.d.ts +4 -0
  101. package/dist/src/usecase.js +44 -0
  102. package/dist/src/utils.d.ts +12 -5
  103. package/dist/src/utils.js +30 -13
  104. package/package.json +9 -3
@@ -0,0 +1,132 @@
1
+ import { SimpleGit } from "simple-git";
2
+ import { ConcurrencyOptions, GitCommitHistory, PRInfo, PRMergeResult, PRMetadata, RetryResult, RulesGitConfig, RuleUser } from "./types";
3
+ /**
4
+ * Interface pour les opérations Git de base
5
+ * Permet de mocker facilement les opérations Git pour les tests
6
+ */
7
+ export interface IGitOperations {
8
+ /**
9
+ * Récupère le contenu d'un fichier depuis Git
10
+ */
11
+ getFileContent(filePath: string, branch?: string): Promise<GitCommitHistory | null>;
12
+ /**
13
+ * Liste tous les fichiers d'un type donné dans une branche
14
+ */
15
+ listFilesInBranch(branch: string, pattern?: string): Promise<string[]>;
16
+ /**
17
+ * Vérifie si un fichier existe dans une branche donnée
18
+ */
19
+ fileExistsInBranch(filePath: string, branch: string): Promise<boolean>;
20
+ /**
21
+ * Vérifie si la dernière version du fichier a été mergée
22
+ */
23
+ isFileMerged(filePath: string, from: string, target?: string): Promise<boolean>;
24
+ /**
25
+ * Récupère la liste de toutes les branches
26
+ */
27
+ getAllBranches(): Promise<string[]>;
28
+ /**
29
+ * Valide la configuration Git
30
+ */
31
+ validateConfiguration(): Promise<boolean>;
32
+ }
33
+ /**
34
+ * Interface pour les opérations de gestion des Pull Requests
35
+ */
36
+ export interface IPROperations {
37
+ /**
38
+ * Vérifie si une branche PR est fermée (version legacy)
39
+ */
40
+ isPRClosed(branch: string): Promise<boolean>;
41
+ /**
42
+ * Vérifie si une branche PR est fermée (version robuste avec Git Notes)
43
+ */
44
+ isPRClosedRobust(branch: string, config?: RulesGitConfig): Promise<boolean>;
45
+ /**
46
+ * Ferme un PR (version legacy)
47
+ */
48
+ closePR(branch: string, author: RuleUser, message?: string, config?: RulesGitConfig): Promise<PRMergeResult>;
49
+ /**
50
+ * Ferme un PR (version robuste avec Git Notes)
51
+ */
52
+ closePRRobust(branch: string, closedBy: RuleUser, message?: string, config?: RulesGitConfig): Promise<PRMergeResult>;
53
+ /**
54
+ * Récupère tous les pull requests avec leur statut
55
+ */
56
+ getAllPR(options?: {
57
+ open?: boolean;
58
+ validationPrefix?: string;
59
+ }): Promise<PRInfo[]>;
60
+ /**
61
+ * Trouve le prochain numéro de PR disponible
62
+ */
63
+ getNextPRNumber(validationPrefix: string): Promise<number>;
64
+ /**
65
+ * Crée un nouveau PR avec incrémentation automatique du numéro
66
+ */
67
+ newPR(files: string[], description: string, author: RuleUser, options?: {
68
+ editorBranch?: string;
69
+ validationPrefix?: string;
70
+ }): Promise<PRInfo>;
71
+ }
72
+ /**
73
+ * Interface pour la gestion de la concurrence
74
+ */
75
+ export interface IConcurrencyManager {
76
+ /**
77
+ * Exécute une fonction avec retry automatique
78
+ */
79
+ withRetry<T>(operation: () => Promise<T>, options: ConcurrencyOptions, operationName?: string): Promise<RetryResult<T>>;
80
+ }
81
+ /**
82
+ * Interface pour les opérations Git Notes
83
+ */
84
+ export interface IGitNotesOperations {
85
+ /**
86
+ * Lit une note Git pour une branche donnée
87
+ */
88
+ readNote(branch: string, namespace: string): Promise<PRMetadata | null>;
89
+ /**
90
+ * Écrit une note Git pour une branche donnée
91
+ */
92
+ writeNote(branch: string, content: PRMetadata, namespace: string): Promise<void>;
93
+ /**
94
+ * Supprime une note Git pour une branche donnée
95
+ */
96
+ deleteNote(branch: string, author: RuleUser, namespace: string): Promise<void>;
97
+ }
98
+ /**
99
+ * Interface pour la configuration Git
100
+ */
101
+ export interface IGitConfigLoader {
102
+ /**
103
+ * Charge la configuration Git depuis les variables d'environnement
104
+ */
105
+ load(): RulesGitConfig;
106
+ /**
107
+ * Valide la configuration chargée
108
+ */
109
+ validate(config: RulesGitConfig): boolean;
110
+ }
111
+ /**
112
+ * Interface principale qui combine toutes les opérations Git
113
+ * Parfaite pour les tests d'intégration et le mocking complet
114
+ */
115
+ export interface IGitRepository extends IGitOperations, IPROperations {
116
+ /**
117
+ * Instance Git sous-jacente
118
+ */
119
+ readonly git: SimpleGit;
120
+ /**
121
+ * Configuration Git actuelle
122
+ */
123
+ readonly config: RulesGitConfig;
124
+ /**
125
+ * Gestionnaire de concurrence
126
+ */
127
+ readonly concurrency: IConcurrencyManager;
128
+ /**
129
+ * Opérations Git Notes
130
+ */
131
+ readonly notes: IGitNotesOperations;
132
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RuleStatus = void 0;
4
+ /**
5
+ * @fileoverview Types et interfaces pour le système de gestion des règles métier
6
+ *
7
+ * Ce fichier définit tous les types TypeScript utilisés dans le workflow de gestion
8
+ * des règles, depuis les types de haut niveau (Rules, PR) jusqu'aux types Git de bas niveau.
9
+ */
10
+ // ===== TYPES DE HAUT NIVEAU POUR LE WORKFLOW =====
11
+ /**
12
+ * Énumération des statuts possibles d'une règle dans le workflow
13
+ *
14
+ * Le statut d'une règle reflète sa position dans le processus de validation
15
+ * et de publication, basé sur la branche Git où elle se trouve.
16
+ *
17
+ * @enum {string}
18
+ */
19
+ var RuleStatus;
20
+ (function (RuleStatus) {
21
+ /** Règle publiée et officielle (branche main) */
22
+ RuleStatus["PUBLISHED"] = "published";
23
+ /** Règle en cours d'édition (branche editor/draft) */
24
+ RuleStatus["EDITING"] = "editing";
25
+ /** Règle en cours de validation via pull request (branche validation) */
26
+ RuleStatus["PULLREQUEST"] = "pullrequest";
27
+ /** Règle candidate pour une release (branche release) */
28
+ RuleStatus["RELEASE_CANDIDATE"] = "candidate";
29
+ /** Règle en correction urgente (branche hotfix) */
30
+ RuleStatus["HOTFIX"] = "hotfix";
31
+ /** Nouvelle règle non encore trackée par Git (fichier local) */
32
+ RuleStatus["NEW"] = "new";
33
+ })(RuleStatus || (exports.RuleStatus = RuleStatus = {}));
@@ -0,0 +1,61 @@
1
+ import { UserMSAL } from '../microsoft/profile';
2
+ import { RuleUser } from './types';
3
+ /**
4
+ * Rôles disponibles pour les règles
5
+ */
6
+ export declare enum RuleRole {
7
+ READER = "reader",
8
+ EDITOR = "editor",
9
+ VALIDATOR = "validator",
10
+ PUBLISHER = "publisher"
11
+ }
12
+ /**
13
+ * Configuration des permissions par rôle
14
+ */
15
+ export interface RolePermissions {
16
+ canRead: boolean;
17
+ canDelete: boolean;
18
+ canEdit: boolean;
19
+ canValidate: boolean;
20
+ canPublish: boolean;
21
+ }
22
+ /**
23
+ * Permissions par rôle
24
+ */
25
+ export declare const ROLE_PERMISSIONS: Record<RuleRole, RolePermissions>;
26
+ /**
27
+ * Mapper pour convertir UserMSAL en RuleUser
28
+ */
29
+ export declare class UserRoleMapper {
30
+ /**
31
+ * Convertit un UserMSAL en RuleUser
32
+ * @param userMSAL L'utilisateur MSAL
33
+ * @param overrideRole Rôle à forcer (optionnel)
34
+ */
35
+ static toRuleUser(userMSAL: UserMSAL, overrideRole?: RuleRole): RuleUser;
36
+ /**
37
+ * Détermine le rôle d'un utilisateur basé sur ses propriétés MSAL
38
+ * @param userMSAL L'utilisateur MSAL
39
+ */
40
+ private static determineRoleFromMSAL;
41
+ /**
42
+ * Vérifie si un utilisateur a une permission spécifique
43
+ * @param userMSAL L'utilisateur MSAL
44
+ * @param permission La permission à vérifier
45
+ * @param overrideRole Rôle à forcer (optionnel)
46
+ */
47
+ static hasPermission(userMSAL: UserMSAL, permission: keyof RolePermissions, overrideRole?: RuleRole): boolean;
48
+ /**
49
+ * Obtient toutes les permissions d'un utilisateur
50
+ * @param userMSAL L'utilisateur MSAL
51
+ * @param overrideRole Rôle à forcer (optionnel)
52
+ */
53
+ static getPermissions(userMSAL: UserMSAL, overrideRole?: RuleRole): RolePermissions;
54
+ /**
55
+ * Vérifie si un utilisateur peut effectuer une action sur une branche donnée
56
+ * @param userMSAL L'utilisateur MSAL
57
+ * @param action L'action à effectuer
58
+ * @param branch La branche concernée
59
+ */
60
+ static canPerformAction(userMSAL: UserMSAL, action: 'read' | 'edit' | 'validate' | 'publish' | 'delete', branch: string): boolean;
61
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserRoleMapper = exports.ROLE_PERMISSIONS = exports.RuleRole = void 0;
4
+ /**
5
+ * Rôles disponibles pour les règles
6
+ */
7
+ var RuleRole;
8
+ (function (RuleRole) {
9
+ RuleRole["READER"] = "reader";
10
+ RuleRole["EDITOR"] = "editor";
11
+ RuleRole["VALIDATOR"] = "validator";
12
+ RuleRole["PUBLISHER"] = "publisher";
13
+ })(RuleRole || (exports.RuleRole = RuleRole = {}));
14
+ /**
15
+ * Permissions par rôle
16
+ */
17
+ exports.ROLE_PERMISSIONS = {
18
+ [RuleRole.READER]: {
19
+ canRead: true,
20
+ canDelete: false,
21
+ canEdit: false,
22
+ canValidate: false,
23
+ canPublish: false
24
+ },
25
+ [RuleRole.EDITOR]: {
26
+ canRead: true,
27
+ canDelete: true,
28
+ canEdit: true,
29
+ canValidate: false,
30
+ canPublish: false
31
+ },
32
+ [RuleRole.VALIDATOR]: {
33
+ canRead: true,
34
+ canDelete: true,
35
+ canEdit: true,
36
+ canValidate: true,
37
+ canPublish: false
38
+ },
39
+ [RuleRole.PUBLISHER]: {
40
+ canRead: true,
41
+ canDelete: true,
42
+ canEdit: true,
43
+ canValidate: true,
44
+ canPublish: true
45
+ }
46
+ };
47
+ /**
48
+ * Mapper pour convertir UserMSAL en RuleUser
49
+ */
50
+ class UserRoleMapper {
51
+ /**
52
+ * Convertit un UserMSAL en RuleUser
53
+ * @param userMSAL L'utilisateur MSAL
54
+ * @param overrideRole Rôle à forcer (optionnel)
55
+ */
56
+ static toRuleUser(userMSAL, overrideRole) {
57
+ // Déterminer le rôle
58
+ let role = overrideRole;
59
+ if (!role) {
60
+ // Déterminer le rôle basé sur les propriétés de l'utilisateur MSAL
61
+ role = this.determineRoleFromMSAL(userMSAL);
62
+ }
63
+ return {
64
+ name: userMSAL.displayName || userMSAL.id,
65
+ email: userMSAL.mail || `${userMSAL.id}@placeholder.local`,
66
+ role: role
67
+ };
68
+ }
69
+ /**
70
+ * Détermine le rôle d'un utilisateur basé sur ses propriétés MSAL
71
+ * @param userMSAL L'utilisateur MSAL
72
+ */
73
+ static determineRoleFromMSAL(userMSAL) {
74
+ // Logique de détermination du rôle basée sur les propriétés MSAL
75
+ // Cette logique peut être personnalisée selon les besoins de l'organisation
76
+ // Par défaut, utiliser hasRole() si disponible
77
+ const userRole = userMSAL.role;
78
+ // Mapper les rôles MSAL vers les rôles de règles
79
+ switch (userRole?.toLowerCase()) {
80
+ case 'admin':
81
+ case 'administrator':
82
+ case 'director':
83
+ case 'publisher':
84
+ return RuleRole.PUBLISHER;
85
+ case 'manager':
86
+ case 'chef':
87
+ case 'validator':
88
+ case 'reviewer':
89
+ return RuleRole.VALIDATOR;
90
+ case 'editor':
91
+ case 'contributor':
92
+ case 'writer':
93
+ return RuleRole.EDITOR;
94
+ case 'reader':
95
+ case 'viewer':
96
+ case 'anonymous':
97
+ default:
98
+ return RuleRole.READER;
99
+ }
100
+ }
101
+ /**
102
+ * Vérifie si un utilisateur a une permission spécifique
103
+ * @param userMSAL L'utilisateur MSAL
104
+ * @param permission La permission à vérifier
105
+ * @param overrideRole Rôle à forcer (optionnel)
106
+ */
107
+ static hasPermission(userMSAL, permission, overrideRole) {
108
+ const ruleUser = this.toRuleUser(userMSAL, overrideRole);
109
+ const role = ruleUser.role || RuleRole.READER;
110
+ return exports.ROLE_PERMISSIONS[role][permission];
111
+ }
112
+ /**
113
+ * Obtient toutes les permissions d'un utilisateur
114
+ * @param userMSAL L'utilisateur MSAL
115
+ * @param overrideRole Rôle à forcer (optionnel)
116
+ */
117
+ static getPermissions(userMSAL, overrideRole) {
118
+ const ruleUser = this.toRuleUser(userMSAL, overrideRole);
119
+ const role = ruleUser.role || RuleRole.READER;
120
+ return exports.ROLE_PERMISSIONS[role];
121
+ }
122
+ /**
123
+ * Vérifie si un utilisateur peut effectuer une action sur une branche donnée
124
+ * @param userMSAL L'utilisateur MSAL
125
+ * @param action L'action à effectuer
126
+ * @param branch La branche concernée
127
+ */
128
+ static canPerformAction(userMSAL, action, branch) {
129
+ // Déterminer le rôle requis selon l'action et la branche
130
+ const isValidationBranch = branch.startsWith('rule-validation-');
131
+ const isMainBranch = branch === 'main';
132
+ switch (action) {
133
+ case 'delete':
134
+ return this.hasPermission(userMSAL, 'canDelete');
135
+ case 'read':
136
+ return this.hasPermission(userMSAL, 'canRead');
137
+ case 'edit':
138
+ // L'édition n'est autorisée que sur la branche d'édition
139
+ if (branch !== 'rule-editor' && !isValidationBranch) {
140
+ return false;
141
+ }
142
+ return this.hasPermission(userMSAL, 'canEdit');
143
+ case 'validate':
144
+ // La validation n'est autorisée que sur les branches de validation
145
+ if (!isValidationBranch) {
146
+ return false;
147
+ }
148
+ return this.hasPermission(userMSAL, 'canValidate');
149
+ case 'publish':
150
+ // La publication n'est autorisée que depuis les branches de validation vers main
151
+ if (!isValidationBranch) {
152
+ return false;
153
+ }
154
+ return this.hasPermission(userMSAL, 'canPublish');
155
+ default:
156
+ return false;
157
+ }
158
+ }
159
+ }
160
+ exports.UserRoleMapper = UserRoleMapper;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility functions for handling slugs in the rules system
3
+ */
4
+ /**
5
+ * Extracts a slug from a file path
6
+ * @param filePath The file path to extract the slug from
7
+ * @returns The slug extracted from the file path
8
+ */
9
+ export declare const slugFromFile: (filePath: string, ext?: string) => string;
10
+ /**
11
+ * Converts a slug back to a file path
12
+ * @param slug The slug to convert to a file path
13
+ * @param ext The file extension to append (default: '.md')
14
+ * @returns The file path created from the slug
15
+ */
16
+ export declare const fileFromSlug: (slug: string, ext?: string) => string;
17
+ /**
18
+ * Validates if a string is a valid slug
19
+ * @param slug The slug to validate
20
+ * @returns True if the slug is valid, false otherwise
21
+ */
22
+ export declare const isValidSlug: (slug: string) => boolean;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for handling slugs in the rules system
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isValidSlug = exports.fileFromSlug = exports.slugFromFile = void 0;
7
+ const utils_1 = require("../../utils");
8
+ /**
9
+ * Extracts a slug from a file path
10
+ * @param filePath The file path to extract the slug from
11
+ * @returns The slug extracted from the file path
12
+ */
13
+ const slugFromFile = (filePath, ext = '.md') => {
14
+ return (0, utils_1.toSlug)(filePath.replace(ext, ''));
15
+ };
16
+ exports.slugFromFile = slugFromFile;
17
+ /**
18
+ * Converts a slug back to a file path
19
+ * @param slug The slug to convert to a file path
20
+ * @param ext The file extension to append (default: '.md')
21
+ * @returns The file path created from the slug
22
+ */
23
+ const fileFromSlug = (slug, ext = '.md') => {
24
+ return `${slug}${ext}`;
25
+ };
26
+ exports.fileFromSlug = fileFromSlug;
27
+ /**
28
+ * Validates if a string is a valid slug
29
+ * @param slug The slug to validate
30
+ * @returns True if the slug is valid, false otherwise
31
+ */
32
+ const isValidSlug = (slug) => {
33
+ return /^[a-z0-9-]+$/.test(slug);
34
+ };
35
+ exports.isValidSlug = isValidSlug;
@@ -0,0 +1,66 @@
1
+ import { FrontMatter, Rule } from "./types";
2
+ /**
3
+ * Parse le front-matter YAML et le contenu Markdown d'un document
4
+ *
5
+ * Cette fonction extrait et parse le front-matter YAML délimité par '---'
6
+ * au début d'un document Markdown. Elle gère automatiquement :
7
+ * - La conversion des types (nombres, booléens, chaînes)
8
+ * - Le parsing des arrays JSON dans le YAML
9
+ * - La normalisation des champs `slugs` et `tags` en arrays
10
+ * - La suppression des guillemets de délimitation
11
+ *
12
+ * @param markdown - Texte Markdown brut avec front-matter optionnel
13
+ * @returns Objet contenant le front-matter parsé et le contenu
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const doc = `---
18
+ * title: Ma Procédure
19
+ * tags: ["urgent", "finance"]
20
+ * version: 1.2
21
+ * active: true
22
+ * ---
23
+ * # Contenu de la procédure
24
+ *
25
+ * Instructions détaillées...`;
26
+ *
27
+ * const { matter, content } = matterParse(doc);
28
+ * // matter: { title: 'Ma Procédure', tags: ['urgent', 'finance'], version: 1.2, active: true }
29
+ * // content: '# Contenu de la procédure\n\nInstructions détaillées...'
30
+ * ```
31
+ */
32
+ export declare function matterParse(markdown: string): {
33
+ matter: {};
34
+ content: string;
35
+ data?: undefined;
36
+ } | {
37
+ data: any;
38
+ content: string;
39
+ matter: any;
40
+ };
41
+ /**
42
+ * Sérialise une Rule en format Markdown avec front-matter
43
+ * ✅ NOUVELLE FONCTION pour reconstruire le contenu complet
44
+ */
45
+ export declare function matterSerializeFromRule(rule: Rule): string;
46
+ export declare function matterSerialize(content: string, matter: FrontMatter | any): string;
47
+ /**
48
+ * Extrait le front-matter (entre les deux premiers '---') et le contenu Markdown.
49
+ * Fonction 100% vanilla : aucun paquet externe requis.
50
+ * PROS:
51
+ * Code plus propre et maintenable
52
+ * - Typage TypeScript strict
53
+ * - Plus robuste (ignore lignes indentées)
54
+ * - Séparation des responsabilités
55
+ * - Meilleure architecture (parsing pur)
56
+ * CONS:
57
+ * - Perte de fonctionnalité (slugs/tags)
58
+ *
59
+ * @param markdown Texte Markdown brut
60
+ * @returns Objet avec matter, content et data
61
+ */
62
+ export declare function matterParse_OTHER(markdown: string): {
63
+ matter: Record<string, any>;
64
+ content: string;
65
+ data: Record<string, any>;
66
+ };