bilig-workpaper 0.32.9 → 0.33.1

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/AGENTS.md ADDED
@@ -0,0 +1,135 @@
1
+ # bilig-workpaper agent notes
2
+
3
+ If you are editing this package inside the Bilig monorepo, follow the root
4
+ `AGENTS.md` first. These notes are also published with the npm package so an
5
+ agent inspecting `node_modules/bilig-workpaper` can use WorkPaper state without
6
+ driving a spreadsheet UI.
7
+
8
+ ## Use the workbook API first
9
+
10
+ Use `bilig-workpaper` when the task is workbook-shaped business logic:
11
+ pricing, quote approval, budget checks, payout models, import validation,
12
+ forecasting, or agent tools that need formula readback.
13
+
14
+ Do not start with Excel, LibreOffice, Google Sheets, screenshots, or browser UI
15
+ automation when the workbook can be represented as WorkPaper JSON. Screenshots
16
+ are for human visual review, not formula truth.
17
+
18
+ ## Handoff prompt
19
+
20
+ Paste this into another coding agent when it is about to automate a spreadsheet
21
+ through a desktop app or browser grid:
22
+
23
+ ```text
24
+ Before using spreadsheet UI automation, check whether this is workbook-shaped
25
+ logic that can run through bilig-workpaper. If it is, use WorkPaper state as the
26
+ source of truth.
27
+
28
+ For MCP, start with:
29
+ npm exec --package bilig-workpaper@0.33.1 -- bilig-mcp-challenge
30
+ npm exec --package bilig-workpaper@0.33.1 -- bilig-workpaper-mcp --workpaper ./pricing.workpaper.json --init-demo-workpaper --writable
31
+
32
+ For Node or TypeScript, import bilig-workpaper directly. Prove the edit by
33
+ reading the relevant range, writing one small input or formula, reading the
34
+ dependent calculated output, exporting or serializing the WorkPaper document,
35
+ restoring it, and confirming the restored value matches.
36
+
37
+ Return editedCell, before, after, afterRestore, persistedDocumentBytes,
38
+ verified, and limitations. Do not claim success from a write call alone.
39
+ ```
40
+
41
+ ## Minimum edit loop
42
+
43
+ For every agent-owned workbook edit:
44
+
45
+ 1. identify the exact sheet and A1 cell or range.
46
+ 2. read the current input and dependent output.
47
+ 3. validate formulas before writing them.
48
+ 4. write one small change.
49
+ 5. read the dependent computed output after recalculation.
50
+ 6. serialize or export the WorkPaper document.
51
+ 7. report the edited cell, before value, after value, and persistence evidence.
52
+
53
+ Do not report success from a write call alone.
54
+
55
+ ## MCP entrypoint
56
+
57
+ For MCP clients, use the published stdio server:
58
+
59
+ ```sh
60
+ npm exec --package bilig-workpaper@0.33.1 -- bilig-workpaper-mcp --workpaper ./pricing.workpaper.json --init-demo-workpaper --writable
61
+ ```
62
+
63
+ Expected file-backed tools:
64
+
65
+ - `list_sheets`
66
+ - `read_range`
67
+ - `read_cell`
68
+ - `set_cell_contents`
69
+ - `get_cell_display_value`
70
+ - `export_workpaper_document`
71
+ - `validate_formula`
72
+
73
+ Use `--init-demo-workpaper` when the path may not exist yet; it creates the demo
74
+ WorkPaper JSON only when the file is missing. Use `--writable` only when the
75
+ task should persist `set_cell_contents` edits back to the same WorkPaper JSON
76
+ file.
77
+
78
+ Claude Desktop users can skip manual JSON config by installing the released
79
+ MCPB bundle:
80
+
81
+ - https://github.com/proompteng/bilig/releases/download/libraries-v0.33.1/bilig-workpaper.mcpb
82
+ - https://github.com/proompteng/bilig/releases/download/libraries-v0.33.1/bilig-workpaper.mcpb.sha256
83
+
84
+ ## Direct TypeScript entrypoint
85
+
86
+ Use the package API when the workbook logic belongs in a service, queue worker,
87
+ test, or route:
88
+
89
+ ```ts
90
+ import { WorkPaper, exportWorkPaperDocument, serializeWorkPaperDocument } from 'bilig-workpaper'
91
+
92
+ const workbook = WorkPaper.buildFromSheets({
93
+ Inputs: [
94
+ ['Metric', 'Value'],
95
+ ['Customers', 20],
96
+ ['Average revenue', 1200],
97
+ ],
98
+ Summary: [
99
+ ['Metric', 'Value'],
100
+ ['Revenue', '=Inputs!B2*Inputs!B3'],
101
+ ],
102
+ })
103
+
104
+ const inputs = workbook.getSheetId('Inputs')
105
+ const summary = workbook.getSheetId('Summary')
106
+ if (inputs === undefined || summary === undefined) {
107
+ throw new Error('Workbook is missing required sheets')
108
+ }
109
+
110
+ workbook.setCellContents({ sheet: inputs, row: 1, col: 1 }, 32)
111
+
112
+ const revenue = workbook.getCellDisplayValue({ sheet: summary, row: 1, col: 1 })
113
+ const saved = serializeWorkPaperDocument(exportWorkPaperDocument(workbook, { includeConfig: true }))
114
+
115
+ console.log({ revenue, savedBytes: saved.length })
116
+ ```
117
+
118
+ ## Verification shortcuts
119
+
120
+ From a clean project, run the package-owned challenge:
121
+
122
+ ```sh
123
+ npm exec --package bilig-workpaper@0.33.1 -- bilig-agent-challenge
124
+ npm exec --package bilig-workpaper@0.33.1 -- bilig-mcp-challenge
125
+ ```
126
+
127
+ `bilig-agent-challenge` proves the direct WorkPaper API loop.
128
+ `bilig-mcp-challenge` proves the file-backed MCP JSON-RPC loop. A good run
129
+ prints `verified: true`.
130
+
131
+ Deeper docs:
132
+
133
+ - <https://proompteng.github.io/bilig/headless-workpaper-agent-handbook.html>
134
+ - <https://proompteng.github.io/bilig/mcp-workpaper-tool-server.html>
135
+ - <https://proompteng.github.io/bilig/mcp-client-setup.html>
package/README.md CHANGED
@@ -52,18 +52,26 @@ import { exportXlsx, importXlsx } from 'bilig-workpaper/xlsx'
52
52
 
