@mrtdown/core 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (112) hide show
  1. package/dist/cli/commands/create.d.ts +30 -0
  2. package/dist/cli/commands/create.js +189 -0
  3. package/dist/cli/commands/create.js.map +1 -0
  4. package/dist/cli/commands/list.d.ts +6 -0
  5. package/dist/cli/commands/list.js +106 -0
  6. package/dist/cli/commands/list.js.map +1 -0
  7. package/dist/cli/commands/show.d.ts +6 -0
  8. package/dist/cli/commands/show.js +156 -0
  9. package/dist/cli/commands/show.js.map +1 -0
  10. package/dist/cli/commands/validate.d.ts +6 -0
  11. package/dist/cli/commands/validate.js +19 -0
  12. package/dist/cli/commands/validate.js.map +1 -0
  13. package/dist/cli/index.d.ts +2 -0
  14. package/dist/cli/index.js +162 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/index.d.ts +20 -11
  17. package/dist/index.js +20 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/llm/client.d.ts +2 -0
  20. package/dist/llm/client.js +5 -0
  21. package/dist/llm/client.js.map +1 -0
  22. package/dist/llm/common/MemoryStore.d.ts +21 -0
  23. package/dist/llm/common/MemoryStore.js +100 -0
  24. package/dist/llm/common/MemoryStore.js.map +1 -0
  25. package/dist/llm/common/MemoryStore.test.d.ts +1 -0
  26. package/dist/llm/common/MemoryStore.test.js +225 -0
  27. package/dist/llm/common/MemoryStore.test.js.map +1 -0
  28. package/dist/llm/common/formatCurrentState.d.ts +10 -0
  29. package/dist/llm/common/formatCurrentState.js +342 -0
  30. package/dist/llm/common/formatCurrentState.js.map +1 -0
  31. package/dist/llm/common/tool.d.ts +32 -0
  32. package/dist/llm/common/tool.js +6 -0
  33. package/dist/llm/common/tool.js.map +1 -0
  34. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.d.ts +1 -0
  35. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js +433 -0
  36. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js.map +1 -0
  37. package/dist/llm/functions/extractClaimsFromNewEvidence/index.d.ts +18 -0
  38. package/dist/llm/functions/extractClaimsFromNewEvidence/index.js +153 -0
  39. package/dist/llm/functions/extractClaimsFromNewEvidence/index.js.map +1 -0
  40. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.d.ts +1 -0
  41. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js +168 -0
  42. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js.map +1 -0
  43. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.d.ts +19 -0
  44. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js +65 -0
  45. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js.map +1 -0
  46. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.d.ts +21 -0
  47. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js +115 -0
  48. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js.map +1 -0
  49. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.d.ts +24 -0
  50. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js +110 -0
  51. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js.map +1 -0
  52. package/dist/llm/functions/generateIssueTitleAndSlug/index.d.ts +14 -0
  53. package/dist/llm/functions/generateIssueTitleAndSlug/index.js +38 -0
  54. package/dist/llm/functions/generateIssueTitleAndSlug/index.js.map +1 -0
  55. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.d.ts +1 -0
  56. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js +23 -0
  57. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js.map +1 -0
  58. package/dist/llm/functions/translate/index.d.ts +1 -0
  59. package/dist/llm/functions/translate/index.js +59 -0
  60. package/dist/llm/functions/translate/index.js.map +1 -0
  61. package/dist/llm/functions/triageNewEvidence/eval.test.d.ts +1 -0
  62. package/dist/llm/functions/triageNewEvidence/eval.test.js +139 -0
  63. package/dist/llm/functions/triageNewEvidence/eval.test.js.map +1 -0
  64. package/dist/llm/functions/triageNewEvidence/index.d.ts +37 -0
  65. package/dist/llm/functions/triageNewEvidence/index.js +121 -0
  66. package/dist/llm/functions/triageNewEvidence/index.js.map +1 -0
  67. package/dist/llm/functions/triageNewEvidence/prompt.d.ts +1 -0
  68. package/dist/llm/functions/triageNewEvidence/prompt.js +60 -0
  69. package/dist/llm/functions/triageNewEvidence/prompt.js.map +1 -0
  70. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.d.ts +19 -0
  71. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js +65 -0
  72. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js.map +1 -0
  73. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.d.ts +19 -0
  74. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js +37 -0
  75. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js.map +1 -0
  76. package/dist/scripts/ingestViaWebhook.d.ts +1 -0
  77. package/dist/scripts/ingestViaWebhook.js +9 -0
  78. package/dist/scripts/ingestViaWebhook.js.map +1 -0
  79. package/dist/validators/buildContext.d.ts +7 -0
  80. package/dist/validators/buildContext.js +164 -0
  81. package/dist/validators/buildContext.js.map +1 -0
  82. package/dist/validators/index.d.ts +17 -0
  83. package/dist/validators/index.js +58 -0
  84. package/dist/validators/index.js.map +1 -0
  85. package/dist/validators/issue.d.ts +13 -0
  86. package/dist/validators/issue.js +220 -0
  87. package/dist/validators/issue.js.map +1 -0
  88. package/dist/validators/landmark.d.ts +7 -0
  89. package/dist/validators/landmark.js +43 -0
  90. package/dist/validators/landmark.js.map +1 -0
  91. package/dist/validators/line.d.ts +8 -0
  92. package/dist/validators/line.js +87 -0
  93. package/dist/validators/line.js.map +1 -0
  94. package/dist/validators/operator.d.ts +7 -0
  95. package/dist/validators/operator.js +43 -0
  96. package/dist/validators/operator.js.map +1 -0
  97. package/dist/validators/service.d.ts +8 -0
  98. package/dist/validators/service.js +87 -0
  99. package/dist/validators/service.js.map +1 -0
  100. package/dist/validators/station.d.ts +8 -0
  101. package/dist/validators/station.js +93 -0
  102. package/dist/validators/station.js.map +1 -0
  103. package/dist/validators/town.d.ts +7 -0
  104. package/dist/validators/town.js +43 -0
  105. package/dist/validators/town.js.map +1 -0
  106. package/dist/validators/types.d.ts +19 -0
  107. package/dist/validators/types.js +2 -0
  108. package/dist/validators/types.js.map +1 -0
  109. package/dist/validators/utils.d.ts +2 -0
  110. package/dist/validators/utils.js +9 -0
  111. package/dist/validators/utils.js.map +1 -0
  112. package/package.json +11 -7
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env node
2
+ import { join } from 'node:path';
3
+ import { Command } from 'commander';
4
+ import { runCreateIssue, runCreateLandmark, runCreateLine, runCreateOperator, runCreateService, runCreateStation, runCreateTown, } from './commands/create.js';
5
+ import { runList } from './commands/list.js';
6
+ import { runShowIssue } from './commands/show.js';
7
+ import { runValidate } from './commands/validate.js';
8
+ const program = new Command();
9
+ program
10
+ .name('mrtdown-cli')
11
+ .description('CLI for mrtdown-data: create entities and validate data')
12
+ .option('-d, --data-dir <path>', 'Data directory', join(process.cwd(), 'data'));
13
+ program
14
+ .command('validate')
15
+ .description('Validate all data files against schemas')
16
+ .option('--scope <scope>', 'Only validate these entity types (repeatable): town, landmark, operator, station, line, service, issue', (val, prev) => (prev ?? []).concat(val))
17
+ .action((opts) => {
18
+ const dataDir = program.opts().dataDir;
19
+ const scope = opts.scope;
20
+ const code = runValidate({
21
+ dataDir,
22
+ scope: scope?.length
23
+ ? scope
24
+ : undefined,
25
+ });
26
+ process.exit(code);
27
+ });
28
+ program
29
+ .command('show')
30
+ .description('Display the current state of an issue')
31
+ .argument('<issue-id>', 'Issue ID (e.g. 2011-09-20-faulty-cable-led-to-circle-line-disruption)')
32
+ .option('--json', 'Output as JSON')
33
+ .action((issueId, opts) => {
34
+ const dataDir = program.opts().dataDir;
35
+ const code = runShowIssue({
36
+ dataDir,
37
+ issueId,
38
+ json: opts.json,
39
+ });
40
+ process.exit(code);
41
+ });
42
+ const list = program.command('list').description('List entities');
43
+ const listEntities = [
44
+ 'issue',
45
+ 'town',
46
+ 'landmark',
47
+ 'operator',
48
+ 'station',
49
+ 'line',
50
+ 'service',
51
+ ];
52
+ for (const entity of listEntities) {
53
+ list
54
+ .command(entity)
55
+ .description(`List ${entity}s`)
56
+ .option('--json', 'Output as JSON')
57
+ .action((opts) => {
58
+ const dataDir = program.opts().dataDir;
59
+ const code = runList({
60
+ dataDir,
61
+ entity,
62
+ json: opts.json,
63
+ });
64
+ process.exit(code);
65
+ });
66
+ }
67
+ const create = program.command('create').description('Create a new entity');
68
+ create
69
+ .command('issue')
70
+ .description('Create a new issue')
71
+ .requiredOption('--date <YYYY-MM-DD>', 'Issue date')
72
+ .requiredOption('--slug <slug>', 'URL-safe slug for the issue')
73
+ .requiredOption('--title <title>', 'English title')
74
+ .option('--type <type>', 'Issue type: disruption, maintenance, infra', 'disruption')
75
+ .option('--source <source>', 'Title source', 'cli')
76
+ .option('--dry-run', 'Print what would be created without writing')
77
+ .action(async (opts) => {
78
+ const dataDir = program.opts().dataDir;
79
+ const code = await runCreateIssue({ dataDir, dryRun: opts.dryRun }, {
80
+ date: opts.date,
81
+ slug: opts.slug,
82
+ title: opts.title,
83
+ type: opts.type,
84
+ source: opts.source,
85
+ });
86
+ process.exit(code);
87
+ });
88
+ create
89
+ .command('town')
90
+ .description('Create a new town')
91
+ .requiredOption('--id <id>', 'Town ID (e.g. yishun)')
92
+ .requiredOption('--name <name>', 'English name')
93
+ .option('--dry-run', 'Print what would be created without writing')
94
+ .action(async (opts) => {
95
+ const dataDir = program.opts().dataDir;
96
+ const code = await runCreateTown({ dataDir, dryRun: opts.dryRun }, { id: opts.id, name: opts.name });
97
+ process.exit(code);
98
+ });
99
+ create
100
+ .command('landmark')
101
+ .description('Create a new landmark')
102
+ .requiredOption('--id <id>', 'Landmark ID (e.g. northpoint-city)')
103
+ .requiredOption('--name <name>', 'English name')
104
+ .option('--dry-run', 'Print what would be created without writing')
105
+ .action(async (opts) => {
106
+ const dataDir = program.opts().dataDir;
107
+ const code = await runCreateLandmark({ dataDir, dryRun: opts.dryRun }, { id: opts.id, name: opts.name });
108
+ process.exit(code);
109
+ });
110
+ create
111
+ .command('operator')
112
+ .description('Create a new operator')
113
+ .requiredOption('--id <id>', 'Operator ID (e.g. SMRT_TRAINS)')
114
+ .requiredOption('--name <name>', 'English name')
115
+ .requiredOption('--founded-at <date>', 'Founded date (YYYY-MM-DD)')
116
+ .option('--url <url>', 'Operator website URL')
117
+ .option('--dry-run', 'Print what would be created without writing')
118
+ .action(async (opts) => {
119
+ const dataDir = program.opts().dataDir;
120
+ const code = await runCreateOperator({ dataDir, dryRun: opts.dryRun }, {
121
+ id: opts.id,
122
+ name: opts.name,
123
+ foundedAt: opts.foundedAt,
124
+ url: opts.url,
125
+ });
126
+ process.exit(code);
127
+ });
128
+ create
129
+ .command('station')
130
+ .description('Create a station from JSON (--stdin or --file)')
131
+ .option('--stdin', 'Read JSON from stdin')
132
+ .option('--file <path>', 'Read JSON from file')
133
+ .option('--dry-run', 'Print what would be created without writing')
134
+ .action(async (opts) => {
135
+ const dataDir = program.opts().dataDir;
136
+ const code = await runCreateStation({ dataDir, dryRun: opts.dryRun, stdin: opts.stdin }, { file: opts.file });
137
+ process.exit(code);
138
+ });
139
+ create
140
+ .command('line')
141
+ .description('Create a line from JSON (--stdin or --file)')
142
+ .option('--stdin', 'Read JSON from stdin')
143
+ .option('--file <path>', 'Read JSON from file')
144
+ .option('--dry-run', 'Print what would be created without writing')
145
+ .action(async (opts) => {
146
+ const dataDir = program.opts().dataDir;
147
+ const code = await runCreateLine({ dataDir, dryRun: opts.dryRun, stdin: opts.stdin }, { file: opts.file });
148
+ process.exit(code);
149
+ });
150
+ create
151
+ .command('service')
152
+ .description('Create a service from JSON (--stdin or --file)')
153
+ .option('--stdin', 'Read JSON from stdin')
154
+ .option('--file <path>', 'Read JSON from file')
155
+ .option('--dry-run', 'Print what would be created without writing')
156
+ .action(async (opts) => {
157
+ const dataDir = program.opts().dataDir;
158
+ const code = await runCreateService({ dataDir, dryRun: opts.dryRun, stdin: opts.stdin }, { file: opts.file });
159
+ process.exit(code);
160
+ });
161
+ program.parse();
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CACL,uBAAuB,EACvB,gBAAgB,EAChB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAC5B,CAAC;AAEJ,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,yCAAyC,CAAC;KACtD,MAAM,CACL,iBAAiB,EACjB,wGAAwG,EACxG,CAAC,GAAW,EAAE,IAA0B,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MA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AACrB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { join } from 'node:path';\nimport { Command } from 'commander';\nimport {\n runCreateIssue,\n runCreateLandmark,\n runCreateLine,\n runCreateOperator,\n runCreateService,\n runCreateStation,\n runCreateTown,\n} from './commands/create.js';\nimport { runList } from './commands/list.js';\nimport { runShowIssue } from './commands/show.js';\nimport { runValidate } from './commands/validate.js';\n\nconst program = new Command();\n\nprogram\n .name('mrtdown-cli')\n .description('CLI for mrtdown-data: create entities and validate data')\n .option(\n '-d, --data-dir <path>',\n 'Data directory',\n join(process.cwd(), 'data'),\n );\n\nprogram\n .command('validate')\n .description('Validate all data files against schemas')\n .option(\n '--scope <scope>',\n 'Only validate these entity types (repeatable): town, landmark, operator, station, line, service, issue',\n (val: string, prev: string[] | undefined) => (prev ?? []).concat(val),\n )\n .action((opts) => {\n const dataDir = program.opts().dataDir;\n const scope = opts.scope as string[] | undefined;\n const code = runValidate({\n dataDir,\n scope: scope?.length\n ? (scope as import('../../src/validators/index.js').ValidationScope[])\n : undefined,\n });\n process.exit(code);\n });\n\nprogram\n .command('show')\n .description('Display the current state of an issue')\n .argument('<issue-id>', 'Issue ID (e.g. 2011-09-20-faulty-cable-led-to-circle-line-disruption)')\n .option('--json', 'Output as JSON')\n .action((issueId, opts) => {\n const dataDir = program.opts().dataDir;\n const code = runShowIssue({\n dataDir,\n issueId,\n json: opts.json,\n });\n process.exit(code);\n });\n\nconst list = program.command('list').description('List entities');\n\nconst listEntities = [\n 'issue',\n 'town',\n 'landmark',\n 'operator',\n 'station',\n 'line',\n 'service',\n] as const;\n\nfor (const entity of listEntities) {\n list\n .command(entity)\n .description(`List ${entity}s`)\n .option('--json', 'Output as JSON')\n .action((opts) => {\n const dataDir = program.opts().dataDir;\n const code = runList({\n dataDir,\n entity,\n json: opts.json,\n });\n process.exit(code);\n });\n}\n\nconst create = program.command('create').description('Create a new entity');\n\ncreate\n .command('issue')\n .description('Create a new issue')\n .requiredOption('--date <YYYY-MM-DD>', 'Issue date')\n .requiredOption('--slug <slug>', 'URL-safe slug for the issue')\n .requiredOption('--title <title>', 'English title')\n .option(\n '--type <type>',\n 'Issue type: disruption, maintenance, infra',\n 'disruption',\n )\n .option('--source <source>', 'Title source', 'cli')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateIssue(\n { dataDir, dryRun: opts.dryRun },\n {\n date: opts.date,\n slug: opts.slug,\n title: opts.title,\n type: opts.type,\n source: opts.source,\n },\n );\n process.exit(code);\n });\n\ncreate\n .command('town')\n .description('Create a new town')\n .requiredOption('--id <id>', 'Town ID (e.g. yishun)')\n .requiredOption('--name <name>', 'English name')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateTown(\n { dataDir, dryRun: opts.dryRun },\n { id: opts.id, name: opts.name },\n );\n process.exit(code);\n });\n\ncreate\n .command('landmark')\n .description('Create a new landmark')\n .requiredOption('--id <id>', 'Landmark ID (e.g. northpoint-city)')\n .requiredOption('--name <name>', 'English name')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateLandmark(\n { dataDir, dryRun: opts.dryRun },\n { id: opts.id, name: opts.name },\n );\n process.exit(code);\n });\n\ncreate\n .command('operator')\n .description('Create a new operator')\n .requiredOption('--id <id>', 'Operator ID (e.g. SMRT_TRAINS)')\n .requiredOption('--name <name>', 'English name')\n .requiredOption('--founded-at <date>', 'Founded date (YYYY-MM-DD)')\n .option('--url <url>', 'Operator website URL')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateOperator(\n { dataDir, dryRun: opts.dryRun },\n {\n id: opts.id,\n name: opts.name,\n foundedAt: opts.foundedAt,\n url: opts.url,\n },\n );\n process.exit(code);\n });\n\ncreate\n .command('station')\n .description('Create a station from JSON (--stdin or --file)')\n .option('--stdin', 'Read JSON from stdin')\n .option('--file <path>', 'Read JSON from file')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateStation(\n { dataDir, dryRun: opts.dryRun, stdin: opts.stdin },\n { file: opts.file },\n );\n process.exit(code);\n });\n\ncreate\n .command('line')\n .description('Create a line from JSON (--stdin or --file)')\n .option('--stdin', 'Read JSON from stdin')\n .option('--file <path>', 'Read JSON from file')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateLine(\n { dataDir, dryRun: opts.dryRun, stdin: opts.stdin },\n { file: opts.file },\n );\n process.exit(code);\n });\n\ncreate\n .command('service')\n .description('Create a service from JSON (--stdin or --file)')\n .option('--stdin', 'Read JSON from stdin')\n .option('--file <path>', 'Read JSON from file')\n .option('--dry-run', 'Print what would be created without writing')\n .action(async (opts) => {\n const dataDir = program.opts().dataDir;\n const code = await runCreateService(\n { dataDir, dryRun: opts.dryRun, stdin: opts.stdin },\n { file: opts.file },\n );\n process.exit(code);\n });\n\nprogram.parse();\n"]}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,25 @@
1
1
  export { FileStore } from '#repo/common/FileStore.js';
