@forwardimpact/model 0.1.0 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Dick Olsson
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @forwardimpact/model
2
+
3
+ Derivation engine for roles, skills, and AI agent profiles.
4
+
5
+ ## Role in the Vision
6
+
7
+ The model package contains the core logic that transforms raw data into
8
+ actionable role definitions. Whether you're generating a human job description
9
+ or an AI agent profile, the same derivation engine ensures consistent
10
+ expectations across both.
11
+
12
+ ## What It Does
13
+
14
+ - **Job derivation** — Combine discipline, track, and grade into complete role
15
+ definitions with skill matrices and behaviour profiles
16
+ - **Agent profiles** — Generate AI coding agent configurations from the same
17
+ foundation as human roles
18
+ - **Interview preparation** — Select appropriate questions based on role
19
+ requirements
20
+ - **Career progression** — Analyze skill gaps and growth paths between grades
21
+ - **Checklists** — Derive stage transition checklists from capability
22
+ definitions
23
+
24
+ ## Usage
25
+
26
+ ```javascript
27
+ import {
28
+ deriveJob,
29
+ deriveSkillMatrix,
30
+ deriveBehaviourProfile,
31
+ } from "@forwardimpact/model/derivation";
32
+ import { prepareAgentProfile } from "@forwardimpact/model/agent";
33
+ import { selectInterviewQuestions } from "@forwardimpact/model/interview";
34
+ import { analyzeProgression } from "@forwardimpact/model/progression";
35
+ ```
36
+
37
+ ## Key Concepts
38
+
39
+ ### Job Derivation
40
+
41
+ ```
42
+ Job = Discipline × Track × Grade
43
+ ```
44
+
45
+ - **Discipline** defines skill tiers (primary/secondary/broad)
46
+ - **Track** applies modifiers to capability areas
47
+ - **Grade** sets base skill levels
48
+
49
+ ### Agent Profiles
50
+
51
+ ```
52
+ Agent = Discipline × Track × Stage
53
+ ```
54
+
55
+ Uses the same skill derivation but filtered for AI-applicable capabilities and
56
+ constrained by lifecycle stage (plan, code, review).
57
+
58
+ ## Package Exports
59
+
60
+ | Export | Purpose |
61
+ | ------------- | --------------------------- |
62
+ | `derivation` | Core derivation functions |
63
+ | `agent` | Agent profile generation |
64
+ | `interview` | Question selection |
65
+ | `job` | Job preparation for display |
66
+ | `job-cache` | Caching for pages |
67
+ | `progression` | Career path analysis |
68
+ | `checklist` | Stage transition checklists |
69
+ | `matching` | Role matching logic |
70
+
71
+ See the [documentation](../../docs/model/index.md) for derivation details.
package/lib/agent.js CHANGED
@@ -177,21 +177,25 @@ function findAgentBehaviour(agentBehaviours, id) {
177
177
  }
178
178
 
179
179
  /**
180
- * Build working style section from emphasized behaviours
181
- * Includes workflow patterns when available
180
+ * @typedef {Object} WorkingStyleEntry
181
+ * @property {string} title - Section title (e.g. "Own the outcome end-to-end")
182
+ * @property {string} content - Working style content (markdown)
183
+ */
184
+
185
+ /**
186
+ * Build working style entries from emphasized behaviours
187
+ * Returns structured data for template iteration
182
188
  * @param {Array} derivedBehaviours - Behaviours sorted by maturity (highest first)
183
189
  * @param {Array} agentBehaviours - Agent behaviour definitions with principles
184
190
  * @param {number} topN - Number of top behaviours to include
185
- * @returns {string} Working style markdown section
191
+ * @returns {WorkingStyleEntry[]} Array of working style entries
186
192
  */