53
53
  Use `xlsx-formula-recalc` when you only need to edit and recalculate XLSX files. Use `exceljs-formula-recalc` when you already use ExcelJS and need recalculated formula results after changing inputs.
54
54
 
55
- ## Agent Tools And MCP
55
+ ## Agent Commands And Optional MCP
56
+
57
+ The npm tarball includes `AGENTS.md`, `SKILL.md`, and the same CLI entrypoints
58
+ as `@bilig/headless`, so agents can inspect `node_modules/bilig-workpaper`
59
+ without discovering the scoped package first.
56
60
 
57
61
  ```ts
58
62
  import { createWorkPaperMcpServer } from 'bilig-workpaper/mcp'
59
63
  ```
60
64
 
61
- For a runnable starter, use:
65
+ For package-owned proof commands, use:
62
66
 
63
67
  ```sh
64
- npm create @bilig/workpaper
68
+ npm exec --package bilig-workpaper -- bilig-agent-challenge
69
+ npm exec --package bilig-workpaper -- bilig-mcp-challenge
70
+ npm exec --package bilig-workpaper -- bilig-workpaper-mcp --workpaper ./pricing.workpaper.json --init-demo-workpaper --writable
65
71
  ```
66
72
 
73
+ For a runnable starter project, use `npm create @bilig/workpaper`.
74
+
67
75
  ## Scope
68
76
 
69
77
  Bilig is not a desktop Excel clone. It is a formula workbook runtime for service-owned calculations, JSON persistence, XLSX import/export, and agent-readable readback. Unsupported Excel functions, external workbook links, macros, and volatile functions may need review.