2
2
  export { MRTDownRepository } from '#repo/MRTDownRepository.js';
3
- export { type IssueBundle, IssueBundleSchema, } from '#schema/issue/bundle.js';
4
- export { type CauseDisruption, CauseDisruptionSchema, type CauseInfra, CauseInfraSchema, type CauseMaintenance, CauseMaintenanceSchema, type CauseSubtype, CauseSubtypeSchema, } from '#schema/issue/cause.js';
5
- export { type AffectedEntity, type AffectedEntityFacility, AffectedEntityFacilitySchema, AffectedEntitySchema, type AffectedEntityService, AffectedEntityServiceSchema, type EntityImpactState, EntityImpactStateSchema, } from '#schema/issue/entity.js';
6
- export { type Evidence, EvidenceSchema, } from '#schema/issue/evidence.js';
7
- export { type FacilityEffect, FacilityEffectSchema, } from '#schema/issue/facilityEffect.js';
8
- export { type ImpactEvent, ImpactEventSchema, } from '#schema/issue/impactEvent.js';
9
- export { type Issue, IssueSchema } from '#schema/issue/issue.js';
10
- export { type IssueType, IssueTypeSchema, } from '#schema/issue/issueType.js';
11
- export { type Period, PeriodSchema, } from '#schema/issue/period.js';
12
- export { type ServiceEffect, ServiceEffectSchema, } from '#schema/issue/serviceEffect.js';
13
- export { type ServiceScope, ServiceScopeSchema, } from '#schema/issue/serviceScope.js';
3
+ export * from '#schema/common.js';
4
+ export * from '#schema/issue/bundle.js';
5
+ export * from '#schema/issue/cause.js';
6
+ export * from '#schema/issue/claim.js';
7
+ export * from '#schema/issue/entity.js';
8
+ export * from '#schema/issue/evidence.js';
9
+ export * from '#schema/issue/facilityEffect.js';
10
+ export * from '#schema/issue/id.js';
11
+ export * from '#schema/issue/impactEvent.js';
12
+ export * from '#schema/issue/issue.js';
13
+ export * from '#schema/issue/issueType.js';
14
+ export * from '#schema/issue/period.js';
15
+ export * from '#schema/issue/serviceEffect.js';
16
+ export * from '#schema/issue/serviceScope.js';
17
+ export * from '#schema/Landmark.js';
18
+ export * from '#schema/Line.js';
19
+ export * from '#schema/Operator.js';
20
+ export * from '#schema/Service.js';
21
+ export * from '#schema/Station.js';
22
+ export * from '#schema/Town.js';
14
23
  export { FileWriteStore } from '#write/common/FileWriteStore.js';
