in2-agent-server 0.20260821.185429

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 (115) hide show
  1. package/README.md +369 -0
  2. package/agents/plan-requirement.md +32 -0
  3. package/dist/campfire/configItem.js +201 -0
  4. package/dist/campfire/configItemDescription.js +379 -0
  5. package/dist/campfire/deriveFromBundle.js +1013 -0
  6. package/dist/cli.js +465 -0
  7. package/dist/core/betaFeedback.js +493 -0
  8. package/dist/core/chapterInstructions.js +473 -0
  9. package/dist/core/claudeAssets.js +61 -0
  10. package/dist/core/gate.js +201 -0
  11. package/dist/core/ids.js +9 -0
  12. package/dist/core/install.js +60 -0
  13. package/dist/core/operatorQa.js +462 -0
  14. package/dist/core/orgCallMeter.js +178 -0
  15. package/dist/core/parcels.js +1235 -0
  16. package/dist/core/paths.js +105 -0
  17. package/dist/core/phases.js +225 -0
  18. package/dist/core/planFile.js +251 -0
  19. package/dist/core/planFragments.js +119 -0
  20. package/dist/core/readsLog.js +398 -0
  21. package/dist/core/registration.js +24 -0
  22. package/dist/core/result.js +38 -0
  23. package/dist/core/resume.js +233 -0
  24. package/dist/core/revisionChain.js +351 -0
  25. package/dist/core/richText.js +61 -0
  26. package/dist/core/semanticHash.js +89 -0
  27. package/dist/core/sessionOrg.js +60 -0
  28. package/dist/core/sfQuery.js +19 -0
  29. package/dist/core/spawn.js +182 -0
  30. package/dist/core/supervisorContract.js +230 -0
  31. package/dist/core/telemetry.js +1297 -0
  32. package/dist/core/telemetryContext.js +154 -0
  33. package/dist/core/telemetrySpool.js +244 -0
  34. package/dist/core/transcriptUpload.js +516 -0
  35. package/dist/core/update.js +363 -0
  36. package/dist/core/viewer.js +117 -0
  37. package/dist/core/workspace.js +92 -0
  38. package/dist/core/writeGrants.js +93 -0
  39. package/dist/core/writebackManifest.js +92 -0
  40. package/dist/direct/applyLoop.js +2516 -0
  41. package/dist/direct/batchReport.js +510 -0
  42. package/dist/direct/comparatorNoise.js +75 -0
  43. package/dist/direct/containers.js +85 -0
  44. package/dist/direct/contamination.js +221 -0
  45. package/dist/direct/crud.js +56 -0
  46. package/dist/direct/destructive.js +168 -0
  47. package/dist/direct/knownTokens.js +94 -0
  48. package/dist/direct/lint.js +382 -0
  49. package/dist/direct/metadataSchema.generated.json +1 -0
  50. package/dist/direct/metadataSchema.js +179 -0
  51. package/dist/direct/operatorPage.js +349 -0
  52. package/dist/direct/orgRepo.js +1531 -0
  53. package/dist/direct/orgRepoSpawnCount.js +21 -0
  54. package/dist/direct/plannedScope.js +119 -0
  55. package/dist/direct/preImageTargets.js +63 -0
  56. package/dist/direct/refVerify.js +191 -0
  57. package/dist/direct/registry.js +129 -0
  58. package/dist/direct/removals.js +262 -0
  59. package/dist/direct/rollback.js +1513 -0
  60. package/dist/direct/rollbackRun.js +1360 -0
  61. package/dist/direct/sessionProjection.js +126 -0
  62. package/dist/direct/snapshotComparability.js +165 -0
  63. package/dist/direct/sourceTree.js +113 -0
  64. package/dist/direct/unstatedChanges.js +106 -0
  65. package/dist/direct/waveAssembly.js +556 -0
  66. package/dist/direct/waveCounts.js +19 -0
  67. package/dist/direct/waveDerivation.js +152 -0
  68. package/dist/direct/waveGrade.js +185 -0
  69. package/dist/index.js +90 -0
  70. package/dist/orgread/customFieldSnapshot.js +48 -0
  71. package/dist/orgread/fieldMetadata.js +178 -0
  72. package/dist/orgread/genericSnapshot.js +61 -0
  73. package/dist/orgread/layoutSnapshot.js +151 -0
  74. package/dist/orgread/salesforceOrgReader.js +184 -0
  75. package/dist/orgread/snapshotTypes.js +9 -0
  76. package/dist/projection/bridge.js +26 -0
  77. package/dist/projection/diff.js +141 -0
  78. package/dist/projection/mapmd.js +213 -0
  79. package/dist/projection/nameAmbiguity.js +106 -0
  80. package/dist/projection/precedent.js +136 -0
  81. package/dist/projection/project.js +214 -0
  82. package/dist/projection/scope.js +110 -0
  83. package/dist/projection/types.js +5 -0
  84. package/dist/tools/analyze.js +322 -0
  85. package/dist/tools/auth.js +915 -0
  86. package/dist/tools/campfire.js +1742 -0
  87. package/dist/tools/closeBatch.js +154 -0
  88. package/dist/tools/closeText.js +35 -0
  89. package/dist/tools/direct.js +1613 -0
  90. package/dist/tools/feedback.js +318 -0
  91. package/dist/tools/operator.js +287 -0
  92. package/dist/tools/org.js +739 -0
  93. package/dist/tools/phase.js +249 -0
  94. package/dist/tools/projection.js +172 -0
  95. package/dist/tools/session.js +313 -0
  96. package/dist/tools/update.js +82 -0
  97. package/dist/tools/waves.js +793 -0
  98. package/package.json +48 -0
  99. package/reference/campfire-configuration-items-guide.md +710 -0
  100. package/reference/deployability-cribs.md +119 -0
  101. package/reference/operator-voice.md +141 -0
  102. package/reference/org-read-cribs.md +34 -0
  103. package/reference/scoped-dml-interim.md +68 -0
  104. package/reference/supervisor-playbook.md +313 -0
  105. package/reference/templates.md +233 -0
  106. package/skills/in2-delivery/SKILL.md +322 -0
  107. package/skills/in2-delivery/references/campfire-configuration-items-guide.md +710 -0
  108. package/skills/in2-delivery/references/deployability-cribs.md +119 -0
  109. package/skills/in2-delivery/references/operator-voice.md +141 -0
  110. package/skills/in2-delivery/references/org-read-cribs.md +34 -0
  111. package/skills/in2-delivery/references/scoped-dml-interim.md +68 -0
  112. package/skills/in2-delivery/references/templates.md +233 -0
  113. package/skills/plan-requirement/SKILL.md +188 -0
  114. package/viewer/index.html +899 -0
  115. package/viewer/server.mjs +433 -0
