fairmake-capacity-load 0.0.0-stage → 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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +198 -2
- package/bin/fairmake-capacity-load.js +7 -0
- package/evals/cases.json +365 -0
- package/fixtures/README.md +7 -0
- package/fixtures/calendar.csv +5 -0
- package/fixtures/clean/README.md +3 -0
- package/fixtures/clean/calendar.csv +6 -0
- package/fixtures/clean/operations.csv +11 -0
- package/fixtures/exports/infor-job-operations.csv +4 -0
- package/fixtures/intl/README.md +12 -0
- package/fixtures/intl/de/calendar.csv +5 -0
- package/fixtures/intl/de/operations.csv +11 -0
- package/fixtures/intl/ja/calendar.csv +5 -0
- package/fixtures/intl/ja/operations.csv +11 -0
- package/fixtures/operations.csv +11 -0
- package/fixtures/settings-overtime.json +1 -0
- package/fixtures/settings.json +1 -0
- package/package.json +58 -4
- package/server.json +37 -0
- package/src/capacity.js +71 -0
- package/src/demo.js +4 -0
- package/src/index.js +2 -0
- package/src/manifest.js +47 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kurt Francisco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,199 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fairmake Capacity Load
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`fairmake-capacity-load` · MCP server and CLI · MIT
|
|
4
|
+
|
|
5
|
+
Open operation hours by work center and week against available hours, overloaded weeks, past-due load and work centers with no calendar. Reschedules nothing.
|
|
6
|
+
|
|
7
|
+
Part of **Fairmake**, the back-office agents for small and mid-size manufacturers and distributors by Mythos Machines. The software is free (MIT); the paid part is a fixed-price setup on your own files. Every result is computed from your files with plain arithmetic, on your computer; no AI model is called by the tools.
|
|
8
|
+
|
|
9
|
+
## What it checks
|
|
10
|
+
|
|
11
|
+
Put each open operation's remaining hours in the week of its due date (past-due ones in the first week) and compare each week with the work center's available hours (hours per day times days per week times efficiency). Flags overloaded weeks, lists weeks near capacity, reviews past-due load and work centers with no calendar.
|
|
12
|
+
|
|
13
|
+
| Finding | Example from the fictional demo data |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `near_capacity` | CNC is near capacity in 2026-11-30 (91.2%). |
|
|
16
|
+
| `no_calendar` | SAW has 6 open hours and no working calendar, so its load cannot be compared. |
|
|
17
|
+
| `overloaded_week` | CNC is loaded past 100% in 1 week(s): 2026-11-16 75/68 h (110.3%). |
|
|
18
|
+
| `past_due_load` | 1 operation(s) on WELD were due before this week (12 h); they are loaded into the week of 2026-11-16. |
|
|
19
|
+
|
|
20
|
+
Each item gets the most serious level of its findings: **flag** (act on it), **review** (data is missing or unclear; a person looks), **watch** (worth knowing) or **ok**. Every finding names the numbers it was worked out from.
|
|
21
|
+
|
|
22
|
+
## What it needs, and what stays with a person
|
|
23
|
+
|
|
24
|
+
- `operations` (required): Open work order operations under --root: work order, operation, work center, due date and hours remaining
|
|
25
|
+
- `calendar` (required): Work center calendar under --root: hours per day, days per week and efficiency %
|
|
26
|
+
- `as_of` (optional): Start of the horizon, YYYY-MM-DD (default today); loading starts on the Monday of that week
|
|
27
|
+
- `settings` (optional): settings JSON under --root; anything left out uses the defaults listed in the result as settings_used
|
|
28
|
+
|
|
29
|
+
It never does these, and any other tool name is blocked:
|
|
30
|
+
|
|
31
|
+
- Never reschedules work orders or operations in the ERP.
|
|
32
|
+
- Never sends new promise dates to customers.
|
|
33
|
+
|
|
34
|
+
`capacity_draft_capacity_review` writes a draft marked DRAFT; nothing goes out from it. Approving it (`capacity_request_send`) takes one click by a named person, even in Auto, and only records the approval: the agent itself sends, posts, files and pays nothing. What to change, send or pay is a person's decision.
|
|
35
|
+
|
|
36
|
+
## Settings
|
|
37
|
+
|
|
38
|
+
Put the ones you want to change in a JSON file and pass it as `settings`; anything left out uses the default. The result lists the settings it used under `settings_used`.
|
|
39
|
+
|
|
40
|
+
| Setting | Default | Meaning |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `weeks` | `6` | Weeks ahead to load, starting with the week of as_of |
|
|
43
|
+
| `overload_pct` | `100` | A week loaded above this percentage of available hours is overloaded |
|
|
44
|
+
| `watch_pct` | `90` | A week above this percentage is listed to watch |
|
|
45
|
+
|
|
46
|
+
<!-- generated:start -->
|
|
47
|
+
|
|
48
|
+
## A demo run
|
|
49
|
+
|
|
50
|
+
`npx -y fairmake-capacity-load demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
Fairmake Capacity Load demo: fictional open operations on five work centers, six weeks from 2026-11-16. Auto mode is on for drafts only.
|
|
54
|
+
|
|
55
|
+
▶ Run the check on the exported files
|
|
56
|
+
status: executed decision: allow
|
|
57
|
+
5 work center(s), 265 open hours, 2026-11-16 to 2026-12-27: 1 overloaded, 2 to review, 0 near capacity, 2 with room.
|
|
58
|
+
flag CNC overloaded_week, near_capacity
|
|
59
|
+
review SAW no_calendar
|
|
60
|
+
review WELD past_due_load
|
|
61
|
+
|
|
62
|
+
▶ Explain CNC
|
|
63
|
+
status: executed decision: allow
|
|
64
|
+
CNC: flag. CNC is loaded past 100% in 1 week(s): 2026-11-16 75/68 h (110.3%). CNC is near capacity in 2026-11-30 (91.2%).
|
|
65
|
+
|
|
66
|
+
▶ Write the report (CSV worklist and HTML page)
|
|
67
|
+
status: executed decision: allow
|
|
68
|
+
Capacity load against available hours written: 5 work center(s), 265 open hours, 2026-11-16 to 2026-12-27: 1 overloaded, 2 to review, 0 near capacity, 2 with room.
|
|
69
|
+
|
|
70
|
+
▶ Write the draft (Auto is opted in for drafts)
|
|
71
|
+
status: executed decision: allow (auto)
|
|
72
|
+
capacity review open drafted with 1 open marker(s) ([TO CONFIRM production planner]). Nothing was sent.
|
|
73
|
+
|
|
74
|
+
▶ Auto: approving the draft stays one named click
|
|
75
|
+
status: needs_approval decision: ask
|
|
76
|
+
reason: binding_send stays one-click, even in Auto
|
|
77
|
+
|
|
78
|
+
▶ Same call after the named click (recorded; a person acts on it)
|
|
79
|
+
status: executed decision: ask approved by: Pat Planner (fictional)
|
|
80
|
+
capacity review open approved and recorded. Nothing was sent or paid by the agent.
|
|
81
|
+
|
|
82
|
+
▶ The agent tries erp_reschedule_orders itself
|
|
83
|
+
status: blocked decision: block
|
|
84
|
+
reason: Never reschedules work orders or operations in the ERP.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Tools
|
|
88
|
+
|
|
89
|
+
| Tool | What it does | Policy |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `capacity_check` | Put each open operation's remaining hours in the week of its due date (past-due ones in the first week) and compare each week with the work center's available hours (hours per day times days per week times efficiency). | runs |
|
|
92
|
+
| `capacity_explain` | Show one work center's figures and findings, from the same files as capacity_check. | runs |
|
|
93
|
+
| `capacity_write_report` | Write capacity-load.csv (one row per work center, with a blank decision column for people to fill in) and capacity-load.html into out_dir (default fairmake-out/capacity). | runs |
|
|
94
|
+
| `capacity_draft_capacity_review` | Write drafts/capacity_review-open.md: the overloaded and near-capacity work centers with their weeks, for the production planner to decide on overtime, shifts or new dates. | asks first (Auto can be opted in) |
|
|
95
|
+
| `capacity_request_send` | After one named human click (even in Auto), record that the reviewed capacity review draft is approved in capacity_review-requests.csv. | one named click, even in Auto (`binding_send`) |
|
|
96
|
+
| `erp_reschedule_orders` | Never reschedules work orders or operations in the ERP. | refused |
|
|
97
|
+
| `customer_promise_send` | Never sends new promise dates to customers. | refused |
|
|
98
|
+
|
|
99
|
+
Any tool name not in this table is blocked, including names a model invents. `refused` tools are listed so a model can see they exist and are refused.
|
|
100
|
+
|
|
101
|
+
## Columns it reads
|
|
102
|
+
|
|
103
|
+
Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL. Columns are matched by the agent's own name, then by the English names below, then by their names in German, French, Spanish, Portuguese, Italian, Japanese, Chinese and Korean. Dates become `YYYY-MM-DD`; amounts are read with either decimal mark; weights, distances and dimensions are converted when the column says it holds kilograms, kilometres or centimetres. Every result lists under `sources` how each file was read.
|
|
104
|
+
|
|
105
|
+
### Open operations (`operations`)
|
|
106
|
+
|
|
107
|
+
| Column | Type | Also read as | For example, in other languages |
|
|
108
|
+
|---|---|---|---|
|
|
109
|
+
| `work_order` (required) | text | Work Order, Job, WO, Production Order | Fertigungsauftrag, Ordre de fabrication, 製造指図, 生产工单 |
|
|
110
|
+
| `operation` | text | Operation, Oper Num, Op, Step | Arbeitsgang, Opération, 工程, 工序 |
|
|
111
|
+
| `work_center` (required) | text | Work Center, Work Centre, Resource, Machine | Arbeitsplatz, Poste de charge, 作業区, 工作中心 |
|
|
112
|
+
| `due_date` | date | Due Date, Op Due Date, Scheduled Finish, Need Date, End Date | Fälligkeitsdatum, Date d'échéance, 期日, 截止日期 |
|
|
113
|
+
| `hours_remaining` | number | Hours Remaining, Remaining Hours, Open Hours, Load Hours, Run Hours Remaining | - |
|
|
114
|
+
|
|
115
|
+
Named exports recognised by their column names:
|
|
116
|
+
|
|
117
|
+
| System | Export | Recognised by | Layout checked |
|
|
118
|
+
|---|---|---|---|
|
|
119
|
+
| Infor CloudSuite Industrial (SyteLine) | Job operations list export | Job, Oper Num, Work Center, Hours Remaining | no |
|
|
120
|
+
|
|
121
|
+
Where a layout says "checked", its column names were compared with the vendor's documentation on that date; where it says "tested", an agent was run on a real published file in that layout. The other layouts were written from knowledge of the export and were not checked. None was tested against a customer's live account.
|
|
122
|
+
|
|
123
|
+
### Work center calendar (`calendar`)
|
|
124
|
+
|
|
125
|
+
| Column | Type | Also read as | For example, in other languages |
|
|
126
|
+
|---|---|---|---|
|
|
127
|
+
| `work_center` (required) | text | Work Center, Work Centre, Resource, Machine | Arbeitsplatz, Poste de charge, 作業区, 工作中心 |
|
|
128
|
+
| `hours_per_day` | number | Hours per Day, Shift Hours, Daily Hours | - |
|
|
129
|
+
| `days_per_week` | number | Days per Week, Working Days, Days | - |
|
|
130
|
+
| `efficiency_pct` | number | Efficiency %, Efficiency, Utilization % | - |
|
|
131
|
+
|
|
132
|
+
### Files from other countries
|
|
133
|
+
|
|
134
|
+
A German export in Windows-1252 with semicolons, `1.234,56` and `03.11.2026`, or a Japanese one in Shift_JIS with `2026/11/03`, is read the same way as the English file. [`fixtures/intl/`](fixtures/intl) has both versions of the demo data, and the eval cases `intl-de-*` and `intl-ja-*` require the same results as the English case. A weight, distance or dimension column found by its translated name with no unit in it is read as metric and converted, and the result says so. Columns named differently? Run `npx fairmake-capacity-load inspect <file>` (names and shapes only, never values) and name them in `fairmake-sources.json`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{ "files": { "exports/bills.csv": { "columns": { "invoice_number": "Beleg" }, "date_order": "dmy", "units": { "weight": "kg" } } } }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Install
|
|
141
|
+
|
|
142
|
+
Node 20 or newer. No other dependencies.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npx -y fairmake-capacity-load demo
|
|
146
|
+
npx -y fairmake-capacity-load mcp --root /path/to/your/files
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Claude Desktop, Cursor and other MCP hosts:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"fairmake-capacity-load": {
|
|
155
|
+
"command": "npx",
|
|
156
|
+
"args": [
|
|
157
|
+
"-y",
|
|
158
|
+
"fairmake-capacity-load",
|
|
159
|
+
"mcp",
|
|
160
|
+
"--root",
|
|
161
|
+
"/path/to/your/files"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Claude Code: `claude mcp add fairmake-capacity-load -- npx -y fairmake-capacity-load mcp --root .`, or install the `fairmake-capacity-load` plugin from this repository's marketplace.
|
|
169
|
+
|
|
170
|
+
## Modes and approvals
|
|
171
|
+
|
|
172
|
+
- **Review** (`--mode review`): reads and reports only.
|
|
173
|
+
- **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairmake-capacity-load approve <id> --as "Your Name"` (or on the local approvals page, `fairmake-capacity-load approvals`), and the same call is repeated.
|
|
174
|
+
- **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairmake-capacity-load kill`). Paying, sending, posting to a ledger or a live system and accepting a learned fact stay **one named click even in Auto**; an approval is tied to the sha256 of the reviewed draft, so a changed draft needs a new click.
|
|
175
|
+
|
|
176
|
+
## CLI
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
fairmake-capacity-load tools # every tool, its policy and arguments
|
|
180
|
+
fairmake-capacity-load sources # the columns each input is read from
|
|
181
|
+
fairmake-capacity-load inspect <file> # how a file would be read (names and shapes, never values)
|
|
182
|
+
fairmake-capacity-load call capacity_check '{"operations":"<operations>","calendar":"<calendar>"}'
|
|
183
|
+
fairmake-capacity-load eval # the private eval cases on the fictional fixtures
|
|
184
|
+
fairmake-capacity-load demo
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Audit log and data
|
|
188
|
+
|
|
189
|
+
Every call is written to `.fairmake/audit.jsonl` under the root: hash-chained JSON lines, with arguments stored as a hash, signed with an Ed25519 key when you configure one. Everything runs on your machine on files you choose. No network calls, no telemetry, no credentials. The bundled fixtures are fictional.
|
|
190
|
+
|
|
191
|
+
<!-- generated:end -->
|
|
192
|
+
|
|
193
|
+
## Limits
|
|
194
|
+
|
|
195
|
+
- Reads only the files you give it. It does not log in to an ERP, MES, CMMS, QMS, EDI network, bank, supplier or customer portal, and changes nothing in them.
|
|
196
|
+
- Thresholds and rules are settings in your own file, with working defaults listed in the result as settings_used. They are not a costing, quality or safety standard; check them against your own policies and contracts.
|
|
197
|
+
- Not legal, tax, customs, safety or accounting advice. A person decides what to change, post, send or pay.
|
|
198
|
+
- Column names for the named exports were written from knowledge of those systems and not checked against a live account; `inspect` shows how a file was read and `fairmake-sources.json` names columns by hand.
|
|
199
|
+
- The bundled fixtures are fictional. Version 0.1.0.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { main } from 'fairmake-core';
|
|
4
|
+
import { manifest } from '../src/manifest.js';
|
|
5
|
+
import { demo } from '../src/demo.js';
|
|
6
|
+
|
|
7
|
+
main(manifest, { bin: 'fairmake-capacity-load', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairmake-capacity-load",
|
|
3
|
+
"root": "..",
|
|
4
|
+
"data_note": "Fictional operations and calendars in ../fixtures, loaded from 2026-11-16. No model is called.",
|
|
5
|
+
"cases": [
|
|
6
|
+
{
|
|
7
|
+
"id": "check-totals",
|
|
8
|
+
"tool": "capacity_check",
|
|
9
|
+
"args": {
|
|
10
|
+
"operations": "fixtures/operations.csv",
|
|
11
|
+
"calendar": "fixtures/calendar.csv",
|
|
12
|
+
"settings": "fixtures/settings.json",
|
|
13
|
+
"as_of": "2026-11-16"
|
|
14
|
+
},
|
|
15
|
+
"expect": {
|
|
16
|
+
"equals": {
|
|
17
|
+
"result.work_centers": 5,
|
|
18
|
+
"result.open_hours": 265,
|
|
19
|
+
"result.horizon": "2026-11-16 to 2026-12-27",
|
|
20
|
+
"result.flag": 1,
|
|
21
|
+
"result.review": 2,
|
|
22
|
+
"result.ok": 2
|
|
23
|
+
},
|
|
24
|
+
"length": {
|
|
25
|
+
"result.by_week": 30
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "every-planted-finding",
|
|
31
|
+
"tool": "capacity_check",
|
|
32
|
+
"args": {
|
|
33
|
+
"operations": "fixtures/operations.csv",
|
|
34
|
+
"calendar": "fixtures/calendar.csv",
|
|
35
|
+
"as_of": "2026-11-16"
|
|
36
|
+
},
|
|
37
|
+
"expect": {
|
|
38
|
+
"contains": [
|
|
39
|
+
"overloaded_week",
|
|
40
|
+
"near_capacity",
|
|
41
|
+
"past_due_load",
|
|
42
|
+
"no_calendar",
|
|
43
|
+
"2026-11-16 75/68 h (110.3%)"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "explain-cnc",
|
|
49
|
+
"tool": "capacity_explain",
|
|
50
|
+
"args": {
|
|
51
|
+
"operations": "fixtures/operations.csv",
|
|
52
|
+
"calendar": "fixtures/calendar.csv",
|
|
53
|
+
"as_of": "2026-11-16",
|
|
54
|
+
"work_center": "cnc"
|
|
55
|
+
},
|
|
56
|
+
"expect": {
|
|
57
|
+
"status": "executed",
|
|
58
|
+
"equals": {
|
|
59
|
+
"result.items.0.available_per_week": 68,
|
|
60
|
+
"result.items.0.open_hours": 167
|
|
61
|
+
},
|
|
62
|
+
"contains": [
|
|
63
|
+
"near capacity in 2026-11-30 (91.2%)"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "planned-overtime",
|
|
69
|
+
"tool": "capacity_check",
|
|
70
|
+
"args": {
|
|
71
|
+
"operations": "fixtures/operations.csv",
|
|
72
|
+
"calendar": "fixtures/calendar.csv",
|
|
73
|
+
"settings": "fixtures/settings-overtime.json",
|
|
74
|
+
"as_of": "2026-11-16"
|
|
75
|
+
},
|
|
76
|
+
"expect": {
|
|
77
|
+
"equals": {
|
|
78
|
+
"result.flag": 0,
|
|
79
|
+
"result.review": 2,
|
|
80
|
+
"result.watch": 1,
|
|
81
|
+
"result.ok": 2,
|
|
82
|
+
"result.settings_used.weeks": 4
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "infor-job-operations",
|
|
88
|
+
"tool": "capacity_check",
|
|
89
|
+
"args": {
|
|
90
|
+
"operations": "fixtures/exports/infor-job-operations.csv",
|
|
91
|
+
"calendar": "fixtures/calendar.csv",
|
|
92
|
+
"as_of": "2026-11-16"
|
|
93
|
+
},
|
|
94
|
+
"expect": {
|
|
95
|
+
"equals": {
|
|
96
|
+
"result.work_centers": 4,
|
|
97
|
+
"result.open_hours": 88,
|
|
98
|
+
"result.flag": 1,
|
|
99
|
+
"result.ok": 3
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "draft-capacity-review-after-approval",
|
|
105
|
+
"tool": "capacity_draft_capacity_review",
|
|
106
|
+
"args": {
|
|
107
|
+
"operations": "fixtures/operations.csv",
|
|
108
|
+
"calendar": "fixtures/calendar.csv",
|
|
109
|
+
"as_of": "2026-11-16",
|
|
110
|
+
"from": "Pat Planner (fictional)"
|
|
111
|
+
},
|
|
112
|
+
"approve": "Pat Example",
|
|
113
|
+
"expect": {
|
|
114
|
+
"status": "executed",
|
|
115
|
+
"equals": {
|
|
116
|
+
"result.open_markers": 1
|
|
117
|
+
},
|
|
118
|
+
"contains": [
|
|
119
|
+
"capacity review open drafted"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "missing-argument-named",
|
|
125
|
+
"tool": "capacity_check",
|
|
126
|
+
"args": {},
|
|
127
|
+
"expect": {
|
|
128
|
+
"status": "error",
|
|
129
|
+
"contains": [
|
|
130
|
+
"operations"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"generated": true
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "file-outside-root-refused",
|
|
137
|
+
"tool": "capacity_check",
|
|
138
|
+
"args": {
|
|
139
|
+
"operations": "../../../outside.csv",
|
|
140
|
+
"calendar": "fixtures/calendar.csv",
|
|
141
|
+
"settings": "fixtures/settings.json",
|
|
142
|
+
"as_of": "2026-11-16"
|
|
143
|
+
},
|
|
144
|
+
"expect": {
|
|
145
|
+
"status": "error",
|
|
146
|
+
"contains": [
|
|
147
|
+
"outside"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"generated": true
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "invented-tool-name-refused",
|
|
154
|
+
"tool": "capacity_pay_everything_now",
|
|
155
|
+
"args": {},
|
|
156
|
+
"expect": {
|
|
157
|
+
"status": "blocked"
|
|
158
|
+
},
|
|
159
|
+
"generated": true
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "review-mode-still-reads",
|
|
163
|
+
"tool": "capacity_check",
|
|
164
|
+
"mode": "review",
|
|
165
|
+
"args": {
|
|
166
|
+
"operations": "fixtures/operations.csv",
|
|
167
|
+
"calendar": "fixtures/calendar.csv",
|
|
168
|
+
"settings": "fixtures/settings.json",
|
|
169
|
+
"as_of": "2026-11-16"
|
|
170
|
+
},
|
|
171
|
+
"expect": {
|
|
172
|
+
"status": "executed",
|
|
173
|
+
"equals": {
|
|
174
|
+
"result.work_centers": 5,
|
|
175
|
+
"result.open_hours": 265,
|
|
176
|
+
"result.horizon": "2026-11-16 to 2026-12-27",
|
|
177
|
+
"result.flag": 1,
|
|
178
|
+
"result.review": 2,
|
|
179
|
+
"result.ok": 2
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"generated": true
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"id": "status-filter-keeps-totals",
|
|
186
|
+
"tool": "capacity_check",
|
|
187
|
+
"args": {
|
|
188
|
+
"operations": "fixtures/operations.csv",
|
|
189
|
+
"calendar": "fixtures/calendar.csv",
|
|
190
|
+
"settings": "fixtures/settings.json",
|
|
191
|
+
"as_of": "2026-11-16",
|
|
192
|
+
"status": "ok",
|
|
193
|
+
"limit": 1
|
|
194
|
+
},
|
|
195
|
+
"expect": {
|
|
196
|
+
"status": "executed",
|
|
197
|
+
"max": {
|
|
198
|
+
"result.items_shown": 1
|
|
199
|
+
},
|
|
200
|
+
"equals": {
|
|
201
|
+
"result.work_centers": 5,
|
|
202
|
+
"result.open_hours": 265,
|
|
203
|
+
"result.horizon": "2026-11-16 to 2026-12-27",
|
|
204
|
+
"result.flag": 1,
|
|
205
|
+
"result.review": 2,
|
|
206
|
+
"result.ok": 2
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"generated": true
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"id": "explain-unknown-item-is-a-readable-error",
|
|
213
|
+
"tool": "capacity_explain",
|
|
214
|
+
"args": {
|
|
215
|
+
"operations": "fixtures/operations.csv",
|
|
216
|
+
"calendar": "fixtures/calendar.csv",
|
|
217
|
+
"settings": "fixtures/settings.json",
|
|
218
|
+
"as_of": "2026-11-16",
|
|
219
|
+
"work_center": "No Such Thing Zz"
|
|
220
|
+
},
|
|
221
|
+
"expect": {
|
|
222
|
+
"status": "error",
|
|
223
|
+
"contains": [
|
|
224
|
+
"not found"
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
"generated": true
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"id": "report-writes-its-files",
|
|
231
|
+
"tool": "capacity_write_report",
|
|
232
|
+
"args": {
|
|
233
|
+
"operations": "fixtures/operations.csv",
|
|
234
|
+
"calendar": "fixtures/calendar.csv",
|
|
235
|
+
"settings": "fixtures/settings.json",
|
|
236
|
+
"as_of": "2026-11-16"
|
|
237
|
+
},
|
|
238
|
+
"expect": {
|
|
239
|
+
"status": "executed",
|
|
240
|
+
"min": {
|
|
241
|
+
"result.files.length": 2
|
|
242
|
+
},
|
|
243
|
+
"matches": [
|
|
244
|
+
"[0-9a-f]{64}"
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
"generated": true
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"id": "draft-waits-for-a-person",
|
|
251
|
+
"tool": "capacity_draft_capacity_review",
|
|
252
|
+
"args": {
|
|
253
|
+
"operations": "fixtures/operations.csv",
|
|
254
|
+
"calendar": "fixtures/calendar.csv",
|
|
255
|
+
"as_of": "2026-11-16",
|
|
256
|
+
"from": "Pat Planner (fictional)"
|
|
257
|
+
},
|
|
258
|
+
"expect": {
|
|
259
|
+
"status": "needs_approval",
|
|
260
|
+
"decision": "ask"
|
|
261
|
+
},
|
|
262
|
+
"generated": true
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"id": "review-mode-drafts-nothing",
|
|
266
|
+
"tool": "capacity_draft_capacity_review",
|
|
267
|
+
"mode": "review",
|
|
268
|
+
"args": {
|
|
269
|
+
"operations": "fixtures/operations.csv",
|
|
270
|
+
"calendar": "fixtures/calendar.csv",
|
|
271
|
+
"as_of": "2026-11-16",
|
|
272
|
+
"from": "Pat Planner (fictional)"
|
|
273
|
+
},
|
|
274
|
+
"expect": {
|
|
275
|
+
"status": "blocked"
|
|
276
|
+
},
|
|
277
|
+
"generated": true
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"id": "request-stays-one-click-in-auto",
|
|
281
|
+
"tool": "capacity_request_send",
|
|
282
|
+
"mode": "auto",
|
|
283
|
+
"auto_actions": [
|
|
284
|
+
"capacity_draft_capacity_review"
|
|
285
|
+
],
|
|
286
|
+
"args": {
|
|
287
|
+
"draft": "fairmake-out/capacity/drafts/none.md",
|
|
288
|
+
"draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
|
|
289
|
+
},
|
|
290
|
+
"expect": {
|
|
291
|
+
"status": "needs_approval",
|
|
292
|
+
"decision": "ask"
|
|
293
|
+
},
|
|
294
|
+
"generated": true
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"id": "refuses-erp-reschedule-orders",
|
|
298
|
+
"tool": "erp_reschedule_orders",
|
|
299
|
+
"mode": "auto",
|
|
300
|
+
"args": {},
|
|
301
|
+
"expect": {
|
|
302
|
+
"status": "blocked"
|
|
303
|
+
},
|
|
304
|
+
"generated": true
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"id": "refuses-customer-promise-send",
|
|
308
|
+
"tool": "customer_promise_send",
|
|
309
|
+
"mode": "auto",
|
|
310
|
+
"args": {},
|
|
311
|
+
"expect": {
|
|
312
|
+
"status": "blocked"
|
|
313
|
+
},
|
|
314
|
+
"generated": true
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"id": "intl-de-check-totals",
|
|
318
|
+
"tool": "capacity_check",
|
|
319
|
+
"args": {
|
|
320
|
+
"operations": "fixtures/intl/de/operations.csv",
|
|
321
|
+
"calendar": "fixtures/intl/de/calendar.csv",
|
|
322
|
+
"settings": "fixtures/settings.json",
|
|
323
|
+
"as_of": "2026-11-16"
|
|
324
|
+
},
|
|
325
|
+
"expect": {
|
|
326
|
+
"equals": {
|
|
327
|
+
"result.work_centers": 5,
|
|
328
|
+
"result.open_hours": 265,
|
|
329
|
+
"result.horizon": "2026-11-16 to 2026-12-27",
|
|
330
|
+
"result.flag": 1,
|
|
331
|
+
"result.review": 2,
|
|
332
|
+
"result.ok": 2
|
|
333
|
+
},
|
|
334
|
+
"length": {
|
|
335
|
+
"result.by_week": 30
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"note": "German export of the same data (fixtures/intl/de); must match the English case \"check-totals\"."
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"id": "intl-ja-check-totals",
|
|
342
|
+
"tool": "capacity_check",
|
|
343
|
+
"args": {
|
|
344
|
+
"operations": "fixtures/intl/ja/operations.csv",
|
|
345
|
+
"calendar": "fixtures/intl/ja/calendar.csv",
|
|
346
|
+
"settings": "fixtures/settings.json",
|
|
347
|
+
"as_of": "2026-11-16"
|
|
348
|
+
},
|
|
349
|
+
"expect": {
|
|
350
|
+
"equals": {
|
|
351
|
+
"result.work_centers": 5,
|
|
352
|
+
"result.open_hours": 265,
|
|
353
|
+
"result.horizon": "2026-11-16 to 2026-12-27",
|
|
354
|
+
"result.flag": 1,
|
|
355
|
+
"result.review": 2,
|
|
356
|
+
"result.ok": 2
|
|
357
|
+
},
|
|
358
|
+
"length": {
|
|
359
|
+
"result.by_week": 30
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"note": "Japanese export of the same data (fixtures/intl/ja); must match the English case \"check-totals\"."
|
|
363
|
+
}
|
|
364
|
+
]
|
|
365
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Fairmake Capacity Load fixtures
|
|
2
|
+
|
|
3
|
+
Fictional open operations and work center calendars, loaded from 2026-11-16.
|
|
4
|
+
|
|
5
|
+
- `operations.csv`, `calendar.csv`: CNC overloaded in its first week and near capacity in the third; WELD with a past-due operation; PAINT and ASSY with room (one ASSY operation is beyond the horizon); SAW with no calendar.
|
|
6
|
+
- `settings.json`, `settings-overtime.json`: default limits, and a shop that plans overtime.
|
|
7
|
+
- `exports/infor-job-operations.csv`: Infor CloudSuite Industrial style job operations. Written from knowledge of the export, not checked against a live system.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Clean set
|
|
2
|
+
|
|
3
|
+
The demo files with every planted problem in [../README.md](../README.md) removed and nothing else changed, made by `scripts/accuracy.mjs` from `scripts/accuracy-specs.mjs` in the repository. The check must report no findings on these files (settings and other JSON inputs: `../settings.json`). Fictional data.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
work_order,operation,work_center,due_date,hours_remaining
|
|
2
|
+
WO-1,10,CNC,2026-11-18,40
|
|
3
|
+
WO-2,20,CNC,2026-11-19,20
|
|
4
|
+
WO-3,10,CNC,2026-11-25,30
|
|
5
|
+
WO-4,10,CNC,2026-12-02,50
|
|
6
|
+
WO-1,20,WELD,2026-11-20,12
|
|
7
|
+
WO-5,10,WELD,2026-11-20,20
|
|
8
|
+
WO-2,30,PAINT,2026-11-27,20
|
|
9
|
+
WO-6,10,ASSY,2026-12-16,30
|
|
10
|
+
WO-7,10,ASSY,2027-01-20,10
|
|
11
|
+
WO-8,10,SAW,2026-11-20,6
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Fixtures from other countries
|
|
2
|
+
|
|
3
|
+
Generated by `node scripts/make-intl-fixtures.mjs` from the English fixtures one
|
|
4
|
+
folder up. The same fictional data, written the way a local export writes it:
|
|
5
|
+
|
|
6
|
+
- `de/`: German column names, Windows-1252 text, semicolons, comma decimals
|
|
7
|
+
(1.234,56), day-first dotted dates (03.11.2026), kilograms and kilometres.
|
|
8
|
+
- `ja/`: Japanese column names, Shift_JIS text, year-first dates (2026/11/03),
|
|
9
|
+
kilograms and kilometres.
|
|
10
|
+
|
|
11
|
+
Values (names, codes, charge wording) stay in English. The eval cases
|
|
12
|
+
`intl-de-*` and `intl-ja-*` expect exactly the same results as the English case.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Fertigungsauftrag;Arbeitsgang;Arbeitsplatz;F�lligkeitsdatum;hours_remaining
|
|
2
|
+
WO-1;10;CNC;18.11.2026;40
|
|
3
|
+
WO-2;20;CNC;19.11.2026;35
|
|
4
|
+
WO-3;10;CNC;25.11.2026;30
|
|
5
|
+
WO-4;10;CNC;02.12.2026;62
|
|
6
|
+
WO-1;20;WELD;10.11.2026;12
|
|
7
|
+
WO-5;10;WELD;20.11.2026;20
|
|
8
|
+
WO-2;30;PAINT;27.11.2026;20
|
|
9
|
+
WO-6;10;ASSY;16.12.2026;30
|
|
10
|
+
WO-7;10;ASSY;20.01.2027;10
|
|
11
|
+
WO-8;10;SAW;20.11.2026;6
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
�����w�},�H��,��Ƌ�,����,hours_remaining
|
|
2
|
+
WO-1,10,CNC,2026/11/18,40
|
|
3
|
+
WO-2,20,CNC,2026/11/19,35
|
|
4
|
+
WO-3,10,CNC,2026/11/25,30
|
|
5
|
+
WO-4,10,CNC,2026/12/02,62
|
|
6
|
+
WO-1,20,WELD,2026/11/10,12
|
|
7
|
+
WO-5,10,WELD,2026/11/20,20
|
|
8
|
+
WO-2,30,PAINT,2026/11/27,20
|
|
9
|
+
WO-6,10,ASSY,2026/12/16,30
|
|
10
|
+
WO-7,10,ASSY,2027/01/20,10
|
|
11
|
+
WO-8,10,SAW,2026/11/20,6
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
work_order,operation,work_center,due_date,hours_remaining
|
|
2
|
+
WO-1,10,CNC,2026-11-18,40
|
|
3
|
+
WO-2,20,CNC,2026-11-19,35
|
|
4
|
+
WO-3,10,CNC,2026-11-25,30
|
|
5
|
+
WO-4,10,CNC,2026-12-02,62
|
|
6
|
+
WO-1,20,WELD,2026-11-10,12
|
|
7
|
+
WO-5,10,WELD,2026-11-20,20
|
|
8
|
+
WO-2,30,PAINT,2026-11-27,20
|
|
9
|
+
WO-6,10,ASSY,2026-12-16,30
|
|
10
|
+
WO-7,10,ASSY,2027-01-20,10
|
|
11
|
+
WO-8,10,SAW,2026-11-20,6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "note": "Saturday overtime on CNC is planned: allow 120 percent.", "weeks": 4, "overload_pct": 120, "watch_pct": 100 }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "note": "Fictional planning settings.", "weeks": 6, "overload_pct": 100, "watch_pct": 90 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairmake-capacity-load",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairmake-capacity-load",
|
|
5
|
+
"description": "Fairmake Capacity Load: open operation hours by work center and week against available hours, overloaded weeks, past-due load and work centers with no calendar. Reschedules nothing.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Kurt Francisco",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
12
|
+
"main": "src/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./src/index.js",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"fairmake-capacity-load": "bin/fairmake-capacity-load.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"bin",
|
|
23
|
+
"fixtures",
|
|
24
|
+
"evals",
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"server.json"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "node scripts/run-tests.cjs",
|
|
32
|
+
"demo": "node bin/fairmake-capacity-load.js demo",
|
|
33
|
+
"eval": "node bin/fairmake-capacity-load.js eval"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"fairmake-core": "^0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/fpavia111-creator/fairmake-agents.git",
|
|
41
|
+
"directory": "packages/fairmake-capacity-load"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairmake-agents/tree/master/packages/fairmake-capacity-load#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/fpavia111-creator/fairmake-agents/issues"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mcp",
|
|
49
|
+
"mcp-server",
|
|
50
|
+
"manufacturing",
|
|
51
|
+
"distribution",
|
|
52
|
+
"erp",
|
|
53
|
+
"fairmake",
|
|
54
|
+
"capacity",
|
|
55
|
+
"load",
|
|
56
|
+
"scheduling",
|
|
57
|
+
"work-center",
|
|
58
|
+
"infor"
|
|
59
|
+
]
|
|
60
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.fpavia111-creator/fairmake-capacity-load",
|
|
4
|
+
"title": "Fairmake Capacity Load",
|
|
5
|
+
"description": "Fairmake Capacity Load: open operation hours by work center and week against available hours…",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairmake-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairmake-capacity-load"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairmake.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairmake-capacity-load",
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"transport": {
|
|
19
|
+
"type": "stdio"
|
|
20
|
+
},
|
|
21
|
+
"packageArguments": [
|
|
22
|
+
{
|
|
23
|
+
"type": "positional",
|
|
24
|
+
"value": "mcp"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "named",
|
|
28
|
+
"name": "--root",
|
|
29
|
+
"description": "Folder holding the exports this agent may read and write (it cannot reach outside it)",
|
|
30
|
+
"isRequired": true,
|
|
31
|
+
"format": "filepath",
|
|
32
|
+
"valueHint": "exports_folder"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
package/src/capacity.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Capacity load against available hours: open operation hours by work center and week, against each work center's calendar.
|
|
2
|
+
import { exportProfile, finding, statusOf, tallyFindings, countBy, round2, pct, str, itemKey, groupBy, weekStart, addDays, asOfDate } from 'fairmake-core';
|
|
3
|
+
|
|
4
|
+
const t = (aliases, extra = {}) => ({ aliases, ...extra });
|
|
5
|
+
export const OP_FIELDS = Object.freeze({
|
|
6
|
+
work_order: t(['Work Order', 'Job', 'WO', 'Production Order'], { required: true }),
|
|
7
|
+
operation: t(['Operation', 'Oper Num', 'Op', 'Step']),
|
|
8
|
+
work_center: t(['Work Center', 'Work Centre', 'Resource', 'Machine'], { required: true }),
|
|
9
|
+
due_date: t(['Due Date', 'Op Due Date', 'Scheduled Finish', 'Need Date', 'End Date'], { type: 'date' }),
|
|
10
|
+
hours_remaining: t(['Hours Remaining', 'Remaining Hours', 'Open Hours', 'Load Hours', 'Run Hours Remaining'], { type: 'number' }),
|
|
11
|
+
});
|
|
12
|
+
export const CAL_FIELDS = Object.freeze({
|
|
13
|
+
work_center: t(['Work Center', 'Work Centre', 'Resource', 'Machine'], { required: true }),
|
|
14
|
+
hours_per_day: t(['Hours per Day', 'Shift Hours', 'Daily Hours'], { type: 'number' }),
|
|
15
|
+
days_per_week: t(['Days per Week', 'Working Days', 'Days'], { type: 'number' }),
|
|
16
|
+
efficiency_pct: t(['Efficiency %', 'Efficiency', 'Utilization %'], { type: 'number' }),
|
|
17
|
+
});
|
|
18
|
+
/** Infor CloudSuite Industrial job operations. Written from knowledge of the export; not checked against a live system. */
|
|
19
|
+
export const OP_PROFILES = Object.freeze([
|
|
20
|
+
exportProfile('infor_csi_job_operations', { work_order: 'Job', operation: 'Oper Num', work_center: 'Work Center', due_date: 'Op Due Date', hours_remaining: 'Hours Remaining' }, { note: 'Infor CloudSuite Industrial job operations: remaining hours per operation.' }),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
export const DEFAULTS = Object.freeze({ weeks: 6, overload_pct: 100, watch_pct: 90 });
|
|
24
|
+
export const SETTINGS_SCHEMA = Object.freeze({
|
|
25
|
+
type: 'object', additionalProperties: false,
|
|
26
|
+
properties: {
|
|
27
|
+
note: { type: 'string', description: 'Free text for your own records' },
|
|
28
|
+
weeks: { type: 'integer', minimum: 1, maximum: 52, description: 'Weeks ahead to load, starting with the week of as_of' },
|
|
29
|
+
overload_pct: { type: 'number', minimum: 1, maximum: 1000, description: 'A week loaded above this percentage of available hours is overloaded' },
|
|
30
|
+
watch_pct: { type: 'number', minimum: 1, maximum: 1000, description: 'A week above this percentage is listed to watch' },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/** Load by work center and week. Finding codes: overloaded_week, near_capacity, past_due_load, no_calendar. */
|
|
35
|
+
export function capacityLoad({ operations, calendar }, s = DEFAULTS, asOf) {
|
|
36
|
+
const today = asOfDate(asOf); const first = weekStart(today);
|
|
37
|
+
const weeks = Array.from({ length: s.weeks }, (_, i) => addDays(first, i * 7)); const last = addDays(first, s.weeks * 7 - 1);
|
|
38
|
+
const CAL = new Map(calendar.filter((c) => str(c.work_center)).map((c) => [itemKey(c.work_center), c]));
|
|
39
|
+
const O = groupBy(operations.filter((o) => str(o.work_center) && str(o.work_order)), (o) => itemKey(o.work_center));
|
|
40
|
+
const grid = [];
|
|
41
|
+
const items = [...new Set([...O.keys(), ...CAL.keys()])].sort().map((k) => {
|
|
42
|
+
const ops = O.get(k) || []; const cal = CAL.get(k); const name = str((ops[0] || cal).work_center);
|
|
43
|
+
const avail = cal ? round2((Number(cal.hours_per_day) || 0) * (Number(cal.days_per_week) || 0) * ((cal.efficiency_pct ?? 100) / 100)) : null;
|
|
44
|
+
const pastDue = ops.filter((o) => o.due_date && o.due_date < first); const pastHrs = round2(pastDue.reduce((x, o) => x + (Number(o.hours_remaining) || 0), 0));
|
|
45
|
+
const load = new Map(weeks.map((w) => [w, 0]));
|
|
46
|
+
for (const o of ops) { const w = !o.due_date || o.due_date < first ? first : weekStart(o.due_date); if (load.has(w)) load.set(w, load.get(w) + (Number(o.hours_remaining) || 0)); }
|
|
47
|
+
const rows = weeks.map((w) => ({ work_center: name, week: w, load: round2(load.get(w)), available: avail, load_pct: avail ? pct(load.get(w), avail) : null }));
|
|
48
|
+
grid.push(...rows);
|
|
49
|
+
const f = [];
|
|
50
|
+
if (!cal || !avail) f.push(finding('no_calendar', null, `${name} has ${round2(ops.reduce((x, o) => x + (Number(o.hours_remaining) || 0), 0))} open hours and no working calendar, so its load cannot be compared.`, 'review'));
|
|
51
|
+
const over = rows.filter((r) => r.load_pct !== null && r.load_pct > s.overload_pct); const near = rows.filter((r) => r.load_pct !== null && r.load_pct > s.watch_pct && r.load_pct <= s.overload_pct);
|
|
52
|
+
if (over.length) f.push(finding('overloaded_week', null, `${name} is loaded past ${s.overload_pct}% in ${over.length} week(s): ${over.map((r) => `${r.week} ${r.load}/${r.available} h (${r.load_pct}%)`).join(', ')}.`));
|
|
53
|
+
if (near.length) f.push(finding('near_capacity', null, `${name} is near capacity in ${near.map((r) => `${r.week} (${r.load_pct}%)`).join(', ')}.`, 'watch'));
|
|
54
|
+
if (pastDue.length) f.push(finding('past_due_load', null, `${pastDue.length} operation(s) on ${name} were due before this week (${pastHrs} h); they are loaded into the week of ${first}.`, 'review'));
|
|
55
|
+
const beyond = round2(ops.filter((o) => o.due_date && o.due_date > last).reduce((x, o) => x + (Number(o.hours_remaining) || 0), 0));
|
|
56
|
+
return { work_center: name, available_per_week: avail, open_hours: round2(ops.reduce((x, o) => x + (Number(o.hours_remaining) || 0), 0)), past_due_hours: pastHrs, beyond_horizon_hours: beyond, peak_load_pct: rows.reduce((m, r) => (r.load_pct !== null && (m === null || r.load_pct > m) ? r.load_pct : m), null), status: statusOf(f), findings: f };
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
as_of: today, horizon: `${first} to ${last}`, work_centers: items.length, operations: operations.length, open_hours: round2(items.reduce((x, i) => x + i.open_hours, 0)),
|
|
60
|
+
flag: items.filter((i) => i.status === 'flag').length, review: items.filter((i) => i.status === 'review').length, watch: items.filter((i) => i.status === 'watch').length, ok: items.filter((i) => i.status === 'ok').length,
|
|
61
|
+
by_week: grid, by_finding: tallyFindings(items), by_status: countBy(items), items,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function capacityReviewText(r, { from } = {}) {
|
|
66
|
+
const rows = r.items.filter((i) => i.status !== 'ok');
|
|
67
|
+
return ['# Capacity to review', '', '**To:** [TO CONFIRM production planner]', `**From:** ${from || '[TO CONFIRM your name]'}`, '',
|
|
68
|
+
`Load for ${r.horizon} against each work center's calendar. For the work centers below, please decide: overtime, another shift, outside processing, or new promise dates. Customer dates are not changed by this note.`, '',
|
|
69
|
+
'| Work center | Available per week | Open hours | Peak load % | Detail |', '| --- | --- | --- | --- | --- |',
|
|
70
|
+
...rows.map((i) => `| ${i.work_center} | ${i.available_per_week ?? ''} | ${i.open_hours} | ${i.peak_load_pct ?? ''} | ${i.findings.map((f) => f.detail).join(' ')} |`)].join('\n');
|
|
71
|
+
}
|
package/src/demo.js
ADDED
package/src/index.js
ADDED
package/src/manifest.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { defineFairmakeAgent, findingRows } from 'fairmake-core';
|
|
3
|
+
import { OP_FIELDS, CAL_FIELDS, OP_PROFILES, DEFAULTS, SETTINGS_SCHEMA, capacityLoad, capacityReviewText } from './capacity.js';
|
|
4
|
+
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
6
|
+
const args = {
|
|
7
|
+
operations: { type: 'string', description: 'Open work order operations under --root: work order, operation, work center, due date and hours remaining' },
|
|
8
|
+
calendar: { type: 'string', description: 'Work center calendar under --root: hours per day, days per week and efficiency %' },
|
|
9
|
+
as_of: { type: 'string', format: 'date', description: 'Start of the horizon, YYYY-MM-DD (default today); loading starts on the Monday of that week' },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const manifest = defineFairmakeAgent({
|
|
13
|
+
name: pkg.name, version: pkg.version, prefix: 'capacity',
|
|
14
|
+
description: 'Loads open operation hours by work center and week (by due date) against each work center\'s available hours: flags overloaded weeks, lists weeks near capacity, reviews past-due load and work centers with no calendar, and drafts a capacity review for the planner. Reschedules nothing and changes no promise date.',
|
|
15
|
+
args, required: ['operations', 'calendar'],
|
|
16
|
+
sources: { operations: { label: 'Open operations', args: ['operations'], fields: OP_FIELDS, profiles: OP_PROFILES }, calendar: { label: 'Work center calendar', args: ['calendar'], fields: CAL_FIELDS } },
|
|
17
|
+
settings: { schema: SETTINGS_SCHEMA, defaults: DEFAULTS },
|
|
18
|
+
run: ({ a, read, s }) => capacityLoad({ operations: read('operations'), calendar: read('calendar') }, s, a.as_of),
|
|
19
|
+
line: (r) => `${r.work_centers} work center(s), ${r.open_hours} open hours, ${r.horizon}: ${r.flag} overloaded, ${r.review} to review, ${r.watch} near capacity, ${r.ok} with room.`,
|
|
20
|
+
item: { key: 'work_center', arg: 'work_center', label: 'work center' },
|
|
21
|
+
check: { title: 'Check capacity load', description: 'Put each open operation\'s remaining hours in the week of its due date (past-due ones in the first week) and compare each week with the work center\'s available hours (hours per day times days per week times efficiency). Flags overloaded weeks, lists weeks near capacity, reviews past-due load and work centers with no calendar.' },
|
|
22
|
+
report: {
|
|
23
|
+
base: 'capacity-load', title: 'Capacity load against available hours',
|
|
24
|
+
rows: (r) => r.items.map((i) => ({ work_center: i.work_center, available_per_week: i.available_per_week, open_hours: i.open_hours, past_due_hours: i.past_due_hours, beyond_horizon_hours: i.beyond_horizon_hours, peak_load_pct: i.peak_load_pct, status: i.status, findings: i.findings.map((f) => f.code).join(' '), reasons: i.findings.map((f) => f.detail).join(' ') })),
|
|
25
|
+
htmlColumns: ['work_center', 'available_per_week', 'open_hours', 'past_due_hours', 'peak_load_pct', 'status', 'reasons'],
|
|
26
|
+
sections: (r) => [{ title: 'By week', rows: r.by_week, columns: ['work_center', 'week', 'load', 'available', 'load_pct'] }, { title: 'By finding', rows: findingRows(r.by_finding), columns: ['code', 'count'] }],
|
|
27
|
+
limits: ['Load is placed by due date only (infinite loading, no sequencing or setup grouping); holidays are not in the calendar file.'],
|
|
28
|
+
},
|
|
29
|
+
draft: {
|
|
30
|
+
noun: 'capacity_review', verb: 'send', category: 'binding_send', actor: 'the operations manager',
|
|
31
|
+
description: 'Write drafts/capacity_review-open.md: the overloaded and near-capacity work centers with their weeks, for the production planner to decide on overtime, shifts or new dates. Marked DRAFT. Sending goes through capacity_request_send (one click).',
|
|
32
|
+
args: { from: { type: 'string', description: 'Your name' } },
|
|
33
|
+
build: (r, a) => { if (r.flag + r.review + r.watch === 0) throw new Error('every work center has room in the horizon'); return { id: 'open', text: capacityReviewText(r, a) }; },
|
|
34
|
+
},
|
|
35
|
+
refused: [
|
|
36
|
+
{ name: 'erp_reschedule_orders', category: 'production_deploy', description: 'Never reschedules work orders or operations in the ERP.' },
|
|
37
|
+
{ name: 'customer_promise_send', category: 'binding_send', description: 'Never sends new promise dates to customers.' },
|
|
38
|
+
],
|
|
39
|
+
prompt: { name: 'capacity_review', title: 'Review capacity load', text: 'You are helping a production planner with fairmake-capacity-load. Call capacity_check with open operations and the work center calendar, as_of the planning date. Lead with overloaded weeks by work center, then past-due load. Offer capacity_write_report and capacity_draft_capacity_review. Rescheduling and customer dates are a person\'s decision.' },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const DEMO = {
|
|
43
|
+
intro: 'Fairmake Capacity Load demo: fictional open operations on five work centers, six weeks from 2026-11-16.',
|
|
44
|
+
files: { operations: 'operations.csv', calendar: 'calendar.csv', settings: 'settings.json', as_of: '2026-11-16' },
|
|
45
|
+
explain: { work_center: 'CNC' },
|
|
46
|
+
draft: { from: 'Pat Planner (fictional)' },
|
|
47
|
+
};
|