15
24
  export { IdGenerator } from '#write/id/IdGenerator.js';
16
25
  export { MRTDownWriter } from '#write/MRTDownWriter.js';
package/dist/index.js CHANGED
@@ -1,16 +1,25 @@
1
1
  export { FileStore } from '#repo/common/FileStore.js';
2
2
  export { MRTDownRepository } from '#repo/MRTDownRepository.js';
3
- export { IssueBundleSchema, } from '#schema/issue/bundle.js';
4
- export { CauseDisruptionSchema, CauseInfraSchema, CauseMaintenanceSchema, CauseSubtypeSchema, } from '#schema/issue/cause.js';
5
- export { AffectedEntityFacilitySchema, AffectedEntitySchema, AffectedEntityServiceSchema, EntityImpactStateSchema, } from '#schema/issue/entity.js';
6
- export { EvidenceSchema, } from '#schema/issue/evidence.js';
7
- export { FacilityEffectSchema, } from '#schema/issue/facilityEffect.js';
8
- export { ImpactEventSchema, } from '#schema/issue/impactEvent.js';
9
- export { IssueSchema } from '#schema/issue/issue.js';
10
- export { IssueTypeSchema, } from '#schema/issue/issueType.js';
11
- export { PeriodSchema, } from '#schema/issue/period.js';
12
- export { ServiceEffectSchema, } from '#schema/issue/serviceEffect.js';
13
- export { ServiceScopeSchema, } from '#schema/issue/serviceScope.js';
3
+ export * from '#schema/common.js';
4
+ export * from '#schema/issue/bundle.js';
5
+ export * from '#schema/issue/cause.js';
6
+ export * from '#schema/issue/claim.js';
7
+ export * from '#schema/issue/entity.js';
8
+ export * from '#schema/issue/evidence.js';
9
+ export * from '#schema/issue/facilityEffect.js';
10
+ export * from '#schema/issue/id.js';
11
+ export * from '#schema/issue/impactEvent.js';
12
+ export * from '#schema/issue/issue.js';
13
+ export * from '#schema/issue/issueType.js';
14
+ export * from '#schema/issue/period.js';
15
+ export * from '#schema/issue/serviceEffect.js';
16
+ export * from '#schema/issue/serviceScope.js';
17
+ export * from '#schema/Landmark.js';
18
+ export * from '#schema/Line.js';
19
+ export * from '#schema/Operator.js';
20
+ export * from '#schema/Service.js';
21
+ export * from '#schema/Station.js';
22
+ export * from '#schema/Town.js';
14
23
  export { FileWriteStore } from '#write/common/FileWriteStore.js';