@@ -0,0 +1,92 @@
1
+ // PER-REQUIREMENT WRITEBACK STATE, on disk, while the writeback runs.
2
+ //
3
+ // `campfire_write_config_items` already knows, per Configuration Item row, which requirement owns
4
+ // it and whether Campfire confirmed the write on read-back — but that knowledge only ever left the
5
+ // tool as prose in one result, at the end. The session viewer polls the session directory, so a
6
+ // ten-minute writeback showed as one undifferentiated "in progress" for every requirement and then
7
+ // jumped to done. This file is the projection that closes that gap.
8
+ //
9
+ // WHY TWO WRITES RATHER THAN A LIVE PER-ROW FEED. The write loop upserts rows CONCURRENTLY
10
+ // (`WRITE_CONCURRENCY`), and a successful upsert is only a claim until the batched read-back
11
+ // confirms every field — so no requirement can honestly be called `written` before that read-back
12
+ // completes. A per-row feed would either lie early or need a second "unconfirmed" state that means
13
+ // nothing to an operator. So: one write BEFORE the loop (`writing`, with the row count each
14
+ // requirement is about to get) and one AFTER the read-back (`written` / `failed`). Requirements
15
+ // whose rows are all held or skipped never enter the loop and stay `pending` in both.
16
+ //
17
+ // Written through `writeJsonAtomic` (tmp+rename), like every other artifact the viewer reads, so a
18
+ // 2s poll can never catch a torn file.
19
+ //
20
+ // FAIL-OPEN throughout, like `readsLog`: a writeback that refused to write to Campfire because its
21
+ // progress file would not save would trade a real capability for a cosmetic one.
22
+ import { log } from "./result.js";
23
+ import { readJson, writeJsonAtomic, writebackDir } from "./workspace.js";
24
+ import path from "node:path";
25
+ export function writebackManifestPath(sessionId) {
26
+ return path.join(writebackDir(sessionId), "manifest.json");
27
+ }
28
+ /**
29
+ * Fold Configuration Item rows into one row per requirement.
30
+ *
31
+ * Pure, so the state machine is testable without an org: the tool supplies the same three sets it
32
+ * already computes for its own report (held, skipped, failed) and this decides what each
33
+ * requirement's row says.
34
+ */
35
+ export function writebackManifestRows(input) {
36
+ const held = new Set(input.held ?? []);
37
+ const skipped = new Set(input.skipped ?? []);
38
+ const failed = new Set(input.failedRequirements ?? []);
39
+ // Insertion order preserves the derivation's own sort (requirement, then type/name), so the
40
+ // manifest reads in the same order as the tool's report.
41
+ const counts = new Map();
42
+ for (const row of input.rows) {
43
+ const extId = row.requirement;
44
+ if (!extId)
45
+ continue; // an unowned row belongs to no requirement; the tool refuses on those anyway
46
+ const writable = !held.has(row.metadataKey) && !skipped.has(row.metadataKey);
47
+ counts.set(extId, (counts.get(extId) ?? 0) + (writable ? 1 : 0));
48
+ }
49
+ return [...counts].map(([extId, ciCount]) => {
50
+ // Nothing to write for this requirement (every row held or skipped) — it is not in flight and
51
+ // it did not fail; it is waiting on the operator's reconcile-and-rerun.
52
+ if (ciCount === 0)
53
+ return { extId, status: "pending", ciCount, writtenAt: null };
54
+ if (!input.done)
55
+ return { extId, status: "writing", ciCount, writtenAt: null };
56
+ return {
57
+ extId,
58
+ status: failed.has(extId) ? "failed" : "written",
59
+ ciCount,
60
+ writtenAt: input.at
61
+ };
62
+ });
63
+ }
64
+ /**
65
+ * Write (or merge into) the session's writeback manifest. Never throws.
66
+ *
67
+ * MERGES rather than replaces, because the tool is DESIGNED to be called once per wave — its own
68
+ * `waves` argument exists so the incremental case does not re-derive the whole session and inflate
69
+ * Campfire's per-requirement Configuration Item counter. A replacing write would erase wave 1's
70
+ * `written` rows the moment wave 2 started, which is exactly the state the viewer is here to show.
71
+ * Rows named by this call win; rows only in the file survive untouched.
72
+ */
73
+ export async function writeWritebackManifest(sessionId, rows) {
74
+ try {
75
+ const file = writebackManifestPath(sessionId);
76
+ let existing = [];
77
+ try {
78
+ const prior = await readJson(file);
79
+ if (Array.isArray(prior?.requirements))
80
+ existing = prior.requirements;
81
+ }
82
+ catch {
83
+ // No manifest yet, or one we cannot parse. Either way this call's rows are the truth.
84
+ }
85
+ const incoming = new Set(rows.map((row) => row.extId));
86
+ const merged = [...existing.filter((row) => row && !incoming.has(row.extId)), ...rows];
87
+ await writeJsonAtomic(file, { requirements: merged });
88
+ }
89
+ catch (error) {
90
+ log("writeback manifest not being recorded:", error instanceof Error ? error.message : String(error));
91
+ }
92
+ }