@krisada-m/ksd-intelligence 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.antigravity-plugin/plugin.json +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +195 -2
  4. package/agy-skills/erosiano-review/SKILL.md +17 -0
  5. package/dist/adapters/agy/skills.js +252 -0
  6. package/dist/adapters/cli/check-changed.js +3 -0
  7. package/dist/adapters/cli/main.js +1013 -0
  8. package/dist/adapters/cli/policy-bin.js +10 -0
  9. package/dist/adapters/cli/review-verdict.js +3 -0
  10. package/dist/adapters/omp/extension.js +884 -0
  11. package/dist/adapters/omp/skills.js +130 -0
  12. package/dist/adapters/ui/hud.js +389 -0
  13. package/dist/adapters/ui/tree.js +471 -0
  14. package/dist/core/audit/index.js +2 -0
  15. package/dist/core/audit/log.js +505 -0
  16. package/dist/core/audit/summary.js +188 -0
  17. package/dist/core/changes/changes.js +591 -0
  18. package/dist/core/changes/git.js +266 -0
  19. package/dist/core/changes/plan.js +109 -0
  20. package/dist/core/changes/render.js +356 -0
  21. package/dist/core/engine/build.js +178 -0
  22. package/dist/core/engine/child.js +389 -0
  23. package/dist/core/engine/host.js +206 -0
  24. package/dist/core/engine/lock.js +133 -0
  25. package/dist/core/engine/protocol.js +43 -0
  26. package/dist/core/engine/runtime.js +44 -0
  27. package/dist/core/engine/status.js +452 -0
  28. package/dist/core/engine/typescript.js +194 -0
  29. package/dist/core/engine/workspace.js +72 -0
  30. package/dist/core/graph/graph.js +127 -0
  31. package/dist/core/graph/limits.js +16 -0
  32. package/dist/core/impact/query.js +1292 -0
  33. package/dist/core/impact/render.js +590 -0
  34. package/dist/core/impact/session.js +694 -0
  35. package/dist/core/indexing/declarations.js +455 -0
  36. package/dist/core/indexing/differential.js +345 -0
  37. package/dist/core/indexing/doctor.js +120 -0
  38. package/dist/core/indexing/indexer.js +811 -0
  39. package/dist/core/indexing/keys.js +451 -0
  40. package/dist/core/indexing/lexical.js +212 -0
  41. package/dist/core/indexing/packages.js +57 -0
  42. package/dist/core/indexing/program.js +171 -0
  43. package/dist/core/indexing/resolve.js +1004 -0
  44. package/dist/core/indexing/stamp.js +52 -0
  45. package/dist/core/indexing/surface.js +335 -0
  46. package/dist/core/indexing/ui-progress.js +37 -0
  47. package/dist/core/indexing/verify.js +76 -0
  48. package/dist/core/kernel/config.js +383 -0
  49. package/dist/core/kernel/glob.js +105 -0
  50. package/dist/core/kernel/guards.js +4 -0
  51. package/dist/core/kernel/types.js +3 -0
  52. package/dist/core/kernel/verdict.js +142 -0
  53. package/dist/core/knowledge/anchors.js +139 -0
  54. package/dist/core/knowledge/knowledge.js +95 -0
  55. package/dist/core/knowledge/learning.js +102 -0
  56. package/dist/core/knowledge/render.js +76 -0
  57. package/dist/core/knowledge/store.js +109 -0
  58. package/dist/core/knowledge/yaml.js +87 -0
  59. package/dist/core/search/lexical.js +382 -0
  60. package/dist/core/search/render.js +98 -0
  61. package/dist/core/search/segments.js +118 -0
  62. package/dist/core/verify/parse.js +127 -0
  63. package/dist/core/verify/render.js +67 -0
  64. package/dist/core/verify/report.js +40 -0
  65. package/dist/core/verify/revision.js +79 -0
  66. package/dist/core/verify/run.js +117 -0
  67. package/dist/core/verify/store.js +66 -0
  68. package/dist/core/verify/verify.js +173 -0
  69. package/dist/core/workspace/init.js +267 -0
  70. package/dist/core/workspace/probe.js +56 -0
  71. package/dist/core/workspace/scan.js +420 -0
  72. package/dist/engineering/baseline.js +337 -0
  73. package/dist/engineering/change-scope.js +500 -0
  74. package/dist/engineering/check-changed.js +40 -0
  75. package/dist/engineering/config.js +129 -0
  76. package/dist/engineering/dist/policy.d.ts +17 -0
  77. package/dist/engineering/dist/policy.js +150 -0
  78. package/dist/engineering/dist/runtime.d.ts +40 -0
  79. package/dist/engineering/dist/runtime.js +77 -0
  80. package/dist/engineering/dist/sdlc.d.ts +7 -0
  81. package/dist/engineering/dist/sdlc.js +27 -0
  82. package/dist/engineering/eslint-rules/index.js +107 -0
  83. package/dist/engineering/index.d.ts +7 -0
  84. package/dist/engineering/index.js +319 -0
  85. package/dist/engineering/intelligence.js +44 -0
  86. package/dist/engineering/package.json +36 -0
  87. package/dist/engineering/policy.js +2 -0
  88. package/dist/engineering/practice-tool.js +72 -0
  89. package/dist/engineering/practices.js +283 -0
  90. package/dist/engineering/practices.json +2453 -0
  91. package/dist/engineering/review-verdict.js +262 -0
  92. package/dist/engineering/sdlc.js +2 -0
  93. package/dist/index.js +20 -0
  94. package/dist/storage/records.js +245 -0
  95. package/dist/storage/sqlite.js +314 -0
  96. package/dist/workflow/catalog.js +69 -0
  97. package/dist/workflow/classify.js +55 -0
  98. package/dist/workflow/loader.js +140 -0
  99. package/dist/workflow/packs.js +469 -0
  100. package/dist/workflow/registry.js +359 -0
  101. package/dist/workflow/render.js +61 -0
  102. package/dist/workflow/router.js +141 -0
  103. package/dist/workflow/sources.js +229 -0
  104. package/dist/workflow/types.js +44 -0
  105. package/dist/workflow/updates.js +532 -0
  106. package/engineering.lock.json +94 -0
  107. package/package.json +81 -4
  108. package/rules/engineering.md +20 -0
  109. package/scripts/agy-mcp.mjs +27 -0
  110. package/scripts/mcp/engineering.mjs +91 -0
  111. package/scripts/mcp/stdio.mjs +304 -0
  112. package/scripts/mcp/tools.mjs +491 -0
  113. package/skills/ksd-intelligence/SKILL.md +54 -0
  114. package/skills/matt-sdlc/SKILL.md +42 -0
  115. package/skills/osmani-quality/SKILL.md +38 -0
  116. package/skills/poteto-mode/SKILL.md +40 -0
  117. package/skills/pstack-analysis/SKILL.md +36 -0
  118. package/skills.lock.json +71 -0
  119. package/skills.registry.json +181 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
