throughline-ms-copilot 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,15 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """throughline-ms-copilot: a throughline graph handed to Microsoft 365 Copilot and back.
4
+
5
+ Copilot in a controlled environment reads at most fifty files, cannot run ``tl``
6
+ and returns only text. This package writes the graph as a folder it reads whole,
7
+ one file per register, and carries the change set it answers with through
8
+ ``tl apply``. Everything of an item is the tool's: the export is ``tl dump``
9
+ unreshaped, and the change is made by ``tl apply``, never here.
10
+ """
11
+
12
+ from .reply import ReplyError
13
+ from .tool import CopilotError
14
+
15
+ __all__ = ["CopilotError", "ReplyError"]
@@ -0,0 +1,199 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """tl-ms-copilot — a throughline graph handed to Microsoft 365 Copilot and back.
4
+
5
+ tl-ms-copilot export [-C DIR] EXCHANGE [--wrap json|md] [--only UID[,UID…]]
6
+ tl-ms-copilot ingest [-C DIR] EXCHANGE [--dry-run]
7
+ tl-ms-copilot apply [-C DIR] [REPLY|-] [--dry-run] [--extract]
8
+
9
+ An exchange folder is one the person keeps where Copilot can reach it — a folder
10
+ in OneDrive, say. ``export`` writes the graph into its ``export/`` (REQ-0002,
11
+ REQ-0003); the person saves Copilot's answers into its ``inbox/`` by register
12
+ (REQ-0006); ``ingest`` gathers them into one change set, has ``tl apply`` carry
13
+ it out all or nothing (REQ-0005) and moves what it applied to ``inbox/applied/``.
14
+ ``apply`` does the same for one reply on its own.
15
+
16
+ Any command takes --repository, --ref, --commit and --tree to state the
17
+ provenance instead of reading git, which is what a host without processes — the
18
+ browser — does (REQ-0007).
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import argparse
24
+ import json
25
+ import shutil
26
+ import sys
27
+ import tempfile
28
+ from dataclasses import replace
29
+ from datetime import datetime, timezone
30
+ from importlib.metadata import PackageNotFoundError, version
31
+ from pathlib import Path
32
+
33
+ from .export import EXPORT, WRAPS, own_uids, to_folder, write_folder
34
+ from .inbox import APPLIED, INBOX, NEW, UPDATES, InboxError, gather, waiting
35
+ from .provenance import TREE_WORDS, Provenance, provenance_of, stated
36
+ from .reply import ReplyError, change_set
37
+ from .tool import CopilotError, call, find_graph, run
38
+
39
+ DIST = "throughline-ms-copilot"
40
+
41
+
42
+ def _version(dist: str) -> str:
43
+ try:
44
+ return version(dist)
45
+ except PackageNotFoundError: # pragma: no cover - only from an uninstalled tree
46
+ return "?"
47
+
48
+
49
+ def _graph_options(p: argparse.ArgumentParser) -> None:
50
+ p.add_argument("-C", dest="directory", metavar="DIR", help="the graph (the directory holding throughline.toml)")
51
+
52
+
53
+ def build_parser() -> argparse.ArgumentParser:
54
+ p = argparse.ArgumentParser(
55
+ prog="tl-ms-copilot",
56
+ description="Hand a throughline graph to Microsoft 365 Copilot, and apply the change sets it sends back.",
57
+ )
58
+ p.add_argument("--version", action="version", version=f"tl-ms-copilot {_version(DIST)}")
59
+ sub = p.add_subparsers(dest="command", required=True)
60
+
61
+ e = sub.add_parser("export", help="write the graph into the exchange folder's export/: one file per register and a manifest")
62
+ _graph_options(e)
63
+ e.add_argument("exchange", metavar="EXCHANGE", help="the exchange folder")
64
+ e.add_argument(
65
+ "--wrap",
66
+ choices=WRAPS,
67
+ default="json",
68
+ help="each file as JSON, or as Markdown holding one fenced JSON block for an assistant that will not read a .json file",
69
+ )
70
+ e.add_argument("--only", action="append", metavar="UID[,UID…]", help="hold only these items, and the clauses they cite")
71
+ e.add_argument("--repository", metavar="OWNER/NAME", help="state the repository instead of reading git")
72
+ e.add_argument("--ref", metavar="REF", help="state the ref instead of reading git")
73
+ e.add_argument("--commit", metavar="SHA", help="state the commit instead of reading git")
74
+ e.add_argument("--tree", choices=sorted(TREE_WORDS), help="state the working tree instead of reading git")
75
+
76
+ i = sub.add_parser("ingest", help="gather the exchange folder's inbox into one change set and carry it out with tl apply")
77
+ _graph_options(i)
78
+ i.add_argument("exchange", metavar="EXCHANGE", help="the exchange folder")
79
+ i.add_argument("--dry-run", action="store_true", help="check and carry out the set, report it, then leave every file as it was")
80
+
81
+ a = sub.add_parser("apply", help="find the change set in one Copilot reply and carry it out with tl apply")
82
+ _graph_options(a)
83
+ a.add_argument("reply", nargs="?", default="-", metavar="REPLY", help="the reply as Copilot wrote it, a text file (- for stdin)")
84
+ a.add_argument("--dry-run", action="store_true", help="check and carry out the set, report it, then leave every file as it was")
85
+ a.add_argument("--extract", action="store_true", help="print the change set found in the reply and stop; tl is not asked")
86
+ return p
87
+
88
+
89
+ def named(values: list[str] | None) -> tuple[str, ...]:
90
+ """The identifiers --only names, once each, in the order given."""
91
+ seen: dict[str, None] = {}
92
+ for value in values or []:
93
+ for uid in value.split(","):
94
+ if uid.strip():
95
+ seen.setdefault(uid.strip(), None)
96
+ return tuple(seen)
97
+
98
+
99
+ def _provenance(args: argparse.Namespace, root: Path, producer: str) -> Provenance:
100
+ given = (args.repository, args.ref, args.commit, args.tree)
101
+ if any(given):
102
+ return stated(producer, *given)
103
+ return provenance_of(root, producer)
104
+
105
+
106
+ def export(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
107
+ only = named(args.only)
108
+ if args.only is not None and not only:
109
+ parser.error("--only names no item")
110
+ root = find_graph(args.directory)
111
+ dump = json.loads(run(root, ["dump"]))
112
+ # An item asked for and not held is the caller's mistake, said before
113
+ # anything is written rather than a folder quietly without it.
114
+ missing = [uid for uid in only if uid not in own_uids(dump)]
115
+ if missing:
116
+ parser.error(f"--only names what the graph does not hold: {', '.join(missing)}")
117
+ tl_version = str((dump.get("throughline_dump") or {}).get("tool_version") or "?")
118
+ provenance = _provenance(args, root, f"{DIST} {_version(DIST)} (throughline {tl_version})")
119
+ if only:
120
+ provenance = replace(provenance, items=f"{len(only)} of {len(own_uids(dump))}")
121
+ entries = to_folder(dump, provenance, run(root, ["apply", "--describe"]), wrap=args.wrap, only=only)
122
+ exchange = Path(args.exchange)
123
+ target = exchange / EXPORT
124
+ # The export is replaced whole, so a register since removed leaves no file
125
+ # behind for Copilot to read; nothing outside export/ is touched.
126
+ if target.exists():
127
+ shutil.rmtree(target)
128
+ write_folder(entries, target)
129
+ for folder in (exchange / INBOX / NEW, exchange / INBOX / UPDATES):
130
+ folder.mkdir(parents=True, exist_ok=True)
131
+ print(f"wrote {target}/ — {len(entries)} files; give Copilot every one of them")
132
+ return 0
133
+
134
+
135
+ def _apply(root: Path, text: str, dry_run: bool) -> int:
136
+ """Hand one change set to ``tl apply`` and pass on what it said."""
137
+ with tempfile.TemporaryDirectory() as scratch:
138
+ path = Path(scratch) / "change-set.json"
139
+ path.write_text(text, encoding="utf-8")
140
+ done = call(root, ["apply", str(path), *(["--dry-run"] if dry_run else [])])
141
+ sys.stdout.write(done.stdout)
142
+ sys.stderr.write(done.stderr)
143
+ return done.code
144
+
145
+
146
+ def ingest(args: argparse.Namespace) -> int:
147
+ root = find_graph(args.directory)
148
+ inbox = Path(args.exchange) / INBOX
149
+ if not inbox.is_dir():
150
+ raise CopilotError(f"{inbox} does not exist — run export first")
151
+ paths = waiting([p.relative_to(inbox).as_posix() for p in inbox.rglob("*") if p.is_file()])
152
+ files = {p: (inbox / p).read_text(encoding="utf-8") for p in paths}
153
+ registers = [r["prefix"] for r in json.loads(run(root, ["dump"])).get("registers") or []]
154
+ gathered = gather(files, registers)
155
+ code = _apply(root, gathered.text, args.dry_run)
156
+ if code == 0 and not args.dry_run:
157
+ # Applied files move aside, so the same answer is never applied twice.
158
+ stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
159
+ for path in gathered.files:
160
+ moved = inbox / APPLIED / stamp / path
161
+ moved.parent.mkdir(parents=True, exist_ok=True)
162
+ (inbox / path).rename(moved)
163
+ print(f"moved {len(gathered.files)} file(s) to {inbox / APPLIED / stamp}/")
164
+ return code
165
+
166
+
167
+ def _read(reply: str) -> str:
168
+ if reply == "-":
169
+ return sys.stdin.read()
170
+ try:
171
+ return Path(reply).read_text(encoding="utf-8")
172
+ except OSError as exc:
173
+ raise CopilotError(f"cannot read {reply}: {exc}") from None
174
+
175
+
176
+ def apply(args: argparse.Namespace) -> int:
177
+ text = change_set(_read(args.reply))
178
+ if args.extract:
179
+ sys.stdout.write(text)
180
+ return 0
181
+ return _apply(find_graph(args.directory), text, args.dry_run)
182
+
183
+
184
+ def main(argv: list[str] | None = None) -> int:
185
+ parser = build_parser()
186
+ args = parser.parse_args(argv)
187
+ try:
188
+ if args.command == "export":
189
+ return export(args, parser)
190
+ if args.command == "ingest":
191
+ return ingest(args)
192
+ return apply(args)
193
+ except (CopilotError, ReplyError, InboxError, OSError, ValueError) as exc:
194
+ print(f"tl-ms-copilot: {exc}", file=sys.stderr)
195
+ return 1
196
+
197
+
198
+ if __name__ == "__main__": # pragma: no cover
199
+ sys.exit(main())
@@ -0,0 +1,170 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """The graph as a folder Microsoft 365 Copilot reads whole (REQ-0002, REQ-0003).
4
+
5
+ Copilot in a controlled environment reads at most fifty files, runs no command
6
+ and returns only text, so it has to read the whole graph from a handful of files
7
+ and be told, in those files, how to send changes back. This form is a folder: one
8
+ file per register, each carrying that register's items exactly as ``tl dump``
9
+ gives them, fingerprint included, one file per adopted source for the clauses it
10
+ lends, and a manifest that says what the export was true of, which file holds
11
+ which register, which tl wrote it, and the change-set form ``tl apply`` accepts —
12
+ taken from the tool, never written here, so it cannot drift from what apply
13
+ reads. One file per register because the cap counts files, not items, and a
14
+ graph holds hundreds of items in fewer than fifty registers; a folder rather than
15
+ an archive because Copilot cannot open one.
16
+
17
+ Nothing of an item is reshaped or computed here: the words and the fingerprint
18
+ are the dump's. What this module adds is the file boundaries, the wrapping, and
19
+ the manifest.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import json
25
+ from pathlib import Path
26
+ from typing import Any
27
+
28
+ from .provenance import Provenance
29
+
30
+ #: How each file is written: JSON, or Markdown holding one fenced JSON block for
31
+ #: an assistant that will not read a ``.json`` file.
32
+ WRAPS = ("json", "md")
33
+
34
+ #: The version of this form, stated in the manifest. It continues the count
35
+ #: throughline-transform 0.6.0 began under the same key.
36
+ FORM_VERSION = 1
37
+
38
+ MANIFEST = "manifest"
39
+
40
+ #: The exchange folder's subfolder the export is written into, replaced whole each time.
41
+ EXPORT = "export"
42
+
43
+ #: One file of the folder: its name and its bytes.
44
+ Entry = tuple[str, bytes]
45
+
46
+ #: What the manifest tells the assistant to do, beside the form it must write.
47
+ INSTRUCTION = (
48
+ "Read every file named under \"files\" before you answer — each has the same "
49
+ "extension as this manifest: together they are the whole graph as it stood at "
50
+ "the commit named under \"provenance\". Send changes back as a change set in "
51
+ "the form given under \"change_set_format\", in one fenced ```json block, "
52
+ "quoting for each item you change the value that form asks for exactly as "
53
+ "these files give it. Name a "
54
+ "new item by a \"label\", never by a UID: the tool gives it one. If the change "
55
+ "set would be long, answer one register at a time — the new items for one "
56
+ "register, which the person saves as inbox/new/<PREFIX>.md, or the changes to "
57
+ "one register's items, saved as inbox/updates/<PREFIX>.md — and say which "
58
+ "register each answer is for. Never send a rewritten item file, and never a "
59
+ "file at all: a change set is text, and the person who gave you this folder "
60
+ "will apply it."
61
+ )
62
+
63
+
64
+ def prefix_of(uid: str) -> str:
65
+ """A UID's register prefix — the part before the number."""
66
+ dash = uid.rfind("-")
67
+ return uid if dash == -1 else uid[:dash]
68
+
69
+
70
+ def own_uids(dump: dict[str, Any]) -> set[str]:
71
+ """The UIDs the graph holds itself, as opposed to clauses a source lends."""
72
+ return {i["uid"] for i in dump.get("items") or [] if not i.get("source")}
73
+
74
+
75
+ def _json(data: dict[str, Any]) -> str:
76
+ return json.dumps(data, indent=2, ensure_ascii=False) + "\n"
77
+
78
+
79
+ def _entry(name: str, title: str, data: dict[str, Any], wrap: str, after: str = "") -> Entry:
80
+ """One file of the folder: the JSON itself, or Markdown holding it in one
81
+ fenced block, with ``after`` — Markdown of its own — following the block."""
82
+ text = _json(data)
83
+ if wrap == "json":
84
+ return (f"{name}.json", text.encode("utf-8"))
85
+ body = f"# {title}\n\n```json\n{text}```\n"
86
+ if after:
87
+ body += f"\n{after}"
88
+ return (f"{name}.md", body.encode("utf-8"))
89
+
90
+
91
+ def to_folder(
92
+ dump: dict[str, Any],
93
+ provenance: Provenance,
94
+ change_set_format: str,
95
+ *,
96
+ wrap: str = "json",
97
+ only: tuple[str, ...] = (),
98
+ ) -> list[Entry]:
99
+ """The folder's files, the manifest first.
100
+
101
+ ``dump`` is ``tl dump``'s document, unreshaped; ``change_set_format`` is what
102
+ ``tl apply --describe`` printed. With ``only``, the register files hold the
103
+ items named and the clauses they cite, and the manifest says how many of how
104
+ many.
105
+ """
106
+ if wrap not in WRAPS:
107
+ raise ValueError(f"wrap must be one of {', '.join(WRAPS)}, not {wrap!r}")
108
+ items: list[dict[str, Any]] = list(dump.get("items") or [])
109
+ if only:
110
+ keep = set(only)
111
+ own = [i for i in items if not i.get("source") and i["uid"] in keep]
112
+ cited = {link["target"] for i in own for link in i.get("links") or []}
113
+ items = own + [i for i in items if i.get("source") and i["uid"] in cited]
114
+ registers: list[dict[str, Any]] = list(dump.get("registers") or [])
115
+ by_register: dict[str, list[dict[str, Any]]] = {r["prefix"]: [] for r in registers}
116
+ borrowed: dict[str, list[dict[str, Any]]] = {}
117
+ for item in items:
118
+ if item.get("source"):
119
+ borrowed.setdefault(str(item["source"]), []).append(item)
120
+ else:
121
+ by_register.setdefault(prefix_of(item["uid"]), []).append(item)
122
+
123
+ files: list[dict[str, Any]] = []
124
+ entries: list[Entry] = []
125
+ for register in registers:
126
+ prefix = register["prefix"]
127
+ title = register.get("title") or prefix
128
+ held = by_register.get(prefix, [])
129
+ entries.append(_entry(prefix, f"{title} ({prefix})", {"register": register, "items": held}, wrap))
130
+ files.append({"file": prefix, "register": prefix, "title": title, "items": len(held)})
131
+ for namespace, clauses in sorted(borrowed.items()):
132
+ name = f"source-{namespace}"
133
+ entries.append(
134
+ _entry(name, f"Clauses of the adopted source {namespace}", {"source": namespace, "items": clauses}, wrap)
135
+ )
136
+ files.append({"file": name, "source": namespace, "items": len(clauses)})
137
+
138
+ meta = dump.get("throughline_dump") or {}
139
+ # The manifest is the same in either wrapping, so a file is named by its stem:
140
+ # the reader holds the files, and sees their kind.
141
+ manifest: dict[str, Any] = {
142
+ "throughline_assistant_form": FORM_VERSION,
143
+ "provenance": provenance.record(),
144
+ "provenance_lines": provenance.lines(),
145
+ "tl": str(meta.get("tool_version") or "?"),
146
+ "dump_schema_version": meta.get("dump_schema_version"),
147
+ "files": files,
148
+ "config": dump.get("config") or {},
149
+ }
150
+ if dump.get("composition"):
151
+ manifest["composition"] = dump["composition"]
152
+ manifest["instruction"] = INSTRUCTION
153
+ manifest["change_set_format"] = change_set_format
154
+ readable = f"## How to answer\n\n{INSTRUCTION}\n\n{change_set_format}" if wrap == "md" else ""
155
+ entries.insert(0, _entry(MANIFEST, "Manifest", manifest, wrap, readable))
156
+ return entries
157
+
158
+
159
+ def write_folder(entries: list[Entry], folder: Path) -> list[Path]:
160
+ """Write the entries beneath ``folder``. Refuses a path that would escape it."""
161
+ folder = folder.resolve()
162
+ written: list[Path] = []
163
+ for path, data in entries:
164
+ target = (folder / path).resolve()
165
+ if folder != target and folder not in target.parents:
166
+ raise ValueError(f"refusing to write outside {folder}: {path}")
167
+ target.parent.mkdir(parents=True, exist_ok=True)
168
+ target.write_bytes(data)
169
+ written.append(target)
170
+ return written
@@ -0,0 +1,184 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """What comes back from Copilot, by register, gathered into one change set (REQ-0006).
4
+
5
+ Copilot's answer is length-capped, so a person asks for one register at a time
6
+ and saves each answer into the exchange folder's inbox:
7
+
8
+ inbox/new/<PREFIX>.md|.json|.txt new items for that register
9
+ inbox/updates/<PREFIX>.md|.json|.txt amend, link, unlink and delete on its items
10
+ inbox/<anything>.md|.json|.txt a whole change set, any registers
11
+
12
+ Each file is Copilot's reply as it wrote it; the change set inside is found as
13
+ for any reply (REQ-0004). The files are gathered into one set and carried out by
14
+ ``tl apply`` all or nothing, so half an answer never lands: every new item
15
+ first, each after any new item it links to by label, then every update, then
16
+ the whole sets. A new item is named by a ``label`` and never by a UID — the tool allocates
17
+ the UID when the set is carried out, against the graph as it then stands — so
18
+ two answers drafted apart can never claim the same identifier, and an item in
19
+ one file may link to one created in another as ``$label``.
20
+
21
+ What a file's place says is checked, not assumed: in ``new/SR.md`` every
22
+ operation is a ``new`` in register SR (one that leaves ``register`` out is in
23
+ SR, as the folder says), and in ``updates/SR.md`` every operation names an item
24
+ of SR. A label used twice across the files refuses the lot.
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import json
30
+ from dataclasses import dataclass
31
+ from pathlib import PurePosixPath
32
+
33
+ from .export import prefix_of
34
+ from .reply import ReplyError, change_set
35
+
36
+ #: The exchange folder's inbox, its own subfolders, and where a file goes once it has been applied.
37
+ INBOX, NEW, UPDATES, APPLIED = "inbox", "new", "updates", "applied"
38
+
39
+ #: What a saved reply may be called.
40
+ SUFFIXES = (".md", ".json", ".txt")
41
+
42
+
43
+ class InboxError(ValueError):
44
+ """The inbox does not gather into one change set; nothing was applied."""
45
+
46
+ def __init__(self, problems: list[str]):
47
+ self.problems = list(problems)
48
+ super().__init__("the inbox was not applied — nothing was changed:\n" + "\n".join(f" {p}" for p in self.problems))
49
+
50
+
51
+ @dataclass(frozen=True)
52
+ class Gathered:
53
+ #: The one change set, as tl apply reads it.
54
+ text: str
55
+ #: The inbox files it was gathered from, relative to the inbox, in the order used.
56
+ files: tuple[str, ...]
57
+
58
+
59
+ def _operations(text: str) -> list[dict]:
60
+ value = json.loads(change_set(text))
61
+ ops = value["operations"] if isinstance(value, dict) else value
62
+ return list(ops)
63
+
64
+
65
+ def _kind(path: str) -> tuple[str, str]:
66
+ """``(kind, prefix)`` for an inbox path: new or updates with its register, or a whole set."""
67
+ parts = PurePosixPath(path).parts
68
+ if len(parts) == 2 and parts[0] in (NEW, UPDATES):
69
+ return parts[0], PurePosixPath(parts[1]).stem
70
+ return "", ""
71
+
72
+
73
+ def waiting(paths: list[str]) -> list[str]:
74
+ """The inbox files that wait to be applied: saved replies, not in ``applied/``."""
75
+ def counts(path: str) -> bool:
76
+ parts = PurePosixPath(path).parts
77
+ if PurePosixPath(path).suffix.lower() not in SUFFIXES:
78
+ return False
79
+ return len(parts) == 1 or (len(parts) == 2 and parts[0] in (NEW, UPDATES))
80
+
81
+ return sorted(p for p in paths if counts(p))
82
+
83
+
84
+ def _creators_first(operations: list[dict], problems: list[str]) -> list[dict]:
85
+ """The new operations ordered so each comes after the new items it links to
86
+ by label, the rest left where they were. A label is only usable once the
87
+ item it names exists, and answers saved apart cannot know each other's order.
88
+ A cycle is refused: no order carries it out."""
89
+ new = [op for op in operations if isinstance(op, dict) and op.get("op") == "new"]
90
+ rest = [op for op in operations if not (isinstance(op, dict) and op.get("op") == "new")]
91
+ by_label = {op["label"]: op for op in new if isinstance(op.get("label"), str)}
92
+
93
+ def needs(op: dict) -> list[dict]:
94
+ targets = [l.get("target") for l in op.get("links") or [] if isinstance(l, dict)]
95
+ return [by_label[t[1:]] for t in targets if isinstance(t, str) and t.startswith("$") and t[1:] in by_label]
96
+
97
+ ordered: list[dict] = []
98
+ state: dict[int, str] = {}
99
+
100
+ def visit(op: dict) -> None:
101
+ mark = state.get(id(op))
102
+ if mark == "done":
103
+ return
104
+ if mark == "visiting":
105
+ problems.append(f"new items link to each other in a cycle through {op.get('label')!r}")
106
+ return
107
+ state[id(op)] = "visiting"
108
+ for dep in needs(op):
109
+ visit(dep)
110
+ state[id(op)] = "done"
111
+ ordered.append(op)
112
+
113
+ for op in new:
114
+ visit(op)
115
+ return ordered + rest
116
+
117
+
118
+ def gather(files: dict[str, str], registers: list[str]) -> Gathered:
119
+ """One change set from the inbox ``files`` (path relative to the inbox → text).
120
+
121
+ ``registers`` is the graph's register prefixes in the order the dump lists
122
+ them, which is the order new items are created in."""
123
+ problems: list[str] = []
124
+ rank = {prefix: i for i, prefix in enumerate(registers)}
125
+ new: list[tuple[int, str]] = []
126
+ updates: list[tuple[int, str]] = []
127
+ whole: list[str] = []
128
+ for path in waiting(list(files)):
129
+ kind, prefix = _kind(path)
130
+ if kind and prefix not in rank:
131
+ problems.append(f"{path}: the graph has no register {prefix}")
132
+ elif kind == NEW:
133
+ new.append((rank[prefix], path))
134
+ elif kind == UPDATES:
135
+ updates.append((rank[prefix], path))
136
+ else:
137
+ whole.append(path)
138
+ order = [p for _, p in sorted(new)] + [p for _, p in sorted(updates)] + whole
139
+ if not order and not problems:
140
+ raise InboxError(["the inbox holds no reply to apply"])
141
+
142
+ operations: list[dict] = []
143
+ labels: dict[str, str] = {}
144
+ for path in order:
145
+ try:
146
+ ops = _operations(files[path])
147
+ except ReplyError as exc:
148
+ problems.append(f"{path}: {exc}")
149
+ continue
150
+ kind, prefix = _kind(path)
151
+ for n, op in enumerate(ops, start=1):
152
+ where = f"{path} #{n}"
153
+ if not isinstance(op, dict):
154
+ operations.append(op) # tl apply names it
155
+ continue
156
+ if kind == NEW:
157
+ if op.get("op") != "new":
158
+ problems.append(f"{where}: a file under new/ holds only new items, not {op.get('op')!r}")
159
+ continue
160
+ if "register" not in op:
161
+ op = {**op, "register": prefix}
162
+ elif op["register"] != prefix:
163
+ problems.append(f"{where}: register {op['register']!r} is not {prefix}, the register this file is for")
164
+ continue
165
+ elif kind == UPDATES:
166
+ uid = op.get("uid")
167
+ if op.get("op") == "new":
168
+ problems.append(f"{where}: a new item belongs under new/, not updates/")
169
+ continue
170
+ if isinstance(uid, str) and not uid.startswith("$") and prefix_of(uid) != prefix:
171
+ problems.append(f"{where}: {uid} is not an item of {prefix}, the register this file is for")
172
+ continue
173
+ label = op.get("label") if op.get("op") == "new" else None
174
+ if isinstance(label, str):
175
+ if label in labels:
176
+ problems.append(f"{where}: label {label!r} is already used in {labels[label]}")
177
+ continue
178
+ labels[label] = where
179
+ operations.append(op)
180
+ if not problems:
181
+ operations = _creators_first(operations, problems)
182
+ if problems:
183
+ raise InboxError(problems)
184
+ return Gathered(json.dumps(operations, indent=2, ensure_ascii=False) + "\n", tuple(order))
@@ -0,0 +1,118 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """What an export was taken from (REQ-0003).
4
+
5
+ The folder outlives the working tree that made it, and the change set that comes
6
+ back is only as good as the assistant's idea of which graph it read. A commit
7
+ answers that when there is one. A tree with uncommitted changes, or none under
8
+ version control at all, is still a graph worth handing over — the manifest has to
9
+ say which it was, because the assistant cannot tell.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import re
15
+ import subprocess
16
+ from dataclasses import asdict, dataclass
17
+ from pathlib import Path
18
+
19
+ CLEAN = "clean"
20
+ DIRTY = "uncommitted changes"
21
+ UNTRACKED = "not under version control"
22
+
23
+ #: The words a caller may state the tree in, and what each is written as.
24
+ TREE_WORDS = {"clean": CLEAN, "dirty": DIRTY, "untracked": UNTRACKED}
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class Provenance:
29
+ repository: str
30
+ ref: str
31
+ commit: str
32
+ tree: str
33
+ tool: str
34
+ #: How many of the graph's items the export holds, where the caller named
35
+ #: them — "2 of 7". Empty for an export of every item.
36
+ items: str = ""
37
+
38
+ def lines(self) -> list[str]:
39
+ lines = [
40
+ f"Repository: {self.repository}",
41
+ f"Ref: {self.ref or 'none'}",
42
+ f"Commit: {self.commit or 'none'}",
43
+ f"Working tree: {self.tree}",
44
+ f"Produced by: {self.tool}",
45
+ ]
46
+ if self.items:
47
+ lines.append(f"Items: {self.items}")
48
+ return lines
49
+
50
+ def record(self) -> dict[str, str]:
51
+ """The fields as data; ``items`` only where a selection was made."""
52
+ fields = asdict(self)
53
+ if not self.items:
54
+ del fields["items"]
55
+ return fields
56
+
57
+ @property
58
+ def stem(self) -> str:
59
+ """A folder name stem: the repository and the ref, made safe for a path."""
60
+ base = self.repository.replace("/", "-")
61
+ if self.ref:
62
+ base = f"{base}-{self.ref}"
63
+ return re.sub(r"[^\w.-]", "-", base).strip("-") or "graph"
64
+
65
+
66
+ def _git(root: Path, *args: str) -> str | None:
67
+ try:
68
+ done = subprocess.run(["git", "-C", str(root), *args], capture_output=True, text=True, encoding="utf-8")
69
+ except OSError:
70
+ return None
71
+ return done.stdout.strip() if done.returncode == 0 else None
72
+
73
+
74
+ _REMOTE = re.compile(r"(?:[:/])([^/:]+/[^/]+?)(?:\.git)?/?$")
75
+
76
+
77
+ def _repository_name(remote: str | None, toplevel: Path) -> str:
78
+ if remote:
79
+ match = _REMOTE.search(remote)
80
+ if match:
81
+ return match.group(1)
82
+ return toplevel.name
83
+
84
+
85
+ def provenance_of(root: Path, tool: str) -> Provenance:
86
+ """Read the working tree's state for the graph at ``root``.
87
+
88
+ Cleanliness is judged over the graph's directory, not the whole repository:
89
+ the export is of the graph, and a change elsewhere does not alter it.
90
+ """
91
+ toplevel = _git(root, "rev-parse", "--show-toplevel")
92
+ if not toplevel:
93
+ return Provenance(repository=root.name, ref="", commit="", tree=UNTRACKED, tool=tool)
94
+ repository = _repository_name(_git(root, "remote", "get-url", "origin"), Path(toplevel))
95
+ ref = _git(root, "rev-parse", "--abbrev-ref", "HEAD") or ""
96
+ if ref == "HEAD":
97
+ ref = "detached"
98
+ commit = _git(root, "rev-parse", "HEAD") or ""
99
+ status = _git(root, "status", "--porcelain", "--", str(root))
100
+ tree = DIRTY if status or not commit else CLEAN
101
+ return Provenance(repository=repository, ref=ref, commit=commit, tree=tree, tool=tool)
102
+
103
+
104
+ def stated(tool: str, repository: str | None, ref: str | None, commit: str | None, tree: str | None) -> Provenance:
105
+ """Provenance as the caller states it (REQ-0007). Git is not consulted.
106
+
107
+ A caller that gives any of the four knows better than git — the browser
108
+ holds them from the branch it synced and has no git to ask — so nothing is
109
+ merged with a reading; what is unstated is none, and an unstated tree is not
110
+ under version control.
111
+ """
112
+ return Provenance(
113
+ repository=repository or "graph",
114
+ ref=ref or "",
115
+ commit=commit or "",
116
+ tree=TREE_WORDS[tree] if tree else UNTRACKED,
117
+ tool=tool,
118
+ )
@@ -0,0 +1,130 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """The change set inside Copilot's reply (REQ-0004).
4
+
5
+ Copilot answers in chat: a change set arrives inside prose, in a fenced block,
6
+ copied out of a window by a person. What ``tl apply`` reads is the change set
7
+ alone, so this module finds it and hands it on exactly as Copilot wrote it —
8
+ nothing is repaired, reshaped or re-serialised, because a set mended here would
9
+ be one nobody drafted. Whether each operation is sound is ``tl apply``'s to say.
10
+
11
+ A reply holds a change set when exactly one fenced block, or the whole reply,
12
+ is JSON in a shape the change-set form names: a list of operations, or an object
13
+ whose ``operations`` is that list. Everything else is refused before the tool is
14
+ asked, with a reason a person can take back to Copilot:
15
+
16
+ * no such block — Copilot answered in words, or quoted items instead;
17
+ * more than one — the person must say which, because joining them would apply
18
+ something no one drafted as one set;
19
+ * a fence opened and never closed, or a block that looks like a change set and
20
+ is not JSON — Copilot's answer is length-capped, and a set cut off mid-way
21
+ must never be read as a shorter set.
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ import json
27
+ import re
28
+ from dataclasses import dataclass
29
+
30
+ # A fenced block: three or more backticks or tildes, an optional info string,
31
+ # the body, and a closing fence of the same character at least as long.
32
+ _OPEN = re.compile(r"^[ \t]{0,3}(`{3,}|~{3,})[ \t]*([^\n`]*)$")
33
+
34
+
35
+ class ReplyError(ValueError):
36
+ """The reply holds no single change set; nothing was handed to ``tl``."""
37
+
38
+
39
+ @dataclass(frozen=True)
40
+ class Block:
41
+ #: The line the block's opening fence is on, counted from 1.
42
+ line: int
43
+ info: str
44
+ body: str
45
+ closed: bool
46
+
47
+
48
+ def blocks(text: str) -> list[Block]:
49
+ """Every fenced block in ``text``, in order, including one never closed."""
50
+ lines = text.splitlines()
51
+ found: list[Block] = []
52
+ i = 0
53
+ while i < len(lines):
54
+ opening = _OPEN.match(lines[i])
55
+ if not opening:
56
+ i += 1
57
+ continue
58
+ fence, info = opening.group(1), opening.group(2).strip()
59
+ closing = re.compile(rf"^[ \t]{{0,3}}{re.escape(fence[0])}{{{len(fence)},}}[ \t]*$")
60
+ j = i + 1
61
+ while j < len(lines) and not closing.match(lines[j]):
62
+ j += 1
63
+ closed = j < len(lines)
64
+ found.append(Block(i + 1, info, "\n".join(lines[i + 1 : j]) + "\n", closed))
65
+ i = j + 1
66
+ return found
67
+
68
+
69
+ def _is_change_set(value: object) -> bool:
70
+ if isinstance(value, dict):
71
+ return isinstance(value.get("operations"), list)
72
+ return isinstance(value, list) and bool(value) and all(isinstance(op, dict) and "op" in op for op in value)
73
+
74
+
75
+ def _looks_like_one(body: str) -> bool:
76
+ """A body that is not JSON but plainly meant to be a change set."""
77
+ return '"op"' in body or '"operations"' in body
78
+
79
+
80
+ def change_set(text: str) -> str:
81
+ """The one change set in a Copilot reply, as Copilot wrote it."""
82
+ if not text.strip():
83
+ raise ReplyError("the reply is empty")
84
+ found = blocks(text)
85
+ if not found:
86
+ # A reply that is nothing but the change set, unfenced.
87
+ try:
88
+ value = json.loads(text)
89
+ except json.JSONDecodeError:
90
+ raise ReplyError(
91
+ "the reply holds no fenced block and is not JSON — ask Copilot for its "
92
+ "change set in one ```json block"
93
+ ) from None
94
+ if not _is_change_set(value):
95
+ raise ReplyError("the reply is JSON but not a change set — a list of operations")
96
+ return text
97
+
98
+ sets: list[Block] = []
99
+ problems: list[str] = []
100
+ for block in found:
101
+ if not block.closed:
102
+ problems.append(
103
+ f"the block opened on line {block.line} is never closed — the reply was "
104
+ "probably cut off; ask Copilot for a shorter change set"
105
+ )
106
+ continue
107
+ try:
108
+ value = json.loads(block.body)
109
+ except json.JSONDecodeError as exc:
110
+ if _looks_like_one(block.body):
111
+ problems.append(
112
+ f"the block on line {block.line} is not JSON ({exc.msg}, its line {exc.lineno}) — "
113
+ "if the reply was cut off, ask Copilot for a shorter change set"
114
+ )
115
+ continue
116
+ if _is_change_set(value):
117
+ sets.append(block)
118
+ if problems:
119
+ raise ReplyError("; ".join(problems))
120
+ if not sets:
121
+ raise ReplyError(
122
+ "no block in the reply is a change set — ask Copilot for its change set in one ```json block"
123
+ )
124
+ if len(sets) > 1:
125
+ where = ", ".join(str(b.line) for b in sets)
126
+ raise ReplyError(
127
+ f"the reply holds {len(sets)} change sets (blocks on lines {where}) — "
128
+ "ask Copilot for one, or save the one you mean on its own"
129
+ )
130
+ return sets[0].body
@@ -0,0 +1,88 @@
1
+ # Copyright (c) 2026 Henry J Grech-Cini
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Reaching the tool (REQ-0001).
4
+
5
+ Three things are asked of ``tl`` and nothing else: ``dump`` for the graph,
6
+ ``apply --describe`` for the change-set form an assistant is told to write, and
7
+ ``apply`` to carry out what comes back. The tool is reached through its command,
8
+ not its modules: its command line is the surface it publishes, and it composes a
9
+ graph that declares sources itself, so a composed graph needs nothing here.
10
+
11
+ The command is called in-process — the console entry point the ``throughline``
12
+ distribution declares, which is what ``tl`` on a terminal runs — never as a
13
+ child process. That is what lets this package run where there are no processes:
14
+ Python under Pyodide in a browser tab, beside the folder the person chose.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import io
20
+ import os
21
+ from contextlib import redirect_stderr, redirect_stdout
22
+ from dataclasses import dataclass
23
+ from importlib.metadata import entry_points
24
+ from pathlib import Path
25
+ from typing import Callable
26
+
27
+ CONFIG = "throughline.toml"
28
+
29
+
30
+ class CopilotError(Exception):
31
+ """A failure the user can act on, reported in one line."""
32
+
33
+
34
+ def find_graph(start: str | os.PathLike[str] | None) -> Path:
35
+ """The directory holding ``throughline.toml``.
36
+
37
+ With ``-C``, that directory must be a graph — a wrong path is refused rather
38
+ than searched around, because an export of the wrong graph reads exactly
39
+ like the right one. Without it, the walk upward from the working directory
40
+ is the one ``tl`` itself makes.
41
+ """
42
+ if start is not None:
43
+ root = Path(start).resolve()
44
+ if not (root / CONFIG).is_file():
45
+ raise CopilotError(f"{root} holds no {CONFIG}")
46
+ return root
47
+ here = Path.cwd().resolve()
48
+ for candidate in (here, *here.parents):
49
+ if (candidate / CONFIG).is_file():
50
+ return candidate
51
+ raise CopilotError(f"no {CONFIG} here or above; pass -C <dir>")
52
+
53
+
54
+ def _entry_point() -> Callable[[list[str]], int | None]:
55
+ """``tl``'s own entry point, resolved from the distribution's metadata rather
56
+ than a module path written here."""
57
+ found = [ep for ep in entry_points(group="console_scripts") if ep.name == "tl" and ep.dist and ep.dist.name == "throughline"]
58
+ if not found:
59
+ raise CopilotError("throughline is not installed beside this tool")
60
+ return found[0].load()
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class Done:
65
+ code: int
66
+ stdout: str
67
+ stderr: str
68
+
69
+
70
+ def call(root: Path, args: list[str]) -> Done:
71
+ """Run ``tl -C root ARGS`` in-process and hand back what it did, whatever its exit."""
72
+ main = _entry_point()
73
+ out, err = io.StringIO(), io.StringIO()
74
+ with redirect_stdout(out), redirect_stderr(err):
75
+ try:
76
+ code = main(["-C", str(root), *args])
77
+ except SystemExit as exc:
78
+ code = exc.code if isinstance(exc.code, int) else (0 if exc.code is None else 1)
79
+ return Done(int(code or 0), out.getvalue(), err.getvalue())
80
+
81
+
82
+ def run(root: Path, args: list[str]) -> str:
83
+ """Run the tool and hand back its output, or fail with what it said."""
84
+ done = call(root, args)
85
+ if done.code != 0:
86
+ detail = done.stderr.strip() or done.stdout.strip() or f"exit {done.code}"
87
+ raise CopilotError(f"tl {args[0]} failed — {detail}")
88
+ return done.stdout
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: throughline-ms-copilot
3
+ Version: 0.1.0
4
+ Summary: Hand a throughline requirements graph to Microsoft 365 Copilot as a folder it reads whole — one file per register — and apply the change set it sends back through tl apply. Ships the tl-ms-copilot CLI.
5
+ Author-email: Henry J Grech-Cini <henry.grechcini@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/rhodium-org/throughline-ms-copilot
8
+ Project-URL: Repository, https://github.com/rhodium-org/throughline-ms-copilot
9
+ Project-URL: Issues, https://github.com/rhodium-org/throughline-ms-copilot/issues
10
+ Keywords: requirements,requirements-management,copilot,microsoft-365-copilot,traceability,idd,intent-driven-development,throughline
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Documentation
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: throughline>=3.18.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # throughline-ms-copilot
29
+
30
+ Work on a [throughline](https://github.com/rhodium-org/throughline) requirements
31
+ graph with **Microsoft 365 Copilot**, in an environment where Copilot is the only
32
+ assistant you have: it reads at most fifty files, runs no command and answers
33
+ only in text. `tl-ms-copilot` writes the graph as a folder Copilot reads whole,
34
+ and carries the changes Copilot sends back into the graph as proposals, through
35
+ `tl apply`, all or nothing.
36
+
37
+ ```bash
38
+ pipx install throughline-ms-copilot
39
+ tl-ms-copilot export -C idd ~/OneDrive/graph-exchange # the folder Copilot reads
40
+ # … give Copilot every file in graph-exchange/export/, ask for changes,
41
+ # save each answer into graph-exchange/inbox/ …
42
+ tl-ms-copilot ingest -C idd ~/OneDrive/graph-exchange --dry-run
43
+ tl-ms-copilot ingest -C idd ~/OneDrive/graph-exchange # carried out by tl apply
44
+ tl -C idd check
45
+ ```
46
+
47
+ The graph's content moves only between your computer and GitHub. The package
48
+ runs `tl` in-process and starts no process, so it runs unchanged under Pyodide
49
+ in a browser tab beside the folder you chose — which is how
50
+ [sync.iddn.uk](https://sync.iddn.uk/) offers it on a laptop where nothing can be
51
+ installed.
52
+
53
+ ## The exchange folder
54
+
55
+ ```
56
+ graph-exchange/
57
+ ├── export/ written by `export`, replaced whole each time
58
+ │ ├── manifest.json what the export was true of, and how to answer
59
+ │ ├── INT.json REQ.json TEST.json … one file per register
60
+ │ └── source-<ns>.json the clauses an adopted source lends
61
+ └── inbox/ Copilot's answers, saved by you
62
+ ├── new/REQ.md new items for one register
63
+ ├── updates/REQ.md amend, link, unlink, delete on one register's items
64
+ ├── anything.md a whole change set, any registers
65
+ └── applied/<when>/ where `ingest` moves what it carried out
66
+ ```
67
+
68
+ **Why one file per register.** Copilot's cap counts files, not items. A graph
69
+ holds hundreds of item files but fewer than fifty registers, so one file per
70
+ register is the smallest layout Copilot can read whole. `--wrap md` writes each
71
+ file as Markdown holding one fenced JSON block, for a Copilot that will not read
72
+ `.json` files. `--only UID,…` narrows the export to the items named.
73
+
74
+ **Why changes come back as a change set, not as files.** Copilot's answer is
75
+ length-capped: a rewritten register file cut off half-way would read as the
76
+ deletion of everything after the cut. A change set names only what changes, and
77
+ `tl apply` refuses the whole set if any item it touches changed since the export.
78
+ The manifest carries the form, as `tl apply --describe` states it, and tells
79
+ Copilot to answer in one fenced `json` block.
80
+
81
+ **Why answers are saved by register.** For long work, ask Copilot for one
82
+ register at a time — the new items for REQ, then the changes to REQ's items —
83
+ and save each answer as `inbox/new/REQ.md` or `inbox/updates/REQ.md`. Paste the
84
+ whole answer; the change set is found inside it. `ingest` gathers every file into
85
+ one change set: new items first, each after any new item it links to, then the
86
+ updates, then whole sets. It checks each file holds what its place says, and
87
+ moves what it applied into `inbox/applied/` so nothing is applied twice.
88
+
89
+ **Why there are no ID conflicts.** Copilot never chooses a UID. A new item is
90
+ named by a `label`, and another item in any answer links to it as `$label`;
91
+ `tl` allocates the real UID when the set is carried out, against the graph as it
92
+ then stands.
93
+
94
+ Everything Copilot drafts arrives with origin `ai` and waits as `proposed`: a
95
+ person decides. Decisions — ratifying, withdrawing — are never in a change set.
96
+
97
+ ## Commands
98
+
99
+ | Command | What it does |
100
+ | --- | --- |
101
+ | `export [-C DIR] EXCHANGE [--wrap json\|md] [--only UID,…]` | Writes `EXCHANGE/export/` and creates `EXCHANGE/inbox/new` and `inbox/updates`. |
102
+ | `ingest [-C DIR] EXCHANGE [--dry-run]` | Gathers `EXCHANGE/inbox/` into one change set and has `tl apply` carry it out. |
103
+ | `apply [-C DIR] [REPLY\|-] [--dry-run] [--extract]` | The same for one saved reply. `--extract` prints the change set found and stops. |
104
+
105
+ `export` reads the repository, ref, commit and working-tree state from git;
106
+ `--repository`, `--ref`, `--commit` and `--tree` state them instead, as a host
107
+ with no git — the browser — does.
108
+
109
+ ## Working on it
110
+
111
+ Its requirements live in [`idd/`](idd); see [AGENTS.md](AGENTS.md).
112
+
113
+ ```bash
114
+ python -m venv .venv && . .venv/bin/activate
115
+ pip install -e ".[dev]"
116
+ pytest -q
117
+ tl -C idd check
118
+ ```
119
+
120
+ Apache-2.0. Microsoft 365 Copilot is a product of Microsoft Corporation; this
121
+ project is not affiliated with or endorsed by Microsoft.
@@ -0,0 +1,14 @@
1
+ throughline_ms_copilot/__init__.py,sha256=xltL9fO0_eYjWaHDKfSbyo-sXHXlWG9ThNz4qIoKn98,653
2
+ throughline_ms_copilot/cli.py,sha256=olKpzzlWbxwX9tEYGXFRKCaoX1ntR0_fzMWh3FsBYWc,8812
3
+ throughline_ms_copilot/export.py,sha256=4vP8QWlDX7PDJtGwr2-qmYWG_9AOgZQv62TIL4Qf6ZM,7489
4
+ throughline_ms_copilot/inbox.py,sha256=VGjlExdXmNZrWBIV1PZyfi3bBA_9EYik3zxiMTW9DvI,7839
5
+ throughline_ms_copilot/provenance.py,sha256=JwLwQt0yQEt7wVRRAP3g983-j6UjyS7e0ECw3WbOJU8,4181
6
+ throughline_ms_copilot/reply.py,sha256=yeLrQrdlrueez4bC1YXoDWKM0fgR3cmayi9IQjPWmJM,4987
7
+ throughline_ms_copilot/tool.py,sha256=SPAJar5FVRTKJ5emJ0MGWw3sB6inUXRKtgw891SdGg8,3370
8
+ throughline_ms_copilot-0.1.0.dist-info/licenses/LICENSE,sha256=S9Q_bLmOHM0uFQ0YUCbKL1RzcaY9sOr-e-8N0CDLxCQ,11363
9
+ throughline_ms_copilot-0.1.0.dist-info/licenses/NOTICE,sha256=Seq0avp0av1YnOtqpB8CPKtbTLPQI4VPqP0Q1DgSPrA,692
10
+ throughline_ms_copilot-0.1.0.dist-info/METADATA,sha256=vm2IMniAIPydmkroNFL0mwnuaq4myOwxVSSI-KWKWQc,6028
11
+ throughline_ms_copilot-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
12
+ throughline_ms_copilot-0.1.0.dist-info/entry_points.txt,sha256=MK5PeGEpfqFvL2i89PtTgUp_GJKqCBaduS5qF01cDoo,123
13
+ throughline_ms_copilot-0.1.0.dist-info/top_level.txt,sha256=8yRpy830ou5h3t_2pO3oTvPtTkVKLHt_fOpa1WeESvU,23
14
+ throughline_ms_copilot-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ throughline-ms-copilot = throughline_ms_copilot.cli:main
3
+ tl-ms-copilot = throughline_ms_copilot.cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 The throughline-transform authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,16 @@
1
+ throughline-ms-copilot
2
+ Copyright 2026 Henry J Grech-Cini
3
+ Created by Dr Henry J Grech-Cini (ORCID https://orcid.org/0009-0007-1565-7530).
4
+
5
+ This product includes software developed by Henry J Grech-Cini.
6
+
7
+ Licensed under the Apache License, Version 2.0. See the LICENSE file for the
8
+ full terms.
9
+
10
+ throughline-ms-copilot is a command-line companion for throughline (the `tl`
11
+ CLI). It builds on throughline's published command line; no third-party source
12
+ code was copied. Its export form was first written in throughline-transform
13
+ 0.6.0, by the same author, and moved here.
14
+
15
+ Microsoft 365 Copilot is a product of Microsoft Corporation. This project is
16
+ not affiliated with or endorsed by Microsoft.
@@ -0,0 +1 @@
1
+ throughline_ms_copilot