一键导入
gas-fakes-dev
Develop, implement, and test the 'gas-fakes' project, emulating ALL Google Apps Script (GAS) functionality using Node.js and Google APIs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Develop, implement, and test the 'gas-fakes' project, emulating ALL Google Apps Script (GAS) functionality using Node.js and Google APIs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | gas-fakes-dev |
| description | Develop, implement, and test the 'gas-fakes' project, emulating ALL Google Apps Script (GAS) functionality using Node.js and Google APIs. |
| tags | ["nodejs","google-apps-script","google-cloud-api","testing","mock","simulation"] |
| version | 2.0.0 |
This skill enables the agent to act as a Senior Expert proficient in Node.js, Google Cloud, and Shell Scripting to assist in the development of the gas-fakes project.
The ultimate objective is to emulate the behavior of live Google Apps Script exactly by mapping classes and methods to their fake equivalents. This allows Apps Script to run anywhere Node runs.
This is achieved using a worker mechanism to handle the conversion from synchronous (Apps Script) to asynchronous (Google APIs) operations, returning the results synchronously. Ultimately, all Apps Script classes and methods will be available via gas-fakes. For a deep dive into this mechanism, see the Sync-to-Async Bridge Guide.
gas-fakes project structure.test/ directory.gas-fakes relies on an .env file (maintained by gas-fakes init and auth) to properly authenticate and run.
.env file. This is required if restricted/sensitive scopes are needed, or if running gas-fakes on Google Cloud Run..env file is provided, gas-fakes falls back to ADC. This is usually fine for local development as standard cloud_platform and drive scopes are automatically assigned during auth.Ensure your .env is properly loaded (e.g., using node --env-file <env-file> or gas-fakes -e <env-file>) to ensure DWD is used when necessary.
TEST_SPREADSHEET_ID: (Optional) Spreadsheet ID for real-environment testing.Before starting implementation, you must understand the full scope and style of the project.
Restricted Directories:
progress directory during the development of gas-fakes. This directory is strictly off-limits.Mandatory Existence Verification:
When adding or updating ANY class or method, you must ALWAYS use the workspace-developer MCP server (if available) or search official documentation to verify the existence and specification of the target and ALL related classes/methods.
Sheet.getCharts(), check what object it returns (EmbeddedChart vs Chart) and verify the methods available on that returned object.Strict Enum Verification: Do not invent Enums. Before using or creating an Enum, verify if it actually exists in Google Apps Script.
ChartType: In Google Apps Script, ChartType is a property of the Charts service (Charts.ChartType), not SpreadsheetApp.Reference Existing Code:
Check the src and test directories to understand the existing coding style and architecture. Apply these patterns to new classes and methods.
Identify Dependencies:
Identify and implement all related classes and methods required for the target feature. (e.g., if newChart() returns EmbeddedChartBuilder, verify/implement that builder class too).
Do not create service files manually. Use the provided helper script.
node .agent/skills/gas-fakes-dev/scripts/scaffold_service.js --service=<ServiceName> --class=<ClassName>
Generate code based on Node.js best practices, adhering to these rules to maintain environmental consistency with live Apps Script:
Comprehensive Implementation: Implement the target feature and its dependencies together.
Cross-Environment Compatibility: Scripts must be designed to run on both Node.js (local) and GAS Script Editor with identical results.
toString() Accuracy: The toString() method must return the exact GAS class name or specific string output (e.g., "Sheet" or "[Document: ...]"). Pay extreme attention to whitespace; GAS output can contain double spaces (e.g., after a colon).
Dynamic Resources and Caching Pattern:
__resource property: Always access the underlying API state via the dynamic __resource getter (tracing back to the parent element or a synchronized cache).__resource ensures you get the most up-to-date state from the API or the fresh cache.Implementation Patterns:
signatureArgs or is.* utilities.this.__batchUpdate (or helper).this for chaining.Coding Patterns:
Fake (e.g., FakeSheet, FakeEmbeddedChart).lazyLoaderApp pattern in their respective app.js to ensure they are only instantiated when accessed.newFakeSpreadsheetApp) that return the singleton instance.Specific Technical Nuances:
Fake Class -> Syncit (fx*) -> callSync -> Worker Loop -> sx* Function -> sxRetry. See detailed guide for implementation steps.getOptions().get("title") instead of internal specs.modify().getChartType() instead of a non-existent getType() method.GridRange to a FakeSheetRange:getRange(row, col, numRows, numCols)) use 1-indexed start positions and row/column counts.endRowIndex or endColumnIndex is undefined in the API response, it means the range extends to the boundary of the sheet. Use sheet.getMaxRows() and sheet.getMaxColumns() as fallbacks to calculate numRows and numCols.EmbeddedChart, Slicer, and Drawing.getAnchorRow() and getAnchorColumn() to 0-indexed API fields anchorCell.rowIndex + 1 and anchorCell.columnIndex + 1.getOffsetX() and getOffsetY() directly to offsetXPixels and offsetYPixels.Element.getName() returns the local name (no prefix).Document.toString() output is very specific: [Document: No DOCTYPE declaration, Root is [Element: <rootName/>]] (note the double space after Document:).getChild(name, namespace)) require mapping prefixes and URIs correctly.You must ensure every implementation is verified by tests that precisely emulate Google Apps Script behavior.
Mandatory Feature Coverage:
Edge Case Capturing:
t.rxMatch(t.threw(() => ...).message, /regex/) to verify that methods throw expected GAS error messages when given invalid arguments.null, undefined, empty strings, and out-of-bounds values where applicable to ensure robust emulation.GAS Compatibility Requirement:
unit.section) must be compatible with the Google Apps Script script editor.fs, path) inside the test logic.ScriptApp.isFake or xxxApp.isFake to toggle environment-specific logging or assertions.Test Script Structure:
@mcpher/gas-fakes, @sindresorhus/is, and helpers from ./testinit.js and ./testassist.js.export const testService = (pack) => { ... }) to allow integration into the main test suite.wrapupTest(testService); at the end of the file for standalone execution.unit.section("description", (t) => { ... }) to group tests.Resource Lifecycle and Cleanup:
toTrash pattern: Maintain a toTrash array within your test function. Push any created resources (files, folders, sheets) into this array.trasher(toTrash) at the end of the test function (usually triggered if fixes.CLEAN is true) to ensure the test environment remains pristine.Naming Convention:
testsheets{class name}.js (e.g., testsheetsrange.js)testdocs{class name}.jstestslides{class name}.jstest{service}{class name}.jsRegistration:
test/.test/test.js.test/package.json.Execution:
[!IMPORTANT] Run tests from the
test/directory.cd test && node test{filename}.js execute(ornpm run <script-name>).
Clasp Verification:
Use testongas/test/ to verify against a real GAS project via clasp.
You can execute any generated Apps Script file using gas-fakes in a local sandbox.
.env file and run the local gas-fakes implementation.
node --env-file ./.env gas-fakes -f myscript.js
npx gas-fakes -f myscript.js
(Sandbox flags can be added as requested by the user to control the environment)To ensure the gas-fakes project and this SKILL continuously evolve and improve efficiently, you MUST actively refine and update the SKILL definition (SKILL.md) and its associated resources based on the outcomes of your development processes.
At the conclusion of every task, perform a "Self-Audit" by answering:
toString() format or Enum location) that wasn't documented?If any criteria in the "Skill Audit" are met, you MUST:
SKILL.md.examples/, resources/, or scripts/ directories to reflect the new best practice.