Skip to content

Commit 3f116d9

Browse files
committed
Add scoped document creation tools and release 1.0.1
1 parent 62d8f08 commit 3f116d9

34 files changed

Lines changed: 828 additions & 5 deletions

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Document any justified exception in the nearest feature doc or ADR.
6666

6767
## Critical rules
6868

69+
- Runtime dependencies must be free for commercial use without paid binary maintenance agreements or a second commercial license. MIT, Apache-2.0, BSD and OFL are acceptable; inspect the shipped NuGet license and transitive dependencies.
70+
6971
- Never commit secrets or generated test artifacts.
7072
- Never weaken or delete a test to make a run green.
7173
- Never push a package directly from a developer machine.

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
All notable changes to ManagedCode.FileContext are documented here.
44

5-
## Unreleased
5+
## 1.0.1
6+
7+
- Add scoped creation of text, CSV, XLSX workbooks and Unicode PDF documents.
8+
- Expose native document tools through FileContextProvider and a reusable function factory, with write opt-in and approval defaults.
9+
- Add public streaming access and bounded recursive file metadata listing, preserving the same path scope as existing reads.
10+
611

712
- Add optional OperationTimeout for all public storage/context operations, preserve caller cancellation, and report configured expiry as a tool-compatible timeout failure.
813
- Validate operation and regex timeout durations at configuration time.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<AnalysisMode>Recommended</AnalysisMode>
1313
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1414
<NoWarn>$(NoWarn);CS1591;MAAI001</NoWarn>
15-
<Version>1.0.0</Version>
15+
<Version>1.0.1</Version>
1616
<PackageVersion>$(Version)</PackageVersion>
1717
</PropertyGroup>
1818

Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.33.0.1635" PrivateAssets="all" />
1010
</ItemGroup>
1111
<ItemGroup>
12+
<PackageVersion Include="DocumentFormat.OpenXml" Version="3.5.1" />
13+
<PackageVersion Include="PdfPig" Version="0.1.16" />
1214
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
1315
<PackageVersion Include="coverlet.msbuild" Version="10.0.1" />
1416
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="2.0.5" />

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,32 @@ dotnet pack src/ManagedCode.FileContext/ManagedCode.FileContext.csproj --configu
352352
Version `1.0.0` is defined centrally in `Directory.Build.props`. Every push to `main` runs the Release workflow: restore, format, build, test with coverage, and pack. For a new package version, it publishes the validated NuGet artifact and creates the matching tag and GitHub release automatically. Already released versions are skipped. To release an update, bump the version, commit, and push; no manual tag is required.
353353

