This repository was archived by the owner on Jun 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare package CLI and workspace contract #151
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c1ed89
feat: prepare package CLI workspace contract
fitz123 6357efc
fix: handle trailing package extension dirs
fitz123 c68cb58
fix: address PR review findings
fitz123 3b75df4
test: expect canonical guard root in package install
fitz123 baa901e
test: expect canonical cron guard root
fitz123 9c696cf
fix: clarify package CLI workspace fallback
fitz123 5894383
fix: normalize hook paths with sed
fitz123 6ece37c
fix: propagate schema path to subagent children
fitz123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/usr/bin/env node | ||
| import { chmodSync, cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; | ||
| import { dirname, join, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import ts from "typescript"; | ||
|
|
||
| const scriptDir = dirname(fileURLToPath(import.meta.url)); | ||
| const packageRoot = resolve(scriptDir, ".."); | ||
| const sourceExtensionDir = join(packageRoot, ".claude", "extensions"); | ||
| const artifactExtensionDir = join(packageRoot, "dist", "extensions", "pi"); | ||
|
|
||
| const wrappers = [ | ||
| ["guardian-protect-files.ts", "guardian-protect-files.js"], | ||
| ["web-tools.ts", "web-tools.js"], | ||
| [join("subagent", "agents.ts"), join("subagent", "agents.js")], | ||
| [join("subagent", "index.ts"), join("subagent", "index.js")], | ||
| ]; | ||
|
|
||
| rmSync(artifactExtensionDir, { recursive: true, force: true }); | ||
|
|
||
| function rewriteImports(source) { | ||
| return source | ||
| .replaceAll("../../src/pi-extensions/", "../../pi-extensions/") | ||
| .replaceAll("../../src/pi-rpc-protocol.js", "../../pi-rpc-protocol.js") | ||
| .replaceAll("../../../src/pi-extensions/", "../../../pi-extensions/") | ||
| .replaceAll("../../../src/pi-rpc-protocol.js", "../../../pi-rpc-protocol.js") | ||
| .replaceAll('from "./agents.ts"', 'from "./agents.js"'); | ||
| } | ||
|
|
||
| function transpileWrapper(sourcePath, targetPath) { | ||
| const source = rewriteImports(readFileSync(sourcePath, "utf8")); | ||
| const result = ts.transpileModule(source, { | ||
| compilerOptions: { | ||
| target: ts.ScriptTarget.ES2022, | ||
| module: ts.ModuleKind.ES2022, | ||
| moduleResolution: ts.ModuleResolutionKind.Bundler, | ||
| esModuleInterop: true, | ||
| sourceMap: false, | ||
| }, | ||
| fileName: sourcePath, | ||
| reportDiagnostics: true, | ||
| }); | ||
| const diagnostics = result.diagnostics?.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error) ?? []; | ||
| if (diagnostics.length > 0) { | ||
| throw new Error(ts.formatDiagnosticsWithColorAndContext(diagnostics, { | ||
| getCanonicalFileName: (fileName) => fileName, | ||
| getCurrentDirectory: () => packageRoot, | ||
| getNewLine: () => "\n", | ||
| })); | ||
| } | ||
| mkdirSync(dirname(targetPath), { recursive: true }); | ||
| writeFileSync(targetPath, result.outputText, "utf8"); | ||
| } | ||
|
|
||
| for (const [sourceRel, targetRel] of wrappers) { | ||
| transpileWrapper( | ||
| join(sourceExtensionDir, sourceRel), | ||
| join(artifactExtensionDir, targetRel), | ||
| ); | ||
| } | ||
|
|
||
| for (const rel of [ | ||
| join("subagent", "agents"), | ||
| join("subagent", "prompts"), | ||
| ]) { | ||
| cpSync(join(sourceExtensionDir, rel), join(artifactExtensionDir, rel), { | ||
| recursive: true, | ||
| force: true, | ||
| }); | ||
| } | ||
|
|
||
| chmodSync(join(packageRoot, "dist", "cli.js"), 0o755); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env node | ||
| import { rmSync } from "node:fs"; | ||
| import { dirname, join, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const scriptDir = dirname(fileURLToPath(import.meta.url)); | ||
| const packageRoot = resolve(scriptDir, ".."); | ||
|
|
||
| rmSync(join(packageRoot, "dist"), { recursive: true, force: true }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.