@attentionform/astra 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.
Files changed (30) hide show
  1. package/LICENSE +206 -0
  2. package/NOTICE +12 -0
  3. package/README.md +211 -2
  4. package/dist/cli.js +40911 -0
  5. package/dist/packages/cli/src/cli/batch-cmd.d.ts +169 -0
  6. package/dist/packages/cli/src/cli/create-cmd.d.ts +4 -0
  7. package/dist/packages/cli/src/cli/errors.d.ts +86 -0
  8. package/dist/packages/cli/src/cli/export-cmd.d.ts +2 -0
  9. package/dist/packages/cli/src/cli/history-cmd.d.ts +5 -0
  10. package/dist/packages/cli/src/cli/import-cmd.d.ts +2 -0
  11. package/dist/packages/cli/src/cli/inspect-cmd.d.ts +3 -0
  12. package/dist/packages/cli/src/cli/io.d.ts +60 -0
  13. package/dist/packages/cli/src/cli/normalize-cmd.d.ts +9 -0
  14. package/dist/packages/cli/src/cli/output.d.ts +95 -0
  15. package/dist/packages/cli/src/cli/run.d.ts +6 -0
  16. package/dist/packages/cli/src/cli/sanitize-cmd.d.ts +26 -0
  17. package/dist/packages/cli/src/cli/search-cmd.d.ts +2 -0
  18. package/dist/packages/cli/src/cli/stats-cmd.d.ts +2 -0
  19. package/dist/packages/cli/src/cli/usage.d.ts +8 -0
  20. package/dist/packages/cli/src/cli/validate-cmd.d.ts +2 -0
  21. package/dist/packages/cli/src/cli/visual-cmd.d.ts +34 -0
  22. package/dist/packages/cli/src/cli.d.ts +44 -0
  23. package/dist/packages/cli/src/export.d.ts +18 -0
  24. package/dist/packages/ooxml-validator/src/index.d.ts +33 -0
  25. package/dist/packages/ooxml-validator/src/one-shot.d.ts +2 -0
  26. package/dist/packages/ooxml-validator/src/protocol.d.ts +30 -0
  27. package/dist/packages/ooxml-validator/src/resolve-binary.d.ts +5 -0
  28. package/dist/packages/ooxml-validator/src/types.d.ts +65 -0
  29. package/dist/packages/ooxml-validator/src/worker-client.d.ts +38 -0
  30. package/package.json +70 -4