187
193
  function buildWorkingStyleFromBehaviours(
188
194
  derivedBehaviours,
189
195
  agentBehaviours,
190
196
  topN = 3,
191
197
  ) {
192
- const sections = [];
193
- sections.push("## Working Style");
194
- sections.push("");
198
+ const entries = [];
195
199
 
196
200
  // Get top N behaviours by maturity
197
201
  const topBehaviours = derivedBehaviours.slice(0, topN);
@@ -207,22 +211,16 @@ function buildWorkingStyleFromBehaviours(
207
211
 
208
212
  // Use title as section header
209
213
  const title = agentBehaviour.title || derived.behaviourName;
210
- sections.push(`### ${title}`);
211
- sections.push("");
212
-
213
- // Include workingStyle if available (structured guidance)
214
- if (agentBehaviour.workingStyle) {
215
- sections.push(agentBehaviour.workingStyle.trim());
216
- sections.push("");
217
- } else if (agentBehaviour.principles) {
218
- // Fall back to principles
219
- const principles = agentBehaviour.principles.trim();
220
- sections.push(principles);
221
- sections.push("");
222
- }
214
+
215
+ // Include workingStyle if available, otherwise fall back to principles
216
+ const content = agentBehaviour.workingStyle
217
+ ? agentBehaviour.workingStyle.trim()
218
+ : agentBehaviour.principles.trim();
219
+
220
+ entries.push({ title, content });
223
221
  }
224
222
 
225
- return sections.join("\n");
223
+ return entries;
226
224
  }
227
225
 
228
226
  /**
@@ -308,8 +306,7 @@ function estimateBodyDataLength(bodyData) {
308
306
  "stageDescription",
309
307
  "identity",
310
308
  "priority",
311
- "delegation",
312
- "operationalContext",
309
+ "roleContext",
313
310
  "workingStyle",
314
311
  "beforeHandoff",
315
312
  ];
@@ -326,11 +323,6 @@ function estimateBodyDataLength(bodyData) {
326
323
  skill.name.length + skill.dirname.length + skill.useWhen.length + 50;
327
324
  }
328
325
  }
329
- if (bodyData.beforeMakingChanges) {
330
- for (const item of bodyData.beforeMakingChanges) {
331
- length += item.text.length + 5; // +5 for "1. " prefix
332
- }
333
- }
334
326
  if (bodyData.constraints) {
335
327
  for (const c of bodyData.constraints) {
336
328
  length += c.length + 2; // +2 for "- " prefix
@@ -496,6 +488,7 @@ function getChecklistStage(stageId) {
496
488
  * @param {Array} params.agentBehaviours - Agent behaviour definitions
497
489
  * @param {Array} params.skills - All skill definitions (for agent section lookup)
498
490
  * @param {string} params.checklistMarkdown - Pre-formatted checklist markdown
491
+ * @param {Array<{id: string, name: string, description: string}>} [params.agentIndex] - List of all available agents
499
492
  * @returns {Object} Structured profile body data
500
493
  */