+ "name": "ksd-intelligence",
4
+ "displayName": "KSD Intelligence",
5
+ "version": "1.1.0",
6
+ "description": "Pinned erosiano-dev engineering guidance and local code intelligence skills.",
7
+ "author": {
8
+ "name": "Krisada-M",
9
+ "url": "https://github.com/Krisada-M"
10
+ },
11
+ "repository": "https://github.com/Krisada-M/ksd-intelligence",
12
+ "license": "MIT",
13
+ "skills": [
14
+ "./agy-skills"
15
+ ],
16
+ "suggestedPrompts": [
17
+ "Establish the effective project baseline before a change",
18
+ "Review the current diff using engineering evidence"
19
+ ]
20
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Krisada M.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,196 @@
1
- # Temporary Holding Version
1
+ # ksd-intelligence
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ KSD helps you find TypeScript and JavaScript code, see what depends on a symbol before editing it, and review what an actual Git diff affects. It builds a private local SQLite index. It suggests checks; it does not run your tests, edit source, approve changes, or deploy. It also supplies the pinned **erosiano-dev** engineering core (baseline, 138 practices, quality gates and evidence-aware review). One product, two host adapters: native extension in OMP and native rules/skills plus fixed-root local MCP in Antigravity (AGY). The integration branch is a candidate, not a released version.
4
+
5
+ ## Install
6
+
7
+ Requirements: Git and **Node ≥ 22.5**; use Node 24 LTS. On Node 22.5–22.12 or 23.0–23.3, `node:sqlite` requires `NODE_OPTIONS=--experimental-sqlite`. Install project dependencies before indexing if the code relies on their types.
8
+
9
+ ### OMP: marketplace
10
+
11
+ Only install `ksd-intelligence@ksd-intelligence` as the engineering/intelligence product. Before switching to the integrated build, back up configuration and uninstall any standalone `engineering-proxy@engineering-proxy` or `erosiano-dev@erosiano-dev` installation that exists. Do not activate both policy owners. Ponytail is independent.
12
+
13
+ ```sh
14
+ omp plugin marketplace add Krisada-M/ksd-intelligence
15
+ omp plugin install ksd-intelligence@ksd-intelligence
16
+ omp plugin list
17
+ ```
18
+
19
+ Restart OMP. Run `/erosiano-dev status` and inspect the EROSIANO status segment. `/engineering-proxy` and `/engineering-review` are migration aliases owned by the same new core. Existing legacy config/session modes are migrated by erosiano-dev; the former policy is not loaded. Default engineering integration uses the four native `ei_*` tools; explicit `intelligenceMode` config overrides it. A missing/inactive tool falls back to native evidence. New core commands include `/erosiano-dev baseline [scope]`, `/erosiano-dev practices [scope]`, `/erosiano-dev review [scope]`. To get the `ei` shell command, install the npm package below; it does not replace the marketplace install. From a built checkout you can instead run `node dist/adapters/cli/main.js` in place of `ei`.
20
+
21
+ ### AGY: native plugin and terminal/MCP
22
+
23
+ The same repository has an Antigravity-native manifest, a generated balanced rule, existing skills and an on-demand `erosiano-review` skill. From a trusted checkout of this candidate, validate and install locally:
24
+
25
+ ```sh
26
+ agy plugin validate /absolute/path/to/ksd-intelligence
27
+ agy plugin install /absolute/path/to/ksd-intelligence
28
+ agy plugin list
29
+ ```
30
+
31
+ Once the integrated build is accepted on main, the same repository URL can be used for AGY installation. AGY's static rule does not implement OMP's session mode or config hooks. Disable the AGY plugin using the host controls. MCP stays an explicit per-workspace setup with an approved absolute root; a global plugin cannot safely infer the active project. Live AGY validation and installation are still required.
32
+
33
+ For terminal tools and the MCP launcher, install an accepted package (or pack/install this candidate from a trusted checkout):
34
+
35
+ ```sh
36
+ npm install -g @krisada-m/ksd-intelligence
37
+ ei setup
38
+ ```
39
+
40
+ The setup command provisions a pinned TypeScript runtime in your user cache and may contact the package registry. Verify it later with `ei setup --check`.
41
+
42
+ Configure AGY to launch `ei mcp --root /absolute/path/to/project`. In AGY's MCP settings, use:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "ksd-intelligence": {
48
+ "command": "ei",
49
+ "args": ["mcp", "--root", "/absolute/path/to/project"],
50
+ "enabledTools": ["ei_status", "ei_impact", "ei_changes", "ei_search"]
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ To expose the same engineering resolver through MCP, explicitly set `env: { "KSD_MCP_ENGINEERING": "1" }` on this server and append `erosiano_baseline` and `erosiano_resolve_practices` to `enabledTools`. The first captures scoped hashes; the second resolves practices using a supplied current fingerprint and path provenance. Both use the configured root, never a tool-supplied root or subprocess. Leave the flag unset to keep the original tool list.
57
+
58
+ Use the absolute path to `ei` if AGY does not inherit your npm bin `PATH`. This is a stdio process, not an HTTP server. The root cannot change through a tool call; use a separate server entry for each project. To expose workflow, append `--workflow`, add `ei_workflow` to `enabledTools`, and set the skill roots below. See the [AGY guide](https://github.com/Krisada-M/ksd-intelligence/blob/main/docs/integrations/antigravity.md).
59
+
60
+ ## Set up a repository
61
+
62
+ Run from the project root:
63
+
64
+ ```sh
65
+ ei setup # once per runtime version
66
+ ei init --dry-run # inspect proposed paths and tsconfig coverage
67
+ ei init # skip existing config; review any new ei.config.json
68
+ ei index # publish first index
69
+ ei status
70
+ ```
71
+
72
+ The nearest `ei.config.json` sets the root; otherwise KSD uses the Git worktree root. Status reports the scanned/indexed/orphan/unindexed counts. An orphan has no owning TypeScript project. Edit `impact.include` to cover your sources **and tests**; add an appropriate `tsconfig.json` or `jsconfig.json` for unowned code. Review any extra paths before committing configuration.
73
+
74
+ ### Workflow skill sources
75
+
76
+ `ei_workflow` reads approved `SKILL.md` files from local checkouts; it does not fetch repositories or run skill scripts. Clone, inspect, and pin the sources yourself before enabling the workflow:
77
+
78
+ ```sh
79
+ mkdir -p "$HOME/ei-skill-sources"
80
+ git clone https://github.com/mattpocock/skills.git "$HOME/ei-skill-sources/matt"
81
+ git clone https://github.com/cursor/plugins.git "$HOME/ei-skill-sources/cursor-plugins"
82
+ git clone https://github.com/addyosmani/agent-skills.git "$HOME/ei-skill-sources/osmani"
83
+ git -C "$HOME/ei-skill-sources/matt" checkout 4ae2317ddb22b046e26455e4f9c9b3aaaf62212d
84
+ git -C "$HOME/ei-skill-sources/cursor-plugins" checkout 6b0300214a09fd6029cfb7077043125758cd1fd2
85
+ git -C "$HOME/ei-skill-sources/osmani" checkout 301b02b12bff98e4688e6984af6556802322bbde
86
+ export EI_MATT_ROOT="$HOME/ei-skill-sources/matt"
87
+ export EI_POTETO_ROOT="$HOME/ei-skill-sources/cursor-plugins"
88
+ export EI_OSMANI_ROOT="$HOME/ei-skill-sources/osmani"
89
+ ei sources check
90
+ ```
91
+
92
+ Set the variables in the host's environment and restart the host. Each points to a checkout root, not a `skills` directory. Treat skill text as untrusted instructions. Do not enable a second automatic workflow router.
93
+
94
+ ## Five tools
95
+
96
+ Actual output excerpts from the installed marketplace extension, invoked directly through OMP's extension loader. The CLI provides the same analysis and has the equivalents below. AGY exposes workflow only when opted in. See the [tool contract](https://github.com/Krisada-M/ksd-intelligence/blob/main/docs/TOOLS.md).
97
+
98
+ | Use | OMP tool | CLI equivalent |
99
+ |---|---|---|
100
+ | Check coverage and runtime | `ei_status` | `ei status` |
101
+ | Find an implementation | `ei_search` | `ei search 'sanitize audit text' --limit 2` |
102
+ | Check a symbol before editing | `ei_impact` | `ei impact 'src/core/kernel/glob.ts#matchGlob'` |
103
+ | Review the actual diff before saying done | `ei_changes` | `ei changes --base HEAD` |
104
+ | Get stage instructions from approved skills | `ei_workflow` | `ei load --task 'fix bug' --stage investigate --type bug` |
105
+
106
+ ```text
107
+ STATUS ready
108
+ ```
109
+
110
+ ```text
111
+ SEARCH "sanitize audit text" — 2 of 172 matches
112
+ ```
113
+
114
+ ```text
115
+ IMPACT matchGlob — src/core/kernel/glob.ts:96
116
+ ACTION check-gaps · level unknown · picture partial (2 gaps)
117
+ ```
118
+
119
+ ```text
120
+ CHANGES vs HEAD — nothing changed in the working tree.
121
+ ```
122
+
123
+ ```text
124
+ # KSD Workflow
125
+ KSD/project policy and explicit owner decisions take precedence over any skill text below.
126
+ Never merge or deploy without explicit approval. Report verification evidence.
127
+ ```
128
+
129
+ Workflow fails closed without the configured skill sources. For indexed work, follow the verdict: `run-tests` means run the listed tests; `check-gaps` means inspect the gaps; `ask-owner` means stop before editing. `proceed` is not proof of safety.
130
+
131
+ ## Configuration and privacy
132
+
133
+ | `ei.config.json` | Controls |
134
+ |---|---|
135
+ | `impact.include`, `impact.exclude` | Scope of compiler-backed TS/JS analysis |
136
+ | `impact.routes` | Explicit route path globs; no framework auto-detection |
137
+ | `impact.freshness` | `stat` (default) or `hash`. `ei_changes` always hashes |
138
+ | `impact.manyCallers`, `impact.commonName` | Verdict thresholds (default 10 each) |
139
+ | `impact.maxMemoryMb`, `impact.useWorkspaceTypescript` | Child memory limit; explicit opt-in to running the workspace's Compiler API instead of the pinned runtime |
140
+ | `riskZones` | `"default"` (payments, auth, migrations, production config), custom `{zone,floor,match}` entries, or `[]`. Zones only raise risk |
141
+ | `search.enabled` | Lexical search only |
142
+
143
+ Set `EI_DISABLED=1` before launching OMP or the MCP server to disable EI tools. In OMP, `EROSIANO_DEV_DISABLED=1` (or legacy `ENGINEERING_PROXY_DISABLED=1`) disables policy guidance and review independently; it is not a way to co-install two policy owners. Engineering configuration lives in `~/.omp/agent/erosiano-dev.json` and project `.erosiano-dev.json`; missing new files fall back to the old files. See the [engineering guide](https://github.com/Krisada-M/ksd-engineering) for precedence and migration. AGY uses its own plugin activation; these environment flags do not control its static rule.
144
+
145
+ Index and audit are local under `~/.cache/ksd-intelligence/`. SQLite keeps symbols, references, capped signature text and first JSDoc paragraphs, not whole source files. `ei audit --since 7d` summarizes tool use. `ei cache clear` deletes the current project's index and audit, **not** the shared runtime; it refuses during a live build.
146
+
147
+ ## KNOWN LIMITS
148
+
149
+ - `unknown` or `partial` means the indexed evidence cannot resolve the whole picture. Read the named gap sites. Report a wrong `low` immediately; stop relying on it until fixed.
150
+ - No runtime data flow, reflection/DI, external consumers, SQL schema effects, native effects, or arbitrary non-TS/JS caller analysis. TypeScript project coverage matters. Changed non-code paths can still be listed and raise a risk-zone verdict.
151
+ - `.env*`, private key files, default excluded trees, and non-code secret-named files are not read as source. Other code filenames are not screened for hard-coded secrets. Scoped-out code can produce lexical name hints without compiler-grade edges.
152
+ - A same-size edit with unchanged mtime can evade the stat probe. Use `impact.freshness: "hash"` or `ei index`, then `ei doctor --deep --differential 300` when checking suspect results.
153
+ - Worktrees have separate caches. Orphan-name guidance may only say `NOT FOUND`; comment-only changes can still list adjacent tests. A large excluded-code census can produce noisy name matches. Check status when `ei init --dry-run` does not display all expected configurations.
154
+ - Large repos can take minutes and several GB. The historical oh-my-pi cold build took 145 s and about 7.1 GB peak RSS on Linux. The default child memory cap is the smaller of 8192 MiB or half of RAM; narrow scope before raising it. These are not latency promises.
155
+ - **PLANNED (V2), not shipped:** golden `ei doctor` canary / `engine-self-check-failed`, automatic OMP-version mismatch warning, general per-capability `enabled` flags, standalone `ei symbol`, and a hard 5 s query budget. Also not shipped: automatic route discovery, heuristic bridges, watcher/worktree seeding, semantic search, context packs, GitLab, verification, learnings and compression. Existing config placeholders do not turn them on.
156
+
157
+ ## Troubleshoot, remove, or roll back
158
+
159
+ | Symptom | Action |
160
+ |---|---|
161
+ | `typescript runtime missing` | Run `ei setup`, then `ei setup --check`. |
162
+ | `NOT INDEXED`, zero callers, or `NOT FOUND` in mixed repositories | Check `ei status`, effective scope, project config ownership, and installed dependencies. Rails importmap resolution is not analyzed. |
163
+ | Stale result or slow build | Check the lock and memory in `ei status`. Run `ei index --full` if the index needs rebuilding. |
164
+ | `SKILLS_UNAVAILABLE` or hash mismatch | Check all three checkout roots, reviewed commits, and hashes with `ei sources check`. Do not re-pin unexplained changes. |
165
+ | No AGY tools | Confirm the MCP command starts, root is absolute, and host tool filter is correct. Inspect startup output in AGY rather than typing at the stdio process. |
166
+
167
+ ```sh
168
+ # Upgrade marketplace install; restart OMP afterward.
169
+ omp plugin marketplace update ksd-intelligence
170
+ omp plugin upgrade ksd-intelligence@ksd-intelligence
171
+
172
+ # Remove the composed product (both OMP policy and intelligence).
173
+ omp plugin uninstall ksd-intelligence@ksd-intelligence
174
+ # AGY: uninstall its native plugin and remove the separately configured MCP entry.
175
+ agy plugin uninstall ksd-intelligence
176
+
177
+ # Remove the AGY MCP entry and reload AGY, then remove the CLI.
178
+ npm uninstall -g @krisada-m/ksd-intelligence
179
+ ```
180
+
181
+ For npm rollback, reinstall a previous approved version or saved tarball, then run `ei setup` and `ei index --full`. Do not use the old index as evidence for the new version. Back up the audit log before `ei cache clear` if you need it. See the [changelog](CHANGELOG.md) and [release checklist](https://github.com/Krisada-M/ksd-intelligence/blob/main/docs/release-checklist.md) for verification and owner gates.
182
+
183
+ ## Engineering bundle provenance
184
+
185
+ [`engineering.lock.json`](engineering.lock.json) pins the exact upstream commit and every allowed runtime Git blob/mode. `src/engineering/` contains byte-identical runtime files; build verifies them offline and copies them to `dist/engineering/`, never fetching dependencies at agent startup. The old `src/policy/` and its frozen tests remain historical contract evidence; no legacy policy is registered or distributed under `dist/policy/`. `npm run verify:engineering` validates both source and distribution. The exported ESLint rules and all four engineering companion CLIs now use the new bundle. To update the core, review the upstream PR, update the pin and bytes together using the sync script, regenerate host assets, build, run CI, then approve the composed product. See [provenance](PROVENANCE.md).
186
+
187
+ ```sh
188
+ # Owner-run, from the consuming repo with a trusted upstream checkout and reviewed full commit.
189
+ node scripts/sync-engineering.mjs /absolute/path/to/ksd-engineering <exact-commit>
190
+ node scripts/generate-agy-engineering.mjs --write
191
+ npm run build
192
+ npm run verify:engineering
193
+ npm test
194
+ ```
195
+
196
+ The upstream allowlist is explicit; newly introduced runtime files require a reviewed change to it. Commit the pin, source, dist and generated AGY rule together. CI also checks the source blob IDs against the separately checked-out upstream commit. No runtime dependency is added.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: erosiano-review
3
+ description: Review scoped changes using the shared erosiano-dev engineering standard, project baseline, code impact and actual verification evidence. Use when reviewing a diff or assessing release readiness.
4
+ ---
5
+
6
+ # Evidence-based engineering review
7
+
8
+ Use the enabled plugin's generated balanced engineering rule. Project instructions, contracts and native safety gates take precedence over personal preferences. Do not reproduce the entire practice catalog.
9
+
10
+ 1. Identify the requested scope, acceptance criteria, affected contracts and risk. Read applicable instructions, maintained code, callers, tests and native gate configuration. Distinguish current, legacy, transitional, local, exception and unknown observations, with evidence and confidence.
11
+ 2. If the explicitly configured workspace MCP is available, check its fixed root and index status; use `ei_search`, `ei_impact` and `ei_changes` for discovery and impact. Partial or degraded evidence is not a safety verdict. If unavailable, inspect source and tests directly.
12
+ 3. For a scoped practice selection, use the approved terminal companions `erosiano-baseline` and `erosiano-practices` from the same installed KSD package. Capture the actual scope and relevant caller/test/config files, then provide the snapshot fingerprint and path-based observation provenance. Never invent a fingerprint or supply another repository root. If the engineering MCP tools are explicitly configured, use them instead. A stale or incomplete baseline must be refreshed or reported unknown.
13
+ 4. Inspect tracked and intended untracked changes, including deletion/rename effects. Determine required native checks from the repository. Verify only through AGY's permitted tools, and record commands, cwd, exit status, counts and exact reviewed revision. Never infer PASS from a test definition, skipped check, admin-only access or synthetic fixture.
14
+ 5. Escalate authentication, tenant isolation, payment replay, database migration, secrets and concurrency based on behavior. Check normal-user denial and failure paths; never execute real payments or destructive shared-database tests.
15
+ 6. Report severity, file/line evidence, affected contracts, verification results, remaining unknowns, rollback impact and approval blockers. Do not merge, publish or deploy.
16
+
17
+ AGY does not emulate OMP's command/session lifecycle. Do not invoke OMP slash commands or change host tool permissions. No automatic execution of bundled scripts or installation of dependencies.
@@ -0,0 +1,252 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { homedir } from 'node:os';
4
+ import { isAbsolute, join, relative, resolve } from 'node:path';
5
+ import { defaultSkillsDir, discoverSkillsForPlatform, } from '../../workflow/packs.js';
6
+ function isStringArray(value) {
7
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
8
+ }
9
+ function uniquePaths(paths) {
10
+ const seen = new Set();
11
+ const out = [];
12
+ for (const raw of paths) {
13
+ if (!raw)
14
+ continue;
15
+ const normalized = resolve(raw);
16
+ if (seen.has(normalized))
17
+ continue;
18
+ seen.add(normalized);
19
+ out.push(normalized);
20
+ }
21
+ return out;
22
+ }
23
+ // Resolves AGY workspace, Snap, global, shared, and KSD catalog paths dynamically
24
+ // using OS/Snap environment variables without hardcoding any username.
25
+ export function detectAgyPaths(options = {}) {
26
+ const env = options.env ?? process.env;
27
+ const realHome = options.homeDir ?? env.SNAP_REAL_HOME ?? env.HOME ?? homedir();
28
+ const ksdCatalogDir = resolve(options.skillsDir ?? defaultSkillsDir());
29
+ const workspaceSkillsDir = options.workspaceRoot
30
+ ? resolve(options.workspaceRoot, '.agents', 'skills')
31
+ : null;
32
+ const workspaceSkillsConfig = options.workspaceRoot
33
+ ? resolve(options.workspaceRoot, '.agents', 'skills.json')
34
+ : null;
35
+ const snapCandidates = [];
36
+ if (env.ANTIGRAVITY_APP_DATA_DIR) {
37
+ snapCandidates.push(join(env.ANTIGRAVITY_APP_DATA_DIR, 'skills'));
38
+ }
39
+ if (env.SNAP_USER_COMMON) {
40
+ snapCandidates.push(join(env.SNAP_USER_COMMON, '.gemini', 'antigravity-cli', 'skills'));
41
+ }
42
+ snapCandidates.push(join(realHome, 'snap', 'antigravity-cli', 'common', '.gemini', 'antigravity-cli', 'skills'));
43
+ const snapSkillsDirs = uniquePaths(snapCandidates);
44
+ const globalSkillsDirs = uniquePaths([
45
+ join(realHome, '.gemini', 'config', 'skills'),
46
+ join(realHome, '.gemini', 'antigravity-cli', 'skills'),
47
+ ]);
48
+ const sharedSkillsDir = resolve(realHome, '.agents', 'skills');
49
+ const detected = [];
50
+ if (workspaceSkillsDir) {
51
+ detected.push({
52
+ scope: 'workspace',
53
+ label: 'agy:workspace',
54
+ path: workspaceSkillsDir,
55
+ exists: existsSync(workspaceSkillsDir),
56
+ });
57
+ }
58
+ for (const dir of snapSkillsDirs) {
59
+ detected.push({ scope: 'snap', label: 'agy:snap', path: dir, exists: existsSync(dir) });
60
+ }
61
+ for (const dir of globalSkillsDirs) {
62
+ detected.push({ scope: 'global', label: 'agy:global', path: dir, exists: existsSync(dir) });
63
+ }
64
+ detected.push({
65
+ scope: 'shared',
66
+ label: 'agy:shared',
67
+ path: sharedSkillsDir,
68
+ exists: existsSync(sharedSkillsDir),
69
+ });
70
+ detected.push({
71
+ scope: 'catalog',
72
+ label: 'ksd:catalog',
73
+ path: ksdCatalogDir,
74
+ exists: existsSync(ksdCatalogDir),
75
+ });
76
+ const snapDetected = Boolean(env.SNAP_USER_COMMON || env.ANTIGRAVITY_APP_DATA_DIR) ||
77
+ snapSkillsDirs.some((dir) => existsSync(dir));
78
+ return {
79
+ realHome,
80
+ snapDetected,
81
+ workspaceSkillsDir,
82
+ workspaceSkillsConfig,
83
+ snapSkillsDirs,
84
+ globalSkillsDirs,
85
+ sharedSkillsDir,
86
+ ksdCatalogDir,
87
+ detected,
88
+ };
89
+ }
90
+ function resolveAgyConfigPath(rawPath, workspaceRoot, realHome) {
91
+ const trimmed = rawPath.trim();
92
+ if (!trimmed)
93
+ return null;
94
+ if (trimmed.startsWith('~/'))
95
+ return resolve(realHome, trimmed.slice(2));
96
+ return isAbsolute(trimmed) ? trimmed : resolve(workspaceRoot, trimmed);
97
+ }
98
+ async function readDeclaredAgyEntries(workspaceRoot, realHome) {
99
+ const configPath = join(workspaceRoot, '.agents', 'skills.json');
100
+ let raw;
101
+ try {
102
+ raw = await readFile(configPath, 'utf8');
103
+ }
104
+ catch {
105
+ return [];
106
+ }
107
+ let parsed;
108
+ try {
109
+ parsed = JSON.parse(raw);
110
+ }
111
+ catch {
112
+ return [];
113
+ }
114
+ if (typeof parsed !== 'object' || parsed === null || !('entries' in parsed))
115
+ return [];
116
+ const entries = parsed.entries;
117
+ if (!Array.isArray(entries))
118
+ return [];
119
+ const roots = [];
120
+ for (const item of entries) {
121
+ if (typeof item !== 'object' || item === null || !('path' in item))
122
+ continue;
123
+ const rawPath = item.path;
124
+ if (typeof rawPath !== 'string')
125
+ continue;
126
+ const resolved = resolveAgyConfigPath(rawPath, workspaceRoot, realHome);
127
+ if (!resolved)
128
+ continue;
129
+ const includeOnly = isStringArray(item.include_only)
130
+ ? item.include_only
131
+ : undefined;
132
+ const exclude = isStringArray(item.exclude)
133
+ ? item.exclude
134
+ : undefined;
135
+ roots.push({
136
+ path: resolved,
137
+ label: `agy:skills.json(${rawPath})`,
138
+ optional: false,
139
+ includeOnly,
140
+ exclude,
141
+ });
142
+ }
143
+ return roots;
144
+ }
145
+ // Builds a portable AGY `.agents/skills.json` entry without hardcoded user-home paths.
146
+ export function buildAgySkillsConfig(options = {}) {
147
+ const target = options.skillsDir ?? defaultSkillsDir();
148
+ const entryPath = options.workspaceRoot ? relative(options.workspaceRoot, target) || '.' : target;
149
+ const entry = { path: entryPath };
150
+ if (options.exclude && options.exclude.length > 0)
151
+ entry.exclude = [...options.exclude];
152
+ return { entries: [entry] };
153
+ }
154
+ // Native AGY skill discovery honoring AGY precedence:
155
+ // workspace `.agents/skills` > `.agents/skills.json` > snap > global/user > shared > KSD catalog.
156
+ export async function discoverAgySkills(options = {}) {
157
+ const paths = detectAgyPaths({
158
+ workspaceRoot: options.workspaceRoot,
159
+ env: options.env,
160
+ homeDir: options.homeDir,
161
+ skillsDir: options.skillsDir,
162
+ });
163
+ const roots = [];
164
+ const seenPaths = new Set();
165
+ const addRoot = (root) => {
166
+ const key = resolve(root.path);
167
+ if (seenPaths.has(key))
168
+ return;
169
+ seenPaths.add(key);
170
+ roots.push(root);
171
+ };
172
+ if (options.workspaceRoot) {
173
+ addRoot({
174
+ path: join(options.workspaceRoot, '.agents', 'skills'),
175
+ label: 'agy:workspace',
176
+ optional: true,
177
+ });
178
+ for (const declared of await readDeclaredAgyEntries(options.workspaceRoot, paths.realHome)) {
179
+ addRoot(declared);
180
+ }
181
+ }
182
+ if (options.snapSkillsDir) {
183
+ addRoot({
184
+ path: options.snapSkillsDir,
185
+ label: 'agy:snap',
186
+ optional: true,
187
+ allowExternalSymlinks: true,
188
+ auditContent: false,
189
+ });
190
+ }
191
+ else if (options.detectHostPaths) {
192
+ for (const snapDir of paths.snapSkillsDirs) {
193
+ addRoot({
194
+ path: snapDir,
195
+ label: 'agy:snap',
196
+ optional: true,
197
+ allowExternalSymlinks: true,
198
+ auditContent: false,
199
+ });
200
+ }
201
+ }
202
+ if (options.userSkillsDir) {
203
+ addRoot({
204
+ path: options.userSkillsDir,
205
+ label: 'agy:user',
206
+ optional: true,
207
+ allowExternalSymlinks: true,
208
+ auditContent: false,
209
+ });
210
+ }
211
+ else if (options.detectHostPaths) {
212
+ for (const globalDir of paths.globalSkillsDirs) {
213
+ addRoot({
214
+ path: globalDir,
215
+ label: 'agy:global',
216
+ optional: true,
217
+ allowExternalSymlinks: true,
218
+ auditContent: false,
219
+ });
220
+ }
221
+ }
222
+ if (options.sharedSkillsDir) {
223
+ addRoot({
224
+ path: options.sharedSkillsDir,
225
+ label: 'agy:shared',
226
+ optional: true,
227
+ allowExternalSymlinks: true,
228
+ auditContent: false,
229
+ });
230
+ }
231
+ else if (options.detectHostPaths) {
232
+ addRoot({
233
+ path: paths.sharedSkillsDir,
234
+ label: 'agy:shared',
235
+ optional: true,
236
+ allowExternalSymlinks: true,
237
+ auditContent: false,
238
+ });
239
+ }
240
+ addRoot({
241
+ path: paths.ksdCatalogDir,
242
+ label: 'ksd:catalog',
243
+ optional: false,
244
+ auditContent: true,
245
+ });
246
+ const discovery = await discoverSkillsForPlatform({
247
+ platform: 'agy',
248
+ roots,
249
+ requireCatalog: options.requireCatalog ?? true,
250
+ });
251
+ return { ...discovery, paths };
252
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runPolicyBin } from './policy-bin.js';
3
+ await runPolicyBin(new URL('../../engineering/check-changed.js', import.meta.url), 'ksd-check-changed --diff git.patch --eslint-report eslint.json');