package/LICENSE ADDED
@@ -0,0 +1,206 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Attentionform, the publisher of ASTra, operated by the
11
+ holder of the GitHub account github.com/Userfrom1995
12
+ and also identified by the GitHub organization
13
+ github.com/Attentionform and the domain
14
+ attentionform.com, together with its successors and
15
+ assigns.
16
+
17
+ Licensed Work: ASTra: the engine, command-line tool, MCP server and
18
+ OOXML validator in this repository, in each version
19
+ that the Licensor makes publicly available, beginning
20
+ with the first public release. Each version carries
21
+ its own Change Date, below.
22
+ The Licensed Work is (c) 2026 Attentionform.
23
+ This License applies to all files in this repository and
24
+ to the packages published from it, UNLESS another license
25
+ file is present in a sub-directory, in which case that
26
+ license applies to the files in that sub-directory.
27
+
28
+ Additional Use Grant: You may make production use of the Licensed Work, free of
29
+ charge, if Your use is Individual Use, Educational and
30
+ Research Use, Non-Profit Use, Public-Sector Use or Small
31
+ Business Use, each as defined below. Any other production
32
+ use requires a commercial license from the Licensor.
33
+
34
+ "Individual Use" means use by a natural person on his or
35
+ her own account, including as a freelancer or consultant,
36
+ either personally or through a business entity that has
37
+ no employees. Contractors engaged for a specific project
38
+ are not employees. Individual Use does not include use
39
+ for the internal operations of an employer or of a client
40
+ (for example, running the Licensed Work on a client's
41
+ systems for the client's own continuing use). Using the
42
+ Licensed Work to prepare documents or other deliverables
43
+ for clients is Individual Use.
44
+
45
+ "Educational and Research Use" means use by an accredited
46
+ school, college or university, or by its students and
47
+ staff, for teaching, learning or non-commercial academic
48
+ research.
49
+
50
+ "Non-Profit Use" means use by a Qualifying Non-Profit in
51
+ furtherance of its exempt purposes, and not in connection
52
+ with the sale of products or services (other than fees
53
+ that only recover the cost of its charitable activities).
54
+ A "Qualifying Non-Profit" is an organization that is
55
+ organized and operated exclusively for charitable,
56
+ educational, religious, scientific or similar
57
+ public-benefit purposes, whose net earnings do not
58
+ benefit any private person, and that is recognized as a
59
+ charity or as exempt from income tax on that basis under
60
+ the law of its jurisdiction (for example, under Section
61
+ 501(c)(3) of the U.S. Internal Revenue Code, or as a
62
+ charity registered in the United Kingdom).
63
+
64
+ "Public-Sector Use" means use by a government department,
65
+ agency, municipality or other public authority for its
66
+ governmental functions. It does not include use by a
67
+ state-owned or government-controlled enterprise, or by
68
+ any body that sells products or services on a commercial
69
+ basis. Fees charged only to recover the cost of statutory
70
+ services are not a commercial basis.
71
+
72
+ Any organization that is not described in Individual Use,
73
+ Educational and Research Use, Non-Profit Use or
74
+ Public-Sector Use, including a company, partnership or
75
+ other business with employees and any state-owned or
76
+ government-controlled enterprise, is a "For-Profit
77
+ Organization". Production use by or for a For-Profit
78
+ Organization requires a commercial license unless it is
79
+ Small Business Use.
80
+
81
+ "Small Business Use" means use by a For-Profit
82
+ Organization that, together with its affiliates, had
83
+ total gross revenue below USD 1,000,000 and fewer than 10
84
+ people working for it in its last completed fiscal year,
85
+ or that has not yet completed a fiscal year and
86
+ reasonably expects to meet both limits in its first one.
87
+ The people working for it are its employees and the
88
+ individuals who work for it on a regular basis as
89
+ contractors, counted as individuals and not as
90
+ companies. An "affiliate" is any entity that controls,
91
+ is controlled by, or is under common control with
92
+ another entity.
93
+
94
+ Individual Use and Small Business Use include using the
95
+ Licensed Work as a component of a product or service of
96
+ Your own that has substantial functionality beyond that
97
+ of the Licensed Work, and Your customers and users may
98
+ use the Licensed Work only as part of that product or
99
+ service. A product or service includes software that You
100
+ make available free of charge. No category above
101
+ includes a Competing Offering, which always requires a
102
+ commercial license. A "Competing Offering" is a product
103
+ or service offered to third parties whose value consists
104
+ mainly of the functionality of the Licensed Work, for
105
+ example hosting the Licensed Work as a service for others
106
+ or reselling it.
107
+
108
+ If You stop qualifying for a category above, You may
109
+ continue Your existing use for 90 days (for Small
110
+ Business Use, until the end of Your next fiscal year),
111
+ and must then obtain a commercial license or stop.
112
+ "Production use" means any use of the Licensed Work
113
+ other than non-production use, including making it part
114
+ of a product or service that You provide to others.
115
+ Non-production use (including evaluation, development,
116
+ testing and demonstration) is permitted by this License
117
+ without any category. Documents and other output that You
118
+ create with the Licensed Work belong to You, and this
119
+ License places no restriction on them.
120
+
121
+ Change Date: Four years after the date on which a specific version of
122
+ the Licensed Work is first made publicly available.
123
+
124
+ Change License: Apache License, Version 2.0
125
+
126
+ For information about commercial licenses for the Licensed Work, contact:
127
+ astra@attentionform.com
128
+
129
+ -----------------------------------------------------------------------------
130
+
131
+ Terms
132
+
133
+ The Licensor hereby grants you the right to copy, modify, create derivative
134
+ works, redistribute, and make non-production use of the Licensed Work. The
135
+ Licensor may make an Additional Use Grant, above, permitting limited
136
+ production use.
137
+
138
+ Effective on the Change Date, or the fourth anniversary of the first publicly
139
+ available distribution of a specific version of the Licensed Work under this
140
+ License, whichever comes first, the Licensor hereby grants you rights under
141
+ the terms of the Change License, and the rights granted in the paragraph
142
+ above terminate.
143
+
144
+ If your use of the Licensed Work does not comply with the requirements
145
+ currently in effect as described in this License, you must purchase a
146
+ commercial license from the Licensor, its affiliated entities, or authorized
147
+ resellers, or you must refrain from using the Licensed Work.
148
+
149
+ All copies of the original and modified Licensed Work, and derivative works
150
+ of the Licensed Work, are subject to this License. This License applies
151
+ separately for each version of the Licensed Work and the Change Date may vary
152
+ for each version of the Licensed Work released by Licensor.
153
+
154
+ You must conspicuously display this License on each original or modified copy
155
+ of the Licensed Work. If you receive the Licensed Work in original or
156
+ modified form from a third party, the terms and conditions set forth in this
157
+ License apply to your use of that work.
158
+
159
+ Any use of the Licensed Work in violation of this License will automatically
160
+ terminate your rights under this License for the current and all other
161
+ versions of the Licensed Work.
162
+
163
+ This License does not grant you any right in any trademark or logo of
164
+ Licensor or its affiliates (provided that you may use a trademark or logo of
165
+ Licensor as expressly required by this License).
166
+
167
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
168
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
169
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
170
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
171
+ TITLE.
172
+
173
+ MariaDB hereby grants you permission to use this License’s text to license
174
+ your works, and to refer to it using the trademark "Business Source License",
175
+ as long as you comply with the Covenants of Licensor below.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Covenants of Licensor
180
+
181
+ In consideration of the right to use this License’s text and the "Business
182
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
183
+ other recipients of the licensed work to be provided by Licensor:
184
+
185
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
186
+ or a license that is compatible with GPL Version 2.0 or a later version,
187
+ where "compatible" means that software provided under the Change License can
188
+ be included in a program with software provided under GPL Version 2.0 or a
189
+ later version. Licensor may specify additional Change Licenses without
190
+ limitation.
191
+
192
+ 2. To either: (a) specify an additional grant of rights to use that does not
193
+ impose any additional restriction on the right granted in this License, as
194
+ the Additional Use Grant; or (b) insert the text "None".
195
+
196
+ 3. To specify a Change Date.
197
+
198
+ 4. Not to modify this License in any other way.
199
+
200
+ -----------------------------------------------------------------------------
201
+
202
+ Notice
203
+
204
+ The Business Source License (this document, or the "License") is not an Open
205
+ Source license. However, the Licensed Work will eventually be made available
206
+ under an Open Source License, as stated in this License.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ ASTra
2
+ Copyright 2026 Attentionform (https://attentionform.com)
3
+
4
+ This product includes software developed by Attentionform and its contributors.
5
+
6
+ ASTra is licensed under the Business Source License 1.1 (source-available, not open source).
7
+ See the LICENSE file for the terms, including who may use it for free. Each version
8
+ converts to the Apache License, Version 2.0 four years after it is first made
9
+ publicly available. For a commercial license, write to astra@attentionform.com.
10
+
11
+ Third-party software included in or used by ASTra, with its own licenses and
12
+ copyright notices, is listed in THIRD_PARTY_NOTICES.md.
package/README.md CHANGED
@@ -1,3 +1,212 @@
1
- # Temporary Holding Version
1
+ # @attentionform/astra
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official command-line interface for the ASTra document engine (`astra`).
4
+
5
+ `@attentionform/astra` provides high-performance terminal inspection, ECMA-376 schema validation, atomic batch editing, privacy sanitization, and multi-format export for Microsoft Word (`.docx`) files. The interactive chat IDE moved to the separate `astra-agent` binary.
6
+
7
+ ---
8
+
9
+ ## Quickstart
10
+
11
+ ### Run with `npx` (Zero Install)
12
+
13
+ Run commands immediately without installing locally:
14
+
15
+ ```bash
16
+ npx -y @attentionform/astra --help
17
+ ```
18
+
19
+ ### Install Globally
20
+
21
+ ```bash
22
+ npm install -g @attentionform/astra
23
+ astra --help
24
+ ```
25
+
26
+ ### 3-Minute Tour
27
+
28
+ ```bash
29
+ # 1. Create a document from an executive template
30
+ astra create proposal.docx --template report
31
+
32
+ # 2. Inspect document structure in token-compact notation
33
+ astra inspect proposal.docx --fidelity compact
34
+
35
+ # 3. Search for headings or paragraphs to find stable node IDs
36
+ astra search proposal.docx "Executive"
37
+
38
+ # 4. Append a new paragraph atomically
39
+ astra batch proposal.docx --append "Project timeline spans 6 months."
40
+
41
+ # 5. Export to PDF and Markdown
42
+ astra export proposal.docx --format pdf -o proposal.pdf
43
+ astra export proposal.docx --format markdown -o proposal.md
44
+
45
+ # 6. Sanitize metadata before external sharing
46
+ astra sanitize proposal.docx proposal_clean.docx
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Command Overview
52
+
53
+ | Command | Description | Example |
54
+ |---|---|---|
55
+ | `inspect` | Displays TOON outline, table grids, and node IDs | `astra inspect doc.docx --fidelity compact` |
56
+ | `validate` | Checks ECMA-376 schema conformance and package integrity | `astra validate doc.docx` |
57
+ | `batch` | Applies atomic operations or JSON streams with rollback | `astra batch doc.docx ops.json` |
58
+ | `search` | Searches text across nodes with literal or regex matching | `astra search doc.docx "Revenue" --limit 5` |
59
+ | `create` | Generates a fresh `.docx` from `report`, `memo`, or `blank` | `astra create new.docx --template memo` |
60
+ | `import` | Compiles Markdown files directly into `.docx` | `astra import spec.md -o spec.docx` |
61
+ | `export` | Headless export to PDF, HTML, or Markdown | `astra export doc.docx --format pdf` |
62
+ | `sanitize` | Scrubs metadata, comments, revision history, and PII | `astra sanitize doc.docx clean.docx` |
63
+ | `normalize` | Canonicalizes XML namespaces and fixes element ordering | `astra normalize doc.docx` |
64
+ | `stats` | Reports word count, paragraph count, and estimated pages | `astra stats doc.docx` |
65
+ | `visual` | Renders one saved-file page to PNG/JPEG via headless LibreOffice | `astra visual doc.docx --out render.png` |
66
+ | `history` | Lists recorded sidecar commits, newest first (read-only) | `astra history doc.docx` |
67
+ | `revert` | Restores the package state recorded N commits back, as a new commit | `astra revert doc.docx --steps 1` |
68
+ | `redo` | Re-applies the state replaced by the most recent revert | `astra redo doc.docx` |
69
+
70
+ ---
71
+
72
+ ## Command Reference
73
+
74
+ Each command lists its job in one line; run `astra <command> --help` for the full flag table and `--json` for scripting.
75
+
76
+ ### 1. Inspect Document (`astra inspect`)
77
+ Structure, node IDs, and document stats; `--visual` adds spatial telemetry plus one headless page render.
78
+
79
+ ### 2. Validate Document (`astra validate`)
80
+ ECMA-376 schema conformance and package integrity; never writes.
81
+
82
+ ### 3. Sanitize Document (`astra sanitize`)
83
+ Scrubs metadata, comments, revision history, and RSIDs; `--redact-pii` also redacts body PII.
84
+
85
+ ### 4. Atomic Batch Operations (`astra batch`)
86
+ Applies an ops file with rollback; supports `--stream`, `--matrix`, and shortcut flags.
87
+
88
+ ### 5. Repair Legacy Files (`astra normalize`)
89
+ Canonicalizes XML namespaces and fixes element ordering.
90
+
91
+ ### 6. Multi-Format Export (`astra export`)
92
+ Exports to PDF, HTML, or Markdown.
93
+
94
+ ### 7. Full-Text Search (`astra search`)
95
+ Finds node IDs by literal or regex text match.
96
+
97
+ ### 8. Create Document (`astra create`)
98
+ Generates a fresh `.docx` from a bundled template.
99
+
100
+ ### 9. Import Markdown (`astra import`)
101
+ Compiles a Markdown file into a `.docx`.
102
+
103
+ ### 10. Document Statistics (`astra stats`)
104
+ Word, paragraph, and page counts (deterministic estimate).
105
+
106
+ ### 11. Visual Page Rendering (`astra visual`)
107
+ Renders one saved-file page to PNG/JPEG via headless LibreOffice (same renderer as `inspect --visual`).
108
+
109
+ ### 12. Document History (`astra history`)
110
+ Lists recorded sidecar commits newest first; read-only; `--init` (alias `--track`) records the current file as the baseline when no sidecar exists yet.
111
+
112
+ ### 13. Revert to Recorded State (`astra revert`)
113
+ Restores the tracked package state `--steps <n>` commits back and records the restore as a new commit (append-only); `preview-revert` previews the same change read-only.
114
+
115
+ ### 14. Redo Reverted State (`astra redo`)
116
+ Re-applies the state replaced by the most recent revert (one redo per revert head).
117
+
118
+ ---
119
+
120
+ ## Global Flags
121
+
122
+ These flags work across all subcommands:
123
+
124
+ | Flag | Purpose |
125
+ |---|---|
126
+ | `--json` | Emits single-line structured JSON on `stdout` for CI/CD scripting and `jq` pipelines. |
127
+ | `--verbose` | Emits detailed operational diagnostics on `stderr`. |
128
+ | `--version` | Displays current CLI version and exits with `0`. |
129
+ | `--help`, `-h` | Displays help information for any command (`astra <command> --help`). |
130
+
131
+ ---
132
+
133
+ ## Practical CLI Recipes
134
+
135
+ ### 1. Atomic Node Replacement (Without an Ops File)
136
+ Quickly replace targeted text without needing to write JSON operations:
137
+
138
+ ```bash
139
+ # Finds the paragraph containing "Draft Status" and updates it
140
+ astra batch doc.docx --target-text "Draft Status" --append "Final Approved"
141
+ ```
142
+
143
+ ### 2. High-Throughput Batch Automation
144
+ Pipe JSON operations directly via `stdin`:
145
+
146
+ ```bash
147
+ cat operations.json | astra batch doc.docx - --out modified.docx
148
+ ```
149
+
150
+ ### 3. CI/CD Schema Verification
151
+ Integrate ASTra into automated build pipelines:
152
+
153
+ ```bash
154
+ # Returns exit code 0 if valid, 1 if schema violations are found
155
+ astra validate generated_report.docx --json | jq .ok
156
+ ```
157
+
158
+ ### 4. Privacy Sanitization for Public Distribution
159
+ Scrub author names, editing history, and metadata:
160
+
161
+ ```bash
162
+ # Default: scrubs metadata, revision tags, and hidden RSIDs while keeping body text
163
+ astra sanitize draft.docx public.docx
164
+
165
+ # Client-Safe: scrubs metadata, redacts body PII, and accepts all tracked changes
166
+ astra sanitize draft.docx client_final.docx --client-safe
167
+ ```
168
+
169
+ ### 5. Multi-Page Visual Telemetry
170
+ Inspect layout and generate high-resolution PNG previews:
171
+
172
+ ```bash
173
+ astra inspect doc.docx --visual --format png
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Dates, authors and reproducible output
179
+
180
+ By default ASTra writes the **current time** into tracked changes, comments and document properties, and attributes them to the author you give: an `author` on the operation, else `--author <name>` (or `ASTRA_AUTHOR`) for the run, else `ASTra`. Any revision or comment operation also takes an explicit ISO 8601 `date`.
181
+
182
+ For **byte-identical output** (same input twice gives the same bytes), pass `--reproducible`, or set `ASTRA_REPRODUCIBLE=1` or `SOURCE_DATE_EPOCH`. Timestamps, ids and document properties are then pinned to `SOURCE_DATE_EPOCH`, else `1980-01-01Z`. `--no-reproducible` (or `ASTRA_NO_REPRODUCIBLE=1`) forces real values even when one of those is set.
183
+
184
+ ---
185
+
186
+ ## Exit Code Contract
187
+
188
+ ASTra enforces a strict, predictable exit code contract for headless automation:
189
+
190
+ | Exit Code | Meaning | Common Causes |
191
+ |:---:|---|---|
192
+ | `0` | **Success** | Operation completed successfully, document validated. |
193
+ | `1` | **Operational Failure** | File not found, corrupted XML archive, schema validation failed, or batch rolled back. |
194
+ | `2` | **Usage Error** | Unknown flag, missing required positional arguments, or file overwrite conflict without `--force`. |
195
+
196
+ ---
197
+
198
+ ## Local Development
199
+
200
+ ```bash
201
+ # Build CLI bundle
202
+ npm run build:packages
203
+
204
+ # Run local CLI binary
205
+ node packages/cli/dist/cli.js --help
206
+ ```
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ Business Source License 1.1 (`BUSL-1.1`): source-available, free for individuals, education, non-profits, public bodies and small businesses; other production use needs a commercial license. Each version converts to Apache-2.0 four years after release. See [LICENSE](LICENSE) and write to astra@attentionform.com for a commercial license.