15
24
  export { IdGenerator } from '#write/id/IdGenerator.js';
16
25
  export { MRTDownWriter } from '#write/MRTDownWriter.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAEL,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,qBAAqB,EAErB,gBAAgB,EAEhB,sBAAsB,EAEtB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,4BAA4B,EAC5B,oBAAoB,EAEpB,2BAA2B,EAE3B,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAEL,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { FileStore } from '#repo/common/FileStore.js';\nexport { MRTDownRepository } from '#repo/MRTDownRepository.js';\nexport {\n type IssueBundle,\n IssueBundleSchema,\n} from '#schema/issue/bundle.js';\nexport {\n type CauseDisruption,\n CauseDisruptionSchema,\n type CauseInfra,\n CauseInfraSchema,\n type CauseMaintenance,\n CauseMaintenanceSchema,\n type CauseSubtype,\n CauseSubtypeSchema,\n} from '#schema/issue/cause.js';\nexport {\n type AffectedEntity,\n type AffectedEntityFacility,\n AffectedEntityFacilitySchema,\n AffectedEntitySchema,\n type AffectedEntityService,\n AffectedEntityServiceSchema,\n type EntityImpactState,\n EntityImpactStateSchema,\n} from '#schema/issue/entity.js';\nexport {\n type Evidence,\n EvidenceSchema,\n} from '#schema/issue/evidence.js';\nexport {\n type FacilityEffect,\n FacilityEffectSchema,\n} from '#schema/issue/facilityEffect.js';\nexport {\n type ImpactEvent,\n ImpactEventSchema,\n} from '#schema/issue/impactEvent.js';\nexport { type Issue, IssueSchema } from '#schema/issue/issue.js';\nexport {\n type IssueType,\n IssueTypeSchema,\n} from '#schema/issue/issueType.js';\nexport {\n type Period,\n PeriodSchema,\n} from '#schema/issue/period.js';\nexport {\n type ServiceEffect,\n ServiceEffectSchema,\n} from '#schema/issue/serviceEffect.js';\nexport {\n type ServiceScope,\n ServiceScopeSchema,\n} from '#schema/issue/serviceScope.js';\nexport { FileWriteStore } from '#write/common/FileWriteStore.js';\nexport { IdGenerator } from '#write/id/IdGenerator.js';\nexport { MRTDownWriter } from '#write/MRTDownWriter.js';\nexport { normalizeRecurringPeriod } from './helpers/normalizeRecurringPeriod.js';\nexport { resolvePeriods } from './helpers/resolvePeriods.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { FileStore } from '#repo/common/FileStore.js';\nexport { MRTDownRepository } from '#repo/MRTDownRepository.js';\n\nexport * from '#schema/common.js';\nexport * from '#schema/issue/bundle.js';\nexport * from '#schema/issue/cause.js';\nexport * from '#schema/issue/claim.js';\nexport * from '#schema/issue/entity.js';\nexport * from '#schema/issue/evidence.js';\nexport * from '#schema/issue/facilityEffect.js';\nexport * from '#schema/issue/id.js';\nexport * from '#schema/issue/impactEvent.js';\nexport * from '#schema/issue/issue.js';\nexport * from '#schema/issue/issueType.js';\nexport * from '#schema/issue/period.js';\nexport * from '#schema/issue/serviceEffect.js';\nexport * from '#schema/issue/serviceScope.js';\nexport * from '#schema/Landmark.js';\nexport * from '#schema/Line.js';\nexport * from '#schema/Operator.js';\nexport * from '#schema/Service.js';\nexport * from '#schema/Station.js';\nexport * from '#schema/Town.js';\n\nexport { FileWriteStore } from '#write/common/FileWriteStore.js';\nexport { IdGenerator } from '#write/id/IdGenerator.js';\nexport { MRTDownWriter } from '#write/MRTDownWriter.js';\nexport { normalizeRecurringPeriod } from './helpers/normalizeRecurringPeriod.js';\nexport { resolvePeriods } from './helpers/resolvePeriods.js';\n"]}