501
494
  function buildStageProfileBodyData({
@@ -509,6 +502,7 @@ function buildStageProfileBodyData({
509
502
  agentBehaviours,
510
503
  skills,
511
504
  checklistMarkdown,
505
+ agentIndex,
512
506
  }) {
513
507
  const name = `${humanDiscipline.specialization || humanDiscipline.name} - ${humanTrack.name}`;
514
508
  const stageName = stage.name.charAt(0).toUpperCase() + stage.name.slice(1);
@@ -523,20 +517,6 @@ function buildStageProfileBodyData({
523
517
  ? substituteTemplateVars(rawPriority, humanDiscipline)
524
518
  : null;
525
519
 
526
- // Build beforeMakingChanges list - prefer track, fall back to discipline
527
- const rawSteps =
528
- agentTrack.beforeMakingChanges || agentDiscipline.beforeMakingChanges || [];
529
- const beforeMakingChanges = rawSteps.map((text, i) => ({
530
- index: i + 1,
531
- text: substituteTemplateVars(text, humanDiscipline),
532
- }));
533
-
534
- // Delegation (from discipline only, optional)
535
- const rawDelegation = agentDiscipline.delegation;
536
- const delegation = rawDelegation
537
- ? substituteTemplateVars(rawDelegation, humanDiscipline)
538
- : null;
539
-
540
520
  // Build skill index from derived skills with agent sections
541
521
  const skillIndex = derivedSkills
542
522
  .map((derived) => {
@@ -550,11 +530,11 @@ function buildStageProfileBodyData({
550
530
  })
551
531
  .filter(Boolean);
552
532
 
553
- // Operational Context - use track's roleContext (shared with human job descriptions)
554
- const operationalContext = humanTrack.roleContext.trim();
533
+ // Role Context - use track's roleContext (shared with human job descriptions)
534
+ const roleContext = humanTrack.roleContext.trim();
555
535
 
556
- // Working Style from derived behaviours (still markdown for now)
557
- const workingStyle = buildWorkingStyleFromBehaviours(
536
+ // Working styles from derived behaviours (structured for template iteration)
537
+ const workingStyles = buildWorkingStyleFromBehaviours(
558
538
  derivedBehaviours,
559
539
  agentBehaviours,
560
540
  3,
@@ -567,18 +547,26 @@ function buildStageProfileBodyData({
567
547
  ...(agentTrack.constraints || []),
568
548
  ];
569
549
 
550
+ // Filter agent index to only include agents with same track and stage (different disciplines)
551
+ // Agent IDs follow pattern: {discipline-abbrev}-{track-id-kebab}-{stage-id}
552
+ const trackSuffix = `-${toKebabCase(humanTrack.id)}-${stage.id}`;
553
+ const currentAgentId = `${getDisciplineAbbreviation(humanDiscipline.id)}${trackSuffix}`;
554
+ const filteredAgentIndex = (agentIndex || []).filter(
555
+ (agent) => agent.id.endsWith(trackSuffix) && agent.id !== currentAgentId,
556
+ );
557
+
570
558
  return {
571
559
  title: `${name} - ${stageName} Agent`,
572
560
  stageDescription: stage.description,
573
561
  identity: identity.trim(),
574
562
  priority: priority ? priority.trim() : null,
575
563
  skillIndex,
576
- beforeMakingChanges,
577
- delegation: delegation ? delegation.trim() : null,
578
- operationalContext,
579
- workingStyle,
564
+ roleContext,
565
+ workingStyles,
580
566
  beforeHandoff: checklistMarkdown || null,
581
567
  constraints,
568
+ agentIndex: filteredAgentIndex,
569
+ hasAgentIndex: filteredAgentIndex.length > 0,
582
570
  };
583
571
  }
584
572
 
@@ -681,6 +669,7 @@ export function deriveStageAgent({
681
669
  * @param {Object} params.agentTrack - Agent track definition
682
670
  * @param {Array} params.capabilities - Capabilities with checklists
683
671
  * @param {Array} params.stages - All stages (for handoff entry criteria)
672
+ * @param {Array<{id: string, name: string, description: string}>} [params.agentIndex] - List of all available agents
684
673
  * @returns {Object} Profile with frontmatter, bodyData, and filename
685
674
  */
686
675
  export function generateStageAgentProfile({
@@ -695,6 +684,7 @@ export function generateStageAgentProfile({
695
684
  agentTrack,
696
685
  capabilities,
697
686
  stages,
687
+ agentIndex,
698
688
  }) {
699
689
  // Derive the complete agent
700
690
  const agent = deriveStageAgent({
@@ -736,6 +726,7 @@ export function generateStageAgentProfile({
736
726
  agentBehaviours,
737
727
  skills,
738
728
  checklistMarkdown,
729
+ agentIndex,
739
730
  });
740
731
 
741
732
  // Build frontmatter
@@ -752,3 +743,71 @@ export function generateStageAgentProfile({
752
743
  filename,
753
744
  };
754
745
  }
746
+
747
+ /**
748
+ * Build an agent description from discipline, track, and stage
749
+ * Uses the same format as generateStageAgentProfile for consistency
750
+ * @param {Object} discipline - Human discipline definition
751
+ * @param {Object} track - Human track definition
752
+ * @param {Object} stage - Stage definition
753
+ * @returns {string} Agent description
754
+ */
755
+ function buildAgentDescription(discipline, track, stage) {
756
+ const disciplineDesc = discipline.description.trim().split("\n")[0];
757
+ const stageDesc = stage.description.split(" - ")[0];
758
+ return `${stageDesc} agent for ${discipline.specialization || discipline.name} on ${track.name} track. ${disciplineDesc}`;
759
+ }
760
+
761
+ /**
762
+ * Build a list of all available agents in the system
763
+ * Enumerates all valid discipline × track × stage combinations
764
+ * Returns id, name, and description for each agent
765
+ * @param {Object} params - Parameters
766
+ * @param {Array} params.disciplines - Human discipline definitions
767
+ * @param {Array} params.tracks - Human track definitions
768
+ * @param {Array} params.stages - Stage definitions
769
+ * @param {Array} params.agentDisciplines - Agent discipline definitions (to filter valid combinations)
770
+ * @param {Array} params.agentTracks - Agent track definitions (to filter valid combinations)
771
+ * @returns {Array<{id: string, name: string, description: string}>} List of all agents
772
+ */
773
+ export function buildAgentIndex({
774
+ disciplines,
775
+ tracks,
776
+ stages,
777
+ agentDisciplines,
778
+ agentTracks,
779
+ }) {
780
+ const agents = [];
781
+
782
+ // Build lookup sets for valid agent combinations
783
+ const agentDisciplineIds = new Set(agentDisciplines.map((d) => d.id));
784
+ const agentTrackIds = new Set(agentTracks.map((t) => t.id));
785
+
786
+ for (const discipline of disciplines) {
787
+ // Skip disciplines without agent definitions
788
+ if (!agentDisciplineIds.has(discipline.id)) continue;
789
+
790
+ for (const track of tracks) {
791
+ // Skip tracks without agent definitions
792
+ if (!agentTrackIds.has(track.id)) continue;
793
+
794
+ // Build base name (matches filename pattern)
795
+ const abbrev = getDisciplineAbbreviation(discipline.id);
796
+ const baseName = `${abbrev}-${toKebabCase(track.id)}`;
797
+
798
+ for (const stage of stages) {
799
+ const id = `${baseName}-${stage.id}`;
800
+ const fullName = `${discipline.specialization || discipline.name} - ${track.name} - ${stage.name.charAt(0).toUpperCase() + stage.name.slice(1)} Agent`;
801
+ const description = buildAgentDescription(discipline, track, stage);
802
+
803
+ agents.push({
804
+ id,
805
+ name: fullName,
806
+ description,
807
+ });
808
+ }
809
+ }
810
+ }
811
+
812
+ return agents;
813
+ }
package/lib/index.js CHANGED
@@ -102,11 +102,15 @@ export {
102
102
  deriveHandoffs,
103
103
  deriveStageAgent,
104
104
  generateStageAgentProfile,
105
+ buildAgentIndex,
105
106
  } from "./agent.js";
106
107
 
107
108
  // Checklists
108
109
  export { deriveChecklist, formatChecklistMarkdown } from "./checklist.js";
109
110
 
111
+ // Toolkit
112
+ export { deriveToolkit } from "./toolkit.js";
113
+
110
114
  // Profile filtering (for agents)
111
115
  export {
112
116
  getPositiveTrackCapabilities,
package/lib/job.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  getDisciplineSkillIds,
13
13
  } from "./derivation.js";
14
14
  import { deriveChecklist } from "./checklist.js";
15
+ import { deriveToolkit } from "./toolkit.js";
15
16
  import { getOrCreateJob } from "./job-cache.js";
16
17
 
17
18
  /**
@@ -28,6 +29,7 @@ import { getOrCreateJob } from "./job-cache.js";
28
29
  * @property {Array} behaviourProfile
29
30
  * @property {Array} derivedResponsibilities
30
31
  * @property {Array} driverCoverage
32
+ * @property {Array} toolkit - De-duplicated tools from skills
31
33
  * @property {Object} checklists - Handoff checklists keyed by handoff type
32
34
  */
33
35
 
@@ -85,6 +87,12 @@ export function prepareJobDetail({
85
87
  }
86
88
  }
87
89
 
90
+ // Derive toolkit from skill matrix
91
+ const toolkit = deriveToolkit({
92
+ skillMatrix: job.skillMatrix,
93
+ skills,
94
+ });
95
+
88
96
  return {
89
97
  title: job.title,
90
98
  disciplineId: discipline.id,
@@ -98,6 +106,8 @@ export function prepareJobDetail({
98
106
  skillMatrix: job.skillMatrix,
99
107
  behaviourProfile: job.behaviourProfile,
100
108
  derivedResponsibilities: job.derivedResponsibilities || [],
109
+ // Derived toolkit
110
+ toolkit,
101
111
  // Transformed driver coverage for display
102
112
  driverCoverage: driverCoverage.map((d) => ({
103
113
  id: d.driverId,
package/lib/toolkit.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Toolkit Derivation Functions
3
+ *
4
+ * Derives a de-duplicated list of tools from a skill matrix by looking up
5
+ * toolReferences from skill definitions.
6
+ */
7
+
8
+ /**
9
+ * @typedef {Object} ToolkitEntry
10
+ * @property {string} name - Tool name
11
+ * @property {string} description - Tool description
12
+ * @property {string} [url] - Tool documentation URL
13
+ * @property {string} [simpleIcon] - Simple Icons slug for the tool icon
14
+ * @property {string[]} skillIds - IDs of skills that reference this tool
15
+ */
16
+
17
+ /**
18
+ * Derive a de-duplicated toolkit from a skill matrix
19
+ *
20
+ * Extracts all tools referenced by skills in the matrix, de-duplicates by name,
21
+ * and collects which skills reference each tool.
22
+ *
23
+ * @param {Object} params
24
+ * @param {Array<{skillId: string}>} params.skillMatrix - Skill matrix with skill IDs
25
+ * @param {Array} params.skills - All skill definitions with toolReferences
26
+ * @returns {ToolkitEntry[]} De-duplicated toolkit sorted by name
27
+ */
28
+ export function deriveToolkit({ skillMatrix, skills }) {
29
+ // Build skill lookup map for O(1) access
30
+ const skillMap = new Map(skills.map((s) => [s.id, s]));
31
+
32
+ // Tool map for de-duplication: name -> ToolkitEntry
33
+ const toolMap = new Map();
34
+
35
+ for (const entry of skillMatrix) {
36
+ const skill = skillMap.get(entry.skillId);
37
+ if (!skill?.toolReferences) continue;
38
+
39
+ for (const tool of skill.toolReferences) {
40
+ const existing = toolMap.get(tool.name);
41
+ if (existing) {
42
+ // Add skill ID if not already present
43
+ if (!existing.skillIds.includes(skill.id)) {
44
+ existing.skillIds.push(skill.id);
45
+ }
46
+ // Prefer first occurrence's metadata, but fill in missing values
47
+ if (!existing.url && tool.url) {
48
+ existing.url = tool.url;
49
+ }
50
+ if (!existing.simpleIcon && tool.simpleIcon) {
51
+ existing.simpleIcon = tool.simpleIcon;
52
+ }
53
+ } else {
54
+ toolMap.set(tool.name, {
55
+ name: tool.name,
56
+ description: tool.description,
57
+ url: tool.url,
58
+ simpleIcon: tool.simpleIcon,
59
+ skillIds: [skill.id],
60
+ });
61
+ }
62
+ }
63
+ }
64
+
65
+ // Sort by name and return
66
+ return Array.from(toolMap.values()).sort((a, b) =>
67
+ a.name.localeCompare(b.name),
68
+ );
69
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@forwardimpact/model",
3
- "version": "0.1.0",
4
- "description": "Business logic for Engineering Pathway framework",
3
+ "version": "0.3.0",
4
+ "description": "Derivation engine for roles, skills, and AI agent profiles",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/forwardimpact/pathway",
8
+ "url": "https://github.com/forwardimpact/monorepo",
9
9
  "directory": "apps/model"
10
10
  },
11
+ "homepage": "https://www.forwardimpact.team/model",
11
12
  "type": "module",
12
13
  "main": "lib/index.js",
13
14
  "files": [
@@ -27,7 +28,7 @@
27
28
  "./progression": "./lib/progression.js"
28
29
  },
29
30
  "dependencies": {
30
- "@forwardimpact/schema": "^0.1.0"
31
+ "@forwardimpact/schema": "^0.3.0"
31
32
  },
32
33
  "engines": {
33
34
  "node": ">=18.0.0"