354354
[MIT licensed](https://github.com/managedcode/FileContext/blob/main/LICENSE) · Built by [ManagedCode](https://github.com/managedcode)
355+
356+
## Create text, CSV, Excel and PDF
357+
358+
Version 1.0.1 adds native document tools to the same scoped FileContext used for reads, listing and metadata. Set `EnableWriteTools = true` on the shared options passed to the store, service and provider. Creation tools retain human approval by default. Each result has a unique `outputs/<id>/<name>` path, content type and byte length; creation never overwrites another file. Hosts own download URLs and user authorization.
359+
360+
```csharp
361+
var options = new FileContextOptions
362+
{
363+
RootPrefix = "conversations/current",
364+
EnableWriteTools = true
365+
};
366+
var store = new ManagedCodeStorageFileStore(storage, options);
367+
var context = new FileContextService(store, options);
368+
var report = await context.Documents.CreateWorkbookAsync("report.xlsx",
369+
new FileContextWorkbook([
370+
new FileContextWorksheet("Sales", [
371+
[new(Text: "Product"), new(Text: "Count")],
372+
[new(Text: "Glasses"), new(Number: 12)]
373+
])
374+
]));
375+
var info = await context.GetInfoAsync(report.Path);
376+
await using var bytes = await store.OpenReadAsync(report.Path);
377+
```
378+
379+
`FileContextProvider` exposes `file_context_create_text`, `file_context_create_csv`, `file_context_create_workbook`, and `file_context_create_pdf` when writes are enabled. `FileContextDocumentTools.Create(store, options)` returns those same native functions for host-managed tool registries, including sandboxed JavaScript bridges.
380+
381+
CSV preserves literal values and escapes quotes, delimiters and newlines. XLSX supports multiple sheets and text/number/boolean/formula cells; Excel calculates explicit formulas when opened. PDF supports paginated paragraphs and a title with embedded Noto Sans for Latin/Cyrillic text. The Noto Sans font is distributed under the bundled SIL Open Font License. The default generated-file budget is 64 MiB, configurable through `MaximumGeneratedFileBytes`; cancellation and `OperationTimeout` apply to generation and persistence.
382+
383+
Document generation uses DocumentFormat.OpenXml (MIT), PdfPig (Apache-2.0), and bundled Noto Sans (OFL-1.1). CSV writing uses the .NET runtime. These components do not require a paid commercial license. See [dependency licenses](docs/Development/dependency-licenses.md) for the audited package boundary and font notice.

docs/Architecture.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,17 @@ All potentially large operations are controlled by `FileContextOptions`: full-re
8686
- Setup: [development setup](Development/setup.md)
8787
- Safety model: [security](Security.md)
8888
- Verification: [testing](Testing/index.md)
89+
90+
## Generated documents
91+
92+
`FileContextDocumentService` shares `ManagedCodeStorageFileStore` with standard navigation and bounded reads. It creates new UTF-8 text/CSV, XLSX workbooks and paginated PDF documents under unique relative paths. `FileContextDocumentTools` supplies the same native functions to FileContextProvider or a host-owned tool registry.
93+
94+
```mermaid
95+
flowchart LR
96+
Provider[FileContextProvider] --> Tools[FileContextDocumentTools]
97+
Host[Host native and JavaScript tools] --> Tools
98+
Tools --> Documents[FileContextDocumentService]
99+
Documents --> Writers[CSV OpenXml PdfPig]
100+
Documents --> Store[ManagedCodeStorageFileStore]
101+
Store --> Storage[IStorage]
102+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dependency licenses
2+
3+
The 1.0.1 runtime package uses dependencies with MIT, Apache-2.0 or BSD licenses. The embedded Noto Sans font uses OFL-1.1. None of these components requires a paid commercial license or binary maintenance agreement. Preserve their license and attribution notices when redistributing.
4+
5+
| Component | Version | License | Role |
6+
|---|---|---|---|
7+
| DocumentFormat.OpenXml / Framework | 3.5.1 | MIT | Workbook creation |
8+
| PdfPig | 0.1.16 | Apache-2.0 | PDF creation |
9+
| Noto Sans Regular | Bundled font | OFL-1.1 | Embedded Latin/Cyrillic font; notice included in NuGet |
10+
| .NET runtime | net10.0 | MIT | CSV/text encoding |
11+
| ManagedCode storage, Markdown-LD, Microsoft Agent Framework and extensions | Centrally pinned | MIT | Storage, context and tool integration |
12+
| Lucene.Net family / J2N | 4.8.0-beta00017 / 2.1.0 | Apache-2.0 | Existing Markdown-LD transitive search dependencies |
13+
14+
```mermaid
15+
flowchart LR
16+
Package[FileContext MIT] --> Excel[OpenXML MIT]
17+
Package --> PDF[PdfPig Apache 2.0]
18+
PDF --> Font[Noto Sans OFL 1.1]
19+
Package --> Existing[Existing storage and context dependencies]
20+
```
21+
22+
The audit inspects the restored NuGet package metadata and embedded license files, not only repository badges. The product dependency closure was reviewed before release. SonarAnalyzer.CSharp is an existing private build dependency under the Sonar Source-Available License, royalty-free for non-competing use. It is not a runtime dependency of the published package and is not represented as MIT. xUnit, LlmTck and filesystem fixtures remain test-only.
23+
24+
Sources: [OpenXML license](https://github.com/dotnet/Open-XML-SDK/blob/main/LICENSE), [PdfPig license](https://github.com/UglyToad/PdfPig/blob/master/LICENSE), [Noto license](https://github.com/notofonts/noto-fonts/blob/main/LICENSE), [Sonar analyzer license](https://github.com/SonarSource/sonar-dotnet/blob/master/LICENSE).

docs/Features/file-context.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,20 @@ Independent writes and range reads on eight different files are tested concurren
9595
- Formatting, Release build, full tests, at least 95% product line coverage, package validation, and clean-install smoke checks pass locally.
9696
- README and durable docs describe only the implemented API.
9797
- GitHub Actions validates each push to `main`, automatically publishes new package versions, and creates the matching version tags and GitHub releases. Existing releases are skipped.
98+
99+
## Generated documents
100+
101+
The shared store and `IFileContext.Documents` create unique text/CSV/XLSX/PDF outputs. Standard listing, metadata, range reads and host streaming access use their returned paths. The document tool factory and context provider share the same implementations; hosts may register a selected subset in a native or JavaScript tool catalog. Writes must be explicitly enabled on shared options and human approval is enabled by default.
102+
103+
```mermaid
104+
sequenceDiagram
105+
participant Agent
106+
participant Tools as FileContext document tools
107+
participant Store as Scoped file store
108+
Agent->>Tools: Create workbook / CSV / PDF / text
109+
Tools->>Store: Persist new outputs/id/name
110+
Store-->>Agent: Relative path and metadata
111+
Agent->>Store: List / info / read the same path
112+
```
113+
114+
Verification: DocumentCreationTests and DocumentValidationTests reopen real formats and test boundary failures; FileDocumentCreationLlmTckTests exercises CSV/XLSX/PDF through real model tool calls and checks closed call/result history.
Binary file not shown.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Copyright 2018 The Noto Project Authors (github.com/googlei18n/noto-fonts)
2+
3+
This Font Software is licensed under the SIL Open Font License,
4+
Version 1.1.
5+
6+
This license is copied below, and is also available with a FAQ at:
7+
http://scripts.sil.org/OFL
8+
9+
-----------------------------------------------------------
10+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11+
-----------------------------------------------------------
12+
13+
PREAMBLE
14+
The goals of the Open Font License (OFL) are to stimulate worldwide
15+
development of collaborative font projects, to support the font
16+
creation efforts of academic and linguistic communities, and to
17+
provide a free and open framework in which fonts may be shared and
18+
improved in partnership with others.
19+
20+
The OFL allows the licensed fonts to be used, studied, modified and
21+
redistributed freely as long as they are not sold by themselves. The
22+
fonts, including any derivative works, can be bundled, embedded,
23+
redistributed and/or sold with any software provided that any reserved
24+
names are not used by derivative works. The fonts and derivatives,
25+
however, cannot be released under any other type of license. The
26+
requirement for fonts to remain under this license does not apply to
27+
any document created using the fonts or their derivatives.
28+
29+
DEFINITIONS
30+
"Font Software" refers to the set of files released by the Copyright
31+
Holder(s) under this license and clearly marked as such. This may
32+
include source files, build scripts and documentation.
33+
34+
"Reserved Font Name" refers to any names specified as such after the
35+
copyright statement(s).
36+
37+
"Original Version" refers to the collection of Font Software
38+
components as distributed by the Copyright Holder(s).
39+
40+
"Modified Version" refers to any derivative made by adding to,
41+
deleting, or substituting -- in part or in whole -- any of the
42+
components of the Original Version, by changing formats or by porting
43+
the Font Software to a new environment.
44+
45+
"Author" refers to any designer, engineer, programmer, technical
46+
writer or other person who contributed to the Font Software.
47+
48+
PERMISSION & CONDITIONS
49+
Permission is hereby granted, free of charge, to any person obtaining
50+
a copy of the Font Software, to use, study, copy, merge, embed,
51+
modify, redistribute, and sell modified and unmodified copies of the
52+
Font Software, subject to the following conditions:
53+
54+
1) Neither the Font Software nor any of its individual components, in
55+
Original or Modified Versions, may be sold by itself.
56+
57+
2) Original or Modified Versions of the Font Software may be bundled,
58+
redistributed and/or sold with any software, provided that each copy
59+
contains the above copyright notice and this license. These can be
60+
included either as stand-alone text files, human-readable headers or
61+
in the appropriate machine-readable metadata fields within text or
62+
binary files as long as those fields can be easily viewed by the user.
63+
64+
3) No Modified Version of the Font Software may use the Reserved Font
65+
Name(s) unless explicit written permission is granted by the
66+
corresponding Copyright Holder. This restriction only applies to the
67+
primary font name as presented to the users.
68+
69+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70+
Software shall not be used to promote, endorse or advertise any
71+
Modified Version, except to acknowledge the contribution(s) of the
72+
Copyright Holder(s) and the Author(s) or with their explicit written
73+
permission.
74+
75+
5) The Font Software, modified or unmodified, in part or in whole,
76+
must be distributed entirely under this license, and must not be
77+
distributed under any other license. The requirement for fonts to
78+
remain under this license does not apply to any document created using
79+
the Font Software.
80+
81+
TERMINATION
82+
This license becomes null and void if any of the above conditions are
83+
not met.
84+
85+
DISCLAIMER
86+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94+
OTHER DEALINGS IN THE FONT SOFTWARE.

0 commit comments

Comments
 (0)