@mrtdown/core 2.0.0-alpha.4 → 2.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -27
- package/dist/index.js +20 -27
- package/dist/index.js.map +1 -1
- package/dist/schema/Landmark.js.map +1 -1
- package/dist/schema/Line.js.map +1 -1
- package/dist/schema/Operator.js.map +1 -1
- package/dist/schema/Service.js.map +1 -1
- package/dist/schema/Station.js.map +1 -1
- package/dist/schema/Town.js.map +1 -1
- package/dist/schema/common.js.map +1 -1
- package/dist/schema/issue/bundle.js.map +1 -1
- package/dist/schema/issue/cause.js.map +1 -1
- package/dist/schema/issue/claim.js.map +1 -1
- package/dist/schema/issue/entity.js.map +1 -1
- package/dist/schema/issue/evidence.js +1 -1
- package/dist/schema/issue/evidence.js.map +1 -1
- package/dist/schema/issue/facilityEffect.js.map +1 -1
- package/dist/schema/issue/id.js.map +1 -1
- package/dist/schema/issue/impactEvent.js.map +1 -1
- package/dist/schema/issue/issue.js +1 -1
- package/dist/schema/issue/issue.js.map +1 -1
- package/dist/schema/issue/issueType.js.map +1 -1
- package/dist/schema/issue/period.js.map +1 -1
- package/dist/schema/issue/serviceEffect.js.map +1 -1
- package/dist/schema/issue/serviceScope.js.map +1 -1
- package/package.json +19 -53
- package/README.md +0 -107
- package/dist/cli/commands/create.d.ts +0 -30
- package/dist/cli/commands/create.js +0 -189
- package/dist/cli/commands/create.js.map +0 -1
- package/dist/cli/commands/list.d.ts +0 -6
- package/dist/cli/commands/list.js +0 -106
- package/dist/cli/commands/list.js.map +0 -1
- package/dist/cli/commands/show.d.ts +0 -6
- package/dist/cli/commands/show.js +0 -156
- package/dist/cli/commands/show.js.map +0 -1
- package/dist/cli/commands/validate.d.ts +0 -6
- package/dist/cli/commands/validate.js +0 -19
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -162
- package/dist/cli/index.js.map +0 -1
- package/dist/constants.d.ts +0 -10
- package/dist/constants.js +0 -11
- package/dist/constants.js.map +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.d.ts +0 -2
- package/dist/helpers/calculateDurationWithinServiceHours.js +0 -13
- package/dist/helpers/calculateDurationWithinServiceHours.js.map +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.test.d.ts +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.test.js +0 -83
- package/dist/helpers/calculateDurationWithinServiceHours.test.js.map +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.d.ts +0 -21
- package/dist/helpers/computeImpactFromEvidenceClaims.js +0 -293
- package/dist/helpers/computeImpactFromEvidenceClaims.js.map +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.test.d.ts +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.test.js +0 -544
- package/dist/helpers/computeImpactFromEvidenceClaims.test.js.map +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.d.ts +0 -2
- package/dist/helpers/computeStartOfDaysWithinInterval.js +0 -15
- package/dist/helpers/computeStartOfDaysWithinInterval.js.map +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.test.d.ts +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.test.js +0 -126
- package/dist/helpers/computeStartOfDaysWithinInterval.test.js.map +0 -1
- package/dist/helpers/estimateOpenAICost.d.ts +0 -40
- package/dist/helpers/estimateOpenAICost.js +0 -55
- package/dist/helpers/estimateOpenAICost.js.map +0 -1
- package/dist/helpers/keyForAffectedEntity.d.ts +0 -7
- package/dist/helpers/keyForAffectedEntity.js +0 -14
- package/dist/helpers/keyForAffectedEntity.js.map +0 -1
- package/dist/helpers/normalizeRecurringPeriod.d.ts +0 -7
- package/dist/helpers/normalizeRecurringPeriod.js +0 -118
- package/dist/helpers/normalizeRecurringPeriod.js.map +0 -1
- package/dist/helpers/normalizeRecurringPeriod.test.d.ts +0 -1
- package/dist/helpers/normalizeRecurringPeriod.test.js +0 -93
- package/dist/helpers/normalizeRecurringPeriod.test.js.map +0 -1
- package/dist/helpers/resolvePeriods.d.ts +0 -224
- package/dist/helpers/resolvePeriods.js +0 -207
- package/dist/helpers/resolvePeriods.js.map +0 -1
- package/dist/helpers/resolvePeriods.test.d.ts +0 -1
- package/dist/helpers/resolvePeriods.test.js +0 -239
- package/dist/helpers/resolvePeriods.test.js.map +0 -1
- package/dist/helpers/splitIntervalByServiceHours.d.ts +0 -2
- package/dist/helpers/splitIntervalByServiceHours.js +0 -30
- package/dist/helpers/splitIntervalByServiceHours.js.map +0 -1
- package/dist/helpers/splitIntervalByServiceHours.test.d.ts +0 -1
- package/dist/helpers/splitIntervalByServiceHours.test.js +0 -152
- package/dist/helpers/splitIntervalByServiceHours.test.js.map +0 -1
- package/dist/helpers/sumIntervalDuration.d.ts +0 -2
- package/dist/helpers/sumIntervalDuration.js +0 -9
- package/dist/helpers/sumIntervalDuration.js.map +0 -1
- package/dist/llm/client.d.ts +0 -2
- package/dist/llm/client.js +0 -5
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/common/MemoryStore.d.ts +0 -21
- package/dist/llm/common/MemoryStore.js +0 -100
- package/dist/llm/common/MemoryStore.js.map +0 -1
- package/dist/llm/common/MemoryStore.test.d.ts +0 -1
- package/dist/llm/common/MemoryStore.test.js +0 -225
- package/dist/llm/common/MemoryStore.test.js.map +0 -1
- package/dist/llm/common/formatCurrentState.d.ts +0 -10
- package/dist/llm/common/formatCurrentState.js +0 -342
- package/dist/llm/common/formatCurrentState.js.map +0 -1
- package/dist/llm/common/tool.d.ts +0 -32
- package/dist/llm/common/tool.js +0 -6
- package/dist/llm/common/tool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.d.ts +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js +0 -433
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.d.ts +0 -18
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.js +0 -153
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.d.ts +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js +0 -168
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.d.ts +0 -19
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js +0 -65
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.d.ts +0 -21
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js +0 -115
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.d.ts +0 -24
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js +0 -110
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js.map +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/index.d.ts +0 -14
- package/dist/llm/functions/generateIssueTitleAndSlug/index.js +0 -38
- package/dist/llm/functions/generateIssueTitleAndSlug/index.js.map +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.d.ts +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js +0 -23
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js.map +0 -1
- package/dist/llm/functions/translate/index.d.ts +0 -1
- package/dist/llm/functions/translate/index.js +0 -59
- package/dist/llm/functions/translate/index.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/eval.test.d.ts +0 -1
- package/dist/llm/functions/triageNewEvidence/eval.test.js +0 -139
- package/dist/llm/functions/triageNewEvidence/eval.test.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/index.d.ts +0 -37
- package/dist/llm/functions/triageNewEvidence/index.js +0 -121
- package/dist/llm/functions/triageNewEvidence/index.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/prompt.d.ts +0 -1
- package/dist/llm/functions/triageNewEvidence/prompt.js +0 -60
- package/dist/llm/functions/triageNewEvidence/prompt.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.d.ts +0 -19
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js +0 -65
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.d.ts +0 -19
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js +0 -37
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js.map +0 -1
- package/dist/repo/MRTDownRepository.d.ts +0 -23
- package/dist/repo/MRTDownRepository.js +0 -28
- package/dist/repo/MRTDownRepository.js.map +0 -1
- package/dist/repo/common/FileStore.d.ts +0 -12
- package/dist/repo/common/FileStore.js +0 -27
- package/dist/repo/common/FileStore.js.map +0 -1
- package/dist/repo/common/StandardRepository.d.ts +0 -32
- package/dist/repo/common/StandardRepository.js +0 -58
- package/dist/repo/common/StandardRepository.js.map +0 -1
- package/dist/repo/common/store.d.ts +0 -29
- package/dist/repo/common/store.js +0 -2
- package/dist/repo/common/store.js.map +0 -1
- package/dist/repo/issue/IssueRepository.d.ts +0 -36
- package/dist/repo/issue/IssueRepository.js +0 -177
- package/dist/repo/issue/IssueRepository.js.map +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.d.ts +0 -51
- package/dist/repo/issue/helpers/deriveCurrentState.js +0 -113
- package/dist/repo/issue/helpers/deriveCurrentState.js.map +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.test.d.ts +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.test.js +0 -477
- package/dist/repo/issue/helpers/deriveCurrentState.test.js.map +0 -1
- package/dist/repo/landmark/LandmarkRepository.d.ts +0 -7
- package/dist/repo/landmark/LandmarkRepository.js +0 -12
- package/dist/repo/landmark/LandmarkRepository.js.map +0 -1
- package/dist/repo/line/LineRepository.d.ts +0 -13
- package/dist/repo/line/LineRepository.js +0 -32
- package/dist/repo/line/LineRepository.js.map +0 -1
- package/dist/repo/operator/OperatorRepository.d.ts +0 -7
- package/dist/repo/operator/OperatorRepository.js +0 -12
- package/dist/repo/operator/OperatorRepository.js.map +0 -1
- package/dist/repo/service/ServiceRepository.d.ts +0 -19
- package/dist/repo/service/ServiceRepository.js +0 -39
- package/dist/repo/service/ServiceRepository.js.map +0 -1
- package/dist/repo/station/StationRepository.d.ts +0 -13
- package/dist/repo/station/StationRepository.js +0 -30
- package/dist/repo/station/StationRepository.js.map +0 -1
- package/dist/repo/town/TownRepository.d.ts +0 -7
- package/dist/repo/town/TownRepository.js +0 -12
- package/dist/repo/town/TownRepository.js.map +0 -1
- package/dist/scripts/ingestViaWebhook.d.ts +0 -1
- package/dist/scripts/ingestViaWebhook.js +0 -9
- package/dist/scripts/ingestViaWebhook.js.map +0 -1
- package/dist/util/assert.d.ts +0 -1
- package/dist/util/assert.js +0 -6
- package/dist/util/assert.js.map +0 -1
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.d.ts +0 -7
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js +0 -24
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js.map +0 -1
- package/dist/util/ingestContent/index.d.ts +0 -12
- package/dist/util/ingestContent/index.js +0 -171
- package/dist/util/ingestContent/index.js.map +0 -1
- package/dist/util/ingestContent/types.d.ts +0 -32
- package/dist/util/ingestContent/types.js +0 -2
- package/dist/util/ingestContent/types.js.map +0 -1
- package/dist/validators/buildContext.d.ts +0 -7
- package/dist/validators/buildContext.js +0 -164
- package/dist/validators/buildContext.js.map +0 -1
- package/dist/validators/index.d.ts +0 -17
- package/dist/validators/index.js +0 -58
- package/dist/validators/index.js.map +0 -1
- package/dist/validators/issue.d.ts +0 -13
- package/dist/validators/issue.js +0 -220
- package/dist/validators/issue.js.map +0 -1
- package/dist/validators/landmark.d.ts +0 -7
- package/dist/validators/landmark.js +0 -43
- package/dist/validators/landmark.js.map +0 -1
- package/dist/validators/line.d.ts +0 -8
- package/dist/validators/line.js +0 -87
- package/dist/validators/line.js.map +0 -1
- package/dist/validators/operator.d.ts +0 -7
- package/dist/validators/operator.js +0 -43
- package/dist/validators/operator.js.map +0 -1
- package/dist/validators/service.d.ts +0 -8
- package/dist/validators/service.js +0 -87
- package/dist/validators/service.js.map +0 -1
- package/dist/validators/station.d.ts +0 -8
- package/dist/validators/station.js +0 -93
- package/dist/validators/station.js.map +0 -1
- package/dist/validators/town.d.ts +0 -7
- package/dist/validators/town.js +0 -43
- package/dist/validators/town.js.map +0 -1
- package/dist/validators/types.d.ts +0 -19
- package/dist/validators/types.js +0 -2
- package/dist/validators/types.js.map +0 -1
- package/dist/validators/utils.d.ts +0 -2
- package/dist/validators/utils.js +0 -9
- package/dist/validators/utils.js.map +0 -1
- package/dist/write/MRTDownWriter.d.ts +0 -27
- package/dist/write/MRTDownWriter.js +0 -27
- package/dist/write/MRTDownWriter.js.map +0 -1
- package/dist/write/common/FileWriteStore.d.ts +0 -13
- package/dist/write/common/FileWriteStore.js +0 -31
- package/dist/write/common/FileWriteStore.js.map +0 -1
- package/dist/write/common/StandardWriter.d.ts +0 -14
- package/dist/write/common/StandardWriter.js +0 -17
- package/dist/write/common/StandardWriter.js.map +0 -1
- package/dist/write/common/store.d.ts +0 -32
- package/dist/write/common/store.js +0 -2
- package/dist/write/common/store.js.map +0 -1
- package/dist/write/id/IdGenerator.d.ts +0 -18
- package/dist/write/id/IdGenerator.js +0 -23
- package/dist/write/id/IdGenerator.js.map +0 -1
- package/dist/write/issue/IssueWriter.d.ts +0 -12
- package/dist/write/issue/IssueWriter.js +0 -33
- package/dist/write/issue/IssueWriter.js.map +0 -1
|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OAAO;4BACrB,MAAM,EAAE,MAAM;yBACf,CAAC,CAAC;oBACL,CAAC;oBAED,aAAa,EAAE,CAAC;oBAChB,MAAM;gBACR,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,QAAQ,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,EAAE;IAExE,MAAM,CAAC,QAAQ,CAAC,aAAa,IAAI,IAAI,EAAE,gCAAgC,CAAC,CAAC;IAEzE,OAAO,QAAQ,CAAC,aAAa,CAAC;AAChC,CAAC","sourcesContent":["import { DateTime } from 'luxon';\nimport type {\n ParsedResponse,\n ResponseInputItem,\n} from 'openai/resources/responses/responses.mjs';\nimport z from 'zod';\nimport { openAiClient } from '#llm/client.js';\nimport type { MRTDownRepository } from '#repo/MRTDownRepository.js';\nimport { IssueIdSchema } from '#schema/issue/id.js';\nimport { IssueTypeSchema } from '#schema/issue/issueType.js';\nimport { assert } from '#util/assert.js';\nimport type { ToolRegistry } from '../../common/tool.js';\nimport { buildSystemPrompt } from './prompt.js';\nimport { FindIssuesTool } from './tools/FindIssuesTool.js';\nimport { GetIssueTool } from './tools/GetIssueTool.js';\n\nconst TOOL_CALL_LIMIT = 5;\n\nconst ResponseSchema = z.object({\n result: z.discriminatedUnion('type', [\n z.object({\n kind: z.literal('part-of-existing-issue'),\n issueId: IssueIdSchema,\n }),\n z.object({\n kind: z.literal('part-of-new-issue'),\n issueType: IssueTypeSchema,\n }),\n z.object({\n kind: z.literal('irrelevant-content'),\n }),\n ]),\n});\n\nexport type TriageNewEvidenceParams = {\n newEvidence: {\n ts: string;\n text: string;\n };\n repo: MRTDownRepository;\n};\n\nexport type TriageNewEvidenceResult = z.infer<typeof ResponseSchema>;\n\nexport async function triageNewEvidence(params: TriageNewEvidenceParams) {\n const evidenceTs = DateTime.fromISO(params.newEvidence.ts);\n assert(evidenceTs.isValid, `Invalid date: ${params.newEvidence.ts}`);\n\n const findIssuesTool = new FindIssuesTool(params.repo);\n const getIssueTool = new GetIssueTool(params.repo);\n const toolRegistry: ToolRegistry = {\n [findIssuesTool.name]: findIssuesTool,\n [getIssueTool.name]: getIssueTool,\n };\n\n const systemPrompt = buildSystemPrompt();\n\n const context: ResponseInputItem[] = [\n {\n role: 'user',\n content: `\nEvidence: ${params.newEvidence.text}\n\nTimestamp: ${evidenceTs.toISO({ includeOffset: true })}\n`.trim(),\n },\n ];\n\n let toolCallCount = 0;\n\n let response: ParsedResponse<z.infer<typeof ResponseSchema>>;\n do {\n response = await openAiClient.responses.parse({\n model: 'gpt-5-mini',\n input: context,\n instructions: systemPrompt,\n text: {\n format: {\n type: 'json_schema',\n name: 'Response',\n strict: true,\n schema: z.toJSONSchema(ResponseSchema),\n },\n },\n tools: Object.values(toolRegistry).map((tool) => {\n return {\n type: 'function',\n name: tool.name,\n description: tool.description,\n parameters: tool.paramsSchema,\n strict: true,\n };\n }),\n // Don't persist conversation with OpenAI, but include reasoning content to\n // continue the thread with the same reasoning.\n store: false,\n include: ['reasoning.encrypted_content'],\n });\n\n for (const item of response.output) {\n switch (item.type) {\n case 'function_call': {\n /**\n * Prevent the `parsed_arguments` field from being included\n * https://github.com/openai/openai-python/issues/2374\n */\n context.push({\n type: 'function_call',\n id: item.id,\n call_id: item.call_id,\n name: item.name,\n arguments: item.arguments,\n });\n\n if (toolCallCount > TOOL_CALL_LIMIT) {\n context.push({\n type: 'function_call_output',\n call_id: item.call_id,\n output: 'Ran out of tool calls. Stop Calling.',\n });\n console.log(\n 'Forced short-circuit, returning error message in tool call result.',\n );\n }\n\n if (item.name in toolRegistry) {\n const tool = toolRegistry[item.name];\n\n const params = tool.parseParams(JSON.parse(item.arguments));\n // Call the tool's run function\n const result = await tool.runner(params);\n\n context.push({\n type: 'function_call_output',\n call_id: item.call_id,\n output: result,\n });\n }\n\n toolCallCount++;\n break;\n }\n default: {\n context.push(item);\n break;\n }\n }\n }\n } while (response.output.some((item) => item.type === 'function_call'));\n\n assert(response.output_parsed != null, 'Response output parsed is null');\n\n return response.output_parsed;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildSystemPrompt(): string;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export function buildSystemPrompt() {
|
|
2
|
-
return `
|
|
3
|
-
You are an expert at triaging new evidence into an existing issue or a new issue.
|
|
4
|
-
|
|
5
|
-
Your task: Triage the new evidence into an existing issue or a new issue.
|
|
6
|
-
|
|
7
|
-
ISSUE TYPES:
|
|
8
|
-
- disruption: Service disruptions (e.g. train delays, line faults, operational failures)
|
|
9
|
-
- maintenance: Planned maintenance works (e.g. system upgrades, infrastructure maintenance)
|
|
10
|
-
- infra: Infrastructure issues (e.g. station lift outages, platform door faults, facility breakdowns)
|
|
11
|
-
|
|
12
|
-
DECISION PROCESS:
|
|
13
|
-
1. Extract key information from evidence: affected service/line, location, issue type, time window
|
|
14
|
-
2. Use findIssues tool to search for related issues by service name or line
|
|
15
|
-
3. Use getIssue tool to review each candidate issue's scope, periods, and effects
|
|
16
|
-
4. Compare evidence location and timing with existing issue scope
|
|
17
|
-
5. Return appropriate classification with clear reasoning
|
|
18
|
-
|
|
19
|
-
CLASSIFICATION RULES:
|
|
20
|
-
|
|
21
|
-
Part of Existing Issue:
|
|
22
|
-
- Evidence must match the service/line AND have geographic overlap (stations or segments)
|
|
23
|
-
- Temporal proximity matters: evidence should occur during or immediately adjacent to the issue's period
|
|
24
|
-
- Multiple separate incidents on the same service are separate issues (not continuous scope expansion)
|
|
25
|
-
|
|
26
|
-
Part of New Issue:
|
|
27
|
-
- Evidence describes a distinct incident not covered by existing issues
|
|
28
|
-
- Different geographic location on the same service (e.g. different stations/segments)
|
|
29
|
-
- Different service/line altogether
|
|
30
|
-
- Different time period or issue type
|
|
31
|
-
|
|
32
|
-
Irrelevant Content:
|
|
33
|
-
- Opinion or commentary without operational details
|
|
34
|
-
- General statements without specific service/location/time information
|
|
35
|
-
- Marketing or non-operational content
|
|
36
|
-
|
|
37
|
-
SPECIFIC GUIDANCE BY ISSUE TYPE:
|
|
38
|
-
|
|
39
|
-
DISRUPTIONS:
|
|
40
|
-
- Location specificity is CRITICAL - different stations or segments are separate incidents
|
|
41
|
-
- Same service line alone is NOT sufficient for matching
|
|
42
|
-
- Must have EXACT geographic overlap: if evidence mentions different station pair, it's a new issue
|
|
43
|
-
- Examples: "fault between A and B" overlaps with existing issue only if existing covers A-B segment
|
|
44
|
-
- A fault "between B and C" on the same line is a different incident, even if it shares one endpoint station
|
|
45
|
-
|
|
46
|
-
MAINTENANCE:
|
|
47
|
-
- Service-level planned works that affect operating hours or service availability
|
|
48
|
-
- Examples: early line closures, reduced service windows, system upgrades affecting all trains
|
|
49
|
-
- NOT about specific facility repairs (those are infra)
|
|
50
|
-
|
|
51
|
-
INFRASTRUCTURE:
|
|
52
|
-
- Specific facility or asset breakdowns that need repair or renewal
|
|
53
|
-
- Examples: lift outages, platform screen door faults/renewal, escalator repairs, door malfunctions
|
|
54
|
-
- Facility-specific: affects particular station and facility type (e.g. lift at Station X)
|
|
55
|
-
- Can be scheduled (renewal works) or unplanned (breakdowns)
|
|
56
|
-
- Link to existing issue if same station, same facility, service still active
|
|
57
|
-
- Different station or facility type = new issue
|
|
58
|
-
`.trim();
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"/","sources":["llm/functions/triageNewEvidence/prompt.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB;IAC/B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDR,CAAC,IAAI,EAAE,CAAC;AACT,CAAC","sourcesContent":["export function buildSystemPrompt() {\n return `\nYou are an expert at triaging new evidence into an existing issue or a new issue.\n\nYour task: Triage the new evidence into an existing issue or a new issue.\n\nISSUE TYPES:\n- disruption: Service disruptions (e.g. train delays, line faults, operational failures)\n- maintenance: Planned maintenance works (e.g. system upgrades, infrastructure maintenance)\n- infra: Infrastructure issues (e.g. station lift outages, platform door faults, facility breakdowns)\n\nDECISION PROCESS:\n1. Extract key information from evidence: affected service/line, location, issue type, time window\n2. Use findIssues tool to search for related issues by service name or line\n3. Use getIssue tool to review each candidate issue's scope, periods, and effects\n4. Compare evidence location and timing with existing issue scope\n5. Return appropriate classification with clear reasoning\n\nCLASSIFICATION RULES:\n\nPart of Existing Issue:\n- Evidence must match the service/line AND have geographic overlap (stations or segments)\n- Temporal proximity matters: evidence should occur during or immediately adjacent to the issue's period\n- Multiple separate incidents on the same service are separate issues (not continuous scope expansion)\n\nPart of New Issue:\n- Evidence describes a distinct incident not covered by existing issues\n- Different geographic location on the same service (e.g. different stations/segments)\n- Different service/line altogether\n- Different time period or issue type\n\nIrrelevant Content:\n- Opinion or commentary without operational details\n- General statements without specific service/location/time information\n- Marketing or non-operational content\n\nSPECIFIC GUIDANCE BY ISSUE TYPE:\n\nDISRUPTIONS:\n- Location specificity is CRITICAL - different stations or segments are separate incidents\n- Same service line alone is NOT sufficient for matching\n- Must have EXACT geographic overlap: if evidence mentions different station pair, it's a new issue\n- Examples: \"fault between A and B\" overlaps with existing issue only if existing covers A-B segment\n- A fault \"between B and C\" on the same line is a different incident, even if it shares one endpoint station\n\nMAINTENANCE:\n- Service-level planned works that affect operating hours or service availability\n- Examples: early line closures, reduced service windows, system upgrades affecting all trains\n- NOT about specific facility repairs (those are infra)\n\nINFRASTRUCTURE:\n- Specific facility or asset breakdowns that need repair or renewal\n- Examples: lift outages, platform screen door faults/renewal, escalator repairs, door malfunctions\n- Facility-specific: affects particular station and facility type (e.g. lift at Station X)\n- Can be scheduled (renewal works) or unplanned (breakdowns)\n- Link to existing issue if same station, same facility, service still active\n- Different station or facility type = new issue\n`.trim();\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import { Tool } from '#llm/common/tool.js';
|
|
3
|
-
import type { MRTDownRepository } from '#repo/MRTDownRepository.js';
|
|
4
|
-
declare const FindIssuesToolParametersSchema: z.ZodObject<{
|
|
5
|
-
query: z.ZodString;
|
|
6
|
-
}, z.z.core.$strip>;
|
|
7
|
-
type FindIssuesToolParameters = z.infer<typeof FindIssuesToolParametersSchema>;
|
|
8
|
-
export declare class FindIssuesTool extends Tool<FindIssuesToolParameters> {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
private readonly repo;
|
|
12
|
-
constructor(repo: MRTDownRepository);
|
|
13
|
-
get paramsSchema(): {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
parseParams(params: unknown): FindIssuesToolParameters;
|
|
17
|
-
runner(params: FindIssuesToolParameters): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { gfmToMarkdown } from 'mdast-util-gfm';
|
|
2
|
-
import { toMarkdown } from 'mdast-util-to-markdown';
|
|
3
|
-
import z from 'zod';
|
|
4
|
-
import { Tool } from '#llm/common/tool.js';
|
|
5
|
-
const FindIssuesToolParametersSchema = z.object({
|
|
6
|
-
query: z.string().describe('Plain text to search for issues.'),
|
|
7
|
-
});
|
|
8
|
-
export class FindIssuesTool extends Tool {
|
|
9
|
-
name = 'findIssues';
|
|
10
|
-
description = 'Find issues by query';
|
|
11
|
-
repo;
|
|
12
|
-
constructor(repo) {
|
|
13
|
-
super();
|
|
14
|
-
this.repo = repo;
|
|
15
|
-
}
|
|
16
|
-
get paramsSchema() {
|
|
17
|
-
return z.toJSONSchema(FindIssuesToolParametersSchema);
|
|
18
|
-
}
|
|
19
|
-
parseParams(params) {
|
|
20
|
-
return FindIssuesToolParametersSchema.parse(params);
|
|
21
|
-
}
|
|
22
|
-
async runner(params) {
|
|
23
|
-
console.log('[findIssues] Calling tool with parameters:', params);
|
|
24
|
-
const issues = this.repo.issues.searchByQuery(params.query);
|
|
25
|
-
const issueTable = {
|
|
26
|
-
type: 'table',
|
|
27
|
-
children: [
|
|
28
|
-
{
|
|
29
|
-
type: 'tableRow',
|
|
30
|
-
children: [
|
|
31
|
-
{
|
|
32
|
-
type: 'tableCell',
|
|
33
|
-
children: [{ type: 'text', value: 'Issue ID' }],
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: 'tableCell',
|
|
37
|
-
children: [{ type: 'text', value: 'Issue Title' }],
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
for (const issue of issues) {
|
|
44
|
-
issueTable.children.push({
|
|
45
|
-
type: 'tableRow',
|
|
46
|
-
children: [
|
|
47
|
-
{
|
|
48
|
-
type: 'tableCell',
|
|
49
|
-
children: [{ type: 'text', value: issue.issue.id }],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
type: 'tableCell',
|
|
53
|
-
children: [{ type: 'text', value: issue.issue.title['en-SG'] }],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const output = toMarkdown(issueTable, {
|
|
59
|
-
extensions: [gfmToMarkdown()],
|
|
60
|
-
});
|
|
61
|
-
console.log(`[findIssues] Response output:\n${output}`);
|
|
62
|
-
return output;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=FindIssuesTool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FindIssuesTool.js","sourceRoot":"/","sources":["llm/functions/triageNewEvidence/tools/FindIssuesTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAw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AC;QAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,WAAW;wBACjB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;qBACpD;oBACD;wBACE,IAAI,EAAE,WAAW;wBACjB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;qBAChE;iBACF;aACF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,EAAE;YACpC,UAAU,EAAE,CAAC,aAAa,EAAE,CAAC;SAC9B,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC;QAExD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import type { Table } from 'mdast';\nimport { gfmToMarkdown } from 'mdast-util-gfm';\nimport { toMarkdown } from 'mdast-util-to-markdown';\nimport z from 'zod';\nimport { Tool } from '#llm/common/tool.js';\nimport type { MRTDownRepository } from '#repo/MRTDownRepository.js';\n\nconst FindIssuesToolParametersSchema = z.object({\n query: z.string().describe('Plain text to search for issues.'),\n});\ntype FindIssuesToolParameters = z.infer<typeof FindIssuesToolParametersSchema>;\n\nexport class FindIssuesTool extends Tool<FindIssuesToolParameters> {\n public name = 'findIssues';\n public description = 'Find issues by query';\n private readonly repo: MRTDownRepository;\n\n constructor(repo: MRTDownRepository) {\n super();\n this.repo = repo;\n }\n\n public get paramsSchema(): { [key: string]: unknown } {\n return z.toJSONSchema(FindIssuesToolParametersSchema);\n }\n\n public parseParams(params: unknown): FindIssuesToolParameters {\n return FindIssuesToolParametersSchema.parse(params);\n }\n\n public async runner(params: FindIssuesToolParameters): Promise<string> {\n console.log('[findIssues] Calling tool with parameters:', params);\n\n const issues = this.repo.issues.searchByQuery(params.query);\n\n const issueTable: Table = {\n type: 'table',\n children: [\n {\n type: 'tableRow',\n children: [\n {\n type: 'tableCell',\n children: [{ type: 'text', value: 'Issue ID' }],\n },\n {\n type: 'tableCell',\n children: [{ type: 'text', value: 'Issue Title' }],\n },\n ],\n },\n ],\n };\n\n for (const issue of issues) {\n issueTable.children.push({\n type: 'tableRow',\n children: [\n {\n type: 'tableCell',\n children: [{ type: 'text', value: issue.issue.id }],\n },\n {\n type: 'tableCell',\n children: [{ type: 'text', value: issue.issue.title['en-SG'] }],\n },\n ],\n });\n }\n\n const output = toMarkdown(issueTable, {\n extensions: [gfmToMarkdown()],\n });\n console.log(`[findIssues] Response output:\\n${output}`);\n\n return output;\n }\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import type { MRTDownRepository } from '#repo/MRTDownRepository.js';
|
|
3
|
-
import { Tool } from '../../../common/tool.js';
|
|
4
|
-
declare const GetIssueToolParametersSchema: z.ZodObject<{
|
|
5
|
-
issueId: z.ZodString;
|
|
6
|
-
}, z.z.core.$strip>;
|
|
7
|
-
type GetIssueToolParameters = z.infer<typeof GetIssueToolParametersSchema>;
|
|
8
|
-
export declare class GetIssueTool extends Tool<GetIssueToolParameters> {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
private readonly repo;
|
|
12
|
-
constructor(repo: MRTDownRepository);
|
|
13
|
-
get paramsSchema(): {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
parseParams(params: unknown): GetIssueToolParameters;
|
|
17
|
-
runner(params: GetIssueToolParameters): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import { deriveCurrentState } from '#repo/issue/helpers/deriveCurrentState.js';
|
|
3
|
-
import { formatCurrentState } from '../../../common/formatCurrentState.js';
|
|
4
|
-
import { Tool } from '../../../common/tool.js';
|
|
5
|
-
const GetIssueToolParametersSchema = z.object({
|
|
6
|
-
issueId: z.string(),
|
|
7
|
-
});
|
|
8
|
-
export class GetIssueTool extends Tool {
|
|
9
|
-
name = 'getIssue';
|
|
10
|
-
description = 'Get an issue by ID';
|
|
11
|
-
repo;
|
|
12
|
-
constructor(repo) {
|
|
13
|
-
super();
|
|
14
|
-
this.repo = repo;
|
|
15
|
-
}
|
|
16
|
-
get paramsSchema() {
|
|
17
|
-
return z.toJSONSchema(GetIssueToolParametersSchema);
|
|
18
|
-
}
|
|
19
|
-
parseParams(params) {
|
|
20
|
-
return GetIssueToolParametersSchema.parse(params);
|
|
21
|
-
}
|
|
22
|
-
async runner(params) {
|
|
23
|
-
console.log('[getIssue] Calling tool with parameters:', params);
|
|
24
|
-
const issueBundle = this.repo.issues.get(params.issueId);
|
|
25
|
-
if (issueBundle == null) {
|
|
26
|
-
return `Issue ${params.issueId} not found`;
|
|
27
|
-
}
|
|
28
|
-
const currentState = deriveCurrentState(issueBundle);
|
|
29
|
-
const output = formatCurrentState({
|
|
30
|
-
state: currentState,
|
|
31
|
-
evidence: issueBundle.evidence,
|
|
32
|
-
});
|
|
33
|
-
console.log(`[getIssue] Response output:\n${output}`);
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=GetIssueTool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetIssueTool.js","sourceRoot":"/","sources":["llm/functions/triageNewEvidence/tools/GetIssueTool.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAGH,MAAM,OAAO,YAAa,SAAQ,IAA4B;IACrD,IAAI,GAAG,UAAU,CAAC;IAClB,WAAW,GAAG,oBAAoB,CAAC;IACzB,IAAI,CAAoB;IAEzC,YAAY,IAAuB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,CAAC,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;IACtD,CAAC;IAEM,WAAW,CAAC,MAAe;QAChC,OAAO,4BAA4B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,MAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAC;QAEhE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO,SAAS,MAAM,CAAC,OAAO,YAAY,CAAC;QAC7C,CAAC;QAED,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAErD,MAAM,MAAM,GAAG,kBAAkB,CAAC;YAChC,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,WAAW,CAAC,QAAQ;SAC/B,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;QAEtD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import z from 'zod';\nimport { deriveCurrentState } from '#repo/issue/helpers/deriveCurrentState.js';\nimport type { MRTDownRepository } from '#repo/MRTDownRepository.js';\nimport { formatCurrentState } from '../../../common/formatCurrentState.js';\nimport { Tool } from '../../../common/tool.js';\n\nconst GetIssueToolParametersSchema = z.object({\n issueId: z.string(),\n});\ntype GetIssueToolParameters = z.infer<typeof GetIssueToolParametersSchema>;\n\nexport class GetIssueTool extends Tool<GetIssueToolParameters> {\n public name = 'getIssue';\n public description = 'Get an issue by ID';\n private readonly repo: MRTDownRepository;\n\n constructor(repo: MRTDownRepository) {\n super();\n this.repo = repo;\n }\n\n public get paramsSchema(): { [key: string]: unknown } {\n return z.toJSONSchema(GetIssueToolParametersSchema);\n }\n\n public parseParams(params: unknown): GetIssueToolParameters {\n return GetIssueToolParametersSchema.parse(params);\n }\n\n public async runner(params: GetIssueToolParameters): Promise<string> {\n console.log('[getIssue] Calling tool with parameters:', params);\n\n const issueBundle = this.repo.issues.get(params.issueId);\n if (issueBundle == null) {\n return `Issue ${params.issueId} not found`;\n }\n\n const currentState = deriveCurrentState(issueBundle);\n\n const output = formatCurrentState({\n state: currentState,\n evidence: issueBundle.evidence,\n });\n console.log(`[getIssue] Response output:\\n${output}`);\n\n return output;\n }\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { IStore } from './common/store.js';
|
|
2
|
-
import { IssueRepository } from './issue/IssueRepository.js';
|
|
3
|
-
import { LandmarkRepository } from './landmark/LandmarkRepository.js';
|
|
4
|
-
import { LineRepository } from './line/LineRepository.js';
|
|
5
|
-
import { OperatorRepository } from './operator/OperatorRepository.js';
|
|
6
|
-
import { ServiceRepository } from './service/ServiceRepository.js';
|
|
7
|
-
import { StationRepository } from './station/StationRepository.js';
|
|
8
|
-
import { TownRepository } from './town/TownRepository.js';
|
|
9
|
-
interface MRTDownRepositoryOptions {
|
|
10
|
-
store: IStore;
|
|
11
|
-
}
|
|
12
|
-
export declare class MRTDownRepository {
|
|
13
|
-
private readonly store;
|
|
14
|
-
readonly stations: StationRepository;
|
|
15
|
-
readonly towns: TownRepository;
|
|
16
|
-
readonly landmarks: LandmarkRepository;
|
|
17
|
-
readonly lines: LineRepository;
|
|
18
|
-
readonly operators: OperatorRepository;
|
|
19
|
-
readonly services: ServiceRepository;
|
|
20
|
-
readonly issues: IssueRepository;
|
|
21
|
-
constructor(options: MRTDownRepositoryOptions);
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IssueRepository } from './issue/IssueRepository.js';
|
|
2
|
-
import { LandmarkRepository } from './landmark/LandmarkRepository.js';
|
|
3
|
-
import { LineRepository } from './line/LineRepository.js';
|
|
4
|
-
import { OperatorRepository } from './operator/OperatorRepository.js';
|
|
5
|
-
import { ServiceRepository } from './service/ServiceRepository.js';
|
|
6
|
-
import { StationRepository } from './station/StationRepository.js';
|
|
7
|
-
import { TownRepository } from './town/TownRepository.js';
|
|
8
|
-
export class MRTDownRepository {
|
|
9
|
-
store;
|
|
10
|
-
stations;
|
|
11
|
-
towns;
|
|
12
|
-
landmarks;
|
|
13
|
-
lines;
|
|
14
|
-
operators;
|
|
15
|
-
services;
|
|
16
|
-
issues;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.store = options.store;
|
|
19
|
-
this.stations = new StationRepository(this.store);
|
|
20
|
-
this.towns = new TownRepository(this.store);
|
|
21
|
-
this.landmarks = new LandmarkRepository(this.store);
|
|
22
|
-
this.lines = new LineRepository(this.store);
|
|
23
|
-
this.operators = new OperatorRepository(this.store);
|
|
24
|
-
this.services = new ServiceRepository(this.store);
|
|
25
|
-
this.issues = new IssueRepository(this.store);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=MRTDownRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MRTDownRepository.js","sourceRoot":"/","sources":["repo/MRTDownRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,MAAM,OAAO,iBAAiB;IACX,KAAK,CAAS;IAEtB,QAAQ,CAAoB;IAC5B,KAAK,CAAiB;IACtB,SAAS,CAAqB;IAC9B,KAAK,CAAiB;IACtB,SAAS,CAAqB;IAC9B,QAAQ,CAAoB;IAC5B,MAAM,CAAkB;IAEjC,YAAY,OAAiC;QAC3C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["import type { IStore } from './common/store.js';\nimport { IssueRepository } from './issue/IssueRepository.js';\nimport { LandmarkRepository } from './landmark/LandmarkRepository.js';\nimport { LineRepository } from './line/LineRepository.js';\nimport { OperatorRepository } from './operator/OperatorRepository.js';\nimport { ServiceRepository } from './service/ServiceRepository.js';\nimport { StationRepository } from './station/StationRepository.js';\nimport { TownRepository } from './town/TownRepository.js';\n\ninterface MRTDownRepositoryOptions {\n store: IStore;\n}\n\nexport class MRTDownRepository {\n private readonly store: IStore;\n\n readonly stations: StationRepository;\n readonly towns: TownRepository;\n readonly landmarks: LandmarkRepository;\n readonly lines: LineRepository;\n readonly operators: OperatorRepository;\n readonly services: ServiceRepository;\n readonly issues: IssueRepository;\n\n constructor(options: MRTDownRepositoryOptions) {\n this.store = options.store;\n this.stations = new StationRepository(this.store);\n this.towns = new TownRepository(this.store);\n this.landmarks = new LandmarkRepository(this.store);\n this.lines = new LineRepository(this.store);\n this.operators = new OperatorRepository(this.store);\n this.services = new ServiceRepository(this.store);\n this.issues = new IssueRepository(this.store);\n }\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IStore } from './store.js';
|
|
2
|
-
/**
|
|
3
|
-
* A store for reading and writing files.
|
|
4
|
-
*/
|
|
5
|
-
export declare class FileStore implements IStore {
|
|
6
|
-
private readonly rootDir;
|
|
7
|
-
constructor(rootDir: string);
|
|
8
|
-
readText(path: string): string;
|
|
9
|
-
readJson<T>(path: string): T;
|
|
10
|
-
listDir(path: string): string[];
|
|
11
|
-
exists(path: string): boolean;
|
|
12
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* A store for reading and writing files.
|
|
5
|
-
*/
|
|
6
|
-
export class FileStore {
|
|
7
|
-
rootDir;
|
|
8
|
-
constructor(rootDir) {
|
|
9
|
-
this.rootDir = rootDir;
|
|
10
|
-
}
|
|
11
|
-
readText(path) {
|
|
12
|
-
const fullPath = join(this.rootDir, path);
|
|
13
|
-
return readFileSync(fullPath, { encoding: 'utf-8' });
|
|
14
|
-
}
|
|
15
|
-
readJson(path) {
|
|
16
|
-
return JSON.parse(this.readText(path));
|
|
17
|
-
}
|
|
18
|
-
listDir(path) {
|
|
19
|
-
const fullPath = join(this.rootDir, path);
|
|
20
|
-
return readdirSync(fullPath);
|
|
21
|
-
}
|
|
22
|
-
exists(path) {
|
|
23
|
-
const fullPath = join(this.rootDir, path);
|
|
24
|
-
return existsSync(fullPath);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=FileStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileStore.js","sourceRoot":"/","sources":["repo/common/FileStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;GAEG;AACH,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,QAAQ,CAAC,IAAY;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAI,IAAY;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { IStore } from './store.js';\n\n/**\n * A store for reading and writing files.\n */\nexport class FileStore implements IStore {\n constructor(private readonly rootDir: string) {}\n\n readText(path: string): string {\n const fullPath = join(this.rootDir, path);\n return readFileSync(fullPath, { encoding: 'utf-8' });\n }\n\n readJson<T>(path: string): T {\n return JSON.parse(this.readText(path));\n }\n\n listDir(path: string): string[] {\n const fullPath = join(this.rootDir, path);\n return readdirSync(fullPath);\n }\n\n exists(path: string): boolean {\n const fullPath = join(this.rootDir, path);\n return existsSync(fullPath);\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IStore } from './store.js';
|
|
2
|
-
type Item = {
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* A standard repository for items represented by single JSON files that are stored in a directory.
|
|
7
|
-
*/
|
|
8
|
-
export declare class StandardRepository<T extends Item> {
|
|
9
|
-
protected store: IStore;
|
|
10
|
-
protected dirPath: string;
|
|
11
|
-
protected byId: Map<string, T>;
|
|
12
|
-
protected loaded: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Create a new standard repository.
|
|
15
|
-
* @param store
|
|
16
|
-
*/
|
|
17
|
-
constructor(store: IStore, dirPath: string);
|
|
18
|
-
/**
|
|
19
|
-
* Load all items from the directory.
|
|
20
|
-
*/
|
|
21
|
-
protected loadAll(): void;
|
|
22
|
-
protected parseItem(_json: unknown): T;
|
|
23
|
-
/**
|
|
24
|
-
* Get an item by ID.
|
|
25
|
-
*/
|
|
26
|
-
get(id: string): T | null;
|
|
27
|
-
/**
|
|
28
|
-
* List all items.
|
|
29
|
-
*/
|
|
30
|
-
list(): T[];
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
/**
|
|
3
|
-
* A standard repository for items represented by single JSON files that are stored in a directory.
|
|
4
|
-
*/
|
|
5
|
-
export class StandardRepository {
|
|
6
|
-
store;
|
|
7
|
-
dirPath;
|
|
8
|
-
byId = new Map();
|
|
9
|
-
loaded = false;
|
|
10
|
-
/**
|
|
11
|
-
* Create a new standard repository.
|
|
12
|
-
* @param store
|
|
13
|
-
*/
|
|
14
|
-
constructor(store, dirPath) {
|
|
15
|
-
this.store = store;
|
|
16
|
-
this.dirPath = dirPath;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Load all items from the directory.
|
|
20
|
-
*/
|
|
21
|
-
loadAll() {
|
|
22
|
-
if (this.loaded) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const dirFiles = this.store.listDir(this.dirPath);
|
|
26
|
-
for (const fileName of dirFiles) {
|
|
27
|
-
const filePath = join(this.dirPath, fileName);
|
|
28
|
-
const json = this.store.readJson(filePath);
|
|
29
|
-
try {
|
|
30
|
-
const item = this.parseItem(json);
|
|
31
|
-
this.byId.set(item.id, item);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error(`Error parsing ${filePath}: ${error}`);
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
this.loaded = true;
|
|
39
|
-
}
|
|
40
|
-
parseItem(_json) {
|
|
41
|
-
throw new Error('Not implemented');
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get an item by ID.
|
|
45
|
-
*/
|
|
46
|
-
get(id) {
|
|
47
|
-
this.loadAll();
|
|
48
|
-
return this.byId.get(id) ?? null;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* List all items.
|
|
52
|
-
*/
|
|
53
|
-
list() {
|
|
54
|
-
this.loadAll();
|
|
55
|
-
return Array.from(this.byId.values());
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=StandardRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StandardRepository.js","sourceRoot":"/","sources":["repo/common/StandardRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACnB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,IAAI,GAAG,IAAI,GAAG,EAAa,CAAC;IAC5B,MAAM,GAAG,KAAK,CAAC;IAEzB;;;OAGG;IACH,YAAY,KAAa,EAAE,OAAe;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACO,OAAO;QACf,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC3C,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,iBAAiB,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;gBACrD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAES,SAAS,CAAC,KAAc;QAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,EAAU;QACZ,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { join } from 'node:path';\nimport type { IStore } from './store.js';\n\ntype Item = {\n id: string;\n};\n\n/**\n * A standard repository for items represented by single JSON files that are stored in a directory.\n */\nexport class StandardRepository<T extends Item> {\n protected store: IStore;\n protected dirPath: string;\n protected byId = new Map<string, T>();\n protected loaded = false;\n\n /**\n * Create a new standard repository.\n * @param store\n */\n constructor(store: IStore, dirPath: string) {\n this.store = store;\n this.dirPath = dirPath;\n }\n\n /**\n * Load all items from the directory.\n */\n protected loadAll() {\n if (this.loaded) {\n return;\n }\n\n const dirFiles = this.store.listDir(this.dirPath);\n for (const fileName of dirFiles) {\n const filePath = join(this.dirPath, fileName);\n const json = this.store.readJson(filePath);\n try {\n const item = this.parseItem(json);\n this.byId.set(item.id, item);\n } catch (error) {\n console.error(`Error parsing ${filePath}: ${error}`);\n throw error;\n }\n }\n\n this.loaded = true;\n }\n\n protected parseItem(_json: unknown): T {\n throw new Error('Not implemented');\n }\n\n /**\n * Get an item by ID.\n */\n get(id: string): T | null {\n this.loadAll();\n return this.byId.get(id) ?? null;\n }\n\n /**\n * List all items.\n */\n list(): T[] {\n this.loadAll();\n return Array.from(this.byId.values());\n }\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A store for reading and writing files.
|
|
3
|
-
*/
|
|
4
|
-
export interface IStore {
|
|
5
|
-
/**
|
|
6
|
-
* Read a text file.
|
|
7
|
-
* @param path
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
readText(path: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Read a JSON file.
|
|
13
|
-
* @param path
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
readJson<T>(path: string): T;
|
|
17
|
-
/**
|
|
18
|
-
* List all files in a directory.
|
|
19
|
-
* @param path
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
listDir(path: string): string[];
|
|
23
|
-
/**
|
|
24
|
-
* Check if a file exists.
|
|
25
|
-
* @param path
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
exists(path: string): boolean;
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"/","sources":["repo/common/store.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A store for reading and writing files.\n */\nexport interface IStore {\n /**\n * Read a text file.\n * @param path\n * @returns\n */\n readText(path: string): string;\n /**\n * Read a JSON file.\n * @param path\n * @returns\n */\n readJson<T>(path: string): T;\n /**\n * List all files in a directory.\n * @param path\n * @returns\n */\n listDir(path: string): string[];\n /**\n * Check if a file exists.\n * @param path\n * @returns\n */\n exists(path: string): boolean;\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { IssueBundle } from '#schema/issue/bundle.js';
|
|
2
|
-
import type { IStore } from '../common/store.js';
|
|
3
|
-
export declare class IssueRepository {
|
|
4
|
-
private readonly store;
|
|
5
|
-
constructor(store: IStore);
|
|
6
|
-
private byId;
|
|
7
|
-
private indexed;
|
|
8
|
-
private bundleCache;
|
|
9
|
-
/**
|
|
10
|
-
* Build the index of all issues.
|
|
11
|
-
*/
|
|
12
|
-
private buildIndex;
|
|
13
|
-
/**
|
|
14
|
-
* Return the relative folder path to the issue.
|
|
15
|
-
* @param id
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
getPath(id: string): string | null;
|
|
19
|
-
get(id: string): IssueBundle | null;
|
|
20
|
-
/**
|
|
21
|
-
* List all issue IDs, sorted by year and month.
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
listIds(): string[];
|
|
25
|
-
/**
|
|
26
|
-
* List all bundles, sorted by year and month.
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
list(): IssueBundle[];
|
|
30
|
-
/**
|
|
31
|
-
* Search issues by query.
|
|
32
|
-
* @param query
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
searchByQuery(query: string): IssueBundle[];
|
|
36
|
-
}
|