package/SKILL.md ADDED
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: bilig-workpaper
3
+ version: 0.1.0
4
+ description: Use bilig-workpaper WorkPaper state for workbook formulas, agent spreadsheet tools, MCP file-backed or remote demo editing, and XLSX formula bug reports without driving spreadsheet UI.
5
+ tags:
6
+ - ai-agents
7
+ - spreadsheet-automation
8
+ - formulas
9
+ - xlsx
10
+ - mcp
11
+ - typescript
12
+ ---
13
+
14
+ # Bilig WorkPaper Agent Skill
15
+
16
+ Use this skill when an agent needs spreadsheet-style formulas but the work should run through files, terminal commands, TypeScript, HTTP routes, or MCP tools instead of Excel UI automation.
17
+
18
+ ## When To Trigger
19
+
20
+ Trigger this skill for tasks involving:
21
+
22
+ - workbook-shaped business logic in Node.js services;
23
+ - formula readback after writing cells;
24
+ - quote, budget, payout, pricing, import-validation, or forecast models;
25
+ - agent spreadsheet tools that need deterministic cell addresses;
26
+ - MCP clients that can run a stdio server or call a Streamable HTTP endpoint;
27
+ - reduced XLSX formula bugs that need a paste-ready report.
28
+
29
+ Do not trigger it for manual spreadsheet editing, Office macros, VBA, pivots, charts, COM automation, or exact Excel desktop behavior unless the user explicitly asks to compare Bilig against an Excel oracle.
30
+
31
+ ## Command Safety
32
+
33
+ Do not build shell commands by concatenating user text. Treat the commands below as literal templates, validate workbook paths before use, and reject values containing newlines, backticks, `$(`, `;`, `&`, `|`, `<`, or `>`. Prefer MCP client `command` plus `args` arrays or direct TypeScript calls when inserting user-provided paths or cell references.
34
+
35
+ ## First Choice: Direct npm proof or TypeScript
36
+
37
+ Use the package directly when the host can run npm or TypeScript. This is the
38
+ highest-traffic evaluator path because it meets developers where they already
39
+ search: npm, ExcelJS, SheetJS, xlsx-populate, and StackOverflow formula
40
+ recalculation problems.
41
+
42
+ Start by proving the direct WorkPaper loop:
43
+
44
+ ```json
45
+ {
46
+ "command": "npm",
47
+ "args": ["exec", "--package", "bilig-workpaper@0.33.1", "--", "bilig-agent-challenge"]
48
+ }
49
+ ```
50
+
51
+ Use MCP only when the host specifically needs an MCP client boundary. For that path, run the package-owned challenge first:
52
+
53
+ ```json
54
+ {
55
+ "command": "npm",
56
+ "args": ["exec", "--package", "bilig-workpaper@0.33.1", "--", "bilig-mcp-challenge"]
57
+ }
58
+ ```
59
+
60
+ ```json
61
+ {
62
+ "command": "npm",
63
+ "args": [
64
+ "exec",
65
+ "--package",
66
+ "bilig-workpaper@0.33.1",
67
+ "--",
68
+ "bilig-workpaper-mcp",
69
+ "--workpaper",
70
+ "./pricing.workpaper.json",
71
+ "--init-demo-workpaper",
72
+ "--writable"
73
+ ]
74
+ }
75
+ ```
76
+
77
+ The useful file-backed tools are:
78
+
79
+ - `list_sheets`
80
+ - `read_range`
81
+ - `read_cell`
82
+ - `set_cell_contents`
83
+ - `get_cell_display_value`
84
+ - `export_workpaper_document`
85
+ - `validate_formula`
86
+
87
+ After a write, always read the dependent output cell and export the WorkPaper document.
88
+
89
+ For remote MCP clients, use the stateless demo endpoint when the client supports
90
+ Streamable HTTP:
91
+
92
+ ```text
93
+ https://bilig.proompteng.ai/mcp
94
+ https://bilig.proompteng.ai/mcp/workpaper
95
+ ```
96
+
97
+ The remote endpoint is request-local and does not write user files. Use it for
98
+ connector smoke tests, tool discovery, and agent onboarding; use the file-backed
99
+ stdio command when the workflow must persist a project WorkPaper JSON file.
100
+
101
+ ## Direct TypeScript
102
+
103
+ Use `bilig-workpaper` directly when workbook logic belongs in a service, queue worker, test, or route:
104
+
105
+ ```ts
106
+ import { WorkPaper, exportWorkPaperDocument, serializeWorkPaperDocument } from 'bilig-workpaper'
107
+
108
+ const workbook = WorkPaper.buildFromSheets({
109
+ Inputs: [
110
+ ['Metric', 'Value'],
111
+ ['Customers', 20],
112
+ ['Average revenue', 1200],
113
+ ],
114
+ Summary: [
115
+ ['Metric', 'Value'],
116
+ ['Revenue', '=Inputs!B2*Inputs!B3'],
117
+ ],
118
+ })
119
+
120
+ const inputs = workbook.getSheetId('Inputs')
121
+ const summary = workbook.getSheetId('Summary')
122
+ if (inputs === undefined || summary === undefined) {
123
+ throw new Error('Workbook is missing required sheets')
124
+ }
125
+
126
+ workbook.setCellContents({ sheet: inputs, row: 1, col: 1 }, 32)
127
+ const revenue = workbook.getCellDisplayValue({ sheet: summary, row: 1, col: 1 })
128
+ const saved = serializeWorkPaperDocument(exportWorkPaperDocument(workbook, { includeConfig: true }))
129
+
130
+ console.log({ revenue, savedBytes: saved.length })
131
+ ```
132
+
133
+ ## XLSX Formula Clinic
134
+
135
+ When the user has a reduced XLSX formula/import bug, generate a local report through an argument array:
136
+
137
+ ```json
138
+ {
139
+ "command": "npm",
140
+ "args": ["exec", "--package", "bilig-workpaper@0.33.1", "--", "bilig-formula-clinic", "./reduced.xlsx", "--cells", "Summary!B7,Inputs!B2"]
141
+ }
142
+ ```
143
+
144
+ The report is local. It does not upload workbook contents. Ask for a reduced public fixture rather than private customer spreadsheets.
145
+
146
+ ## Required Verification
147
+
148
+ Return proof, not vibes. A successful agent response should include:
149
+
150
+ - the exact edited sheet and A1 cell;
151
+ - before values for relevant inputs and dependent outputs;
152
+ - after values read from the recalculated workbook;
153
+ - persistence evidence from serialized or exported WorkPaper state;
154
+ - restore or reimport proof when file boundaries matter;
155
+ - limitations for unsupported formulas or Excel-only features.
156
+
157
+ If any proof step fails, report the blocker instead of claiming the workbook was updated.
158
+
159
+ ## Reference URLs
160
+
161
+ - Compact docs map: https://proompteng.github.io/bilig/llms.txt
162
+ - Full agent context: https://proompteng.github.io/bilig/llms-full.txt
163
+ - Agent handbook: https://proompteng.github.io/bilig/headless-workpaper-agent-handbook.html
164
+ - Agent workbook challenge: https://proompteng.github.io/bilig/agent-workbook-challenge.html
165
+ - MCP server guide: https://proompteng.github.io/bilig/mcp-workpaper-tool-server.html
166
+ - XLSX formula clinic: https://proompteng.github.io/bilig/formula-bug-clinic.html
167
+ - Compatibility limits: https://proompteng.github.io/bilig/where-bilig-is-not-excel-compatible-yet.html
168
+ - Repository: https://github.com/proompteng/bilig
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { runAgentWorkbookChallengeCli } from '@bilig/headless/cli';
3
+ process.exitCode = runAgentWorkbookChallengeCli({
4
+ argv: process.argv.slice(2),
5
+ });
6
+ //# sourceMappingURL=agent-workbook-challenge-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-workbook-challenge-bin.js","sourceRoot":"","sources":["../src/agent-workbook-challenge-bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,CAAC,QAAQ,GAAG,4BAA4B,CAAC;IAC9C,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { runFormulaClinicCli } from '@bilig/headless/cli';
3
+ import { importXlsx } from './xlsx.js';
4
+ process.exitCode = runFormulaClinicCli({
5
+ argv: process.argv.slice(2),
6
+ importXlsx,
7
+ });
8
+ //# sourceMappingURL=formula-clinic-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-clinic-bin.js","sourceRoot":"","sources":["../src/formula-clinic-bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,OAAO,CAAC,QAAQ,GAAG,mBAAmB,CAAC;IACrC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,UAAU;CACX,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { runMcpChallengeCli } from '@bilig/headless/cli';
3
+ process.exitCode = runMcpChallengeCli({
4
+ argv: process.argv.slice(2),
5
+ });
6
+ //# sourceMappingURL=mcp-challenge-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-challenge-bin.js","sourceRoot":"","sources":["../src/mcp-challenge-bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,CAAC,QAAQ,GAAG,kBAAkB,CAAC;IACpC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { buildDemoWorkPaper, createFileBackedWorkPaperMcpToolServer, createFileBackedWorkPaperMcpToolServerFromFile, parseWorkPaperMcpStdioCliArgs, runDemoWorkPaperMcpStdioServer, workPaperMcpStdioHelpText, } from '@bilig/headless/mcp';
3
+ const cliOptions = parseWorkPaperMcpStdioCliArgs(process.argv.slice(2));
4
+ if (cliOptions.help) {
5
+ process.stdout.write(workPaperMcpStdioHelpText());
6
+ process.exit(0);
7
+ }
8
+ if (cliOptions.demoWorkPaperTools) {
9
+ runDemoWorkPaperMcpStdioServer({
10
+ server: createFileBackedWorkPaperMcpToolServer({
11
+ workbook: buildDemoWorkPaper(),
12
+ sourcePath: 'demo://bilig-workpaper',
13
+ writable: false,
14
+ }),
15
+ });
16
+ }
17
+ else if (cliOptions.workpaperPath === undefined) {
18
+ runDemoWorkPaperMcpStdioServer();
19
+ }
20
+ else {
21
+ runDemoWorkPaperMcpStdioServer({
22
+ server: createFileBackedWorkPaperMcpToolServerFromFile({
23
+ initDemoWorkPaper: cliOptions.initDemoWorkPaper,
24
+ workpaperPath: cliOptions.workpaperPath,
25
+ writable: cliOptions.writable,
26
+ }),
27
+ });
28
+ }
29
+ //# sourceMappingURL=work-paper-mcp-stdio-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work-paper-mcp-stdio-bin.js","sourceRoot":"","sources":["../src/work-paper-mcp-stdio-bin.ts"],"names":[],"mappings":";AACA,OAAO,EACL,kBAAkB,EAClB,sCAAsC,EACtC,8CAA8C,EAC9C,6BAA6B,EAC7B,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,MAAM,UAAU,GAAG,6BAA6B,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACvE,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;IACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAA;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,IAAI,UAAU,CAAC,kBAAkB,EAAE,CAAC;IAClC,8BAA8B,CAAC;QAC7B,MAAM,EAAE,sCAAsC,CAAC;YAC7C,QAAQ,EAAE,kBAAkB,EAAE;YAC9B,UAAU,EAAE,wBAAwB;YACpC,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;KAAM,IAAI,UAAU,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;IAClD,8BAA8B,EAAE,CAAA;AAClC,CAAC;KAAM,CAAC;IACN,8BAA8B,CAAC;QAC7B,MAAM,EAAE,8CAA8C,CAAC;YACrD,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;YAC/C,aAAa,EAAE,UAAU,CAAC,aAAa;YACvC,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bilig-workpaper",
3
- "version": "0.32.9",
3
+ "version": "0.33.1",
4
4
  "description": "Bilig WorkPaper runtime for Node.js services, agent tools, and server-side spreadsheet formulas.",
5
5
  "keywords": [
6
6
  "agent-tools",
@@ -40,8 +40,16 @@
40
40
  "url": "git+https://github.com/proompteng/bilig.git",
41
41
  "directory": "packages/bilig"
42
42
  },
43
+ "bin": {
44
+ "bilig-agent-challenge": "./dist/agent-workbook-challenge-bin.js",
45
+ "bilig-formula-clinic": "./dist/formula-clinic-bin.js",
46
+ "bilig-mcp-challenge": "./dist/mcp-challenge-bin.js",
47
+ "bilig-workpaper-mcp": "./dist/work-paper-mcp-stdio-bin.js"
48
+ },
43
49
  "files": [
44
50
  "dist",
51
+ "AGENTS.md",
52
+ "SKILL.md",
45
53
  "README.md",
46
54
  "LICENSE"
47
55
  ],
@@ -70,7 +78,7 @@
70
78
  "build": "pnpm --dir ../.. --filter @bilig/headless build && rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json"
71
79
  },
72
80
  "dependencies": {
73
- "@bilig/headless": "0.32.9"
81
+ "@bilig/headless": "0.33.1"
74
82
  },
75
83
  "engines": {
76
84
  "node": ">=22.0.0"