@@ -0,0 +1,2 @@
1
+ import OpenAI from 'openai';
2
+ export declare const openAiClient: OpenAI;
@@ -0,0 +1,5 @@
1
+ import OpenAI from 'openai';
2
+ export const openAiClient = new OpenAI({
3
+ apiKey: process.env.OPENAI_AI_KEY,
4
+ });
5
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"/","sources":["llm/client.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;CAClC,CAAC,CAAC","sourcesContent":["import OpenAI from 'openai';\n\nexport const openAiClient = new OpenAI({\n apiKey: process.env.OPENAI_AI_KEY,\n});\n"]}
@@ -0,0 +1,21 @@
1
+ import type { IStore } from '#repo/common/store.js';
2
+ import type { IWriteStore } from '#write/common/store.js';
3
+ export declare class MemoryStore implements IStore, IWriteStore {
4
+ private readonly files;
5
+ private readonly dirs;
6
+ constructor(seed?: {
7
+ files?: Record<string, string>;
8
+ });
9
+ private toStorePath;
10
+ exists(path: string): boolean;
11
+ readText(path: string): string;
12
+ readJson<T>(path: string): T;
13
+ listDir(path: string): string[];
14
+ ensureDir(path: string): void;
15
+ private addChild;
16
+ writeText(path: string, text: string): void;
17
+ writeJson(path: string, json: unknown): void;
18
+ appendText(path: string, text: string): void;
19
+ delete(path: string): void;
20
+ dumpFiles(): Record<string, string>;
21
+ }
@@ -0,0 +1,100 @@
1
+ import { basename, dirname, normalize } from 'node:path';
2
+ export class MemoryStore {
3
+ files = new Map();
4
+ dirs = new Map();
5
+ constructor(seed) {
6
+ // Root dir
7
+ this.dirs.set('', new Set());
8
+ if (seed?.files) {
9
+ for (const [path, text] of Object.entries(seed.files)) {
10
+ this.writeText(path, text);
11
+ }
12
+ }
13
+ }
14
+ // --------- IStore ---------
15
+ toStorePath(path) {
16
+ const p = normalize(path);
17
+ return p === '.' ? '' : p;
18
+ }
19
+ exists(path) {
20
+ const p = this.toStorePath(path);
21
+ return this.files.has(p) || this.dirs.has(p);
22
+ }
23
+ readText(path) {
24
+ const p = this.toStorePath(path);
25
+ const v = this.files.get(p);
26
+ if (v == null) {
27
+ throw new Error(`MemoryStore: File not found: ${path}`);
28
+ }
29
+ return v;
30
+ }
31
+ readJson(path) {
32
+ return JSON.parse(this.readText(path));
33
+ }
34
+ listDir(path) {
35
+ const p = this.toStorePath(path);
36
+ const children = this.dirs.get(p);
37
+ if (children == null) {
38
+ throw new Error(`MemoryStore: Directory not found: ${path}`);
39
+ }
40
+ return Array.from(children.values()).sort();
41
+ }
42
+ // --------- IWriteStore ---------
43
+ ensureDir(path) {
44
+ const p = this.toStorePath(path);
45
+ if (this.dirs.has(p)) {
46
+ return;
47
+ }
48
+ // Ensure parents (dirname returns '.' for root, treat as '')
49
+ const rawParent = dirname(p === '' ? '.' : p);
50
+ const parent = rawParent === '.' ? '' : rawParent;
51
+ if (parent !== '') {
52
+ this.ensureDir(parent);
53
+ }
54
+ // Create this directory
55
+ this.dirs.set(p, new Set());
56
+ // Register in parent (including root when parent is '')
57
+ this.addChild(parent, basename(p));
58
+ }
59
+ addChild(dir, child) {
60
+ const d = this.toStorePath(dir);
61
+ const set = this.dirs.get(d);
62
+ if (set == null) {
63
+ this.ensureDir(d);
64
+ this.addChild(d, child);
65
+ return;
66
+ }
67
+ set.add(child);
68
+ }
69
+ writeText(path, text) {
70
+ const p = this.toStorePath(path);
71
+ this.ensureDir(dirname(p));
72
+ this.addChild(dirname(p), basename(p));
73
+ this.files.set(p, text);
74
+ }
75
+ writeJson(path, json) {
76
+ this.writeText(path, JSON.stringify(json));
77
+ }
78
+ appendText(path, text) {
79
+ const p = this.toStorePath(path);
80
+ this.ensureDir(dirname(p));
81
+ this.addChild(dirname(p), basename(p));
82
+ const prevContent = this.files.get(p) ?? '';
83
+ this.files.set(p, prevContent + text);
84
+ }
85
+ delete(path) {
86
+ const p = this.toStorePath(path);
87
+ this.files.delete(p);
88
+ this.dirs.delete(p);
89
+ this.dirs.delete(path);
90
+ }
91
+ // Debug helpers
92
+ dumpFiles() {
93
+ const result = {};
94
+ for (const [path, text] of this.files.entries()) {
95
+ result[path] = text;
96
+ }
97
+ return result;
98
+ }
99
+ }
100
+ //# sourceMappingURL=MemoryStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryStore.js","sourceRoot":"/","sources":["llm/common/MemoryStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAIzD,MAAM,OAAO,WAAW;IACL,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,IAAI,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEvD,YAAY,IAAyC;QACnD,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAE7B,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;YAChB,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IAED,6BAA6B;IACrB,WAAW,CAAC,IAAY;QAC9B,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1B,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,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,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,gBAAgB;IAChB,SAAS;QACP,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAChD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { basename, dirname, normalize } from 'node:path';\nimport type { IStore } from '#repo/common/store.js';\nimport type { IWriteStore } from '#write/common/store.js';\n\nexport class MemoryStore implements IStore, IWriteStore {\n private readonly files = new Map<string, string>();\n private readonly dirs = new Map<string, Set<string>>();\n\n constructor(seed?: { files?: Record<string, string> }) {\n // Root dir\n this.dirs.set('', new Set());\n\n if (seed?.files) {\n for (const [path, text] of Object.entries(seed.files)) {\n this.writeText(path, text);\n }\n }\n }\n\n // --------- IStore ---------\n private toStorePath(path: string): string {\n const p = normalize(path);\n return p === '.' ? '' : p;\n }\n\n exists(path: string): boolean {\n const p = this.toStorePath(path);\n return this.files.has(p) || this.dirs.has(p);\n }\n\n readText(path: string): string {\n const p = this.toStorePath(path);\n const v = this.files.get(p);\n if (v == null) {\n throw new Error(`MemoryStore: File not found: ${path}`);\n }\n return v;\n }\n\n readJson<T>(path: string): T {\n return JSON.parse(this.readText(path));\n }\n\n listDir(path: string): string[] {\n const p = this.toStorePath(path);\n const children = this.dirs.get(p);\n if (children == null) {\n throw new Error(`MemoryStore: Directory not found: ${path}`);\n }\n return Array.from(children.values()).sort();\n }\n\n // --------- IWriteStore ---------\n ensureDir(path: string): void {\n const p = this.toStorePath(path);\n if (this.dirs.has(p)) {\n return;\n }\n\n // Ensure parents (dirname returns '.' for root, treat as '')\n const rawParent = dirname(p === '' ? '.' : p);\n const parent = rawParent === '.' ? '' : rawParent;\n if (parent !== '') {\n this.ensureDir(parent);\n }\n\n // Create this directory\n this.dirs.set(p, new Set());\n\n // Register in parent (including root when parent is '')\n this.addChild(parent, basename(p));\n }\n\n private addChild(dir: string, child: string): void {\n const d = this.toStorePath(dir);\n const set = this.dirs.get(d);\n if (set == null) {\n this.ensureDir(d);\n this.addChild(d, child);\n return;\n }\n set.add(child);\n }\n\n writeText(path: string, text: string): void {\n const p = this.toStorePath(path);\n this.ensureDir(dirname(p));\n this.addChild(dirname(p), basename(p));\n this.files.set(p, text);\n }\n\n writeJson(path: string, json: unknown): void {\n this.writeText(path, JSON.stringify(json));\n }\n\n appendText(path: string, text: string): void {\n const p = this.toStorePath(path);\n this.ensureDir(dirname(p));\n this.addChild(dirname(p), basename(p));\n const prevContent = this.files.get(p) ?? '';\n this.files.set(p, prevContent + text);\n }\n\n delete(path: string): void {\n const p = this.toStorePath(path);\n this.files.delete(p);\n this.dirs.delete(p);\n this.dirs.delete(path);\n }\n\n // Debug helpers\n dumpFiles(): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [path, text] of this.files.entries()) {\n result[path] = text;\n }\n return result;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};